// JavaScript Document
function checkDate(theYear,theMonth,theDay){
  if(!(fucPWDchk(theYear) && fucPWDchk(theMonth) && fucPWDchk(theDay)))return false;
  
  if(theYear=="" || theMonth=="" || theDay=="" || theMonth<1 || theMonth>12 || theDay<1)return false;
    
  if(theMonth==1 || theMonth==3 || theMonth==5 || theMonth==7 || theMonth==8 || theMonth==10 || theMonth==12){
    if(theDay>31)return false;
  }
  
  if(theMonth==4 || theMonth==6 || theMonth==9 || theMonth==11){
    if(theDay>30)return false;
  }
  
  if(theMonth==2){
    if((theYear%400==0) || (theYear%4==0 && theYear%100!=0)){
	  if(theDay>29){return false;}
	}else{
	  if(theDay>28){return false;}
	}
  }
  
  return true;
}

function fucPWDchk(str)
{
  var strSource ="0123456789";
  var ch;
  var i;
  var temp;
  
  for (i=0;i<=(str.length-1);i++)
  {
    ch = str.charAt(i);
    temp = strSource.indexOf(ch);
    if (temp==-1) 
    {
	 return false;
    }
  }
  if (strSource.indexOf(ch)==-1)
  {
    return false;
  }
  else
  {
	return true;
  } 
}

function checkD(theyearF,themonthF,thedayF){
  theyear=document.getElementById(theyearF).value;
  themonth=document.getElementById(themonthF).value;
  theday=document.getElementById(thedayF).value;
  if(!checkDate(theyear,themonth,theday)){
	return false;
  }
  return true;
}

function toMonth(theYear,theMonth){
  if(document.getElementById(theYear).value.length==4)document.getElementById(theMonth).focus();
}
function toDay(theMonth,theDay){
  if(document.getElementById(theMonth).value>1 || document.getElementById(theMonth).length==2)document.getElementById(theDay).focus();
}