<!--

	CalMonths = ["January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"];
	MonthText=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'];
	MonthNumber=['01','02','03','04','05','06','07','08','09','10','11','12'];

	CalMonth1 = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	CalMonth2 = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

	var IE = document.all?true:false
	if (!IE) document.captureEvents(Event.MOUSEMOVE)

	document.onmousemove = getMouseXY;

	var tempX = 0;
	var tempY = 0;

	var Xbuffer = 0;
	var Ybuffer = 20;

	var thisMonth = new Date();
    var CurrentMonth = thisMonth.getMonth() + 1;
    var CurrentDay = thisMonth.getDate();
    var CurrentYear = thisMonth.getYear();
	if (CurrentYear < 2000)	CurrentYear += 1900;

	var month=CurrentMonth;
	var year=CurrentYear;
	var target;

	function choose(day){
		if (day < 10) day = "0"+day;
		var short_month = MonthNumber[month-1]
		if (target == 1){
			document.Form1.ctlAvailCriteria_cboDepMon.value = short_month + "/" + year;
			selYrDeptOnChange();
			setReturnCalendarDate();
			document.Form1.ctlAvailCriteria_cboDepDay.value= day;
		}else{
            document.Form1.ctlAvailCriteria_cboRetMon.value = short_month + "/" + year;
			selYrRetuOnChange();
			setReturnCalendarDate();
			document.Form1.ctlAvailCriteria_cboRetDay.value= day;
        }
		go('one',0);
	}
	function Next(){
		month=month+1;
		if (month >12){
			month = 1;
			year++;
		}
		go('one',1);
	}
	function Prev(){
		month=month-1;
		if (month < 1){
			month = 12;
			year--;
		}
		go('one',1);
	}
	function Calendar_get_daysofmonth(monthNo, p_year) {
		if ((p_year % 4) == 0) {
        		if ((p_year % 100) == 0 && (p_year % 400) != 0)	return CalMonth1[monthNo];
                return CalMonth2[monthNo];
		}else	return CalMonth1[monthNo];
	}
	function getMouseXY(e) 
	{
		if (IE){
			tempX = event.clientX + document.body.scrollLeft + Xbuffer;
	    		tempY = event.clientY + document.body.scrollTop + Ybuffer;
		}else{
	    	tempX = e.pageX + Xbuffer;
	    	tempY = e.pageY + Ybuffer;
	  	}  
	 	if (tempX < 0){tempX = 0;}
	  	if (tempY < 0){tempY = 0;}  
	  	return true;
	}
	function printDay(day,month,year){
		if ((day == CurrentDay) && (month == CurrentMonth) && (year == CurrentYear))	cclass = 'current_day';
		else	cclass= 'cal_day';
		if (month == CurrentMonth && year == CurrentYear){
			if (day < CurrentDay){
				cclass = 'passed_day';
			}
		}
		if (cclass == 'passed_day')	var link = '';
		else						var link = "<a href=\"javascript:choose('"+day+"');\" class=\""+cclass+"\">";
		return "<td class=\""+cclass+"\">"+link+""+day+"</a></td>";
	}
	function go(id,cmd){
		d = document.getElementById(""+id);
		var MaxMonthYear = document.Form1.ctlAvailCriteria_cboDepMon.options[document.Form1.ctlAvailCriteria_cboDepMon.length-1].text;
		var retCal = 0;
		var nullOB = 0;
		if (cmd == 2){
			target = 1;
			d.style.top = tempY + "px";
			d.style.left = tempX + "px";	
			cmd = 1;
		}
		if (cmd == 3){
			target = 2;
            d.style.top = tempY + "px";
            d.style.left = tempX + "px";
			retCal = 1;
			if (document.Form1.ctlAvailCriteria_cboDepMon.value == -1){
			nullOB = 1;
			}
            cmd = 1;
        }

		var test = new Date(year,month-1,1);
		var first_day  = test.getDay()-1;
		if (first_day == -1)	first_day = 6;

		
		var days_in_month = Calendar_get_daysofmonth(month-1,year);

		if (cmd == 1){
			str = "<table class=\"cal_table\">";
			str += "<tr><td colspan=\"7\"><a href=\"javascript:go('one',0);\" class=\"close\">Close[X]</a></td></tr>";
			str += "<tr><td class=\"arrow_head\">";
			if (CurrentMonth == month && CurrentYear == year)	str += "&#171;";
			else												str += "<a href=\"javascript:Prev();\">&#171;</a>";

			str += "</td><td colspan=\"5\" class=\"month_head\">";
			str += CalMonths[month-1]+" "+year+"</td><td class=\"arrow_head\">";

			var short_month = CalMonths[month-1].substr(0,3).toUpperCase() + " " + year;
			if (MaxMonthYear.toUpperCase() == short_month)str += "&#187;";	
			else							str += "<a href=\"javascript:Next();\">&#187;</a>";

			str +=  "</td></tr>";
			str += "<tr><td class=\"day_head\">Mon</td><td class=\"day_head\">Tue</td><td class=\"day_head\">Wed</td><td class=\"day_head\">Thu</td><td class=\"day_head\">Fri</td><td class=\"day_head\">Sat</td><td class=\"day_head\">Sun</td></tr>";
			str += "<tr>";
			var day = 0;
			for (var x=0;x<first_day;x++)	str += "<td>&nbsp;</td>";	//blank days before month starts
			for (var x=first_day;x<7;x++){  day++;  str += printDay(day,month,year); }
			str += "</tr>";

			while (day < days_in_month){
				str += "<tr>";
				for (var x=0;x<7;x++){
					day++;
					if (day > days_in_month)	str += "<td>&nbsp;</td>";
					else						str += printDay(day,month,year);
				}
				str += "</tr>";
			}
			str += "</table>";
			d.innerHTML = str;
		}
		else{
 			d.innerHTML = "&nbsp;";
		}
	}
//-->

