﻿// JScript 文件
jQuery.fn.selectCity = function(targetId) {
		var _seft = this;
		var targetId = $(targetId);
		this.click(function(){
		    //alert($('#id_startCity').val());
			var A_top = $(this).offset().top + $(this).outerHeight(true)+2;  //  1
			var A_left =  $(this).offset().left;//定位浮动层位置
			var city;
			if(document.getElementById("id_startCity")){
			    city=$('#id_startCity').val();
			}
			else if(document.getElementById("radio1") && document.getElementById("radio2")){
			    city=$("input[name='radiocity']:checked").val();
			}
			//alert(city);
			if(('中文/拼音' == city) || ('' == city) || (undefined == city)){
				targetId.html("<div id='selectItemCount'><div id='selectSub'>请先选择城市！</div></div>");
				targetId.bgiframe();
				targetId.show().css({"position":"absolute","width":"395px","top":A_top+"px" ,"left":A_left+"px"});
			}else{
				targetId.html("<img src='/images/ajax-loader.gif'/>")
				targetId.bgiframe();
				targetId.show().css({"position":"absolute","top":A_top+"px" ,"left":A_left+"px"});	
				jQuery("#selectItemCount").html("");
				//var queryForm=$('#id_queryHotelForm').serialize(); 
				//alert(queryForm);
				var cityName;
				var cityCode;
				if(document.getElementById("id_startCity")){
			        cityName=$("#id_startCity").val();
				    cityCode=$("#id_cityCode").val();
			    }
			    else if(document.getElementById("radio1") && document.getElementById("radio2")){
			        cityName="";
			        cityCode=city;
			    }
				//alert(cityCode);
				jQuery.ajax({ 
				  type: "get", 
				  url: "/ajax/getBusiness.aspx", 
				  data:"cityName="+escape(cityName)+"&cityCode="+cityCode+"&d="+new Date().getTime(),
				  error:function(response){
				    alert("查询区域错误！");
				  },
				  success:function(response){
				  	if(jQuery.trim(response)==null||jQuery.trim(response)==""){
						targetId.html('非法的城市名或者该城市还没有添加数据！');
						return;	
					}
					targetId.find("#selectItemClose").click(function(){
						jQuery("#selectItem2").hide();
					});
					//alert("/ajax/getBusiness.aspx?cityName="+escape(cityName)+"&cityCode="+cityCode+"&d="+new Date().getTime())
					//alert(response);
				  	targetId.html(response);
				  	targetId.show().css({"position":"absolute","top":A_top+"px" ,"left":A_left+"px"});			
				  }
				});  
			}
		});
	    return this;
	}

/* 酒店位置商业区单击不限位置时隐藏及负值start*/
function hideItem(){
	jQuery("#selectItem2").hide();
	document.getElementById("address2").value="";
	document.getElementById("bizCode").value="";
	document.getElementById("bizFlag").value="";
}
/* 酒店位置商业区单击不限位置时隐藏及负值end*/


