function getDays(month,year)
{
	switch(month) {
		case 1: {
			if((year%4 == 0)||((year%100 == 0)&&(year%400 == 0)))
				return 29;
			else
				return 28;
		}
		case 0:
		case 2:
		case 4:
		case 6:
		case 7:
		case 9:
		case 11: 
			return 31;
		default: 
			return 30;
	}
}
function changeDate(aDay, aMonth, aYear)
{
	if(document.all){
		var year = document.all.item(aYear).value;
		var month = document.all.item(aMonth).value;
		var day = document.all.item(aDay).value;
		var days = getDays(month-1, year);
		var select = document.all.item(aDay);
	}else{
		for(i=0; i<document.forms.length; i++) {
			tmp=document.forms[i];
			for(j=0; j<tmp.length; j++){
				el=tmp.elements[j];
				if(el.name == aYear){
					form = 'document.'+tmp.name;
				}
			}
		}
		var year = eval(form+"."+aYear+".value");
		var month = eval(form+"."+aMonth+"["+form+"."+aMonth+".selectedIndex].value");
		var day = eval(form+"."+aDay+"["+form+"."+aDay+".selectedIndex].value");
		var days = getDays(month-1, year);
		var select = eval(form+"."+aDay);
	}
	if (!year) return true;
	for(i=select.length; i>=0; i--) {
		if(select[i])
			if (document.all)
				select.remove(i);
			else
				select[i] = null;
	}
	if (document.all) oOption = document.createElement("OPTION");
	else oOption = new Option;
	oOption.text='Day';
	oOption.value='';
	if (document.all)
		select.add(oOption);
	else
		select[select.length] = oOption;

	for(i=0; i<days; i++ ) {
		if (document.all) oOption = document.createElement("OPTION");
		else oOption = new Option;
		oOption.text=(((i+1)< 10) ? "0":"")+(i+1);
		oOption.value=i+1;
		if (document.all)
			select.add(oOption);
		else
			select[select.length] = oOption;
		if(i==day) {
			select[i].selected = true;
		}
	}
	var last = select.length;
	if(select.selectedIndex == -1) {
		select[last-1].selected = true;
	}
}

