
<!-- Begin
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin

/* 	INCLUDE THIS CONTENT IN A .cs FILE - this is to format the calendar rows and columns
	<!--
	span.label {color:black;width:30;height:16;text-align:center;margin-top:0;background:#000000;font:bold 10px Arial;color: #FFFFFF;}
	span.c1 {cursor:hand;color:black;width:30;height:16;text-align:center;margin-top:0;background:#ffF;font:bold 10px Arial}
	span.c2 {cursor:hand;color:red;width:30;height:16;text-align:center;margin-top:0;background:#ffF;font:bold 10px Arial}
	span.c3 {cursor:hand;color:#b0b0b0;width:30;height:16;text-align:center;margin-top:0;background:#ffF;font:bold 9px Arial}
-->
*/
function maxDays(mm, yyyy){
var mDay
	if((mm == 3) || (mm == 5) || (mm == 8) || (mm == 10)){
		mDay = 30;
  	}
  	else{
  		mDay = 31
  		if(mm == 1){
   			if (yyyy/4 - parseInt(yyyy/4) != 0){
   				mDay = 28
   			}
		   	else{
   				mDay = 29
  			}
		}
  }
  
//document.write("maxdays:" + mDay)
return mDay
}

function changeBg(id){
//today's date
var now = new Date;
var mm = now.getMonth();
var dd = now.getDate();
var yyyy = now.getFullYear();
//selected date
var currY = parseInt(document.calForm.selYear.value);
var currM = parseInt(document.calForm.selMonth.value) ;
var curD=eval(document.getElementById(id).innerText);
//onMouseOver='changeBg(this.id)' onMouseOut='changeBg(this.id)'
	if (eval(id).style.backgroundColor != "#003399"){
		eval(id).style.backgroundColor = "#003399"
	}
	else if ((dd==curD)&&(mm==currM)&&(yyyy==currY)){
				//mark today's date
				eval(id).style.backgroundColor="#CC0000";
			}
	else{
		eval(id).style.backgroundColor = "#ffffff"
	}
//alert(dd + ","+curD+","+mm+","+currM);

}

function selectDate(id){
var currY = parseInt(document.calForm.selYear.value);
var currM = parseInt(document.calForm.selMonth.value) + 1;

//this check for the browser document.all object that works for netscape and document.getElementById that works for IE
//if (document.all)
	curD=document.all[id].innerHTML;
//else
	//curD=document.getElementById(id).innerText

if(eval(curD)) {

	window.opener.dialogArguments.value=currM+"/"+curD+"/"+currY;
	window.close();
}
//onMouseOver='changeBg(this.id)' onMouseOut='changeBg(this.id)'

}