$(function(){
   try
   {
   
        if(document.getElementById("radio1") && document.getElementById("radio2")){
            $("#hotelcitytd input").click(function(){
                var cityid=$("input[name='radiocity']:checked").val();
                if(cityid=='3201'){
                    $("#HotelTj3201").css("display","");
                    $("#HotelTj3301").css("display","none");
                    $("#hotelInfo3201").css("display","");
                    $("#hotelInfo3301").css("display","none");
                }
                else if(cityid='3301'){
                    $("#HotelTj3301").css("display","");
                    $("#HotelTj3201").css("display","none");
                    $("#hotelInfo3301").css("display","");
                    $("#hotelInfo3201").css("display","none");
                }
            });
		    //city=$("input[name='radiocity']:checked").val();
		}
			
			
		//$('#id_startDate').val(DateAdd('d',1,new Date(),'1'));
		//if(getCookie("indate") == null || getCookie("outdate") == null){
//		    $('#id_hotelStartDate').val(DateAdd('d',0,new Date(),'1'));
//		    $('#id_hotelBackDate').val(DateAdd('d',1,new Date(),'1')); 
//			if(document.getElementById("id_startDate")&&document.getElementById("id_backDate"))
//			{
//			$('#id_startDate').val(DateAdd('d',0,new Date(),'1'));
//			$('#id_backDate').val(DateAdd('d',1,new Date(),'1'));
//			}
//		}else{
//		    $('#id_hotelStartDate').val(DateAdd('d',0,new Date(),'1'));
//		    $('#id_hotelBackDate').val(DateAdd('d',1,new Date(),'1'));
//			if(document.getElementById("id_startDate")&&document.getElementById("id_backDate"))
//			{
//			$('#id_startDate').val(DateAdd('d',0,new Date(),'1'));
//			$('#id_backDate').val(DateAdd('d',1,new Date(),'1'));
//			}
//		}
//		
		
		/* 给酒店入住日期输入框绑定日期输入控件开始*/
		$('#id_hotelStartDate').click(function(event) {
			showSearchCalendarn(this, 0, new Date(), AddDay('n', 1, new Date()), undefined, 0, $("#id_hotelBackDate"), event, compareDateHotel_start_back);
			return false;
		}).focus(function() {
		    this.click();
		}).blur(function() {
			showSearchCalendarn(this, 1);
			return false;
		});
		/* 给酒店入住日期输入框绑定日期输入控件结束*/
		
		/* 给酒店离店日期输入框绑定日期输入控件开始*/
		$('#id_hotelBackDate').click(function(event) {
			var starDateVal = $('#id_hotelStartDate').val();
			var startDate;
			if (null == starDateVal || "" == starDateVal || "yyyy-mm-dd" == starDateVal) {
				startDate = new Date();
			} else {
				startDate = getDateFromString(starDateVal);
			}
			showSearchCalendarn(this, 0, AddDay('d', 0, startDate), AddDay('n', 1, new Date()), undefined, 0, undefined, event);
			return false;
		}).focus(function() {
		    this.click();
		}).blur(function() {
			showSearchCalendarn(this, 1);
			return false;
		});
		/* 给酒店离店日期输入框绑定日期输入控件结束*/
		
		/* 给出发城市输入框绑定城市显示控件开始*/
	    $('#id_startCity').click(function(event){
	         var nextHiddenId = $(this).next().attr('id');
	         suggest.displayClick(this, nextHiddenId,event,"hotel");
	    }).keyup(function(event){
	         showCitySuggest(this, event,"hotel");
	    }).blur(function(){
	         showSearch(this,1);
	         suggest.hidden_suggest();
	    }).focus(function(event){
	         $(this).click();
	         showSearch(this);
	    }).attr('maxlength', 12);
		
		var tempStartCity = $('#id_startCity').val();
		if (tempStartCity == undefined || tempStartCity == null || tempStartCity == '') {
			$('#id_startCity').val("中文/拼音").css('color', '#C1C1C1');
		}
		/* 给出发城市输入框绑定城市显示控件结束*/
		
		$("#address2").selectCity("#selectItem2");
        $(document).click(function(event){
			if((event.target.id!=jQuery("#selectItem2").selector.substring(1))&&(event.target.id!="address2"))jQuery("#selectItem2").hide();	
	     });
	     
	     /* 连锁酒店页面选定某城市的连锁连锁酒店品牌start*/
	     $("#id_CityChain").click(function(event){
	        var A_top = $(this).offset().top + $(this).outerHeight(true)+2;  //  1
			var A_left =  $(this).offset().left;//定位浮动层位置
			if(('中文/拼音'==$('#id_startCity').val())||(''==$('#id_startCity').val())){
			    $('#cityChain').html("<div id='selectItemCount'><div id='selectSub'>请先选择城市！</div></div>");
				$('#cityChain').bgiframe();
				$('#cityChain').show().css({"position":"absolute","width":"395px","top":A_top+"px" ,"left":A_left+"px"});
			}else{
			    $('#cityChain').html("<img src='/images/ajax-loader.gif'/>")
				$('#cityChain').bgiframe();
				$('#cityChain').show().css({"position":"absolute","width":"395px","top":A_top+"px" ,"left":A_left+"px","z-index":"300"});	
				jQuery("#selectItemCount").html("");
				var cityCode=$("#id_cityCode").val();
				jQuery.ajax({ 
				      type: "get", 
				      url: "/ajax/getCityChain.aspx", 
				      data:"at=cpp&cid=" + cityCode + "&d=" + new Date().getTime(),
				      error:function(response){
				        alert("查询区域错误！");
				      },
				      success:function(response){
				  	    if(jQuery.trim(response) == null || jQuery.trim(response) == ""){
						    $('#cityChain').html('非法的城市名或者该城市还没有添加数据！');
						    return;	
					    }
					    $('#cityChain').find("#selectItemClose").click(function(){
						    jQuery("#cityChain").hide();
					    });
				  	    $('#cityChain').html(response);
				  	    $('#cityChain').show().css({"position":"absolute","width":"395px","top":A_top+"px" ,"left":A_left+"px","z-index":"300"});			
				      }
				 });
			}
	     });
	     
	     $(document).click(function(event){
			if((event.target.id!=jQuery("#cityChain").selector.substring(1))&&(event.target.id!="id_CityChain"))jQuery("#cityChain").hide();	
	     });
	     
	     var tempStartCity = $('#id_CityChain').val();
	     if (tempStartCity == undefined || tempStartCity == null || tempStartCity == '') {
		    $('#id_CityChain').val("如：如家").css('color', '#C1C1C1');
	     }
	     /* 连锁酒店页面选定某城市的连锁连锁酒店品牌end*/
	     
	     /* 连锁酒店页面选定某城市的商业区start*/
	     $("#id_chainBusiness").click(function(){
	        var A_top = $(this).offset().top + $(this).outerHeight(true)+2;  //  1
			var A_left =  $(this).offset().left;//定位浮动层位置
			if(('中文/拼音'==$('#id_startCity').val())||(''==$('#id_startCity').val())){
			    $('#chainBusiness').html("<div id='selectItemCount'><div id='selectSub'>请先选择城市！</div></div>");
				$('#chainBusiness').bgiframe();
				$('#chainBusiness').show().css({"position":"absolute","width":"395px","top":A_top+"px" ,"left":A_left+"px"});
			}else{
			    $('#chainBusiness').html("<img src='/images/ajax-loader.gif'/>")
				$('#chainBusiness').bgiframe();
				$('#chainBusiness').show().css({"position":"absolute","width":"395px","top":A_top+"px" ,"left":A_left+"px"});	
				jQuery("#selectItemCount").html("");
				var cityCode=$("#id_cityCode").val();
				jQuery.ajax({ 
				      type: "get", 
				      url: "/ajax/getBusinessChain.aspx", 
				      data:"cid="+cityCode+"&d="+new Date().getTime(),
				      error:function(response){
				        alert("查询区域错误！");
				      },
				      success:function(response){
				  	    if(jQuery.trim(response)==null||jQuery.trim(response)==""){
						    $('#chainBusiness').html('非法的城市名或者该城市还没有添加数据！');
						    return;	
					    }
					    $('#chainBusiness').find("#selectItemClose").click(function(){
						    jQuery("#chainBusiness").hide();
					    });
				  	    $('#chainBusiness').html(response);
				  	    $('#chainBusiness').show().css({"position":"absolute","width":"395px","top":A_top+"px" ,"left":A_left+"px"});			
				      }
				 });
			}
			
	     });
	     
	     $(document).click(function(event){
			if((event.target.id!=jQuery("#chainBusiness").selector.substring(1))&&(event.target.id!="id_chainBusiness"))jQuery("#chainBusiness").hide();	
	     });
	     
	     var tempStartCity = $('#id_chainBusiness').val();
	     if (tempStartCity == undefined || tempStartCity == null || tempStartCity == '') {
		    $('#id_chainBusiness').val("如：白云国际机场").css('color', '#C1C1C1');
	     }
	     /* 连锁酒店页面选定某城市的商业区end*/
	     
//	     /* 给出发城市输入框绑定城市显示控件开始*/
//	    $('#id_startCity').click(function(event){
//	        alert("sdfsdf");
//	         var nextHiddenId = $(this).next().attr('id');
//	         suggest.displayClick(this, nextHiddenId,event,"hotel");
//	    }).keyup(function(event){
//	         showCitySuggest(this, event,"hotel");
//	    }).blur(function(){
//	         showSearch(this,1);
//	         suggest.hidden_suggest();
//	    }).focus(function(event){
//	         $(this).click();
//	         showSearch(this);
//	    }).attr('maxlength', 12);
//		
//		var tempStartCity = $('#id_startCity').val();
//		if (tempStartCity == undefined || tempStartCity == null || tempStartCity == '') {
//			$('#id_startCity').val("中文/拼音").css('color', '#C1C1C1');
//		}
//		/* 给出发城市输入框绑定城市显示控件结束*/

	     
	     /* 连锁酒店点击搜索start*/
	     $("#chainSearch").click(function(){
	        var cityID = $("#id_cityCode").val();
	        var chainID = $("#chaingID").val();
	        var businessID;
	        
	        if(document.getElementById("businessID")){
	            businessID = $("#businessID").val();
	        }
	        if(cityID==undefined||cityID==null||cityID==""){
	            alert('请输入正确城市名！');
	            $("#id_startCity").click();
	            return false;
	        }
	        if(chainID==undefined||chainID==null||chainID==""){
	            alert('请选择连锁酒店品牌！');
	            $("#id_CityChain").click();
	            return false;
	        }
	        var dD = $("#id_hotelStartDate").val();
	        var eD = $("#id_hotelBackDate").val();
	        var s = dD.split(" ");
		    var s1 = s[0].split("-");
		    var date1 = new Date(s1[0],s1[1]-1,s1[2],0,0,0);
    		
		    var b = eD.split(" ");
		    var b1 = b[0].split("-");
		    var date2 = new Date(b1[0],b1[1]-1,b1[2],0,0,0);
		     
		    if(date1>=date2){
			   alert("提示入住日期应早于离店日期");
			   return;
		    }
		    if(daysElapsed(date1,date2)>28){
			   alert("入住晚数不能超过28天！");
			   return;
		    }
		    
	        if(dD != "" && eD != ""){
               document.cookie = "indate=" + dD + ";path=/";
               document.cookie = "outdate=" + eD + ";path=/";
            }
            
            if(businessID != "" && businessID != null && businessID != undefined){
		        window.location.href = "/chain/chainHotel_" + businessID + "_" + chainID + "_1.html";
		    }
		    else{
		        window.location.href="/chain/chainHotel_" + cityID + "_" + chainID + "_1.html";
		    }
            
	        //alert(cityID+"-"+chainID+"-"+businessID);
	     });
	     /* 连锁酒店点击搜索end*/
	     
		
		//首页酒店搜索表单提交事件
		$("#id_hotelSearch").click(function(){
		   var flag = hotelQueryCheck();
		   var tempC = flag.split("&");
		   if (tempC[0] == "success") 
	       {
	         $("#id_cityCode").val(getThreeWordByCity($("#id_startCity").val(),"hotel"));
	         var hotelName=$("#id_hotelName").val();
	         var cityCode=$("#id_cityCode").val();
	         var dD = $("#id_hotelStartDate").val();
	         var eD = $("#id_hotelBackDate").val();
	         var price;
	         if(document.getElementById("id_hotelPriceStr")){
	            price=$("#id_hotelPriceStr").val();
	         }
	         
	         var s = dD.split(" ");
		     var s1 = s[0].split("-");
		     var date1 = new Date(s1[0],s1[1]-1,s1[2],0,0,0);
    		
		     var b = eD.split(" ");
		     var b1 = b[0].split("-");
		     var date2 = new Date(b1[0],b1[1]-1,b1[2],0,0,0);
		     
		     if(date1>=date2){
			    alert("提示入住日期应早于离店日期");
			    return;
		     }
		     if(daysElapsed(date1,date2)>28){
			    alert("入住晚数不能超过28天！");
			    return;
		     }
		     if(document.getElementById('id_startCity')){
		         if(cityCode==null || cityCode==''){
			        alert("请正确输入查询的城市");
			        return;
		         }
		     }
		     else if(document.getElementById("radio1") && document.getElementById("radio2")){
			    cityCode = $("input[name='radiocity']:checked").val();
			 }
		     
	         if(dD != "" && eD != ""){
                document.cookie = "indate=" + dD + ";path=/";
                document.cookie = "outdate=" + eD + ";path=/";
             }
	         
	         //alert(escape(hotelName));
	         //alert($("#id_hotelPriceStr").val());id_hotelName
	         //alert($("#id_hotelName").val());
	         $(this).attr("disabled", true);
	         var hotelStar = 0;
	         if(document.getElementById("star0"))
	         {
	            hotelStar=$("input[name='star']:checked").val();
	            //alert($("input[name='star']:checked").val());
	         } else if(document.getElementById("hotelstar")){
	            hotelStar = document.getElementById("hotelstar").value;
	         }
	         //alert(hotelStar);
	         var linkStr="/City" + cityCode + "/";
	         if(document.getElementById("address2") && document.getElementById("bizCode") && document.getElementById("bizFlag")){
	            var bizCode = document.getElementById("bizCode").value;
                var bizFlag = document.getElementById("bizFlag").value;
                if(bizFlag == 1) linkStr += "BusinessHotel_" + bizCode + "_" + hotelStar + "_1.html";
	            else if(bizFlag == 2) linkStr += "SarHotel_" + bizCode + "_" + hotelStar + "_1.html";
	            else linkStr += "HotelList_"+hotelStar+"_1.html";
	            //linkStr="/City" + cityCode + "/HotelList_"+hotelStar+"_1.html";
	         }
	         else{
	            linkStr += "HotelList_"+hotelStar+"_1.html";
	         }
	         if(price != undefined && price != "0") linkStr += "?price=" + price;
	         if(hotelName != ""){
	         	if(linkStr.indexOf("?") > 0) linkStr += "&hn=" + escape(hotelName);
	         	else linkStr += "?hn=" + escape(hotelName);
	      }
	      if (dD != "" && eD != "") {
	          if (linkStr.indexOf("?") > 0) linkStr += "&indate=" + dD + "&outdate=" + eD;
	          else linkStr += "?indate=" + dD + "&outdate=" + eD;
	      }
	         self.location=linkStr;
	         //$('#id_queryHotelForm')[0].submit();
	         //__ozclk();
	         return false;
	       } 
	       else 
	       {
			 alert(tempC[1] + "!");
			 window.setTimeout(function() { $('#' + tempC[0]).focus(); }, 10);
		   }
		}); 
		
		/* 学校页面搜索学校名称start*/
		$("#searchSchool").click(function(){
		    var proID = document.getElementById("ProvinceID").value;
		    var CityID = document.getElementById("CityID").value;
		    var kw = $("#id_schoolName").val();
		    if(proID == 0){
		        alert("请选择省份！");
		        return false;
		    }
		    if(CityID == 0){
		        alert("请选择城市！");
		        return false;
		    }
		    if(kw == undefined||kw == null||kw == ""){
		        window.location.href = "/School/SchoolList_"+CityID+"_0.html";
		    }else{
		        jQuery.ajax({ 
				      type: "get", 
				      url: "/ajax/getSchool.aspx", 
				      data:"at=searchResult&cid=" + CityID + "&kw=" + escape(kw) + "&d=" + new Date().getTime(),
				      success:function(response){
				  	    if("0" == response){
				  	        alert('未找到相关学校！');
				  	    }
				  	    else if(response.indexOf("1|") == 0){
				  	        window.location.href = "/City" + CityID + "/SchoolHotel_" + response.substr(2) + "_11_1.html";
				  	    }
				  	    else
				  	    {
				  	        window.location.href = "/School/SchoolList_" + CityID + "_0.html?sn=" + escape(kw);
				  	    }
				  	    
				  	  }
				 });
		    }
		    
		});
		/* 学校页面搜索学校名称end*/
		
	  /* 酒店客户预订页给入住日期输入框绑定日期输入控件start*/
      $('#id_startDate').click(function(event){
          showSearchCalendarn(this, 0, new Date(),AddDay('n',1,new Date()),document.getElementById('id_backDate'),1,undefined,event);
          return false;
      }).focus(function(event){
          $(this).click();
          return false;
      }).blur(function(){
          showSearchCalendarn(this, 1);
          return false;
      });
      /* 酒店客户预订页给入住日期输入框绑定日期输入控件end*/
      
      /* 酒店客户预订页给离店日期输入框绑定日期输入控件start*/
      $('#id_backDate').click(function(event){
          showSearchCalendarn(this, 0, AddDay('d',1,getDateFromString($('#id_startDate').val())),AddDay('n',1,new Date()),undefined,0,undefined,event);
          return false;
      }).focus(function(event){
          $(this).click();
          return false;
      }).blur(function(){
          showSearchCalendarn(this, 1);
          return false;
      });
      /* 酒店客户预订页给离店日期输入框绑定日期输入控件end*/
      
      $("#ChangDateSearchPrice").click(function(event){
          var id = document.getElementById("id_startDate").value;
		  var od = document.getElementById("id_backDate").value;
		  //modify by shizhongwen 2.10 start
		  var s = id.split(" "); 
		  var s1 = s[0].split("-"); 	
		  var date1 = new Date(s1[0],s1[1]-1,s1[2],0,0,0); 
    	
		  var b = od.split(" "); 
		  var b1 = b[0].split("-"); 	
		  var date2 = new Date(b1[0],b1[1]-1,b1[2],0,0,0);
		  if(date1>=date2){
		    alert("提示入住日期应早于离店日期");
		    return;
		  }
		  if(daysElapsed(date1,date2)>28){
		    alert("入住晚数不能超过28天！");
		    return;
		  }
    		
		  if(id != "" && od != ""){
            document.cookie = "indate=" + id + ";path=/";
            document.cookie = "outdate=" + od + ";path=/";
          }
          
          var signed=document.getElementById("signed").value;
          var hotelID=document.getElementById("hotelID").value;
          var eID=document.getElementById("elongID").value;
          //alert(signed);
		  //alert(hotelID);
		  //alert(eID);
		  //alert("GetHotelRoomList("+eID+","+hotelID+","+id+","+od+","+signed+")");
          GetHotelRoomList(""+eID+"",hotelID,""+id+"",""+od+"",signed);
          
      });
		
   }
   catch(exception)
   {}

});

