function getDaysInMonth(year,month)
{
   if(month == 3 || month == 5 || month == 8 || month == 10)
   {
      return 30;
   }else if(month == 1)
   {
      if(Math.floor(year/4) == year/4 && (Math.floor(year/100) != year/100 || Math.floor(year/400) == year/400))
      {
         return 29;
      }else
      {
         return 28;
      }
   }else
   {
      return 31;
   }
}

function updateSelectDay(selectYear,selectMonth,selectDay)
{
   var yearIndex = selectYear.selectedIndex;
   var monthIndex = selectMonth.selectedIndex;
   var dayIndex = selectDay.selectedIndex;

   if(yearIndex>=0 && monthIndex>=0 && dayIndex>=0)
   {
      var year = selectYear.options[yearIndex].value;
      var month = selectMonth.options[monthIndex].value;
      var dayCount = getDaysInMonth(year,month);
      var lastDay = selectDay.options[selectDay.length-1].value;

      if(dayCount > lastDay)
      {
         selectDay.length = dayCount;
         for(day = dayCount; day>lastDay; day--)
         {
            selectDay.options[day-1].text = day;
            selectDay.options[day-1].value = day;
         }
      }else if(dayCount < lastDay)
      {
         if(selectDay.selectedIndex >= dayCount)
         {
            selectDay.length = dayCount;
            selectDay.selectedIndex = 0;
         }else
         {
            selectDay.length = dayCount;
         }
      }
   }
}

function getSelectedValue(select)
{
   var index = select.selectedIndex;

   if(index>=0)
   {
      return select.options[index].value;
   }else
   {
      return null;
   }
}
