	  // format onclick="showCalendar('frmSend.txtDueDate','<%=Year(Date)%>','<%=Year(Date)+3%>','DD/MON/YYYY')"
      
      var temp;
      var currMonth;
      var currYear;
      var str;
      var cal1;
      monthNames = new Array("<option value='01'>January","<option value='02'>February","<option value='03'>March","<option value='04'>April","<option value='05'>May","<option value='06'>June","<option value='07'>July","<option value='08'>August","<option value='09'>Sepember","<option value='10'>October","<option value='11'>November","<option value='12'>December");
      monthArray = new Array("January","February","March","April","May","June","July","August","September","October","Novemeber","December")
      
      var position
      var givenMonth
      var givenYear
      var format
      var startYear
      var endYear
      var first=false
      var windowOpened =false
      var Datewindow
      
      function showCalendar(position,startYear,endYear,format,X)
      {  		
	 
		 // alert(X)
    	document.getElementById('cal').style.left=findPosX(X) ;//position of X
	
		document.getElementById('cal').style.top=findPosY(X) + 20; 
      	this.position = "document."+position
      	this.startYear = startYear
      	this.endYear = endYear
      	this.format = format
      	Datewindow 	=	showCal();
      //	alert("222");
      	return Datewindow;
      }
      
      
      
      
      function last1()
      {
      	temp=28;
      	currMonth = document.calendar.month.value;
      	currYear = document.calendar.year.value;
      	while (temp <= 32)
      	{
      		if ( currMonth == new Date(document.calendar.month.value + "/" + temp + "/" + document.calendar.year.value).getMonth() + 1 )
      			temp = temp + 1;
      		else
      			break;
      	}
      	temp = temp - 1;
      }
      
      
      function constructTable()
      {
      	var count=1;
      	var firstDay = new Date(document.calendar.month.value + "/01/" + document.calendar.year.value).getDay();
      	last1();

      	str = "";
      	str = str + "<table WIDTH = '200' BORDER='0px' CELLPADDING='0' CELLSPACING='0' BORDERCOLORLIGHT='#cccccc' BORDERCOLORDARK='#000000' bgcolor='#ffffff'><tr><td><table cellspacing=1>";
      	str = str + "<tr><td align='center' width=50 bgcolor='#DADADA'><font size='1.5' face='Arial' color=000000>S</td><td align='center' width=50 bgcolor='#DADADA'><font size='1.5' face='Arial' color=000000 >M</td><td align='center' width=50 bgcolor='#DADADA'><font size='1.5' face='Arial' color=000000 >T</td><td align='center' width=50 bgcolor='#DADADA'><font size='1.5' face='Arial' color=000000 >W</td>"
      	str = str + "<td align='center' width=50 bgcolor='#DADADA'><font size='1.5' face='Arial' color=000000 >T</td><td align='center' width=50 bgcolor='#DADADA'><font size='1.5' face='Arial' color=000000 >F</td><td align='center' width=50 bgcolor='#DADADA'><font size='1.5' face='Arial' color=000000 >S</td></tr>"
      	str = str + "<tr>";
      	for (i=1;i<=firstDay;i++)
      	{
      		str = str + "<td bgcolor='#EEEEEE'><font  size='1.5' face='Arial' color='#6666FF' >&nbsp;</td>";
      		count = count + 1;
      	}
      	for (i=1;i<=temp;i++)
      	{
      		if ((new Date().getDate() == i) && (new Date().getMonth() == new Date(currMonth + "/01/01").getMonth()) && (new Date().getYear() == new Date("01/01/" + currYear).getYear()) )
      			str = str + "<td align='center' width=50 bgcolor='#666666' style='cursor:hand;cursor:pointer' onclick=javascript:showDate('"+i+"')><font  size='1.5' face='Arial'  color='FFFFFF' >" + i + " </font></td>";
			else if (((new Date().getDate() > i) || (new Date().getMonth()> new Date(currMonth + "/01/01").getMonth()) || (new Date().getYear() > new Date("01/01/" + currYear).getYear())) && (new Date().getMonth()>= new Date(currMonth + "/01/01").getMonth())&&(new Date().getYear() >= new Date("01/01/" + currYear).getYear()))
      			str = str + "<td align='center' width=50 bgcolor='#DADADA'  ><font  size='1.5' face='Arial'  color='FFFFFF' >" + i + " </font></td>";
      		else
      			str = str + "<td align='center' style='cursor:hand;cursor:pointer' width=50 bgcolor='EEEEEE' onmouseover=javascript:this.style.backgroundColor='#C5E0F5'   onmouseout=javascript:this.style.backgroundColor='EEEEEE' onclick=javascript:showDate('"+i+"')><font size='1.5' face='Arial' color='#000000'  >" + i + "</td>";
      		if ((count % 7) == 0)
      			str = str + "</tr>"
      		count = count + 1;
      	}
      	if (((count-1) % 7) != 0 )
      	{
      		for(i=((count-1) % 7);i<7;i++)
      			str = str + "<td bgcolor='#666666'><font size='2' face='Arial'  color='#6666FF' >&nbsp;</td>";
      	}
		
      	document.getElementById('dataLayer').innerHTML = str + "</tr></table></td></tr></table></font>";
      }
      
      
      function showDate(dateValue)
      {
      	
      //	alert("showDate");
      	checkedMonth = document.calendar.month.value
      	//alert(checkedMonth);
      	if(dateValue<10)
      	dateValue = "0"+dateValue
      	selectedDate = setFormat(dateValue);
      	eval(position).value= selectedDate 
      	windowOpened = false
      	document.getElementById('cal').innerHTML =""
      }
      
      function setFormat (dValue) {
      var month = "";
      	if(format.toUpperCase() == 'MM/DD/YYYY')
		  {	
			return checkedMonth+"/"+dValue+"/"+document.calendar.year.value
			alert("sam")	;
		}
      	else if(format.toUpperCase() == 'DD/MON/YYYY')
      	{
      		switch(checkedMonth)
      		{
      		case '01':
      			month = "JAN";
      			break;
      		case '02':
      			month = "FEB";
      			break;
      		case '03':
      			month = "MAR";
      			break;
      		case '04':
      			month = "APR";
      			break;
      		case '05':
      			month = "MAY";
      			break;
      		case '06':
      			month = "JUN";
      			break;
      		case '07':
      			month = "JUL";
      			break;
      		case '08':
      			month = "AUG";
      			break;
      		case '09':
      			month = "SEP";
      			break;
      		case '10':
      			month = "OCT";
      			break;
      		case '11':
      			month = "NOV";
      			break;
      		case '12':
      			month = "DEC";
      			break;
      		default:
      			month = "";
      		}
      		return dValue+"/"+month+"/"+document.calendar.year.value
      	}
      	else if(format.toUpperCase() == 'YYYY/MM/DD')
      		return document.calendar.year.value+"/"+checkedMonth+"/"+dValue
      	else{
      		//return checkedMonth+"/"+dValue+"/"+cal1.document.calendar.year.value
      		return checkedMonth+"/"+dValue+"/"+document.calendar.year.value
			//return dValue+"/"+checkedMonth+"/"+document.calendar.year.value
      }}
      function showCal()
      {
      //alert("showcal called:" + windowOpened);
      removePicker();
      	if(!windowOpened)
      	{
      		//cal1 = window.open("","cal1","width=250,height=180,status=no,resizable=no,top=200,left=200")
cal1="";

      		windowOpened = true
      		//cal1.document.write("<html><head><title>Calendar</title>")
      /*		cal1.document.write("<script>");
      		
      		cal1.document.write("function ds() {");
      		cal1.document.write("alert('iiiiiiiiiiiiii');");
      	//	if(self.closed)
      		cal1.document.write(windowOpened);
      		cal1.document.write(" } </script>"); 
      */		
      		//cal1.document.write("</head><body onLoad='javascript:window.opener.constructTable()' bgcolor='#FFFFFF'>")
      		cal1 = cal1 +("<style type='text/css'>")
      		cal1 = cal1 +("<!--")
      		cal1 = cal1 +(".alert {  font-family: Arial, Helvetica, sans-serif; font-size: 8pt; color: #000066}")
      		cal1 = cal1 +(".text {  font-family: Arial, Helvetica, sans-serif; font-size: 8pt; font-weight: normal; color: #FFFFFF}")
      		cal1 = cal1 +("--></style>")
      	  
      		cal1 = cal1 +("<form name='calendar'>")
      		cal1 = cal1 +("<table WIDTH = '200' BORDER='0px' CELLPADDING='2' CELLSPACING='0' BORDERCOLORLIGHT='#666666' BORDERCOLORDARK='#FFFFFF'><tr bgcolor='#cde4f6'><td align=center><select class=alert name='month' onChange='javascript:constructTable()'>")
      		for(i=0;i<12;i++)
      		{
      			cal1 = cal1 +(monthNames[i]);
      		}

      		cal1 = cal1 +("</select>&nbsp;&nbsp;<select class=alert name='year' onChange='javascript:constructTable()'>")
    
      		for(i=startYear;i<=endYear;i++)
      		{
      			if (new Date().getYear() == new Date("01/01/" + i).getYear())
      				cal1 = cal1 +('<option value='+i+' selected>'+i+'</option>')
      			else
      				cal1 = cal1 +('<option value='+i+'>'+i+'</option>');
      		}
      
      		cal1 = cal1 +("</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:removePicker();' style='text-decoration:none;color:#330000'><b>X</b></a></td></tr></table><div id='dataLayer'> ")
      		cal1 = cal1 +(" </div></form></body></html>")

		
		 document.getElementById('cal').innerHTML =cal1
      	document.calendar.month.selectedIndex = new Date().getMonth();
		//document.close()
      		constructTable();
      		return cal1;
      	}
      	else
      	{
      	windowOpened = false;
      	cal1 ="";
      	showCal();
      /*		alert("Inside else");
      		if(typeof(cal1) == "object")
      			alert("inside if typeof")
      		cal1.focus();
      		return cal1; //235057 	*/
      	}
      
      }
      
      /* function for closing the window*/
      function removePicker()
      {
      //	alert("in remove method");
      	if(windowOpened) {
      		document.getElementById('cal').innerHTML =""
      		windowOpened = false;
      	//	alert("in remove if condition :"  + windowOpened);
      	}
}
 function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
