function checkLeapYear(datea)
{
	datea = parseInt(datea);

	if(datea%4 == 0){
		if(datea%100 != 0){
			return true;
		}
		else{
			if(datea%400 == 0)
				return true;
			else
				return false;
		}
	}
	
	return false;
}

function updateDaysDropDown(monthDropDown, dayDropDown, yearDropDown){
	var intNumberOfDaysInMonth=0;
		
	switch(monthDropDown.options[monthDropDown.selectedIndex].value){
		case "1":
			intNumberOfDaysInMonth=31;
			break;
		case "2":
			if(yearDropDown.options[yearDropDown.selectedIndex].value.length>0)
				if(checkLeapYear(yearDropDown.options[yearDropDown.selectedIndex].value))
					intNumberOfDaysInMonth=29;
				else
					intNumberOfDaysInMonth=28;
			else
				intNumberOfDaysInMonth=28;
			
			break;
		case "3":
			intNumberOfDaysInMonth=31;
			break;
		case "4":
			intNumberOfDaysInMonth=30;
			break;
		case "5":
			intNumberOfDaysInMonth=31;
			break;
		case "6":
			intNumberOfDaysInMonth=30;
			break;
		case "7":
			intNumberOfDaysInMonth=31;
			break;
		case "8":
			intNumberOfDaysInMonth=31;
			break;
		case "9":
			intNumberOfDaysInMonth=30;
			break;
		case "10":
			intNumberOfDaysInMonth=31;
			break;
		case "11":
			intNumberOfDaysInMonth=30;
			break;
		case "12":
			intNumberOfDaysInMonth=31;
			break;
	}
		
	if(intNumberOfDaysInMonth>0){
		if(dayDropDown.selectedIndex>-1)
			if(parseInt(dayDropDown.options[dayDropDown.selectedIndex].value)>intNumberOfDaysInMonth)
				dayDropDown.selectedIndex=0;
		
		if(parseInt(dayDropDown.options[dayDropDown.options.length-1].value)<intNumberOfDaysInMonth)
			for(var i=dayDropDown.options.length; i<=intNumberOfDaysInMonth; i++){
				dayDropDown.options[dayDropDown.options.length]=new Option(i+"", i+"");
			}
		
		if(parseInt(dayDropDown.options[dayDropDown.options.length-1].value)>intNumberOfDaysInMonth)
			dayDropDown.options.length=intNumberOfDaysInMonth+1;
	}
}