<!------------------Designed By Alex Cao 2002.3.21------------------->
<!------------------        for new Training      ------------------->
<!------------------   Date Format : 03/12/2002   ------------------->

<!-- get current time -->
var dt = new Date ()
var dttemp = new Date ()
var mouseleft=null
var mousetop=null
<!-- handle of popup window -->
var newWin = null
var objArray = new Array ()
function setdt ()
{
  dt = new Date (dt.getUTCFullYear (), dt.getMonth (), 1, 0, 0, 0, 0)
}
<!-- set current date -->
document.onLoad = setdt ()
<!-- set date value to input box and close popup window, @d is day of this month, @date is name of input box, the same as below -->
function getDate (d, date)
{
//2002/10/20 --- below  
//objArray[date].value=dt.getUTCFullYear () + '/' +  (dt.getMonth () > 8 ? String (dt.getMonth () + 1)  :  '0' + String (dt.getMonth () + 1)) + '/' +  (parseInt (d) > 9 ? d  :  '0' + d)
//20/10/2002 --- below
//objArray[date].value= (parseInt (d) > 9 ? d  :  '0' + d) + '/' +  (dt.getMonth () > 8 ? String (dt.getMonth () + 1)  :  '0' + String (dt.getMonth () + 1)) + '/' + dt.getUTCFullYear ()
  objArray[date].value= (dt.getMonth () > 8 ? String (dt.getMonth () + 1)  :  '0' + String (dt.getMonth () + 1)) + '-' + (parseInt (d) > 9 ? d  :  '0' + d) + '-' +  dt.getUTCFullYear () 
  newWin.close ()
}
<!-- show last month -->
function selectyear(date)
{
	
	d=newWin.document.getElementById("yearid").options[newWin.document.getElementById("yearid").selectedIndex ].text
	parseInt(d)
	dt=new Date (d, dt.getMonth (), 1, 10, 0, 0, 0)
	fill (date)
}
function selectmonth(date)
{
	
	d=newWin.document.getElementById("monthid").options[newWin.document.getElementById("monthid").selectedIndex ].text
	parseInt(d)
	dt=new Date (dt.getUTCFullYear (), d-1, 1, 10, 0, 0, 0)
	fill (date)
}
function lastMonth (date)
{
  dt = new Date (dt.getUTCFullYear (), dt.getMonth () - 1, 1, 10, 0, 0, 0)
  fill (date)
}
<!-- show next month -->
function nextMonth (date)
{
  dt = new Date (dt.getUTCFullYear (), dt.getMonth () + 1, 1, 10, 0, 0, 0)
  fill (date)
}
<!-- show last year -->
function lastYear (date)
{
  dt = new Date (dt.getUTCFullYear () - 1, dt.getMonth (), 1, 10, 0, 0, 0)
  fill (date)
}
<!-- show next year -->
function nextYear (date)
{
  dt = new Date (dt.getUTCFullYear () + 1, dt.getMonth (), 1, 10, 0, 0, 0)
  fill (date)
}


	


	

	

