function DaysInMonth(iMonth, iYear)
{
    return 32 - new Date(iYear, iMonth, 32).getDate();
}

function UpdateDaysInMonth(drpDnLstDayCtrlId, drpDnLstMonthCtrlId, drpDnLstYearCtrlId)
{
    var drpDnLstDayCtrl = document.getElementById(drpDnLstDayCtrlId);
    var drpDnLstMonthCtrl = document.getElementById(drpDnLstMonthCtrlId);
    var drpDnLstYearCtrl = document.getElementById(drpDnLstYearCtrlId);
    var currentDay = drpDnLstDayCtrl[drpDnLstDayCtrl.selectedIndex].value;
    var daysInMonth = DaysInMonth(drpDnLstMonthCtrl.selectedIndex, drpDnLstYearCtrl.selectedIndex);
    drpDnLstDayCtrl.length=daysInMonth;
    for(var i=0; i<daysInMonth;)
    {
        drpDnLstDayCtrl[i].value = drpDnLstDayCtrl[i].text = ++i;
    }
    if (currentDay>0 && currentDay<=daysInMonth) 
    {
        drpDnLstDayCtrl.selectedIndex = currentDay - 1;
    }
    else
    {
        drpDnLstDayCtrl.selectedIndex = 0;
    }
}
