// JavaScript Document
function isDate(year,month,day) {
    if(parseInt(day) <=	daynumber(year,month)){
		
		return true;
	}else{
		return false;	
	}
}

		
function daynumber(whichyear,whichmonth){
        montht = parseInt(whichmonth);
        yeart = parseInt(whichyear);
       
   switch(montht){
          case 1:
              return 31;
          case 2:
              if((yeart % 4) == 0){
                if(((yeart % 100) == 0) && !((yeart % 400 ==0))){ 
                    return 28;
                }else{
                    return 29;
                }         
              }else{
                return 28;
              }  
          case 3:
              return 31;
          case 4:
              return 30;
          case 5:
              return 31;
          case 6:
			  return 30;
		  case 7:
              return 31;
          case 8:
              return 31;
          case 9:
              return 30;
          case 10:
			  return 31;
		  case 11:
              return 30;
          case 12:
              return 31;
          default:
              return 0;
          }        
     }   

function search()
{
  var area_seq=form_search.area_seq.value;
  if (area_seq.length==0)
  {
    alert("請先選擇區域");
    form_search.area_seq.focus();
    
    return false;  
  }

  var year = form_search.year1.value;
  if (!(isDate(year,form_search.month1.value,form_search.day1.value))){
	alert("請檢查出團日期是否錯誤");
	form_search.month1.focus();
	return false;
  } 
  
  var year2 = form_search.year2.value;
  if (!(isDate(year2,form_search.month2.value,form_search.day2.value))){
	alert("請檢查出團日期是否錯誤");
	form_search.month2.focus();
	return false;
  } 
  
 
}
