<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="../css/css.css" type=text/css rel=stylesheet>
<title>无标题文档</title>
<!--具体业务操作区域-->
            <SCRIPT language=javascript>
function onSubmit()
{
  var beginDate=document.thisForm.beginTime.value;
  var endDate=document.thisForm.endTime.value;

  
  var curDate=new Date();


 if(beginDate.length!=10){
     alert("起始时间长度不对，应为YYYY-MM-DD形式");
     return ;
  }

 if(endDate.length!=10){
    alert("结束时间长度不对，应为YYYY-MM-DD形式");
    return ;
 }

//判断结束时间是否大于当前时间
 if(endDate>curDate){
   alert("结束时间不能大于当前日期 "+curDate);
   return;
 }

//判断起始时间是否小于结束时间
  if(document.thisForm.beginTime.value > document.thisForm.endTime.value)
   {
      alert("起始时间应该小于结束时间，请您检查后重新输入!");
      return;
   }

//判断查询时间段是否小于31天
/*
  var beginYear=beginDate.substr(0,4);
  var beginMonth=beginDate.substr(5,2);
  var beginDay=beginDate.substr(8,2);

  var endYear=endDate.substr(0,4);
  var endMonth=endDate.substr(5,2);
  var endDay=endDate.substr(8,2);

  var curYear=2005
  var curMonth=9
  var curDay=14

  var days=new Array(12);
   days[0]=1;

  if(isLeapYear(beginYear)){
   days[1]=-1;
  }
  else {
    days[1]=-2;
  }

   days[2]=1;
   days[3]=0;
   days[4]=1;
   days[5]=0;
   days[6]=1;
   days[7]=1;
   days[8]=0;
   days[9]=1;
   days[10]=0;
   days[11]=1;
 var diff=(endYear-beginYear)*365+(endMonth-beginMonth)*30+(endDay-beginDay)+days[beginMonth-1];
 if(diff>31){
  alert("查询时间段不能超过31天");
  return ;
 }
 */

  document.thisForm.submit();

}
function SelectDate(DivID)
{
     var fullPath="PopDate.Htm";
     var strDate;	//Chinese date formate
     var intDate;	//Integer date formate
     var objEffectDate=eval("thisForm." + DivID);
     intDate=showModalDialog(fullPath,window,"dialogWidth=360px;dialogHeight=310px;center=yes;border=this;help=no");
     if (intDate!=null)
     {
         objEffectDate.value=intDate.substr(0,4)+"-"+intDate.substr(5,2)+"-"+intDate.substr(8,2);
         if (objEffectDate.value!="undefined")
         {
             strDate=intDate.substr(0,4)+"-"+intDate.substr(5,2)+"-"+intDate.substr(8,2);
             objEffectDate.value=strDate;
         }
         else
         {
             objEffectDate.value="";
         }
     }
     event.returnValue =false;
}

//判断是否为润年
function isLeapYear(year){
  if(year%100==0){
    if(year%400==0){
      return true;
    }
  }
else if(year%4==0){
  return true;
}
return false;
}
</SCRIPT>
</head>

<body>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <form name="thisForm" id="form1" method="post" action="search.htm" target="_parent">
      <td width="10%" height="30" valign="middle">
        <div align="center">站内搜索</div></td>
      <td width="14%"><input name="keywords" class="INPUT3" value="请输入关键字" size="16" />
      </td>
      <td width="17%" valign="middle"><div align="center">
          <select name="keyitem" class="INPUT5">
            <option value="" selected="selected">-选择搜索选项-</option>
            <option value="标题">标题</option>
            <option value="内容">内容</option>
            <option value="发布单位">发布单位</option>
          </select>
      </div></td>
      <td width="8%">开始日期</td>
      <td width="17%"><input 
                                name="beginTime" class="INPUT3" 
                                onclick="SelectDate('beginTime')" 
                                onkeypress="SelectDate('beginTime')" size="20" /></td>
      <td width="8%">结束日期</td>
      <td width="17%"><input name="endTime" class="INPUT3" 
                                onclick="SelectDate('endTime')" 
                                onkeypress="SelectDate('endTime')" size="20" /></td>
      <td width="9%">
        <div align="center"> <img 
                                style="CURSOR: hand" onclick="onSubmit();" 
                                height="19" src="gsyw/photo/tijiao.gif" width="55" /> </div></td>
    </form>
  </tr>
</table>
</body>
</html>