/* 返回时间差额start*/
function daysElapsed(date1,date2)
{
    var difference = Date.UTC(date1.getYear(),date1.getMonth(),date1.getDate(),0,0,0)
                   - Date.UTC(date2.getYear(),date2.getMonth(),date2.getDate(),0,0,0);
    var difdays=difference/(1000*60*60*24);
    if(difdays<0){
    	return 0-difdays;
    }else{
    	return difdays;
    }
}
/* 返回时间差额end*/

/* 选择城市商业区及行政区start*/
function selectItemSeftVal(bizName,bizCode,bizFlag)
{
	document.getElementById("address2").value=bizName;
	document.getElementById("bizCode").value=bizCode;
	document.getElementById("bizFlag").value=bizFlag;
	jQuery("#selectItem2").hide();
}
/* 选择城市商业区及行政区end*/

/* 酒店日期使离店日期比入住日期多1天开始*/
function compareDateHotel_start_back(value) {
    var startDate = getDateFromString(value);
    if ($('#id_hotelBackDate').val() != undefined && $('#id_hotelBackDate').val() != null && $('#id_hotelBackDate').val() != '') {
	    var backDate = getDateFromString($('#id_hotelBackDate').val());
	    if (startDate >= backDate) {
		    $('#id_hotelBackDate').val(formatDate(AddDay('d', 1, startDate), 1));
	    }
    }// end if
    else {
	    $('#id_hotelBackDate').val(formatDate(AddDay('d', 1, startDate), 1));
    }
}
/* 酒店日期使离店日期比入住日期多1天结束*/

