		var directory = "";
		var today = new Date();
		var monthLength = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
		var hiddenArray = new Array(35);
		
		var currentyear = today.getYear();
		var currentmonth = today.getMonth();
		var currenttime = today.getHours() + ":" + today.getMinutes( ) + ":" + today.getSeconds();
		if (currentyear < 1000) {currentyear += 1900;} 
		var dp_dir = "";
		var newWin_doc = null;
		var newWin = null;
		var txtboxObj = null;
		
		function formatdate(dd,mm,yy){
			var strf = newWin_doc.getElementById('dateformat').value;
			var chr = '/';
			var dstr = "";
			if (strf.charAt(3)== '1') {chr = '-';}
			else if (strf.charAt(3)== '3') {chr = '.';}
			
			for (var a=0; a<3; a++){
				if (strf.charAt(a)== 'd') {dstr += dd;}
				else if (strf.charAt(a)== 'm') {dstr += mm;}
				else if (strf.charAt(a)== 'y') {dstr += yy;}
				
				if (a < 2) {dstr += chr;}
			}	
			if (newWin_doc.getElementById('including').checked) {
				dstr += " " + newWin_doc.getElementById('time').value;
			}		
			return dstr;
		}
	
		function returndate(indx){
	   		if(hiddenArray[indx] > 0) {
				if (txtboxObj) {
					document.getElementById(txtboxObj).value = formatdate(hiddenArray[indx],newWin_doc.getElementById('months').options.selectedIndex+1,parseInt(newWin_doc.getElementById('years').value));
				}
				newWin.close();
			}
	   		
		}
		function updateoutput() {
			var ml = newWin_doc.getElementById('months').options.selectedIndex;
			var sday = new Date(parseInt(newWin_doc.getElementById('years').value),ml,01)
			var startindex = sday.getDay();
			var numberOfDays = monthLength[ml];
			if (startindex==0) {startindex = 7;}
			
			if (ml==1 && (parseInt(newWin_doc.getElementById('years').value)%4) == 0){numberOfDays = 29;}
			
			for (var n=0; n<35; n++) {
				var str = "c"+n;
				newWin_doc.getElementById(str).src =dp_dir + "0.gif";
				hiddenArray[n] = 0;
			}
			
			for (var m=0; m<numberOfDays; m++)
			{
				var str = "c"+((startindex+m-1)%35);
				newWin_doc.getElementById(str).src =dp_dir + (m+1) + ".gif";
				hiddenArray[((startindex+m-1)%35)] = (m+1);
			}
		}
		
		function updateyears()
		{
			var tempyear = newWin_doc.getElementById('years').value;
			var styear = tempyear - 10;
			for (var i=0; i <= 20; i++) {
				var s = "yopt"+i;
				newWin_doc.getElementById(s).text = (styear+i);
				newWin_doc.getElementById(s).value = (styear+i);
			}
			for (var i = 0; i < newWin_doc.getElementById('years').options.length; i++ )
			{
				if (newWin_doc.getElementById('years').options[i].value == ""+tempyear)
				{
			  		newWin_doc.getElementById('years').options.selectedIndex = i;
					break;
				}
			}
		}	

		
