function DayInMonth(MonthSelect, DaySelect, YearField, IsAny)
{
	if ((MonthSelect.options[MonthSelect.selectedIndex].value == '1') || (MonthSelect.options[MonthSelect.selectedIndex].value == '3') || 
		(MonthSelect.options[MonthSelect.selectedIndex].value == '5') || (MonthSelect.options[MonthSelect.selectedIndex].value == '7') ||
		(MonthSelect.options[MonthSelect.selectedIndex].value == '8') || (MonthSelect.options[MonthSelect.selectedIndex].value == '10') ||
		(MonthSelect.options[MonthSelect.selectedIndex].value == '12')){
		if (DaySelect.length < (29+IsAny)){
				DaySelect.options[28+IsAny] = new Option("29", "29");
		};
		if (DaySelect.length < (30+IsAny)){
				DaySelect.options[29+IsAny] = new Option("30", "30");
		};
		if (DaySelect.length < (31+IsAny)){
				DaySelect.options[30+IsAny] = new Option("31", "31");
		}
	}else{
		if ((MonthSelect.options[MonthSelect.selectedIndex].value == '4') || (MonthSelect.options[MonthSelect.selectedIndex].value == '6') || 
			(MonthSelect.options[MonthSelect.selectedIndex].value == '9') || (MonthSelect.options[MonthSelect.selectedIndex].value == '11')){
			if (DaySelect.length > (30+IsAny)){
				if (DaySelect.options[30+IsAny].selected){
					DaySelect.options[30+IsAny].selected = false;
					DaySelect.options[0].selected = true;
				}
				DaySelect.options[30+IsAny] = null
			}else {
				if (DaySelect.length < (29+IsAny)){
						DaySelect.options[28+IsAny] = new Option("29", "29");
				};
				if (DaySelect.length < (30+IsAny)){
					DaySelect.options[29+IsAny] = new Option("30", "30");
				}
			}
		}else{
			if(MonthSelect.options[MonthSelect.selectedIndex].value == '2'){
				if (DaySelect.length > (29+IsAny)){
					if (DaySelect.selectedIndex >= (29+IsAny)){
						DaySelect.options[0].selected = true;
					}
					DaySelect.options[30+IsAny] = null;
					DaySelect.options[29+IsAny] = null;
				}
				if ((DaySelect.length > (28+IsAny)) && ((YearField.value%4)!=0)){
					if (DaySelect.options[28+IsAny].selected){
						DaySelect.options[28+IsAny].selected = false;
						DaySelect.options[0].selected = true;
					}
					DaySelect.options[28+IsAny] = null;
				}
			}
		}
	}
	return true;
}

function FebruaryDay(MonthSelect, DaySelect, YearField, IsAny)
{
	if ( (YearField.value.length != 0) && (MonthSelect.options[MonthSelect.selectedIndex].value == '2') && ((YearField.value%4)!=0)){
		if (DaySelect.length >(28+IsAny)){
			if (DaySelect.options[28+IsAny].selected){
				DaySelect.options[28+IsAny].selected = false;
				DaySelect.options[0].selected = true;
			}
			DaySelect.options[28+IsAny] = null;
		}
	}else{
		if (DaySelect.length <(29+IsAny)){
			DaySelect.options[28+IsAny] = new Option("29", "29");
		}
	}
	return true;
}

/*function SetDays(DaySelect, DaysArray) {
	var i
	for (i = 0 ; i < DaysArray.length; i++) {
		DaySelect.options[DaySelect.options.length] = new Option (DaysArray[i][0], DaysArray[i][1])
		if (DaysArray[i][2] == 'selected') {
			DaySelect.selectedIndex = DaySelect.options.length - 1
		}			
	}
}*/

function SetDays(DaySelect, DaysCount, DaySelected, IsAny) {
	var i
	if (IsAny == 1){
		DaySelect.options[DaySelect.options.length] = new Option ("", "Any")
	}
	for (i = 0 ; i <= DaysCount; i++) {
		DaySelect.options[DaySelect.options.length] = new Option (i, i)
		if (i == DaySelected) {
			DaySelect.selectedIndex = DaySelect.options.length - 1
		}			
	}
}