/* 显示城市列表控件start*/
function showCitySuggest(cityInputObj, event,flag) {
	var nextHiddenId = $(cityInputObj).next().attr('id');
	suggest.display(cityInputObj, nextHiddenId, event,flag);
}
/* 显示城市列表控件end*/

//首页检测表单填写情况
function hotelQueryCheck() {
	var flag = "success";
	var startCity;
	var startDate = $('#id_hotelStartDate').val();
	var backDate = $('#id_hotelBackDate').val();
	if(document.getElementById('id_startCity')) {
	    startCity = $('#id_startCity').val();
	    if (getThreeWordByCity(startCity,"hotel") == "")return "id_startCity" + "&" + "请填写正确的城市";
	}
	if (!startDate.isDateString())return "id_hotelStartDate" + "&" + "请填写正确的入住日期";
	if (!backDate.isDateString())return "id_hotelBackDate" + "&" + "请填写正确的离店日期";
	if ( getDateFromString(startDate) > getDateFromString(backDate))return "id_hotelBackDate" + "&" + "离店日期应晚于入住日期";
	return flag;
}

/**
 * 判断是否日期格式start
 * @return {Boolean} 符合日期格式返回<code>true</code>,否则返回<code>false</code>
 */
String.prototype.isDateString = function() {
	var iaMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	var iaDate = new Array(3);
	var year, month, day;
	if (this == undefined || this == null || this.trim() == "")
	{
		return false;
	}
	var reg = /^\d{4}-\d{2}-\d{2}$/;
	var sDateTemp = this.trim();
	var reTemp = reg.test(sDateTemp);
	if (!reTemp)
		return false;
	iaDate = this.toString().split("-");
	if (iaDate.length != 3)
		return false;
	if (iaDate[1].length > 2 || iaDate[2].length > 2)
		return false
	if (isNaN(iaDate[0]) || isNaN(iaDate[1]) || isNaN(iaDate[2]))
		return false
	year = parseFloat(iaDate[0])
	month = parseFloat(iaDate[1])
	day = parseFloat(iaDate[2])
	if (year < 1900 || year > 2100)
		return false
	if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
		iaMonthDays[1] = 29;
	if (month < 1 || month > 12)
		return false
	if (day < 1 || day > iaMonthDays[month - 1])
		return false
	return true
}
/* 判断是否日期格式end*/