function show_calendar(textfieldname, dir) {
	if (dir) {dp_dir = dir;}
	newWin = window.open("", "Calendar", "width=218,height=208,status=no,resizable=no, scrollbars=no,top=200,left=300");
	newWin.opener = self;
	newWin_doc = newWin.document;
	txtboxObj = textfieldname;
	
	
	newWin_doc.writeln('<html><head><title>DatePicker</title></head>');
	newWin_doc.writeln('<body  style="margin: 2px;" scroll=no  onBlur="self.focus()">');
	newWin_doc.writeln('<div align=\"center\"><table bgcolor="#003399" width="200" cellpadding="0" cellspacing="0"><tr><td align="center" height="35">');
	newWin_doc.writeln('<select id="months" onchange="window.opener.updateoutput();">');
		newWin_doc.writeln('<option value="1">Jan</option>');
		newWin_doc.writeln('<option value="2">Feb</option>');
		newWin_doc.writeln('<option value="3">Mar</option>');
		newWin_doc.writeln('<option value="4">Apr</option>');
		newWin_doc.writeln('<option value="5">May</option>');
		newWin_doc.writeln('<option value="6">Jun</option>');
		newWin_doc.writeln('<option value="7">Jul</option>');
		newWin_doc.writeln('<option value="8">Aug</option>');
		newWin_doc.writeln('<option value="9">Sep</option>');
		newWin_doc.writeln('<option value="10">Oct</option>');
		newWin_doc.writeln('<option value="11">Nov</option>');
		newWin_doc.writeln('<option value="12">Dec</option>');
	newWin_doc.writeln('</select>&nbsp;');
	
	newWin_doc.getElementById('months').options.selectedIndex = parseInt(currentmonth);
	
	newWin_doc.writeln('<select id="years" onchange="window.opener.updateoutput();window.opener.updateyears();">');
			var styear = currentyear - 10;
			for (var i=0; i <= 20; i++) {
				newWin_doc.write("<option id=\"yopt"+ i +"\" value=\""+ (styear+i) +"\">" + (styear+i) +"</option>\n");
			}
	newWin_doc.writeln('</select>&nbsp;');
	
	for (var i = 0; i < newWin_doc.getElementById('years').options.length; i++ )
	{
		if (newWin_doc.getElementById('years').options[i].value == ""+currentyear)
		{
	  		newWin_doc.getElementById('years').options.selectedIndex = i;
			break;
		}
	}
	
	newWin_doc.writeln('<select id="dateformat" class="choice">');
		newWin_doc.writeln('<option value="mdy1">m-d-y</option>');
		newWin_doc.writeln('<option value="mdy2">m/d/y</option>');
		newWin_doc.writeln('<option value="mdy3">m.d.y</option>');
		newWin_doc.writeln('<option value="dmy1">d-m-y</option>');
		newWin_doc.writeln('<option value="dmy2">d/m/y</option>');
		newWin_doc.writeln('<option value="dmy3">d.m.y</option>');
		newWin_doc.writeln('<option value="ymd1">y-m-d</option>');
		newWin_doc.writeln('<option value="ymd2">y/m/d</option>');
		newWin_doc.writeln('<option value="ymd3">y.m.d</option>');
	newWin_doc.writeln('</select>');
	newWin_doc.writeln('</td></tr>');
	newWin_doc.writeln('<tr><td>');
	
		newWin_doc.writeln('<TABLE width="100%" cellpadding="1px" cellspacing="1px">');
		newWin_doc.writeln('<TBODY>');
		newWin_doc.writeln('<TR>');
		newWin_doc.writeln('<TD align="center" width="25" bgcolor="#52d9f5"><img src="'+ dp_dir + 'd_mon.gif" width="25" height="20" alt="" border="0"></TD>');
		newWin_doc.writeln('<TD align="center" width="25" bgcolor="#52d9f5"><img src="'+ dp_dir + 'd_tue.gif" width="25" height="20" alt="" border="0"></TD>');
		newWin_doc.writeln('<TD align="center" width="25" bgcolor="#52d9f5"><img src="'+ dp_dir + 'd_wed.gif" width="25" height="20" alt="" border="0"></TD>');
		newWin_doc.writeln('<TD align="center" width="25" bgcolor="#52d9f5"><img src="'+ dp_dir + 'd_thu.gif" width="25" height="20" alt="" border="0"></TD>');
		newWin_doc.writeln('<TD align="center" width="25" bgcolor="#52d9f5"><img src="'+ dp_dir + 'd_fri.gif" width="25" height="20" alt="" border="0"></TD>');
		newWin_doc.writeln('<TD align="center" width="25" bgcolor="#52d9f5"><img src="'+ dp_dir + 'd_sat.gif" width="25" height="20" alt="" border="0"></TD>');
		newWin_doc.writeln('<TD align="center" width="25" bgcolor="#52d9f5"><img src="'+ dp_dir + 'd_sun.gif" width="25" height="20" alt="" border="0"></TD>');
		newWin_doc.writeln('</TR>');
			newWin_doc.writeln("<tr>");
			for (var j=1;j<=35;j++){
				if (j==6 || j==7 || j==13 || j==14 || j==20 || j==21 || j==27 || j==28 || j==34 || j==35) {
					newWin_doc.writeln("<td align=\"center\" valign=\"middle\" width=\"25px\" bgcolor='#c6eafd' onmouseover=\"this.bgColor='#b79eeb';\" onmouseout=\"this.bgColor='#c6eafd'\"><a href=\"#\"><img id=\"c"+(j-1)+"\" src=\""+ dp_dir + "0.gif\" onclick=\"window.opener.returndate("+(j-1)+");\" border=\"0\"></a></td>");
				} else {
					newWin_doc.writeln("<td align=\"center\" valign=\"middle\" width=\"25px\" bgcolor='#ffffff' onmouseover=\"this.bgColor='#b79eeb';\" onmouseout=\"this.bgColor='#ffffff'\"><a href=\"#\"><img id=\"c"+(j-1)+"\" src=\""+ dp_dir + "0.gif\" onclick=\"window.opener.returndate("+(j-1)+");\" border=\"0\"></a></td>");
				}
				if ((j % 7) == 0) {newWin_doc.writeln("</tr>");}
			}
			newWin_doc.writeln("</tr>");
			
			newWin_doc.writeln("<tr>");
			newWin_doc.writeln("<td colspan=\"7\" align=\"center\" valign=\"top\"><font face=\"Arial\" size=\"-1\" color=\"#ffffff\"><strong>Time:</strong> <input type=\"Text\" id=\"time\" value=\""+ currenttime +"\" size=\"6\">");
			newWin_doc.writeln("<input type=\"Checkbox\" id=\"including\" value=\"yes\" checked></font></td>");			
			newWin_doc.writeln("</tr>");			
		newWin_doc.writeln('</TBODY></TABLE>');
	
	newWin_doc.writeln('</td></tr></table></div>');
	
	updateoutput();
	newWin_doc.writeln('</body></html>');
	
	
	if(navigator.appName != "Microsoft Internet Explorer")
  	{
		newWin_doc.close();
  	}
}