<!-- show/refresh calendar -->
function fill (date)
{
	 dttemp=new Date(objArray[date].value)
	 select_day=dttemp.getDate ()
   select_month=dttemp.getMonth()
   //this_day=parseInt(thisday)
   var s=""
   s += (dttemp.getMonth() + 1) + "/";
   s += dttemp.getDate() + "/";
   s += dttemp.getYear();

   //alert(s)

  newWin.document.open ()
  newWin.document.write ('<html><head><title>Calendar</title>')
  newWin.document.write ('<style>')
  newWin.document.write ('A{FONT-WEIGHT: bold; FONT-FAMILY: Helvetica, Arial, sans-serif;color:#000000;TEXT-DECORATION: none}')
  newWin.document.write ('A:hover {FONT-WEIGHT: bold; FONT-FAMILY: Helvetica, Arial, sans-serif;color:#FF0000;TEXT-DECORATION:underline}')
  newWin.document.write ('table{font-size:13px;}')
  newWin.document.write ('td{}')
  newWin.document.write ('</style>')
  newWin.document.write ('</head>')
  
  newWin.document.write ('<body onload=\"this.focus();window.setTimeout(\'window.close();\',30000)\">')
  newWin.document.write ('<table border=0 cellspacing=0 cellpadding=0 align=center>')
  //newWin.document.write ('<tr><td align=center colspan=7 height=25 align=center><b>Calendar<input type=hidden id=reload></b></td></tr>')
  

  newWin.document.write ('<tr>')
  newWin.document.write ('<td align=center class="everlianbg"><a href="javascript:window.opener.lastYear(\'' + date + '\')" class="a2">&lt;&lt;</a></td>')
  newWin.document.write ('<td align=center class="everlianbg"><a href="javascript:window.opener.lastMonth(\'' + date + '\')" class="a2">&lt;</a></td>')
  newWin.document.write ('<td align=center colspan=3 class="everlianbg">')
	var stroption=""
	for(i=0;i<100;i++)
	{
		ii=1980+i
		stroption=stroption+"<OPTION >"+ii+"</OPTION>"
		
		}
	newWin.document.write ('<SELECT id=yearid  onchange="javascript:window.opener.selectyear(\'' + date + '\')">'+stroption+'</select>')
	for(i=0;i<100;i++)
	{
		ii=1980+i
		if(ii==dt.getFullYear())
		
			newWin.document.getElementById("yearid").selectedIndex=i
	}
  
  stroption=""
  for(i=0;i<12;i++)
	{
		ii=i+1
		stroption=stroption+"<OPTION >"+ii+"</OPTION>"
		}
	newWin.document.write ('<SELECT id=monthid  onchange="javascript:window.opener.selectmonth(\'' + date + '\')">'+stroption+'</select>')
	for(i=0;i<12;i++)
	{
		ii=i+1
		if(ii==dt.getMonth())
			newWin.document.getElementById("monthid").selectedIndex=ii
	}
  newWin.document.write ('</td>')
  //newWin.document.write ('<td align=center colspan=3 class="everlianbg">' + dt.getUTCFullYear () + ' ' +  (dt.getMonth () > 8 ? String (dt.getMonth () + 1)  :  '0' + String (dt.getMonth () + 1)) + '</td>')
  newWin.document.write ('<td align=center class="everlianbg"><a href="javascript:window.opener.nextMonth(\'' + date + '\')" class="a2">&gt;</a></td>')
  newWin.document.write ('<td align=center class="everlianbg"><a href="javascript:window.opener.nextYear(\'' + date + '\')" class="a2">&gt;&gt;</a></td>')
  newWin.document.write ('</tr>')
  var desc = ["Sun ", "Mon ", "Tue ", "Wed ", "Thu ", "Fri ", "Sat "]
  newWin.document.write ('<tr bgcolor=#eeeee6 height=18>')
  for (i=0;i<7;i++){
    var tdbg="";
   // if (i==0||i==6)
    //   tdbg=" bgcolor=#ffffff"-->
    newWin.document.write ('<td align=center '+tdbg+' style=color:#000000>' + desc[i] + '</td>')
    }
  newWin.document.write ('</tr>')
  <!--here generate calendar content content of calendar.We add extra date in date array of this month to insure the first day begin at sunday. for example, if feb 1th is Tuesday, then we add [-1, 0] at the beginning of date array. And we also add null at the end of date array so that the length can be times of 7. Then we start loop at the beginning of our date array and put valid date into week 'grid'-->
  begin = 0 - dt.getDay () + 1
  temp = new Date (dt.getUTCFullYear (), dt.getMonth (), 32, 0, 0, 0, 0)
  term = 32 - temp.getDate ()
  plus = 6 -  (term - begin) % 7
  
  for (i=begin;i<=term + plus;i++)
  {
    if ( (i - begin) % 7 == 0)
      newWin.document.write ('<tr bgcolor=#dddddd>')
  now_i=new Date()
   this_day=now_i.getDate()
   this_month=now_i.getMonth()
   
   
    if (i > 0 && i <= term){
	     if (i == this_day && newWin.document.getElementById("monthid").selectedIndex == this_month)
	     {
	      newWin.document.write ('<td align=center bgcolor=#dddddd width=28 style=border-width:1px;border-style:outset><a href=# onClick=reload.value=\'true\';window.opener.getDate(' + i + ',\'' + date + '\')>' + i+ '</a></td>')
	    }else if (i == select_day && newWin.document.getElementById("monthid").selectedIndex == select_month)
	     {
	      newWin.document.write ('<td align=center bgcolor=#fff000 width=28 style=border-width:1px;border-style:outset><a href=# onClick=reload.value=\'true\';window.opener.getDate(' + i + ',\'' + date + '\')>' + i+ '</a></td>')
	    }else
	    {
				newWin.document.write ('<td align=center bgcolor=#ffffff width=28 style=border-width:1px;border-style:outset><a href=# onClick=reload.value=\'true\';window.opener.getDate(' + i + ',\'' + date + '\')>' + i + '</a></td>')    	
	    }
    }else
      newWin.document.write ('<td align=center>&nbsp;</td>')
   
    
    if ( (i - begin - 6) % 7 == 0)
      newWin.document.write ('</tr>')
  }
  newWin.document.write ('<tr>')
  newWin.document.write ('<td align=center class="everlianbg"><a href="javascript:window.opener.lastYear(\'' + date + '\')" class="a2">&lt;&lt;</a></td>')
  newWin.document.write ('<td align=center class="everlianbg"><a href="javascript:window.opener.lastMonth(\'' + date + '\')" class="a2">&lt;</a></td>')
  newWin.document.write ('<td align=center colspan=3 class="everlianbg">' + dt.getUTCFullYear () + ' ' +  (dt.getMonth () > 8 ? String (dt.getMonth () + 1)  :  '0' + String (dt.getMonth () + 1)) + '</td>')
  newWin.document.write ('<td align=center class="everlianbg"><a href="javascript:window.opener.nextMonth(\'' + date + '\')" class="a2">&gt;</a></td>')
  newWin.document.write ('<td align=center class="everlianbg"><a href="javascript:window.opener.nextYear(\'' + date + '\')" class="a2">&gt;&gt;</a></td>')
  newWin.document.write ('</tr>')
  newWin.document.write ('</table>')
  newWin.document.write ('<table border=0 cellspacing=1 cellpadding=0 align=center>')
  newWin.document.write ('<tr>')
  newWin.document.write ('<tr><td ><b><input type=hidden id=reload></b></td></tr>')
  //newWin.document.write ('<td align=center class="everlianbg">注：本窗口将在3分钟以后自动关闭。</td>')
  newWin.document.write ('</tr>')
  newWin.document.write ('</table>')
  newWin.document.write ('</body></html>')
  newWin.document.close ()
}
document.onMouseDown=mousedown
   function mousedown()
 {
  if(window.event.button==1)
  {
  	mouseleft=window.event.x
  	mousetop=window.event.y
  }
 <!-- document.site.mousesite.value="("+window.event.x+","+window.event.y+")"-->
 }
<!-- popup calendar window -->
function openWindow (date, seq)
{
  if (seq == 's'){
     objArray[date] = eval ('document.' + date)
   }
   else{
     objArray[date] = eval ('document.' + date + '[' + seq + ']')
   }
   
  mouseleft=window.event.x+50
  mousetop=window.event.y
  newWin=window.open ("","mydoc","height=200,width=225,titlebar=no,left="+mouseleft+",top="+mousetop+",title=no")
  <!-- if default is valid then show this date in calendar -->
  <!-- else show current time -->
  var dtArray = objArray[date].value.split ('-')
  if (dtArray.length == 3)
  {
    dt = new Date (parseInt (dtArray[2]), parseInt (dtArray[0].substring (0,1)) * 10 + parseInt (dtArray[0].substring (1,2)) - 1, 1, 10, 0, 0, 0)
  }
  //alert(date)
  fill (date)
}