//选择城市
function checkCityName(){
	var citys=document.getElementsByName("citys");
	var cityName=document.getElementsByName("cityName");
	var city=document.getElementsByName("city");
	citys[0].checked=true;
	cityName[0].focus();
	for(var i=0;i<city.length;i++){
		city[i].checked=false;
	}
}

function checkCitys(){
	var citys=document.getElementsByName("citys");
	var cityName=document.getElementsByName("cityName");
	citys[0].checked=false;
	cityName[0].value="";
}


//更多查询条件
function showgdtj(theText){
	if(gdtj.style.display=="none"){
		gdtj.style.display="";
		theText.innerHTML="隐藏更多查询条件↑";
	}else{
		gdtj.style.display="none";
		theText.innerHTML="显示更多查询条件↓";
	}
}

//酒店资料显示选项卡
function xdetails(x,k){
	var xobj=new Array(x1,x2,x3,x4,x5);
	for(var i=0;i<xobj.length;i++){
		xobj[i].className="h_details_3";
	}
	x.className="h_details_4";
	
	var kobj=new Array(k1,k2,k3,k4,k5);
	for(var i=0;i<kobj.length;i++){
		kobj[i].style.display="none";
	}
	k.style.display="";
}

//修改预订日期
function editDate(hotel,theForm){
	if(theForm.inDate.value==""){
		alert("请选择入住日期!");
		event.cancelBubble=true;
		showCalendar('inDate',false,'inDate','outDate');
		return false;
	}
	var matchArray = theForm.inDate.value.match(/^[0-9]+-[0-1][0-9]-[0-3][0-9]$/);
	if(matchArray==null){	
		alert("入住日期有误!")
		event.cancelBubble=true;
		showCalendar('inDate',false,'inDate','outDate');
		return false;	
	}
	if(theForm.outDate.value==""){
		alert("请选择离店日期!");
		event.cancelBubble=true;
		showCalendar('outDate',false,'outDate','inDate');
		return false;
	}
	var matchArray = theForm.outDate.value.match(/^[0-9]+-[0-1][0-9]-[0-3][0-9]$/);
	if(matchArray==null){	
		alert("离店日期有误!")
		event.cancelBubble=true;
		showCalendar('outDate',false,'outDate','inDate');
		return false;	
	}
	var inDate =theForm.inDate.value;
	var outDate =theForm.outDate.value;
	var inDates=inDate.split("-");
	var outDates=outDate.split("-");
	if (Date.parse(inDates[1]+"/"+inDates[2]+"/"+inDates[0]) < Date.parse(outDates[1]+"/"+outDates[2]+"/"+outDates[0])==false){
		alert("离店日期必须大于入住日期!");
		event.cancelBubble=true;
		showCalendar('outDate',false,'outDate','inDate');
		return false;			
	}
	var iDates = new Date(inDates[0],inDates[1],inDates[2]);
	var oDates = new Date(outDates[0],outDates[1],outDates[2]);
	var t = Math.abs(oDates.getTime()-iDates.getTime());
	var Days = t/(1000*60*60*24)
	if(Days>20){
		alert("如果您需要在酒店入住20天以上,请和我们预定中心联系,联系电话:0551-5150513-8121,我们将竭诚为您服务!");
		event.cancelBubble=true;
		showCalendar('outDate',false,'outDate','inDate');
		return false;
	}
	theForm.action="?hotel="+hotel+"&inDate="+theForm.inDate.value+"&outDate="+theForm.outDate.value;
	return;
}

