 function DateDiff(sDate1, sDate2){ //sDate1和sDate2是2002-12-18格式
var aDate, oDate1, oDate2, iDays
aDate = sDate1.split("-")
oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]) //转换为12-18-2002格式
aDate = sDate2.split("-")
oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])
iDays = (oDate1 - oDate2) / 1000 / 60 / 60 /24 //把相差的毫秒数转换为天数
return iDays
} 
function isDateString(haoaho) {
				var reg=/^\d{4}-[0-1]?\d{1}-[0-3]?\d{1}$/;
	           return reg.test(haoaho);
               }
    function checkLogin(userName,n) {
	if (n == 0 && userName.value =="yyyy-mm-dd")
	{userName.value="";userName.style.cssText = "color:#000";
	event.cancelBubble=true;
	showCalendar('dimg1',false,'hdate1',null,'setstartdate1');}

  }
      function checkLogin2(userName,n) {
	if (n == 0 && userName.value =="yyyy-mm-dd")
	{userName.value="";userName.style.cssText = "color:#000";
	event.cancelBubble=true;
	showCalendar('dimg2',false,'hdate2','hdate1');}

  }
function resetcity()
				{
				document.form1.companycity.length = 0;
				document.form1.companycity.options[0] = new Option("城市选择列表      ","");
				document.form1.companycity.options[0].selected=true;}
				function resetprovince()
				{
				document.form1.companyprovince.length=0;
				document.form1.companyprovince.options[0] = new Option("省份选择列表","");
				}
				function chooseprovince(iprovince,oSelect)
				{
				resetcity();
				if (document.form1.companyprovince.value) ImportCity(iprovince,oSelect);
				}
				
function check()
{
  if (document.form1.companycity.value=="")
        {
        alert("请选择所查询的城市！");
		document.form1.companycity.focus();
        return (false);
        } 
		if (! isDateString(form1.startdate1.value)) 
{	alert('日期格式不正确，请重新填写！');
	form1.startdate1.focus();
	return false;
	}
if (! isDateString(form1.enddate1.value)) 
{	alert('日期格式不正确，请重新填写！');
	form1.enddate1.focus();
	return false;
	}
		
if (document.form1.startdate1.value.length==0)
{alert("请输入入住时间!");
document.form1.startdate1.focus();
return false;
}

if (document.form1.enddate1.value.length==0)
{alert("请输入离店时间!");
document.form1.enddate1.focus();
return false;
}
  iy = document.form1.startdate1.value; 
  oy = document.form1.enddate1.value; 
  tDate = iy.split("-")
  oDate = new Date(tDate[0] + '/' + tDate[1] + '/' + tDate[2])
  
 if(DateDiff(oy,iy)<=0) 
 { alert("离店日期不能早于入住日期！"); 
return false;} 		
		 document.form1.submit()
 }