﻿
        function populatemonths(cacheobj){
            
            var months  = new Array("Month", "January", "February", "March", 
            "April", "May", "June", "July", "August", "September", 
            "October", "November", "December");
            //var currentdate = new Date(dt.toString())
            //currentdate.setDate(dt)
            //alert(currentdate.getDate())
            for (m=cacheobj.options.length-1;m>0;m--)
            cacheobj.options[m]=null
            cacheobj.options[0]=new Option("Month", "")
            for (i=1;i<months.length;i++)
            {
                cacheobj.options[i]=new Option(months[i], i)
             if(i==currentdate.getMonth() + 1)   
                cacheobj.options[i].selected=true
            }
            //alert("Current Month:" + currentdate.getMonth())
        }
        function populatedays(cacheobj, cacheobj1){
            if (cacheobj.selectedIndex > 0)
            {
                year = new Date().getFullYear()
                for (m=cacheobj1.options.length-1;m>0;m--)
                cacheobj1.options[m]=null
                n = cacheobj.options[cacheobj.selectedIndex].value
                days = 0;
                    switch(n){
                        case '1':
                        case '3':
                        case '5':
                        case '7':
                        case '8':
                        case '10':
                        case '12':
                            days = 31
                          break;    
                        case '2':
                            days = (leapYear(year)) ? 29 : 28 // February
                          break;
                        default: //4,6,9,11
                            days = 30
                    } 
                //cacheobj1.options[0]=new Option("Day", "")
                for (i=1;i<=days;i++)
                cacheobj1.options[i-1]=new Option(i, i)
                cacheobj1.options[0].selected=true

            }
        }
        function leapYear(year) {
            if (year % 4 == 0) // basic rule
            return true // is leap year
            return false // is not leap year
        }
