var MonthDays = new Array('',31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

function GetDayCount(YearList, Monthlist) { 
SomeYear = YearList.value;
SomeMonth = Monthlist.value;  
   return ((SomeMonth == 1) && ((SomeYear % 400 == 0) || ((SomeYear % 4 == 0) && (SomeYear % 100 != 0)))) ? 29 : MonthDays[SomeMonth];
}

function InsertDays(YearList, Monthlist, DayList){
var OldSize = DayList.length;
var NewDays = GetDayCount(YearList, Monthlist);
	if (NewDays != OldSize) {
    	for (var k=Math.min(NewDays,OldSize);k<Math.max(NewDays,OldSize);k++) {	
         	(k >= NewDays) ? DayList.options[NewDays] = null : DayList.options[k] = new Option(k+1, k+1);
      	}
	}
}