//检测酒店搜索
function checkSearch(theForm){
	citys=document.getElementsByName("citys");
	cityName=document.getElementsByName("cityName");
	if(citys[0].checked){
		if(cityName[0].value==""){
			alert("城市名称不能为空!");
			cityName[0].focus();
			return false;
		}		
	}
	if(theForm.inDate.value==""){
		alert("请选择入住日期!");
		event.cancelBubble=true;
		showCalendar('inDate',false,'inDate','outDate');
		return false;
	}
	var matchArray = theForm.inDate.value.match(/^[0-9]+-[0-1][0-9]-[0-3][0-9]$/);
	if(matchArray==null){	
		alert("入住日期有误!")
		event.cancelBubble=true;
		showCalendar('inDate',false,'inDate','outDate');
		return false;	
	}
	if(theForm.outDate.value==""){
		alert("请选择离店日期!");
		event.cancelBubble=true;
		showCalendar('outDate',false,'outDate','inDate');
		return false;
	}
	var matchArray = theForm.outDate.value.match(/^[0-9]+-[0-1][0-9]-[0-3][0-9]$/);
	if(matchArray==null){	
		alert("离店日期有误!")
		event.cancelBubble=true;
		showCalendar('outDate',false,'outDate','inDate');
		return false;	
	}
	var inDate =theForm.inDate.value;
	var outDate =theForm.outDate.value;
	var inDates=inDate.split("-");
	var outDates=outDate.split("-");
	if (Date.parse(inDates[1]+"/"+inDates[2]+"/"+inDates[0]) < Date.parse(outDates[1]+"/"+outDates[2]+"/"+outDates[0])==false){
		alert("离店日期必须大于入住日期!");
		event.cancelBubble=true;
		showCalendar('outDate',false,'outDate','inDate');
		return false;			
	}
	var iDates = new Date(inDates[0],inDates[1],inDates[2]);
	var oDates = new Date(outDates[0],outDates[1],outDates[2]);
	var t = Math.abs(oDates.getTime()-iDates.getTime());
	var Days = t/(1000*60*60*24)
	if(Days>20){
		alert("如果您需要在酒店入住20天以上,请和我们预定中心联系,联系电话:0551-5150513-8121,我们将竭诚为您服务!");
		event.cancelBubble=true;
		showCalendar('outDate',false,'outDate','inDate');
		return false;
	}
	return;
}

//酒店查询排序
function orderURL(num,url,order){
	if(num!=""){
		if(order==""){
			url1=url+"&orders="+num;	
		}else{
			url1=url.replace("orders="+order,"orders="+num);
		}
		window.location.href=url1;
	}
}

//酒店查询排序
function qyURL(str,url,type1,qy1){
	var url1;
	if(str!=""){
		var qyType=document.getElementsByName("qyType");
		if(qyType[0].checked){types=0};
		if(qyType[1].checked){types=1};
		if(type1==""){
			url1=url+"&qyType="+types+"&qy="+str;
		}
		if(type1!="" && qy1!=""){
			url1=url.replace("qyType="+type1+"&qy="+qy1,"qyType="+types+"&qy="+str);
		}
		window.location.href=url1;	
	}
}

//更多查询条件
function cxtj(){
	star=document.getElementsByName("star");
	dc=document.getElementsByName("dc");
}

//检测重新搜索
function checkrSearch(theForm){
	if(theForm.inDate.value==""){
		alert("请选择入住日期!");
		event.cancelBubble=true;
		showCalendar('inDate',false,'inDate','outDate');
		return false;
	}
	var matchArray = theForm.inDate.value.match(/^[0-9]+-[0-1][0-9]-[0-3][0-9]$/);
	if(matchArray==null){	
		alert("入住日期有误!")
		event.cancelBubble=true;
		showCalendar('inDate',false,'inDate','outDate');
		return false;	
	}
	if(theForm.outDate.value==""){
		alert("请选择离店日期!");
		event.cancelBubble=true;
		showCalendar('outDate',false,'outDate','inDate');
		return false;
	}
	var matchArray = theForm.outDate.value.match(/^[0-9]+-[0-1][0-9]-[0-3][0-9]$/);
	if(matchArray==null){	
		alert("离店日期有误!")
		event.cancelBubble=true;
		showCalendar('outDate',false,'outDate','inDate');
		return false;	
	}
	var inDate =theForm.inDate.value;
	var outDate =theForm.outDate.value;
	var inDates=inDate.split("-");
	var outDates=outDate.split("-");
	if (Date.parse(inDates[1]+"/"+inDates[2]+"/"+inDates[0]) < Date.parse(outDates[1]+"/"+outDates[2]+"/"+outDates[0])==false){
		alert("离店日期必须大于入住日期!");
		event.cancelBubble=true;
		showCalendar('outDate',false,'outDate','inDate');
		return false;			
	}
	var iDates = new Date(inDates[0],inDates[1],inDates[2]);
	var oDates = new Date(outDates[0],outDates[1],outDates[2]);
	var t = Math.abs(oDates.getTime()-iDates.getTime());
	var Days = t/(1000*60*60*24)
	if(Days>20){
		alert("如果您需要在酒店入住20天以上,请和我们预定中心联系,联系电话:0551-5150513-8121,我们将竭诚为您服务!");
		event.cancelBubble=true;
		showCalendar('outDate',false,'outDate','inDate');
		return false;
	}
	return;
}