/* 字符串trim方法去掉首尾空格start*/
String.prototype.trim = function() {    
    return this.replace(/(^\s*)|(\s*$)/g, "");    
}
/* 字符串trim方法去掉首尾空格end*/

/* 首页特推城市选择start*/
function selectIndexCity(cityID){
    chooseHotelCity(cityID);
    $.ajax({
        type:'get',
        url:'/ajax/getIndexCity.aspx?cityID='+cityID+'&d='+new Date().getTime(),
        beforeSend:function(){
            $('#id_hotelList1').html("<img src='/images/ajax-loader.gif' style='width:32px; height:32px;'>");
            $('#cityXingJi').html("<img src='/images/ajax-loader.gif' style='width:32px; height:32px;'>");
            $('#cityPinPai').html("<img src='/images/ajax-loader.gif' style='width:32px; height:32px;'>");
            $('#cityBusiness').html("<img src='/images/ajax-loader.gif' style='width:32px; height:32px;'>");
        },
        success:function(data){
            //alert(data);
            var cityInfoArr=data.split('δ');
            $('#id_hotelList1').html(cityInfoArr[1]);
            $('#cityXingJi').html(cityInfoArr[2]);
            $('#cityPinPai').html(cityInfoArr[3]);
            $('#cityBusiness').html(cityInfoArr[4]);
            //alert(cityInfoArr[2]);
        }
    });
}

