function getDaysForMonth(A,B){switch(A){case"1":case"3":case"5":case"7":case"8":case"10":case"12":return 31;break;case"2":return(B%4!=0)?28:((B%2000==0)?29:((B%400!=0)?29:28));return 28;break;case"4":case"6":case"9":case"11":return 30;break;case"-1":return 31;break;default:return 0;break}}function onMonthYearChanged(A){currentDay=document.getElementById(A+"_day").options[document.getElementById(A+"_day").selectedIndex].value;currentMonth=document.getElementById(A+"_month").options[document.getElementById(A+"_month").selectedIndex].value;currentYear=document.getElementById(A+"_year").options[document.getElementById(A+"_year").selectedIndex].value;if(currentYear!=-1&&currentMonth!=-1){daysInMonth=getDaysForMonth(currentMonth,currentYear);document.getElementById(A+"_day").innerHTML="";for(i=1;i<=daysInMonth;i++){_addOption(A+"_day",i,i,false,false)}i++;if(currentDay!=-1){if(currentDay>daysInMonth){document.getElementById(A+"_day").selectedIndex=0}else{document.getElementById(A+"_day").selectedIndex=currentDay-1}}}else{if(currentMonth==-1){daysInMonth=getDaysForMonth(currentMonth,currentYear);document.getElementById(A+"_day").innerHTML="";_addOption(A+"_day","--",-1,false,false);for(i=1;i<=daysInMonth;i++){_addOption(A+"_day",i,i,false,false)}if((currentDay>daysInMonth)||currentDay<0){document.getElementById(A+"_day").selectedIndex=0}else{document.getElementById(A+"_day").selectedIndex=currentDay}}else{if(currentYear==-1){daysInMonth=getDaysForMonth(currentMonth,currentYear);document.getElementById(A+"_day").innerHTML="";_addOption(A+"_day","--",-1,false,false);for(i=1;i<=daysInMonth;i++){_addOption(A+"_day",i,i,false,false)}if((currentDay>daysInMonth)||currentDay<0){document.getElementById(A+"_day").selectedIndex=0}else{document.getElementById(A+"_day").selectedIndex=currentDay}}}}}function _addOption(F,E,B,D,A){var C=document.createElement("option");C.appendChild(document.createTextNode(E));C.setAttribute("value",B);if(D){C.defaultSelected=true}else{if(A){C.selected=true}}document.getElementById(F).appendChild(C)};
