function populate(objYear,objMonth,objDay,objDate,pFormat) 
{
	var selectedDay = objDay[objDay.selectedIndex].value - 1;
	var curDay = objDay[objDay.selectedIndex].value;
	var curMonth = objMonth[objMonth.selectedIndex].value;
	var curYear = objYear[objYear.selectedIndex].value;

			timeA = new Date(curYear, curMonth,1);
			timeB = new Date(timeA- 86400000);
			var daysInMonth = timeB.getDate();
			
			for (var i = 0; i < objDay.length; i++) 
			{
				objDay.options[0] = null;
			}
			
			for (var i = 0; i < daysInMonth; i++) 
			{
				objDay.options[i] = new Option(i+1);
				objDay.options[i].value = i+1;
			}

		if (selectedDay < objDay.length)	
		{
			if (selectedDay >= 0) objDay.options[selectedDay].selected = true;
			//if (selectedDay >= 0) objDay.selectedIndex = selectedDay;
		}
		else
		{
			objDay.options[0].selected = true;
		}
			refreshDay(objDate,objDay,objMonth,objYear,pFormat);
			
			
}

function refreshDay(objDate,objDay,objMonth,objYear,pFormat)
{
			switch (pFormat)
			{
				case 'MM/DD/YYYY':
					objDate.value = objMonth[objMonth.selectedIndex].value + "/" + objDay[objDay.selectedIndex].value + "/" + objYear[objYear.selectedIndex].value
					break;
				case 'mm/dd/yyyy':
					objDate.value = objMonth[objMonth.selectedIndex].value + "/" + objDay[objDay.selectedIndex].value + "/" + objYear[objYear.selectedIndex].value
					break;
				default:
					objDate.value = objDay[objDay.selectedIndex].value + "/" + objMonth[objMonth.selectedIndex].value + "/" + objYear[objYear.selectedIndex].value
			}
}