function chooseHotelCity(cityID){
   if(cityID==undefined||cityID==null||cityID=="") setCityColor('0101');
   else setCityColor(cityID);
}

function setCityColor(cityID)
{
   var tempChildren = $(".hotelCity_");
   var i=0;
   var tcArr=['0101','0201','2001','2002','2006','1402','2104','1201','1602'];
   tempChildren.removeClass("current");
   tempChildren.each(function(){
      if(cityID == tcArr[i]) $(this).addClass("current");
      else {}
      i++;
   });
}
/* 首页特推城市选择end*/
function selectBookingCity(cityID){
    chooseBookingCity(cityID);
    $.ajax({
        type:'get',
        url:'/ajax/getBookingCity.aspx?cityID='+cityID+'&d='+new Date().getTime(),
        beforeSend:function(){
            $('#cityBus').html("<img src='/images/ajax-loader.gif' style='width:32px; height:32px;'>");
            $('#cityHotel').html("<img src='/images/ajax-loader.gif' style='width:32px; height:32px;'>");
            $('#cityChain').html("<img src='/images/ajax-loader.gif' style='width:32px; height:32px;'>");
        },
        success:function(data){
            //alert(data);
            var cityInfoArr=data.split('δ');
            $('#cityBus').html(cityInfoArr[1]);
            $('#cityHotel').html(cityInfoArr[2]);
            //alert(cityInfoArr[3]);
            $('#cityChainPinPai').html(cityInfoArr[3]);
            //alert($('#cityChain').html());
            //alert(cityInfoArr[1]);
        }
    });
}

