//Call this to build the date list for the specified month
// Parameters:
//	oForm		= the form
//	sDateName	= partial form field name to act upon
function rebuildDays(oForm, sDateName) 
{
	monthselect	= oForm[sDateName + "Month"];
	dayselect	= oForm[sDateName + "Day"];
	yearselect	= oForm[sDateName + "Year"];
	
	month		= monthselect.options[monthselect.selectedIndex].value;
	dayindex	= dayselect.selectedIndex;
	year		= yearselect.options[yearselect.selectedIndex].value;
	
	if (year == "") year = 0;

	if (month > 0) 
	{
		if (month==4 || month==6 || month==9 || month==11) 
		{
			daysinmonth = 30;
		}
		else if (month==2) 
		{
			if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
				daysinmonth = 29;
			else
				daysinmonth = 28;
		}
		else 
		{
			daysinmonth = 31;
		}
		
		//Set the length of the select list
		dayselect.length = daysinmonth + 1;
		dayselect.options[0] = new Option("Day",0);
		
		for(i=1; i <= daysinmonth; i++) 
		{
			strDayValue = i<10 ? "0"+i : ""+i;
			dayselect.options[i] = new Option(i,strDayValue);
		}
		
		//Select the picked date
		if (dayindex <= daysinmonth) 
			dayselect.selectedIndex = dayindex;
		else
			dayselect.selectedIndex = 0;
		
	}
}