/*comment1 starts
Author: Badrinath Chebbi
Date: 01-04-2002
comment1 ends*/
	//Browser detection code
	var IE4 = (document.all && !document.getElementById) ? true : false;
    var NS4 = (document.layers) ? true : false;
    var IE5 = (document.all && document.getElementById) ? true : false;
    var N6 = (document.getElementById && !document.all) ? true : false;
   //Browser detection code ends here

var aMonthNames = new Array(
	'JANUARY', 'FEBRUARY', 'MARCH', 
	'APRIL', 'MAY', 'JUNE', 
	'JULY',	'AUGUST', 'SEPTEMBER', 
	'OCTOBER', 'NOVEMBER', 'DECEMBER'
	);
var aMonthDisplay = new Array(
	'01', '02', '03', 
	'04', '05', '06', 
	'07',	'08', '09', 
	'10', '11', '12'
	);	
var aMonthDays = new Array(  
	/* Jan */ 31,     /* Feb */ 28, /* Mar */ 31,     /* Apr */ 30, 
	/* May */ 31,     /* Jun */ 30, /* Jul */ 31,     /* Aug */ 31, 
	/* Sep */ 30,     /* Oct */ 31, /* Nov */ 30,     /* Dec */ 31 
	);
var days = new Array(42);
		
		/*Comment2 starts
		  This Function populates the table with the dates for a particular month in a year.
		  comment2 ends*/
		function daylayerdisplay(b,a,c)
		{
		/*newwindow=window.open("");
		newwindow.status=b + "" + a + "" + c + "";*/
		/*Comment3 starts
		  b is Year in yyyy format
		  a is Months in numerical format viz 0=january,1=february etc
		  c is day in numeric format
		  Comment3 ends
		*/
		monthreduction=a;
		monthincrease=a;
		            if (b%4 == 0 || b%100 ==0){
					aMonthDays[1]=29;
					}
					else{
					aMonthDays[1]=28;
					}
				    var oDateNow = new Date();	
					var oDate = new Date(aMonthNames[a] +  1 + "," + b);
					dayofweek=oDate.getDay();
					//Input values in td's
					var count=0;
					var count1;
					var end=aMonthDays[a]+(dayofweek);
					for (s=1;s<=42;s++){
					document.getElementById("day"+s).childNodes[0].innerHTML="";
					}
					for (s=(dayofweek+1);s<=end;s++){
					count=count+1;
					document.getElementById("day"+s).childNodes[0].innerHTML=count;
					if (count<=9)
					{
					count1=0+""+count;
					}
					else
					{
					count1=count;
					}
					document.getElementById("day"+s).childNodes[0].id=count1;
					}
			}
				
				/*Comment4 starts
				This function sends the value back to the form object of the window
				which called it*/
				function sendvalue(y,m,d)
				{
					if (y == 1){
					todayobj= new Date();
					today=todayobj.getYear()+todayobj.getMonth()+todayobj.getDate();
					if (N6){
					year=todayobj.getYear()+1900;
					}
					else
					{
					year=todayobj.getYear();
					}					
					if (todayobj.getDate() <= 9)
					{
					var todayday=0+""+todayobj.getDate();
					}
					else
					{
					var todayday=todayobj.getDate();
					}
					parent.document.callingform.receivedate.value=aMonthDisplay[todayobj.getMonth()]+ "-" + todayday + "-" + year;
					parent.document.getElementById('calendarframe').style.display='none'
					}
					else{
					parent.document.callingform.receivedate.value= aMonthDisplay[m]+"-"+d+"-"+y;//y + m + d;
					parent.document.getElementById('calendarframe').style.display='none'
					}
				 }
				 /*Comment4 ends here*/
				 
				 /*Comment5 starts
				 This function reduces the month by one everytime prev.gif is clicked*/
				 function reducemonths()
				 { 
				 monthreduction= +monthreduction - 1;
				 if (monthreduction==-1)
				 {
				 monthreduction=11;
				 document.calendarform.year.value=
				 parseFloat(document.calendarform.year.value)-1;
				 }
				 
				 document.calendarform.month[monthreduction].selected = "1";
				 daylayerdisplay(document.calendarform.year.value,monthreduction,101);
				 }
				 /*Comment5 ends here*/
				 
				 /*Comment6 starts
				 This function Increases the month by one everytime next.gif is clicked*/
				 function increasemonths()
				 { 
				 monthincrease= +monthincrease + 1;
				 if (monthincrease==12)
				 {
				 monthincrease=0;
				 document.calendarform.year.value=
				 parseFloat(document.calendarform.year.value)+1;
				 }
				 document.calendarform.month[monthincrease].selected = "1";
				 daylayerdisplay(document.calendarform.year.value,monthincrease,101);
				 }
				 /*Comment6 ends here*/				 