function writeCalendar(){
var now = new Date
var dd = now.getDate()
var mm = now.getMonth()
var dow = now.getDay()
var yyyy = now.getFullYear()
var arrM = new Array("January","February","March","April","May","June","July","August","September","October","November","December")
var arrY = new Array()
	for (ii=0;ii<=10;ii++){
		arrY[ii] = yyyy - 2 + ii
	}
var arrD = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")

var text = ""
text = "<form name=calForm>"
text += "<table cellspacing='0' cellpadding='0' border='0' style='background-color:#66CCFF;border-style:solid;border-width:1px;border-color:#003399;margin:0px;padding:0px;'>"
text += "<tr><td>"
text += "<table><tr>"

//write the calendar months
text += "<td align=left>"
//text += "<select name=selMonth onChange='changeCal()'>"
	for (ii=0;ii<=11;ii++){
		if (ii==mm){
			//text += "<option value= " + ii + " Selected>" + arrM[ii] + "</option>"
			text += "<input readonly='readonly' value= " + arrM[ii] + " size='10'></input>"
		}
		/*else{
			text += "<option value= " + ii + ">" + arrM[ii] + "</option>"
		}*/
		
		//document.write(text)
	}
//text += "</select>"

text += "</td>"
text += "<td align=right>"

//write the calendar years
//text += "<select name=selYear onChange='changeCal()'>"
	for (ii=0;ii<=10;ii++){
		if (ii==2){
			//text += "<option value= " + arrY[ii] + " Selected>" + arrY[ii] + "</option>"
			text += "<input readonly='readonly' value= " + arrY[ii] + " size='2'></input>"
		}
		/*else{
			text += "<option value= " + arrY[ii] + ">" + arrY[ii] + "</option>"
		}*/
	}
//text += "</select>"

text += "</td>"
text += "</tr></table>"
text += "</td></tr>"
text += "<tr><td>"
text += "<table cellspacing='1' cellpadding='0' border='0'>"
//write the calendar weekday
text += "<tr>"
	for (ii=0;ii<=6;ii++){
		text += "<td align=center><span class=label>" + arrD[ii] + "</span></td>"
	}
text += "</tr>"
aa = 0
	for (kk=0;kk<=5;kk++){
		text += "<tr>"
		for (ii=0;ii<=6;ii++){
			text += "<td align=center name=sp" + aa + "><span id=sp" + aa + " onClick='selectDate(this.id)' onMouseOver='changeBg(this.id)' onMouseOut='changeBg(this.id)'>1</span></td>"
			aa += 1
			//document.write("value: " + aa)
		}
		text += "</tr>"
		
		//document.write("value: " + aa)
	}
text += "</table>"
text += "</td></tr>"
text += "</table>"
text += "</form>"
document.write(text)

//call this function to set the days in the calendar
changeCal()

}


//The changeCal function sets the days in the calendar for each month selected
function changeCal(){
var now = new Date
var dd = now.getDate()
var mm = now.getMonth()
var dow = now.getDay()
var yyyy = now.getFullYear()
var currM = mm //parseInt(document.calForm.selMonth.value) //get the month from the document
var prevM


	if (currM!=0){
		prevM = currM - 1
	}
	else{
		prevM = 11
	}
var currY = yyyy //parseInt(document.calForm.selYear.value) //get the year from the document
mmyyyy= new Date(currY, currM, 1);
var day1 = mmyyyy.getDay(); //get the day number of the week

//alert("month: " + document.calForm.selMonth.value + " date: " + mmyyyy + " day1: " + day1);
	if (day1 == 0){
		day1 = 7
	}


var arrN = new Array(41)
var aa =0
	for (ii=0;ii<day1;ii++){
		arrN[ii] = maxDays((prevM),currY) - day1 + ii + 1
		
	}
	aa = 1
	for (ii=day1;ii<=day1+maxDays(currM,currY)-1;ii++){
		arrN[ii] = aa
		aa += 1
		//document.write("changing date1")
	}
	aa = 1
	for (ii=day1+maxDays(currM,currY);ii<=41;ii++){
		arrN[ii] = aa
		//document.write("value: " + aa)
		aa += 1
		
		//document.write("index: " + li)
	}
	
	for (ii=0;ii<=41;ii++){
		dcol = document.getElementById("sp"+ii)
		dcol.style.backgroundColor = "#FFFFFF"
	}

var dcol //day column variable

//write out the days in the calendar
var dCount = 0
	for (ii=0;ii<=41;ii++){
		if (((ii<7)&&(arrN[ii]>20))||((ii>27)&&(arrN[ii]<20))){
			//set the value to empty so the extra days are not written
			dcol = document.getElementById("sp"+ii)
			dcol.innerHTML = "";//arrN[ii]
			dcol.className = "c3"
			//document.write("extra days")
		}
		else{
			dcol = document.getElementById("sp"+ii)
			dcol.innerHTML = arrN[ii]
			if ((dCount==0)||(dCount==6)){
				dcol.className = "c2"
			}
			else{
				dcol.className = "c1"
			}
			if ((arrN[ii]==dd)&&(mm==currM)&&(yyyy==currY)){
				dcol.style.backgroundColor="#CC0000"
				dcol.style.color="#FFFFFF"
			}
		}
	dCount += 1
		if (dCount>6){
			dCount=0
		}
	}
}

//--> 