var today = new Date(new Date().valueOf());
     
    
    function setDates()

     {

       // This will populate the date dropdowns with today and tomarrow's values.

       theForm = document.Form1;

       var yearOffset = parseInt(theForm.ddlinyear.options[0].value,10);

       // getDate

       var tomorrow = new Date(new Date().valueOf() + (24*60*60*1000));

       var ddlinmonth=tomorrow.getMonth();

       var ddlindate=tomorrow.getDate();

       var ddlinyear=y2k(tomorrow.getYear());

     

       if(isLeapYear(ddlinyear)) { var days = new Array(31,29,31,30,31,30,31,31,30,31,30,31); }

       else { var days = new Array(31,28,31,30,31,30,31,31,30,31,30,31); }

     

       ddloutmonth=ddlinmonth;

       ddloutdate = ddlindate%days[ddlinmonth];

       ddloutyear=ddlinyear;

       if(ddloutdate == 0) { ddloutmonth = (ddlinmonth + 1) % 12; }

       if(ddloutdate == 0 && ddlinmonth == 11) { ddloutyear++; }

     

       // Now set the select boxes to the appropriate dates:

       theForm.ddlinmonth.options[ddlinmonth].selected=true;

       theForm.ddlindate.options[(ddlindate-1)].selected=true;

       theForm.ddlinyear.options[(ddlinyear-yearOffset)].selected=true;

       theForm.ddloutmonth.options[ddloutmonth].selected=true;

       theForm.ddloutdate.options[ddloutdate].selected=true;

       theForm.ddloutyear.options[(ddloutyear-yearOffset)].selected=true;

     }

     // quadYear

    

     function y2k(number){return (number < 1000) ? number + 1900 : number;}

    

    

     function isLeapYear(yr)

     {

       if (((yr % 4 == 0) && (yr % 100 != 0)) || (yr % 400 == 0)) { return true; }

       else { return false; } 

     }

     

     function changeDates()

     {

       theForm = document.Form1;

       var yearOffset = parseInt(theForm.ddlinyear.options[0].value,10);

       var ddlinmonth=parseInt(theForm.ddlinmonth.options[theForm.ddlinmonth.selectedIndex].value,10)-1;

       var ddlinyear=parseInt(theForm.ddlinyear.options[theForm.ddlinyear.selectedIndex].value,10);

       var baseMonth=today.getMonth();

       var baseDay=today.getDate();

       var baseYear=y2k(today.getYear());

      

       if(isLeapYear(ddlinyear)) { var days = new Array(31,29,31,30,31,30,31,31,30,31,30,31); }

       else { var days = new Array(31,28,31,30,31,30,31,31,30,31,30,31); }

     

       var ddlindate=parseInt(theForm.ddlindate.options[theForm.ddlindate.selectedIndex].value,10);

       

       if(ddlindate >= days[ddlinmonth]) { ddlindate = days[ddlinmonth]; }

       else { ddlindate = ddlindate%days[ddlinmonth]; }

       theForm.ddlindate.options[ddlindate-1].selected=true;

     

     /* This is causing problems with some people

       if((ddlinmonth < baseMonth) || (ddlinmonth == baseMonth && ddlindate < baseDay))

       {

         theForm.ddlinyear.options[((baseYear-yearOffset)+1)].selected=true;

         ddlinyear = baseYear+1;

       }

     */

       var currddloutmonth = parseInt(theForm.ddloutmonth.options[theForm.ddloutmonth.selectedIndex].value,10)-1;

       var currddloutdate = parseInt(theForm.ddloutdate.options[theForm.ddloutdate.selectedIndex].value,10);

       var currddloutyear = parseInt(theForm.ddloutyear.options[theForm.ddloutyear.selectedIndex].value,10);

       

       if((currddloutyear < ddlinyear) || (currddloutyear == ddlinyear && currddloutmonth < ddlinmonth) ||

         (currddloutyear == ddlinyear && currddloutmonth == ddlinmonth && currddloutdate <= ddlindate))

       {

         ddloutmonth=ddlinmonth;

         ddloutdate = ddlindate%days[ddlinmonth];

         ddloutyear=ddlinyear;

         if(ddloutdate == 0) { ddloutmonth = (ddlinmonth + 1) % 12; }

         if(ddloutdate == 0 && ddlinmonth == 11) { ddloutyear++; }

       

         theForm.ddloutmonth.options[ddloutmonth].selected=true;

         theForm.ddloutdate.options[ddloutdate].selected=true;

         theForm.ddloutyear.options[(ddloutyear-yearOffset)].selected=true;

       }

     }

     

    

    function checkOutDate()

     {

       theForm = document.Form1;

       var yearOffset = parseInt(theForm.ddlinyear.options[0].value,10);

       var ddloutmonth=parseInt(theForm.ddloutmonth.options[theForm.ddloutmonth.selectedIndex].value,10)-1;

       var ddloutyear=parseInt(theForm.ddloutyear.options[theForm.ddloutyear.selectedIndex].value,10);

       

       if(isLeapYear(ddloutyear)) { var days = new Array(31,29,31,30,31,30,31,31,30,31,30,31); }

       else { var days = new Array(31,28,31,30,31,30,31,31,30,31,30,31); }

     

       var ddloutdate=parseInt(theForm.ddloutdate.options[theForm.ddloutdate.selectedIndex].value,10);

       

       if(ddloutdate >= days[ddloutmonth]) { ddloutdate = days[ddloutmonth]; }

       else { ddloutdate = ddloutdate%days[ddloutmonth]; }

       theForm.ddloutdate.options[ddloutdate-1].selected=true;

     }