function chooseBookingCity(cityID){
    if(cityID==undefined||cityID==null||cityID=="") setCitybg('0101');
    else setCitybg(cityID);
}

function setCitybg(cityID){
    var tempChildren = $(".bookingCity");
    var i=0;
    var tcArr=['0101','0201','2001','2002','1201','1101','2301','1801','1001','1402'];
    tempChildren.removeClass("current");
    tempChildren.each(function(){
        if(cityID == tcArr[i]) $(this).addClass("current");
        else {}
        i++;
    });
}
/* 国内酒店预订页start*/

/* 连锁酒店中间品牌推荐显示各城市酒店start*/
function gethotel(chain_type,cid){
    $("#city"+chain_type+"_"+cid).addClass("current");
	var chain_city=$("#chain_city"+chain_type).children();
	for(i=0;i<chain_city.length;i++)
	{
		if (chain_city[i].id!="city"+chain_type+"_"+cid){
			chain_city[i].className="";
		}
	}
	//alert("/ajax/getCityChain.aspx?at=cch&cid="+cid+"&chainType="+chain_type+"&d="+new Date().getTime());
	$.get(
	    "/ajax/getCityChain.aspx?at=cch&cid=" + cid + "&chainType=" + chain_type + "&d=" + new Date().getTime(), 
	    
	    function(data){
	        $('#chain'+chain_type).html(data);
	    }
	);
}
/* 连锁酒店中间品牌推荐显示各城市酒店end*/

