
function GetDayOfMonth(DayCtrl, MonthCtrl, YearCtrl){
   
   var lastDayValue=DayCtrl.value;
   var DaysCount=31;
   
   if (MonthCtrl.options[MonthCtrl.selectedIndex].value=='2' && (parseInt(YearCtrl.options[YearCtrl.selectedIndex].value)%4)==0){
       DaysCount=29;
   }else if (MonthCtrl.options[MonthCtrl.selectedIndex].value=='2'){
       DaysCount=28;
   }else if (MonthCtrl.options[MonthCtrl.selectedIndex].value=='4' || MonthCtrl.options[MonthCtrl.selectedIndex].value=='6' || MonthCtrl.options[MonthCtrl.selectedIndex].value=='9' || MonthCtrl.options[MonthCtrl.selectedIndex].value=='11'){
       DaysCount=30;
   }
   
   if (DayCtrl.options.length != DaysCount+1){           
       DayCtrl.options.length=0;
       var oOption;
       
       oOption = document.createElement('option');
       DayCtrl.options.add(oOption);
       oOption.innerHTML='Day';
       oOption.value='-1';
       
       for (var i=1;i<=DaysCount;i++){
           oOption = document.createElement('option');
           DayCtrl.options.add(oOption);
           oOption.innerHTML=i;
           oOption.value=i;
           if (i==lastDayValue) oOption.selected=true;
       }
   }
}