<!--
//  DATE Selection...
//		- customizes select box for day depending on the month
//		- checks for leap year
//		- combines year, month & day selects to a string in the format m/dd/yyyy
//
//	Add this to year and month selects (year checks for leap year):
//		onchange="myFillDays('document.FRM_CONTRACT_NEW','CLOSING_YEAR','CLOSING_MONTH','CLOSING_DAY');"
//
//	And the submit button:
//		<input type="button" value="Save" onClick="javascript:myCombineDate('document.FRM_CONTRACT_NEW','CLOSING_YEAR','CLOSING_MONTH','CLOSING_DAY','CLOSING_DATE');">



//---------------------------------------------------------
//  populate hidden date field and submit if good date

	/*var date1
	var date2
	var date3
	
	function myCombineDate(ThisForm,ThisYear,ThisMonth,ThisDay,HiddenDate){		
		if (eval(ThisForm + "." + ThisMonth).value < 0 || eval(ThisForm + "." + ThisDay).value < 0 || eval(ThisForm + "." + ThisYear).value < 0){
			alert("There is a problem a date selection. \nPlease review try again.");
			date1 = 0
		}else{
			eval(ThisForm + "." + HiddenDate).value = eval(ThisForm + "." + ThisMonth).value + "/" + eval(ThisForm + "." + ThisDay).value + "/" + eval(ThisForm + "." + ThisYear).value;
			date1 = 1
		}
	}
	
	function myCombineDate2(ThisForm,ThisYear,ThisMonth,ThisDay,HiddenDate){		
		if (eval(ThisForm + "." + ThisMonth).value < 0 || eval(ThisForm + "." + ThisDay).value < 0 || eval(ThisForm + "." + ThisYear).value < 0){
			alert("There is a problem a date selection. \nPlease review try again.");
			date2 = 0
		}else{
			eval(ThisForm + "." + HiddenDate).value = eval(ThisForm + "." + ThisMonth).value + "/" + eval(ThisForm + "." + ThisDay).value + "/" + eval(ThisForm + "." + ThisYear).value;
			date2 = 1
		}				
		
	}

	function myCombineDate3(ThisForm,ThisYear,ThisMonth,ThisDay,HiddenDate){		
		if (eval(ThisForm + "." + ThisMonth).value < 0 || eval(ThisForm + "." + ThisDay).value < 0 || eval(ThisForm + "." + ThisYear).value < 0){
			alert("There is a problem a date selection. \nPlease review try again.");
			date3 = 0
		}else{
			eval(ThisForm + "." + HiddenDate).value = eval(ThisForm + "." + ThisMonth).value + "/" + eval(ThisForm + "." + ThisDay).value + "/" + eval(ThisForm + "." + ThisYear).value;
			date3 = 1
		}				
		
		if (date1==1 && date2==1 && date3==1){
			eval(ThisForm + ".submit();")
		}
	}*/
	
//---------------------------------------------------------
//  test for leap year 

	var LeapYearSelected
	
	function checkYear(ThisForm,ThisYear){
		var year = eval(ThisForm + "." + ThisYear).value
		return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) ? 1 : 0;
	}
	
	function myTestTheYear(ThisForm,ThisYear){
		checkYear(ThisForm,ThisYear);
		if (!checkYear(ThisForm,ThisYear)){
			LeapYearSelected = false;
		}else{
			LeapYearSelected = true;
		}
	}


//---------------------------------------------------------
//  repopulate days select depending on the month selected

	function myFillDays(ThisForm,ThisYear,ThisMonth,ThisDay){
		
		var Situation;
		myTestTheYear(ThisForm,ThisYear);
			
		if ((eval(ThisForm + "." + ThisMonth).value == "April") || (eval(ThisForm + "." + ThisMonth).value == "June") || (eval(ThisForm + "." + ThisMonth).value == "September") || (eval(ThisForm + "." + ThisMonth).value == "November")){
			Situation = 1;
		}else if (eval(ThisForm + "." + ThisMonth).value == "February"){
			if (LeapYearSelected == false){
				Situation = 2;
			}else{
				Situation = 3;
			}
		}else{
			Situation = 4;		
		}
		
		switch (Situation){
			case 1:
				eval(ThisForm + "." + ThisDay).options.length = 1;
				for (i=1;i<31;i++){
					eval(ThisForm + "." + ThisDay).options.length = (i+1);
					eval(ThisForm + "." + ThisDay).options[i].value = i;
					eval(ThisForm + "." + ThisDay).options[i].text = i;
				}
				break;
			case 2:
				eval(ThisForm + "." + ThisDay).options.length = 1;
			  	for (i=1;i<29;i++){
					eval(ThisForm + "." + ThisDay).options.length = (i+1);
					eval(ThisForm + "." + ThisDay).options[i].value = i;
					eval(ThisForm + "." + ThisDay).options[i].text = i;
				}
				break;
			case 3:
				eval(ThisForm + "." + ThisDay).options.length = 1;
				for (i=1;i<30;i++){
					eval(ThisForm + "." + ThisDay).options.length = (i+1);
					eval(ThisForm + "." + ThisDay).options[i].value = i;
					eval(ThisForm + "." + ThisDay).options[i].text = i;
				}
				break;
			case 4: 
				eval(ThisForm + "." + ThisDay).options.length = 1;			
				for (i=1;i<32;i++){
					eval(ThisForm + "." + ThisDay).options.length = (i+1);
					eval(ThisForm + "." + ThisDay).options[i].value = i;
					eval(ThisForm + "." + ThisDay).options[i].text = i;
				}
				break;
		}
	}
//---------------------------------------------------------
//-->