/* 连锁酒店底部品牌推荐酒店start*/
function getchainhotel(chain_type){
	$("#type" + chain_type).addClass("current");
	var chain_city = $("#morechain").children();
	for(i = 0; i < chain_city.length; i++)
	{
		if (chain_city[i].id != "type"+chain_type){
			chain_city[i].className = "";
		}
	}
	//alert("/ajax/getCityChain.aspx?at=tjc&chainType="+chain_type);
	$.get(
	    "/ajax/getCityChain.aspx?at=tjc&chainType="+chain_type+"&d="+new Date().getTime(), 
	    function(data){
	        //alert(data);
	        $('#chain_xinxi').html(data);
	    }
	);
}
/* 连锁酒店底部品牌推荐酒店end*/


/* 级联菜单省份改变时start*/
function ChangeCity(zoneID,cityID){
    $.ajax({ 
        type: "get",
        url: "/ajax/getAjaxArea.aspx",
        data:"at=getCity&zoneID="+zoneID+"&d="+new Date().getTime(),
        dataType:"json",
        success:function(data){
            var citys=eval(data);
            var cityCount=citys.city.length;
            var obj=document.getElementById("CityID");
            obj.length=1;
            for(i=0;i<cityCount;i++){
                obj.options.add(new Option(citys.city[i].cityName,citys.city[i].cityID));
            }
            if(cityID != undefined && cityID != "" && cityID != null) document.getElementById("CityID").value = cityID;
            //alert(citys.city.length);
//	  	  var citys=data.responseText.evalJSON();
//          var cityCount=citys.city.length;
//          var obj=document.getElementById("CityID");
//          obj.length=1;
//          for(i=0;i<cityCount;i++){
//              obj.options.add(new Option(citys.city[i].cityName,citys.city[i].cityID));
//          }
	   }
    });
    
}
/* 级联菜单省份改变时end*/

/* 级联菜单城市改变时start*/
function ChangeRegion(cityID,sarID){
    $.ajax({ 
        type: "get",
        url: "/ajax/getAjaxArea.aspx",
        data:"at=getSar&cityID="+cityID+"&d="+new Date().getTime(),
        dataType:"json",
        success:function(data){
            var sars=eval(data);
            var sarCount=sars.Sar.length;
            var obj=document.getElementById("sarID");
            obj.length=1;
            for(i=0;i<sarCount;i++){
                obj.options.add(new Option(sars.Sar[i].SarName,sars.Sar[i].SarID));
            }
            if(sarID != undefined && sarID != "" && sarID != null) document.getElementById("sarID").value = sarID;
	   }
    });
}
/* 级联菜单城市改变时end*/

function ItemChange(item){
    if(item==1){
        $("#showItem1").addClass("current");
        $("#showItem2").removeClass("current");
        $("#showItemContent1").css("display","");
        $("#showItemContent2").css("display","none");
    }
    else if(item==2){
        $("#showItem1").removeClass("current");
        $("#showItem2").addClass("current");
        $("#showItemContent1").css("display","none");
        $("#showItemContent2").css("display","");
    }
}

/* 酒店点评搜索start*/
function CommentSearch(){
    var proID = document.getElementById("ProvinceID").value;
    var CityID = document.getElementById("CityID").value;
    var kw = $("#id_hotelName1").val();
    if(proID == 0){
        alert("请选择省份！");
        return false;
    }
    if(CityID == 0){
        alert("请选择城市！");
        return false;
    }
    if(kw == undefined||kw == null||kw == ""){
        window.location.href = "/City"+CityID+"/CommentList_1.html";
    }else{
        window.location.href = "/City"+CityID+"/CommentList_1.html?keyword="+escape(kw);
    }
}
/* 酒店点评搜索end*/


function getCookie(name){ 
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)")); 
    if(arr != null) 
    return unescape(arr[2]); 
    return null; 
}
