﻿function   YYYYMMDDstart()   
  {   
          MonHead   =   [31,   28,   31,   30,   31,   30,   31,   31,   30,   31,   30,   31];   
      
          var   y       =   new   Date().getFullYear();   
          for   (var   i   =   (y-100);   i   <=   y;   i++)   
                  document.aspnetForm.ctl00$DefaultContent$yearDropDownList.options.add(new   Option( i,i));   
          document.aspnetForm.ctl00$DefaultContent$yearDropDownList.value   = document.aspnetForm.ctl00$DefaultContent$yearHiddenField.value; 
          
          var m = 11;
          if(new   Date().getFullYear() ==document.aspnetForm.ctl00$DefaultContent$yearDropDownList.value)
          {
                m = new   Date().getMonth();
          }
          for   (var   i   =   1;   i   <   m+2;   i++)   
                  document.aspnetForm.ctl00$DefaultContent$monthDropDownList.options.add(new   Option(i,i));    
          document.aspnetForm.ctl00$DefaultContent$monthDropDownList.value   = document.aspnetForm.ctl00$DefaultContent$monthHiddenField.value;  
          for   (var   i   =   1;   i   <   32;   i++)   
                  document.aspnetForm.ctl00$DefaultContent$dayDropDownList.options.add(new   Option(i,i));    
          
          //var   n   =   MonHead[new   Date().getMonth()];   
          //if   (new   Date().getMonth()   ==1   &&   IsPinYear(YYYYvalue))   n++;   
          //writeDay(n); 
          //alert(document.aspnetForm.ctl00$DefaultContent$dayDropDownList.value);  
          //document.aspnetForm.ctl00$DefaultContent$dayDropDownList.value   =   new   Date().getDate(); 
          document.aspnetForm.ctl00$DefaultContent$birthdayHiddenField.value = document.aspnetForm.ctl00$DefaultContent$yearDropDownList.value+"-"+document.aspnetForm.ctl00$DefaultContent$monthDropDownList.value+"-"+document.aspnetForm.ctl00$DefaultContent$dayDropDownList.value;
          //alert(document.aspnetForm.ctl00$DefaultContent$birthdayHiddenField.value);
          document.aspnetForm.ctl00$DefaultContent$yearDropDownList.value   = document.aspnetForm.ctl00$DefaultContent$yearHiddenField.value;
          document.aspnetForm.ctl00$DefaultContent$monthDropDownList.value   = document.aspnetForm.ctl00$DefaultContent$monthHiddenField.value;
          document.aspnetForm.ctl00$DefaultContent$dayDropDownList.value   = document.aspnetForm.ctl00$DefaultContent$dayHiddenField.value;
          
  }   
  if(document.attachEvent)   
      window.attachEvent("onload",   YYYYMMDDstart);   
  else   
      window.addEventListener('load',   YYYYMMDDstart,   false);   
  function   YYYYDD(str)    
  { 
          optionsClear(document.aspnetForm.ctl00$DefaultContent$monthDropDownList);
           var m = 11;
          if(new   Date().getFullYear() ==document.aspnetForm.ctl00$DefaultContent$yearDropDownList.value)
          {
                m = new   Date().getMonth();
          }
          for   (var   i   =   1;   i   <   m+2;   i++)   
                  document.aspnetForm.ctl00$DefaultContent$monthDropDownList.options.add(new   Option(i,i));    
          if(document.aspnetForm.ctl00$DefaultContent$monthHiddenField.value < m+2)
          {

                document.aspnetForm.ctl00$DefaultContent$monthDropDownList.value   = document.aspnetForm.ctl00$DefaultContent$monthHiddenField.value;  
          }
          else
          {
                document.aspnetForm.ctl00$DefaultContent$monthDropDownList.value = m+1;
          }
            
          var   MMvalue   =   document.aspnetForm.ctl00$DefaultContent$monthDropDownList.options[document.aspnetForm.ctl00$DefaultContent$monthDropDownList.selectedIndex].value;   
          if   (MMvalue   ==   ""){   var   e   =   document.aspnetForm.ctl00$DefaultContent$dayDropDownList;   optionsClear(e);   return;}   
          var   n   =   MonHead[MMvalue   -   1];   
          if   (MMvalue   ==2   &&   IsPinYear(str))   n++;   
                  writeDay(n)   
          document.aspnetForm.ctl00$DefaultContent$birthdayHiddenField.value = document.aspnetForm.ctl00$DefaultContent$yearDropDownList.value+"-"+document.aspnetForm.ctl00$DefaultContent$monthDropDownList.value+"-"+document.aspnetForm.ctl00$DefaultContent$dayDropDownList.value;
  }   
  function   MMDD(str)  
  {   
          var   YYYYvalue   =   document.aspnetForm.ctl00$DefaultContent$yearDropDownList.options[document.aspnetForm.ctl00$DefaultContent$yearDropDownList.selectedIndex].value;   
          if   (YYYYvalue   ==   ""){   var   e   =   document.aspnetForm.ctl00$DefaultContent$dayDropDownList;   optionsClear(e);   return;}   
          var   n   =   MonHead[str   -   1];   
          if   (str   ==2   &&   IsPinYear(YYYYvalue))   n++;   
                  writeDay(n)   
          document.aspnetForm.ctl00$DefaultContent$birthdayHiddenField.value = document.aspnetForm.ctl00$DefaultContent$yearDropDownList.value+"-"+document.aspnetForm.ctl00$DefaultContent$monthDropDownList.value+"-"+document.aspnetForm.ctl00$DefaultContent$dayDropDownList.value;
          document.aspnetForm.ctl00$DefaultContent$monthHiddenField.value = document.aspnetForm.ctl00$DefaultContent$monthDropDownList.value;
  }   
  
  function   DD()  
  {   
      document.aspnetForm.ctl00$DefaultContent$birthdayHiddenField.value = document.aspnetForm.ctl00$DefaultContent$yearDropDownList.value+"-"+document.aspnetForm.ctl00$DefaultContent$monthDropDownList.value+"-"+document.aspnetForm.ctl00$DefaultContent$dayDropDownList.value;
  }  
  
  function   writeDay(n)  
  {   
          var   e   =   document.aspnetForm.ctl00$DefaultContent$dayDropDownList; 
          var datevalue = document.aspnetForm.ctl00$DefaultContent$dayHiddenField.value;
          optionsClear(e); 
          
          var m = n;
          if(new   Date().getFullYear() ==document.aspnetForm.ctl00$DefaultContent$yearDropDownList.value && new   Date().getMonth() +1 ==document.aspnetForm.ctl00$DefaultContent$monthDropDownList.value)
          {
            m = new   Date().getDate();
          }

          var isRight = false;  
          for   (var   i=1;  i<=m;  i++)   
          {
              if(i == datevalue)
              {
                isRight = true;
              }
              e.options.add(new   Option(i,i)); 
          }
          if(isRight == true)
          {    
            document.aspnetForm.ctl00$DefaultContent$dayDropDownList.value   = datevalue;
          }
          else
          {
            document.aspnetForm.ctl00$DefaultContent$dayDropDownList.value   = 1;
          }
          //alert(document.aspnetForm.ctl00$DefaultContent$dayDropDownList.value);
  }   
  function   IsPinYear(year)
  {       return(0   ==   year%4   &&   (year%100   !=0   ||   year%400   ==   0));}   
  function   optionsClear(e)   
  {   
          e.options.length   =   0;   
  }   