//*******************************************************
// FUNCTION UpdateDays()
//*******************************************************
//  this takes three select boxes as arguments and adjusts the number of days in the day select box
//  according to the month and year. 
//  This function uses the LeapYear function
//
// assumption 1: the values for the month select box options is a number representing the month, ie January=1, February=2
// assumption 2: the values for any option not a valid date (ie, the first option that says "--select month--") is -1
//*******************************************************
	function UpdateDays(monthSelect, daySelect, yearSelect){
		var month = monthSelect.options[monthSelect.selectedIndex].value;

		if (month != -1) {
			var daysinmonthinmonth;
			var days = daySelect.options[daySelect.length-1].value;

			if (month == 2) {
				if (yearSelect.options[yearSelect.selectedIndex].value == -1) daysinmonth = 29;
				else if (LeapYear(yearSelect.options[yearSelect.selectedIndex].value)) daysinmonth = 29;
				else daysinmonth = 28;
			}
			else if ((month == 4) || (month == 6) || (month == 9) || (month == 11)) daysinmonth = 30;
			else daysinmonth = 31;
			
			if (days > daysinmonth) {
				daySelect.options.length = daySelect.options.length - (days - daysinmonth);
			}
			else if (days < daysinmonth){
				var adddays = daysinmonth - days
				for (var i=1; i<=adddays; i++){
					days++;
					daySelect.options[daySelect.options.length] = new Option(days,days);	
				}
			}	
		}		
	}

//*******************************************************
// FUNCTION LeapYear(year)
//*******************************************************
// this takes a year and returns true if it is a leap year, false if it is not
//*******************************************************
	function LeapYear(year) {
             if (year%4 != 0) return false
             else if  (year%400 == 0) return true;
             else if (year%100 == 0) return false;
             else return true;
	}

	function showDiv(id) {
	   if (document.getElementById) {document.getElementById(id).style.display="";document.getElementById(id).style.visibility="visible";}
	   else if (document.all) {document.all[id].style.display="";document.all[id].style.visibility="visible";}
	}
	
	function hideDiv(id) {
	   if (document.getElementById) {document.getElementById(id).style.display="none";document.getElementById(id).style.visibility="hidden"}
	   else if (document.all) {document.all[id].style.display="none";document.all[id].style.visibility="hidden"}
	}