//预定房间数和住宿人数的代码
function yFjs(theFjs){
	document.form1.rs.length=0;
	if(theFjs.value!=""){
		for ( var i=theFjs.value;i<=theFjs.value*2;i++){
			document.form1.rs.options[document.form1.rs.length]=new Option(i,i);
		}
	}
}

//客房预定最早到达时间与最晚到达时间
function yzz(theForm){
		if(theForm.value!=""){
				if(theForm.value.length==4){
					var a=theForm.value.substring(0,1);
					var b=theForm.value.substring(2,4);
				}else{
					var a=theForm.value.substring(0,2);
					var b=theForm.value.substring(3,5);
				}
				
				var f=document.form1;
				f.zwdd.length=0;
				for(var i=0;i<=23;i++){
					f.zwdd.options[f.zwdd.length]=new Option(i+":00",i+":00");
					f.zwdd.options[f.zwdd.length]=new Option(i+":30",i+":30");
				}
				f.zwdd.options[f.zwdd.length]=new Option("23:59","23:59");
				
				if(a*2<40){
					if(b=="00"){
						f.zwdd.selectedIndex=(a*2+8);
					}else{
						f.zwdd.selectedIndex=(a*2+9);
					}
				}else{
					f.zwdd.selectedIndex=48;
				}
			}
	}
	
//检测客户预订
function checkOrder(theForm){
	rzr=document.getElementsByName("rzr");
	er=true;
	for(var i=0;i<rzr.length;i++){
		if(rzr[i].value==""){	
			er=false;
			break;
		}
	}
	if(!er){
		alert("入住人姓名不能小于入住人数！");	
		return false;
	}
	if(theForm.lxr.value==""){
		alert("请填写联系人！");
		theForm.lxr.focus();
		return false;
	}
	sex=document.getElementsByName("sex");
	if(!sex[0].checked && !sex[1].checked){
		alert("请选择性别！");
		return false;
	}
	if(theForm.qrfs.value==""){
		alert("请选择确认方式！");
		theForm.qrfs.focus();
		return false;
	}
	if(theForm.MB.value==""){
		alert("请填写手机号码！");
		theForm.MB.focus();
		return false;
	}
	if(isNaN(theForm.MB.value)==true || theForm.MB.value.substring(0,1)!=1 || theForm.MB.value.length<11){
		alert("手机号码填写不正确!")
		theForm.MB.select();
		return false;
	}
	if(theForm.mail.value==""){
		alert("请填写电子邮箱！");
		theForm.mail.focus();
		return false;
	}
	if(theForm.mail.value.indexOf("@",1)==-1 ||theForm.mail.value.indexOf(".",1)==-1 ){
		alert("电子邮箱地址填写不正确!");
		theForm.mail.select();
		return false;
	}
	return ;
}


//入住人姓名
function orderRzr(){
	var str="";
	fjs=document.getElementsByName("rs")[0].value;
	for(var i=1;i<=fjs;i++){
		str=str+"<input name='rzr' type='text' id='rzr' size='15' maxlength='20' />";
		if(i % 4==0)str=str+"<br>"
	}
	rzrlist.innerHTML=str;
}
