function fixdaymenu(dayCtrl, monthCtrl, yearCtrl, startYear)
{
	var i, j;
	var prompt;
	var days;
	var year;
	var month;
	var selected_day;
	
	month = monthCtrl.selectedIndex + 1;
	year = yearCtrl.selectedIndex + startYear;
	selected_day = dayCtrl.selectedIndex;
	
	
	// empty existing items
	for(i = dayCtrl.options.length; i >= 0; i--)
	{
		dayCtrl.options[i] = null; 
	}

	if( month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12 )
		days = 31;
	if( month == 4 || month ==  6 || month == 9 || month == 11 )
		days = 30;
	if( month == 2 )
		days = 28;
	if((((year%4) == 0 && (year%100) != 0) || ((year % 400) == 0)) && (month==2) )
		days = 29;

	j = 0;
	// add new items
	for(i = 1; i <= days; i++)
	{
		dayCtrl.options[j] = new Option(i);
		dayCtrl.options[j].value = i; 
		
		j++;
	}
	
	if( selected_day < dayCtrl.options.length )
		i = selected_day;
	else
		i = dayCtrl.options.length-1;
	
	// select proper item (prompt) for sub list
	dayCtrl.options[i].selected = true;	
}
