function MonthChanged(month_dropdown, year_dropdown, day_dropdown){
/* This function changes the options in the day drop down based on the month and */
/* year selected. */

	/* This is the month dropdown in the date selectors */
	var month_ctrl = document.getElementById(month_dropdown);
	/* This is the year dropdown in the date selectors */
	var year_ctrl = document.getElementById(year_dropdown);
	/* This is the day dropdwon inthe date selectors */
	var day_ctrl = document.getElementById(day_dropdown);
	
	/* Get the number of days to put into the day dropdown. */
	var daysInMonth = DaysInMonth(year_ctrl.value,month_ctrl.value - 1);
	
	/* Refill the day dropdowns. */
	FillDayDropdown(1, daysInMonth, day_ctrl.value, day_ctrl);
}

function FillDayDropdown(from, to, selectedvalue, ctrl){
/* This function sets values into the starting day drop down */
	var index = 0;
	while (from <= to)
	{
		ctrl.options[index] = new Option(from,from);
		from++;
		index++;
	}
	
	while (index < ctrl.length)
	{
		ctrl.options[ctrl.length - 1] = null;
	}
	
	/* This is done to correct an issue on the open entry form, this does not affect admin pages */
	if(selectedvalue == null){selectedvalue = "1";}
	if(selectedvalue == ""){selectedvalue = "1";}
	
	/* These keep track of where the starting day was */
	if (selectedvalue > ctrl.length){
		/* The old months day was past the last day of the new month, ie, Jan 31 to Feb 28 */
		/* so set the selected value to the last day of the next month. */
		ctrl.selectedIndex = ctrl.length - 1;
	}
	else{
		/* Set drop down to the same day of the new month */
		ctrl.selectedIndex = selectedvalue - 1;
	}
}

function DaysInMonth(year, month){
	/* Given a year and month this function returns the number of days in the month. */
	return 32 - new Date(year, month, 32).getDate();
}