var HOTEL_IMAGES_PATH_HTTPSERVER="http://resource.elong.com/cn/hotels/images/" ;

function getObj(objID)
{
	if (document.getElementById) {return document.getElementById(objID);}
	else if (document.all) {return document.all[objID];}
	else if (document.layers) {return document.layers[objID];}
}

function HiddenErrDIV(divid)
{
	getObj( divid+'_err').style.visibility = 'hidden';
}

function CheckSafeString(obj,Msg)
{
    if (obj !=null)
    {
       var strObjValue = obj.value;
       if (strObjValue !="")
	   {
	      if (!IsSafeString(strObjValue))
	      {
	          alert( Msg);			
	          obj.focus();
	          return (false);
	      }
	   } 
    }    
    return true;
}

function CheckEmptyString(obj,Msg)
{
 if (obj !=null)
   {
      var strObjValue = trim(obj.value);
      if (strObjValue == "")
	  {
	 	 alert(Msg);			
		 obj.focus();
		 return (false);
	  }	 
   }
   return true;
}

function CheckEmptyAndSafeString(obj,Msg)
{
   if (obj !=null)
   {
      var strObjValue = trim(obj.value);
      if (strObjValue == "")
	  {
	 	 alert(HOTEL_REQUEST_SAFE_EMPTY + Msg + "!");			
		 obj.focus();
		 return (false);
	  }
	  else
	  {
	     if (!IsSafeString(strObjValue))
		 {
		    alert( Msg);			
		    obj.focus();
		    return (false);
		 }
	  }      
   }
   return true;
}

function SubmitForm(obj,strServerDate,Theme)
{        
	var returnValue = false;
	returnValue = Page_ClientValidate(Page_CityName_Validators);
	
	var isLicitCity = validateLicitCity();				
	var city;
	for (i = 0; i < document.HotSrch.raCityName.length-1; i++) {
	    if (document.HotSrch.raCityName[i].checked == true) {
	        city = document.HotSrch.raCityName[i].value;
	        break;
	    }
	}
	if (city == null) {
	    city = document.HotSrch.InCityName.value;
	}
	if(returnValue && isLicitCity)
	{
		WaitingProcess();
				
		var pp = Math.random();
		if (city != null && city != "" && isGATCity(city) == true) {
		    document.HotSrch.action = "/hotels/search.aspx?x=" + pp + "&isgat=gat";
		} else {
		    document.HotSrch.action = "/hotels/search.aspx?x=" + pp;
		}
		document.HotSrch.submit();	
	}

}
function isGATCity(city) {
    var gatCityList = "Hong kong,Hongkong,Xg,Xiang gang,Xianggang,香港,Tai Wan,TaiWan,台湾,Tw,MaCau,Am,Ao Men,AoMen,澳门";
    if (city != null && gatCityList.indexOf(city) > -1) {
        return true;
    } else {
        return false;
    }
}

//酒店新首页提交表单
function SubmitNewForm()
{
  var returnValue = false;
	returnValue = Page_ClientValidate(Page_CityName_Validators);					
	if(returnValue == true)
	{
		var pp = Math.random();
		
		document.HotSrch.action="/hotels/search.aspx?x="+pp;					
		document.HotSrch.submit();	
	}
}

function CityBox_LostFocus(obj)
{
	//changeSelect(document.HotSrch.area_id, obj.value);
}

function CheckFixCityName()
{
    if ((document.HotSrch.raCityName!=null)&&(document.HotSrch.cityid==null))
	{
		if (document.HotSrch.InCityName.value!="")
		{
			document.HotSrch.raCityName[document.HotSrch.raCityName.length - 1].value=document.HotSrch.InCityName.value;
		}
			
		 if (document.HotSrch.raCityName[document.HotSrch.raCityName.length - 1].checked ==true)
		   {
		        //if (!CheckEmptyAndSafeString(document.HotSrch.InCityName,HOTEL_REQUEST_CITY_NAME))
		        //{
		        //   return false;
		        //}
		        if (!CheckEmptyString(document.HotSrch.InCityName,HOTEL_REQUEST_CITY_NAME_SAFEEMPTY))
				{
					return false;
				}
				else
				{
					if (!CheckSafeString(document.HotSrch.InCityName,HOTEL_REQUEST_CITY_NAME_SAFESTIRNG))
					{
						return false;
					}
				}				          		       
	       }	      		
		}
		
		else
		{
	
		if (document.HotSrch.cityid!=null)
		{
		   if (document.HotSrch.cityid[document.HotSrch.cityid.length - 1].checked ==true)
		   {
		        
		       //if (!CheckEmptyAndSafeString(document.HotSrch.raCityName,HOTEL_REQUEST_CITY_NAME))
		       //{
		       //    return false;
		       // }
		       if (!CheckEmptyString(document.HotSrch.raCityName,HOTEL_REQUEST_CITY_NAME_SAFEEMPTY))
				{
					return false;
				}
				else
				{
					if (!CheckSafeString(document.HotSrch.raCityName,HOTEL_REQUEST_CITY_NAME_SAFESTIRNG))
					{
						return false;
					}
				}				          		       		       
	       }
	   }   
	 }	   
      return true;
}


function CheckFixScenery()
{
  	if (document.HotSrch.sceneryid!=null)
		{
		   if (document.HotSrch.sceneryid[document.HotSrch.sceneryid.length - 1].checked ==true)
		   {
		        //if (!CheckEmptyAndSafeString(document.HotSrch.InScenicSpot,HOTEL_REQUEST_SCENERY))
		        //{
		          // return false;
		        //}	
		        if (!CheckEmptyString(document.HotSrch.InScenicSpot,HOTEL_REQUEST_SCENERY_SAFEEMPTY))
				{
					return false;
				}
				else
				{
					if (!CheckSafeString(document.HotSrch.InScenicSpot,HOTEL_REQUEST_SCENERY_SAFESTIRNG))
					{
						return false;
					}
				}				  	       
	       }
	   }
	   else
	   {
	       //if (!CheckEmptyAndSafeString(document.HotSrch.InScenicSpot,HOTEL_REQUEST_SCENERY))
		   //{
		         //return false;
		   //}
		   if (!CheckEmptyString(document.HotSrch.InScenicSpot,HOTEL_REQUEST_SCENERY_SAFEEMPTY))
			{
				return false;
			}
			else
			{
				if (!CheckSafeString(document.HotSrch.InScenicSpot,HOTEL_REQUEST_SCENERY_SAFESTIRNG))
				{
					return false;
				}
			}				  		       
	   
	   }
	   return true;
}


function CheckFixLandmark()
{
   if (document.HotSrch.landmarkid!=null)
		{
		   if (document.HotSrch.landmarkid[document.HotSrch.landmarkid.length - 1].checked ==true)
		   {
		       //if (!CheckEmptyAndSafeString(document.HotSrch.InLandMark,HOTEL_REQUEST_LINKMARK))
		       // {
		       //    return false;
		       // }  
		        if (!CheckEmptyString(document.HotSrch.InLandMark,HOTEL_REQUEST_LINKMARK_SAFEEMPTY))
				{
					return false;
				}
				else
				{
					if (!CheckSafeString(document.HotSrch.InLandMark,HOTEL_REQUEST_LINKMARK_SAFESTIRNG))
					{
						return false;
					}
				}				                
	       }
	   }
	   else
	   {
	       if (document.HotSrch.InLandMark!=null)
	       {
	            //if (!CheckEmptyAndSafeString(document.HotSrch.InLandMark,HOTEL_REQUEST_LINKMARK))
		        //{
		        //   return false;
		        //} 
		        if (!CheckEmptyString(document.HotSrch.InLandMark,HOTEL_REQUEST_LINKMARK_SAFEEMPTY))
				{
					return false;
				}
				else
				{
					if (!CheckSafeString(document.HotSrch.InLandMark,HOTEL_REQUEST_LINKMARK_SAFESTIRNG))
					{
						return false;
					}
				}				             
		    }
	   }
	   return true;
}




function SubmitFixForm(obj,strFrom)
{		


 var returnValue = false;
						
		if (strFrom == "0")
		{			
			returnValue = Page_ClientValidate(Page_CityName_Validators);					
		} 
		
		else if (strFrom == "1")
		{		
		   	returnValue = Page_ClientValidate(Page_ScenicSpot_Validators);		  
		}
		
		else
		{			
			returnValue = Page_ClientValidate(Page_LandMark_Validators);				          
		}
		
		
		if(returnValue == true)
		{
			document.HotSrch.action="/hotels/search.aspx?f=fix"
			document.HotSrch.submit();
		}		  
}

// 格式化字符串;
//example:The {0} format to The dog.
function FormatString(sFormatStr,sParam)
{
	return sFormatStr.replace(/{[0-9]}/,sParam);
}

// 提示信息加入促销代码;
function DisplaySalesCode(sStrWithSalesCode,sStrWithoutSalesCode)
{
	//取促销代码
	if (document.getElementById("V_SalesCode") != null)
	{
		var strSalesCode = document.getElementById("V_SalesCode").value;
		if (strSalesCode.length > 0)
		{
			return FormatString(sStrWithSalesCode,strSalesCode);
		}
	}
	
	return sStrWithoutSalesCode;
}
function CheckInOutDate(objCheckInDate,objCheckOutDate,strServerDate,Theme)
{
   	var strCheckInDate = objCheckInDate.value;
   	var strCheckOutDate = objCheckOutDate.value;   	
   	
   	if ((!IsDate(strCheckInDate))||(strCheckInDate=="yyyy-mm-dd")||(strCheckInDate=="")||(strCheckInDate=="mm/dd/yyyy"))		
		{
			alert(HOTEL_REQUEST_IN_ISDATE);			
			objCheckInDate.focus();
			return (false);
		}
	if (!compareToday(strCheckInDate,strServerDate))
		{
		  alert(HOTEL_REQUEST_COMPARE_IN_TODAY);			
		  objCheckInDate.focus();
		  return (false);
		}
		
	//debugger;
	/*if (Theme=="eLongEn")
	{		  
	}
	else //if (Theme=="eLongBig5" || Theme=="OnLine")
	{*/
		//从配置文件中读取 开始 add by minjiang 09-12-2
		var intInDays20 = 20;
		var intInDays60 = 60;
		try {
		    intInDays20 = parseInt(document.getElementById("IntervallCheckInAndChekOut").value);
		    intInDays60 = parseInt(document.getElementById("IntervallCheckInAndNow").value);
		}
		catch (e)
	{ }
		//从配置文件中读取 结束

		if (compareDate(strServerDate,strCheckInDate,intInDays60 ))
	    {
		if (Theme=="eLongEn" || Theme=="OnLineEn")
		{
		   alert(HOTEL_REQUEST_COMPARE_IN60);
		}
		//else if (Theme=="elongcn")
		//{
		//   alert(HOTEL_REQUEST_COMPARE_TODAY_IN30_F + strCheckInDate + HOTEL_REQUEST_COMPARE_TODAY_IN30_B);
		//}
		else
		{
			//Add by:Wangh 2007-12-8
			var strIN30 = HOTEL_REQUEST_COMPARE_TODAY_IN30_F + strCheckInDate + HOTEL_REQUEST_COMPARE_TODAY_IN30_B;
			alert(DisplaySalesCode(strIN30,FormatString(HOTEL_REQUEST_COMPARE_TODAY_IN30_N,strCheckInDate)));
			
		}
		return false;
	    }    
	/*}*/
		
	if ((!IsDate(strCheckOutDate))||(strCheckOutDate=="yyyy-mm-dd")||(strCheckOutDate=="")||(strCheckOutDate=="mm/dd/yyyy"))		
		{
			alert(HOTEL_REQUEST_OUT_ISDATE);			
			objCheckOutDate.focus();
			return (false);
		}
	if (!compareToday(strCheckOutDate,strServerDate))
		{
		  alert(HOTEL_REQUEST_COMPARE_OUT_TODAY);			
		  objCheckOutDate.focus();
		  return (false);
		} 
	if (!CheckDate(strCheckInDate,strCheckOutDate)) {
		objCheckOutDate.focus();
		alert(HOTEL_REQUEST_COMPARE_IN_OUT);
		return (false);
}
	if (compareDate(strCheckInDate,strCheckOutDate,intInDays20))
	    {
	    //Modify by:Wangh 2008-1-24
	    alert(DisplaySalesCode(HOTEL_REQUEST_COMPARE_IN_OUT20.replace(/REPLACE_DAYS/g,20),HOTEL_REQUEST_COMPARE_IN_OUT20_N.replace(/REPLACE_DAYS/g,20)));
		return false;
	    }

//	    if (!CheckSafeString(document.getElementById("HotelName"), HOTEL_REQUEST_HOTEL_NAME_SAFESTIRNG)) {
//	        return false;
	    //	    }
	    //增加是否是详细页的判断 add by minjiang 09-6-30
			if (window.location.href.toLowerCase().indexOf("details") == -1) {
	        if (!CheckSafeString(document.getElementById("HotelName"), HOTEL_REQUEST_HOTEL_NAME_SAFESTIRNG)) {
	            return false;
	        }
	    	   
	    }
	    return true;		

}

function CheckRequestValue(preName)
{
	var price="" ;
	if(document.HotSrch.Price != null)
	{
		price = document.HotSrch.Price.value;
	}
	else
	{
		if(document.HotSrch.priceType.value == 'rmb')
		{
			price = document.HotSrch.price_rmb.value;
		}
		else
		{
			price = document.HotSrch.price_usd.value;
		}
		price = price + document.HotSrch.priceType.value;
	}
	
	var checkInDate = eval("document.HotSrch." + preName + "CheckInDate").value;
    var checkOutDate = eval("document.HotSrch." + preName + "CheckOutDate").value;
	
	if (document.HotSrch.InCityName!=null)
	{
		var revalue = checkInDate+checkOutDate+document.HotSrch.HotelName.value + document.HotSrch.Star.value + price + document.HotSrch.InCityName.value + document.HotSrch.searchRoomNum.value + document.HotSrch.searchhPersonNum.value;
	}else{
		var revalue = checkInDate+checkOutDate+document.HotSrch.HotelName.value + document.HotSrch.Star.value + price + document.HotSrch.searchRoomNum.value + document.HotSrch.searchhPersonNum.value;
	}
	if(revalue == document.HotSrch.RequestValue.value)
	{
		return false;
	}
	return true;
}

function CheckRequestValueEn(preName)
{
    var checkInDate = eval("document.HotSrch." + preName + "CheckInDate").value;
    var checkOutDate = eval("document.HotSrch." + preName + "CheckOutDate").value;
	var revalue = checkInDate+checkOutDate+document.HotSrch.HotelName.value + document.HotSrch.Star.value+document.HotSrch.searchRoomNum.value + document.HotSrch.searchhPersonNum.value;
	if(revalue == document.HotSrch.RequestValue.value)
	{
		return false;
	}
	return true;
}

function CheckLeftBox(obj,strServerDate,Theme)
{
	if (Theme == "elongen" || Theme == "onlineen")
	{
		if(!CheckRequestValueEn(""))
		{
		return false;
		}
	}
	else
	{
		if(!CheckRequestValue(""))
		{
		return false;
		}
	}
	if (document.HotSrch.InCityName != null){
		if (!CheckSafeString(document.HotSrch.InCityName,HOTEL_REQUEST_CITY_NAME_SAFESTIRNG)){
			return false;
		}
		if (GetHotelCityName(document.HotSrch.InCityName.value)==null)
		{
			alert(HOTEL_REQUEST_CITY_NAME_SAFEEMPTY);
			return false;
		}
		if (!validateLicitCity())
		{
		    return false;
		}
		document.HotSrch.InCityName.value = GetHotelCityName(document.HotSrch.InCityName.value);
		document.HotSrch.InCityName_input.value = GetHotelCityCodeByName(document.HotSrch.InCityName.value);
	}
	
	if (!CheckInOutDate(document.HotSrch.CheckInDate,document.HotSrch.CheckOutDate,strServerDate,Theme))
	{ 
	   return false;
	}
		
	if (!CheckSafeString(document.HotSrch.HotelName,HOTEL_REQUEST_HOTEL_NAME_SAFESTIRNG))
	{
	  return false;
	}
	document.HotSrch.lflag.value = "yes";	
	
	WaitingProcess();
	return true;
}

function CheckTopBox(obj,strServerDate,Theme,preName)
{
    if (Theme == "elongen" || Theme == "onlineen")
	{
		if(!CheckRequestValueEn(preName))
		{
		return false;
		}
	}
	else
	{
		if(!CheckRequestValue(preName))
		{
		return false;
		}
	}
	
    var checkInDate = eval("document.HotSrch." + preName + "CheckInDate");
    var checkOutDate = eval("document.HotSrch." + preName + "CheckOutDate");
    if (CheckInOutDate(checkInDate,checkOutDate,strServerDate,Theme))
	{ 
	   document.HotSrch.CheckInDate.value = checkInDate.value;
	   document.HotSrch.CheckOutDate.value = checkOutDate.value;
	}
	else
	{
	   return false;
	}
	
	document.HotSrch.lflag.value = "yes";	
	
	WaitingProcess();
	return true;
}

function WaitingProcess(){
		document.getElementById("hts_features").style.display = 'none';	
		document.getElementById("flashAd").innerHTML = document.getElementById("flashAd").innerHTML;
		document.getElementById("flashAd").style.display = 'block';
}

function SearchTypeClick(obj)
{	
	
	if (obj.value == 1 || obj.value == 6)
	{
		document.getElementById("divSrh1").style.display = 'none';
		document.getElementById("divSrh2").style.display = 'block';
		document.getElementById("divSrh3").style.display = 'none';
	}
	
	else if (obj.value == 2 || obj.value == 7)
	{
		document.getElementById("divSrh1").style.display = 'none';
		document.getElementById("divSrh2").style.display = 'none';
		document.getElementById("divSrh3").style.display = 'block';	
	}
	
	else
	{
	    document.getElementById("divSrh1").style.display = 'block';
		document.getElementById("divSrh2").style.display = 'none';
		document.getElementById("divSrh3").style.display = 'none';
	}
	
	if (obj.value == 5)
	{
		for(i=1;i<document.HotSrch.raCityName.length;i++)
		{
			if (document.HotSrch.raCityName[i].value == "3201:178263")
			{
				document.HotSrch.raCityName[i].checked=true;
				break;
			}
		}
	} 
	if (obj.value == 7)
	{
		for(i=1;i<document.HotSrch.raCityName.length;i++)
		{
			if (document.HotSrch.raCityName[i].value == "3404:3518")
			{
				document.HotSrch.raCityName[i].checked=true;
				break;
			}
		}
		//edit by bin.wu 2010-01-18 
		document.getElementById("tableMore").style.display = 'none';
		document.getElementById("divExpCollAsst_1").style.display = 'none';
	} 
}

function HotelTypeClick(i)
{
    
	for(j=1;j<=2;j++)
	{
	    if(j==i)
		{
			document.getElementById("hotel_type_title"+j).className="jiudian_haha";
			document.getElementById("sh_title_td" + j).style.backgroundImage='url(' + "'+HOTEL_IMAGES_PATH_HTTPSERVER+'hotel_title_bg" + j + ".jpg" +')';
			//document.getElementById("sh_title_td" + j).background="images/hotel_title_bg" + j + ".jpg";
		}
		else
		{
			document.getElementById("hotel_type_title"+j).className="white";
			document.getElementById("sh_title_td" + j).style.backgroundImage='url(none)';
			//document.getElementById("sh_title_td" + j).background="";
		}
		
	}
}

function HotelTypeClickGAT(i)
{
    
	for(j=1;j<=3;j++)
	{
	    if(j==i)
		{
			document.getElementById("hotel_type_title"+j).className="jiudian_haha";
			document.getElementById("sh_title_td" + j).style.backgroundImage='url("'+HOTEL_IMAGES_PATH_HTTPSERVER+'hotel_title_bgGAT.jpg")';
			//document.getElementById("sh_title_td" + j).background="images/hotel_title_bg" + j + ".jpg";
		}
		else
		{
			document.getElementById("hotel_type_title"+j).className="white";
			document.getElementById("sh_title_td" + j).style.backgroundImage='url(none)';
			//document.getElementById("sh_title_td" + j).background="";
		}
		
	}
}

function HotelTypeClickEn(i)
{
    
	for(j=1;j<=2;j++)
	{
	    if(j==i)
		{
			document.getElementById("hotel_type_title"+j).className="jiudian_haha";
			document.getElementById("sh_title_td" + j).style.backgroundImage='url(' + "'+HOTEL_IMAGES_PATH_HTTPSERVER+'hotel_title_bg" + "4" + ".jpg" +')';
			//document.getElementById("sh_title_td" + j).background="images/hotel_title_bg" + "4" + ".jpg";
		}
		else
		{
			document.getElementById("hotel_type_title"+j).className="white";
			document.getElementById("sh_title_td" + j).style.backgroundImage='url(none)';
			//document.getElementById("sh_title_td" + j).background="";
		}
		
	}
}


function LinkMoreSearch_OnClick() 
{
   if (document.getElementById("morestar").style.display == 'none')
   {
  	  document.getElementById("morestar").style.display = 'block';
	  document.getElementById("moretext").style.display = 'none';
   }
   else
   {
	  document.getElementById("morestar").style.display = 'none';
    }
}


function RoomNumChange(objPersonNum,objRoomNum)
{
	
	var j = 0;
		
	if (objPersonNum.length>0)
	{
		for (i=0;i<=20;i++)
		{
			if (objPersonNum.options[0]!=null)
			{
				objPersonNum.remove(0);
			}
		}
	}
			
	for (var i=objRoomNum.value; i<= objRoomNum.value*4;i++)
	{		
		objPersonNum.options[j] = new Option(i);		
		objPersonNum.options[j].value = i;
		j++;
	}
	
	return;
									
}
					

function LinkRoomNum_OnClick() 
{
   if (document.getElementById("ROOMNUMTABLE").style.display == 'none')
   {
	  document.getElementById("ROOMNUMTABLE").style.display = 'block';
   }
   else
   {
  	  document.getElementById("ROOMNUMTABLE").style.display = 'none';
   }
}


function ClickOtherSelect(strFlag)
{
    switch(strFlag)
    {
       case "raCityName":
       {          
          document.HotSrch.raCityName[document.HotSrch.raCityName.length - 1].checked=true;
          break;
       }
       case "cityid":
       {
          document.HotSrch.cityid[document.HotSrch.cityid.length - 1].checked=true;
          break;
       }
       case "landmarkid":
       {
          document.HotSrch.landmarkid[document.HotSrch.landmarkid.length - 1].checked=true;
          break;
       }
       case "sceneryid":
       {
          document.HotSrch.sceneryid[document.HotSrch.sceneryid.length - 1].checked=true;
          break;
       }
    }
	
}

function ClickOtherSelect_Fix(strFlag)
{
    switch(strFlag)
    {
       case "raCityName":
       {          
          document.HotSrch.raCityName.checked=true;
          for (var i=0;i<document.HotSrch.cityid.length;i++)
		{
			document.HotSrch.cityid[i].checked = false;
		}
          break;
       }
       case "cityid":
       {
          document.HotSrch.cityid[document.HotSrch.cityid.length - 1].checked=true;
          break;
       }
       case "landmarkid":
       {
          document.HotSrch.landmarkid[document.HotSrch.landmarkid.length - 1].checked=true;
          break;
       }
       case "sceneryid":
       {
          document.HotSrch.sceneryid[document.HotSrch.sceneryid.length - 1].checked=true;
          break;
       }
    }
	
}

function InCityNameFocus(obj)
{
	if(obj.value=='中文/拼音') obj.value='';
	if (obj !=undefined && document.HotSrch.currCityName !=undefined)
	{
		obj.select();
		document.HotSrch.raCityName[document.HotSrch.raCityName.length - 1].value=document.HotSrch.InCityName.value;
		document.HotSrch.currCityName.value=document.HotSrch.InCityName.value;
		//changeSelect(document.HotSrch.area_id,document.HotSrch.InCityName.value);
	}
}


function InCityNameChange(obj)
{
   if (obj !=undefined && document.HotSrch.currCityName !=undefined)
	{
		document.HotSrch.raCityName[document.HotSrch.raCityName.length - 1].value=document.HotSrch.InCityName.value;
		document.HotSrch.currCityName.value=document.HotSrch.InCityName.value;
		//changeSelect(document.HotSrch.area_id,document.HotSrch.InCityName.value);
	}
}


function InCityNameChange()
{
		document.HotSrch.raCityName[document.HotSrch.raCityName.length - 1].value=document.HotSrch.InCityName.value;
}


function InCityNameChange_Fix()
{
		document.HotSrch.raCityName.value=document.HotSrch.InCityName.value;
}

function CityChanged()
{
	//document.HotSrch.InCityName_input.value = document.HotSrch.InCityName.value;
		//changeSelect(document.HotSrch.area_id, document.HotSrch.InCityName.value);
}

function Radio_OnClick(obj)
{
	if (obj !=undefined && document.HotSrch.currCityName !=undefined)
	{
		var formName = obj.form;
		document.HotSrch.raCityName[document.HotSrch.raCityName.length - 1].value=-1;
		document.HotSrch.InCityName.value='';
		document.HotSrch.InCityName_input.value='';
		document.HotSrch.currCityName.value=obj.value;
		//changeSelect(document.HotSrch.area_id, obj.value);
	}
}
	

function CityChange(obj)
{
	if (document.HotSrch.InCityName.value=="")
	{
		//changeSelect(document.HotSrch.area_id, document.HotSrch.currCityName.value);
	}
	else
	{
		//changeSelect(document.HotSrch.area_id,document.HotSrch.InCityName.value);
	}
}


function  radio_select(areatype)
{
	if (areatype =="")
	{
		return;
	}

	if(areatype==1)
	{	
	  document.HotSrch.checkarea[0].checked =true;		
	}
	else if(areatype==0)
	{
	  document.HotSrch.checkarea[1].checked =true;
	}
	
}


function btnShowList_onclick() 
{
	if (document.getElementById("divCityName").style.display == 'none')
	{
		document.getElementById("divCityName").style.display = 'block';
		LoadSelectCityList(document.getElementById("slCityName"))
	}
	else
	{
		document.getElementById("divCityName").style.display = 'none';
	}
}


function UCListBox_click()
{
	document.getElementById("InCityName").value = document.getElementById("slCityName").value;
	document.getElementById("divCityName").style.display = 'none';
	document.HotSrch.raCityName[document.HotSrch.raCityName.length - 1].checked=true;
	document.HotSrch.raCityName[document.HotSrch.raCityName.length - 1].value=document.HotSrch.slCityName.value;	
	//changeSelect(document.HotSrch.area_id,document.HotSrch.slCityName.value);
	return false;
}


function radio_checked(r1,i1,r1_value)
{

	var ncount=0;
	for (i=0;i<r1.length;i++)
	{
		if (r1[i].value==r1_value)
		{   
			ncount = ncount+1;
			r1[i].checked=true;
			break;
		}
	}
	if (ncount==0)
	{
	   i1.value = r1_value;
	   r1[r1.length - 1].checked=true;
	}
	document.HotSrch.currCityName.value=r1_value;		
	//changeSelect(document.HotSrch.area_id,r1_value);	
}								


function window_onload()
{
	//i = document.getElementById("InCityName").style.height;
	//document.getElementById("btnShowList").style.width = i;
	//document.getElementById("btnShowList").style.height = i;
/*	
    if (document.HotSrch.srh_type[0]!=null)
    {
		//if (document.getElementById("HotelName").value != "")
		//{
		//	LinkMoreSearch_OnClick();
		//}
		
	   if (document.HotSrch.srh_type[0].checked==true)
	   {
		  document.HotSrch.srh_type[0].checked=true;
		  SearchTypeClick(document.HotSrch.srh_type[0]);	
		  if (document.HotSrch.area_id !=undefined && document.HotSrch.currCityName != undefined)
		  {		
			//changeSelect(document.HotSrch.area_id,document.HotSrch.currCityName.value);
	      }			
	      return;
		}	 
	 }
	 	
	 if (document.HotSrch.srh_type[1]!=null)
	 {
	    if ( document.HotSrch.srh_type[1].checked==true)
		{
			document.HotSrch.srh_type[1].checked=true;
			SearchTypeClick(document.HotSrch.srh_type[1]);			
	      	return;
		}
	 }
	  
	 if (document.HotSrch.srh_type[2]!=null)
	 {
	    if ( document.HotSrch.srh_type[2].checked==true)
		{
			document.HotSrch.srh_type[2].checked=true;
			SearchTypeClick(document.HotSrch.srh_type[2]);			
	      	return;
		}	  
	  }	
*/
}

function BookingExpedia(hid,rid,id,ruleid)
{
	var url = "http://www.elong.com/globalhotels/confirm.aspx?hotelid="+hid +"&roomtypeid="+rid +"&rateplanid="+id+"&rateruleid="+ruleid ;
	document.location.href = url ;
}
//expedia string ScriptAug = "'" + HotelId +"','" + RoomInfo.RoomTypeId + "','" + 
//RoomInfo.RatePlanID + "','" + RoomInfo.RateRuleID + "'";

//参数参数名称：roomNumber , startDate
//增加人：chiyubo
//增加日期：2007-12-15	
//参数说明：hoteltype-酒店类型，hid-酒店协议id ， rid-房型协议id ，id- ，
//ruleid- ， roomNumber-预订房间数量，languageType-语言类型 ， startDate-预订开始日期
//rateplanid:rateplanid,avgrage:均价
//function onBooking(hoteltype , hid , rid , id , ruleid , roomNumber , languageType , startDate , querystr , apno,rateplanid,avgrage)
//{
//    //取消冒泡
//    if(navigator.userAgent.indexOf('MSIE') >= 0)
//    {
//        event.cancelBubble = true;
//    }
//    else
//    {
//        onBooking.caller.arguments[0].cancelBubble = true;
//    }

//	 //判断是否是expedia合作站点，如果是，就直接跳转到提示页面，不走预订流程(liangliang.xu修改 2008-3-21)
//     if(IsNotExpedia())
//     {
//        //判断是否是expedia合作站点结束
//	    //增加对房量的判断(chiyubo on 2007-12-15)
//	    try
//	    {
//		    var sumFlag = CheckSumRooms(hid , rid , roomNumber , languageType);
//		    if(sumFlag == true) //判断总房量
//		    {
//			    var remnantFlag = CheckRemnantRooms(hid , rid , startDate , roomNumber , languageType);
//			    if(remnantFlag == false) //判断剩余房量
//			    {
//				    return;
//			    }
//		    }
//		    else
//		    {
//			    return;
//		    }
//	    }
//	    catch(e)
//	    {}
//	
//	    //增加结束(chiyubo on 2007-12-15)
//    	
//	    if(hoteltype == "expedia")
//	    {
//		    BookingExpedia(hid,rid,id,ruleid);
//	    }
//	    else
//	    {	
//		    document.HotSrch.hotelid.value = hid;
//		    document.HotSrch.roomtypeid.value = rid;
//		    document.HotSrch.roomid.value = id;
//		    document.HotSrch.rateplanid.value = rateplanid;
//		    document.HotSrch.avgrage.value = avgrage;
//		    //如果用户未登录则弹出登录页
//		    //		    if (GetCookie("member") == null || GetCookie("member") == '192928' || GetCookie("member") == '7036777182')
//		    //            var status = loadAjaxRequest(apno);
//		    var status;
//		    if (typeof(apno) != "undefined" && apno != null) {
//		        status = GetData("/hotels/AjaxRequestProxy.aspx?RequestType=getlogin&apno=" + apno);
//		    } else {
//		        status = GetData("/hotels/AjaxRequestProxy.aspx?RequestType=getlogin");
//		    }
//		    //本地测试不弹出登录框 add by minjiang 09-6-5
//		    //如果想测试注释掉就行
//		    if (window.location.href.indexOf("localhost") != -1)
//		    {status = "1"; }
////		    if (status != null && status == "0")
////		    {
////		        if (window.location.href.indexOf("www.elong.com") != -1 || window.location.href.indexOf("www.elong.net") != -1 ||  window.location.href.indexOf("localhost") != -1)		        
////		        {
////		            window.top.UserLogin(querystr, languageType);
////		        }		        
////                else if( window.location.href.toLowerCase().indexOf("big5.elong.com") != -1 )
////                {
////                    var q = querystr.replace("/smalllogin.aspx?","/login.aspx?");
////		            window.location.href = q;
////                }
////		        else 
////		        {
////		            if (window.parent != null && (window.location.href.indexOf("travel.elong.com") != -1 || window.location.href.indexOf("travel.elong.net") != -1)) {
////		                window.parent.location.href = querystr;
////		            } else {
////		                window.location.href = querystr;
////		            }
////		        }
////		    } 
////		    else
////		    {
////		        var pp = Math.random();
////		        document.HotSrch.action = "/hotels/order.aspx?xx=" + pp;

////		        //If this page is in a frame then open the page in top frame.
////		        if (window.top != window.self) {
////		            document.HotSrch.target = "_top"; //"_blank"
////		        }
////		        document.HotSrch.submit();
//		    //		    }
//		    //增加QQ判断逻辑 add by minjiang 09-11-3
//		    if (window.location.href.indexOf("localhost") != -1&&languageType=="cn") {
//		        addCookie("ispop", "1", 1);
//		        addCookie("haseid", "1", 1);
//		        addCookie("key", "624000103", 1);
//		    }
//		    var ispop = GetCookie("ispop");
//		    //alert("aa");
//		    if(ispop=="1") {
//		        //说明需要弹出补真页
//		        //内嵌iframe对象
//		        var qqrul = getQQurl(querystr);
//		        var contentHtml = '<iframe id="iframeQQ" frameborder="0"  src="' + qqrul + '" width="510px" height="355px" scrolling="no"></iframe>';
//		        if (languageType.toLowerCase() == "cn") {
//		            $("#msgBoxDiv").dialog("option", "title", "激活提示");
//		            //$('#msgBoxDiv').dialog('option', 'height', 600);
//		            $("#msgBoxDiv").dialog("option", "width", 540);
//		            $("#msgBoxDiv").html(contentHtml).dialog("open");
//		            
//		            
//		        }
//		       
//		    
//		    }
//		    else if (status != null && status == "0") {
//		        if (window.location.href.indexOf("www.elong.com") != -1 || window.location.href.indexOf("www.elong.net") != -1 || window.location.href.indexOf("localhost") != -1) {
//		            window.top.UserLogin(querystr, languageType);
//		        }
//		        else if (window.location.href.toLowerCase().indexOf("big5.elong.com") != -1) {
//		            var q = querystr.replace("/smalllogin.aspx?", "/login.aspx?");
//		            window.location.href = q;
//		        }
//		        else {
//		            if (window.parent != null && (window.location.href.indexOf("travel.elong.com") != -1 || window.location.href.indexOf("travel.elong.net") != -1)) {
//		                window.parent.location.href = querystr;
//		            } else {
//		                window.location.href = querystr;
//		            }
//		        }
//		    }
//		    else {
//		        var pp = Math.random();
//		        document.HotSrch.action = "/hotels/order.aspx?xx=" + pp;

//		        //If this page is in a frame then open the page in top frame.
//		        if (window.top != window.self) {
//		            document.HotSrch.target = "_top"; //"_blank"
//		        }
//		        document.HotSrch.submit();
//		    }
//	    }
//	 }

//}

//点击预订按钮不再判断登录,登录转移到订单填写页中 add by minjiang 10-1-7
function onBooking(hoteltype, hid, rid, id, ruleid, roomNumber, languageType, startDate, querystr, apno, rateplanid, avgrage) {
    //取消冒泡
    if (navigator.userAgent.indexOf('MSIE') >= 0) {
        event.cancelBubble = true;
    }
    else {
        onBooking.caller.arguments[0].cancelBubble = true;
    }

    //判断是否是expedia合作站点，如果是，就直接跳转到提示页面，不走预订流程(liangliang.xu修改 2008-3-21)
    if (IsNotExpedia()) {
        //判断是否是expedia合作站点结束
        //增加对房量的判断(chiyubo on 2007-12-15)
        try {
            var sumFlag = CheckSumRooms(hid, rid, roomNumber, languageType);
            if (sumFlag == true) //判断总房量
            {
                var remnantFlag = CheckRemnantRooms(hid, rid, startDate, roomNumber, languageType);
                if (remnantFlag == false) //判断剩余房量
                {
                    return;
                }
            }
            else {
                return;
            }
        }
        catch (e)
	    { }

        //增加结束(chiyubo on 2007-12-15)

        if (hoteltype == "expedia") {
            BookingExpedia(hid, rid, id, ruleid);
        }
        else {
            document.HotSrch.hotelid.value = hid;
            document.HotSrch.roomtypeid.value = rid;
            document.HotSrch.roomid.value = id;
            document.HotSrch.rateplanid.value = rateplanid;
            document.HotSrch.avgrage.value = avgrage;

            var status;
            if (typeof (apno) != "undefined" && apno != null) {
                status = GetData("/hotels/AjaxRequestProxy.aspx?RequestType=getlogin&apno=" + apno);
            } else {
                status = GetData("/hotels/AjaxRequestProxy.aspx?RequestType=getlogin");
            }
            //本地测试不弹出登录框 add by minjiang 09-6-5
            //如果想测试注释掉就行
            if (window.location.href.indexOf("localhost") != -1)
            { status = "1"; }
            var hidBookType = "";
            try {
                hidBookType = jQuery("#hidBookType").val();
            }
            catch (e)
            { }
            //增加QQ判断逻辑 add by minjiang 09-11-3
            if (window.location.href.indexOf("localhost") != -1 && languageType == "cn") {
                addCookie("ispop", "0", 1);
                addCookie("haseid", "1", 1);
                addCookie("key", "624000103", 1);
                status = 0;
            }
            var ispop = GetCookie("ispop");
            //alert("aa");
            if (ispop == "1") {
                //说明需要弹出补真页
                //内嵌iframe对象
                var qqrul = getQQurl(querystr);
                var contentHtml = '<iframe id="iframeQQ" frameborder="0"  src="' + qqrul + '" width="510px" height="355px" scrolling="no"></iframe>';
                if (languageType.toLowerCase() == "cn") {
                    $("#msgBoxDiv").dialog("option", "title", "激活提示");
                    //$('#msgBoxDiv').dialog('option', 'height', 600);
                    $("#msgBoxDiv").dialog("option", "width", 540);
                    $("#msgBoxDiv").html(contentHtml).dialog("open");
                }

            }
            else if (status != null && status == "0" && hidBookType == "p") {
            //积分广场逻辑
            //用户登录
            var loginurl = "http://www.elong.com/myelong/smalllogin.aspx";
            if (window.location.href.toLowerCase().indexOf("big5.elong.com") != -1) {
                loginurl = "http://big5.elong.com/gate/big5/myelong/login.aspx";
            }
            querystr = loginurl + "?nexturl=" + escape(querystr);
                if (window.location.href.indexOf("www.elong.com") != -1 || window.location.href.indexOf("www.elong.net") != -1 || window.location.href.indexOf("localhost") != -1) {
                    window.top.UserLogin(querystr, languageType);
                }
                else if (window.location.href.toLowerCase().indexOf("big5.elong.com") != -1) {
                    var q = querystr.replace("/smalllogin.aspx?", "/login.aspx?");
                    window.location.href = q;
                }
                else {
                    if (window.parent != null && (window.location.href.indexOf("travel.elong.com") != -1 || window.location.href.indexOf("travel.elong.net") != -1)) {
                        window.parent.location.href = querystr;
                    } else {
                        window.location.href = querystr;
                    }
                }
            }
            else {
                querystr = getOrderUrl(querystr);
                var surl = window.location.href.toLowerCase();
                if (surl.indexOf("maphotel.aspx") == -1) {
                    window.location.href = querystr;
                }
                else {
                    //地图页特殊逻辑
                    window.parent.location.href = querystr;
                }
            }
        }
    }

}
//取订单填写页URL add by minjiang 10-1-7
function getOrderUrl(querystr) {
    //querystr = unescape(querystr);
    //querystr = querystr.toLowerCase();
    //querystr = querystr.substring(querystr.indexOf("nexturl=") + 8);
    return querystr;
}


function SetWinHeight(obj)
{
var win=obj;
if (document.getElementById)
{
if (win && !window.opera)
{
   if (win.contentDocument && win.contentDocument.body.offsetHeight) 
     win.height = win.contentDocument.body.offsetHeight; 
   else if(win.Document && win.Document.body.scrollHeight)
     win.height = win.Document.body.scrollHeight;
}
}
}

//QQ补填页地址 add by minjiang 09-11-3
function getQQurl(querystr) {
    //querystr = querystr.toLowerCase();
    //querystr = querystr.substring(querystr.indexOf("nexturl="));
    //    var nexturl = "";
    //    var list = querystr.split('&');
    //    if (list.length > 0) {
    //        nexturl = list[0];
    //    }
    var nexturl = escape(querystr);
    nexturl += escape("&tenpay=1");
    //    var sUrl = "myelong/tenpay.aspx?page=wallet&hasid=" + GetCookie("haseid") + "&Key=" + GetCookie("key") + "&name=&" + nexturl;
    var sUrl = "myelong/tenpay.aspx?page=wallet&hasid=" + GetCookie("haseid") + "&Key=" + GetCookie("key") + "&name=&nexturl=" + nexturl;
    var s = "http://localhost/";
    if (window.location.href.indexOf("localhost") == -1)
    { s = "http://www.elong.com/"; }
    sUrl = s + sUrl;
    return sUrl;
}

function onSeoBooking(hoteltype , hid , rid , id , ruleid , roomNumber , languageType , startDate , querystr , apno)
{
    //取消冒泡
    if(navigator.userAgent.indexOf('MSIE') >= 0)
    {
        event.cancelBubble = true;
    }
    else
    {
        onSeoBooking.caller.arguments[0].cancelBubble = true;
    }

	 //判断是否是expedia合作站点，如果是，就直接跳转到提示页面，不走预订流程(liangliang.xu修改 2008-3-21)
     if(IsNotExpedia())
     {
        //判断是否是expedia合作站点结束
	    try
	    {
		    var sumFlag = CheckSumRooms(hid , rid , roomNumber , languageType);
		    if(sumFlag == true) //判断总房量
		    {
			    var remnantFlag = CheckRemnantRooms(hid , rid , startDate , roomNumber , languageType);
			    if(remnantFlag == false) //判断剩余房量
			    {
				    return;
			    }
		    }
		    else
		    {
			    return;
		    }
	    }
	    catch(e)
	    {}
	
	    if(hoteltype == "expedia")
	    {
		    BookingExpedia(hid,rid,id,ruleid);
	    }
	    else
	    {	
		    window.top.SeoUserBooking(querystr, languageType);
		    
	    }
	 }

}

/*
function Login(querystr) 
{
    //var pas = "http://localhost/hotels/order.aspx?" + querystr;
    tb_show("", querystr + "&TB_iframe=true&height=254&width=450", false, "scrollbars=no", "border=0", "top=0", "left=0", "resizable=no");
}
*/

function SeoUserBooking(querystr, languageType) 
{
    if(languageType.toLowerCase()=="cn")
	{
		smallBooking(querystr, true);
	}
	else
	{
		smallBooking(querystr, false);
	}
}

function ReloadIframe(url) 
 {
     window.parent.document.getElementById("hotelframe").src = url;
     window.parent.document.getElementById("hotelframe").width = 480;
     window.parent.document.getElementById("hotelframe").height = 250;
 }



function UserLogin(querystr, languageType) 
{
    if(languageType.toLowerCase()=="cn")
	{
		smallLogin(querystr, true);
	}
	else
	{
		smallLogin(querystr, false);
	}
}
 


function GetCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = window.document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (window.document.cookie.substring(i, j) == arg) return getCookieVal(j);
        i = window.document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}

function getCookieVal(offset) {
    var endstr = window.document.cookie.indexOf(";", offset);
    if (endstr == -1) endstr = window.document.cookie.length;
    return unescape(window.document.cookie.substring(offset, endstr));
}

//added by jianbo.liu 2008/01/29
//拆分订单
function onBookingForSplit(payType, hid, rid, CheckInDate, CheckOutDate, querystr, apno)
{
    //取消冒泡
    if(navigator.userAgent.indexOf('MSIE') >= 0)
    {
        event.cancelBubble = true;
    }
    else
    {
        onBooking.caller.arguments[0].cancelBubble = true;
    }

		 //判断是否是expedia合作站点，如果是，就直接跳转到提示页面，不走预订流程(liangliang.xu修改 2008-3-21)
     if(IsNotExpedia())
     {
    //判断是否是expedia合作站点结束
//		document.HotSrch.hotelid.value = hid;
//		document.HotSrch.roomtypeid.value = rid;
//		document.HotSrch.roomid.value = id;
//		document.HotSrch.CheckInDate.value = CheckInDate;
         //		document.HotSrch.CheckOutDate.value = CheckOutDate;
         var status;
         if (typeof(apno) != "undefined" && apno != null) {
             status = GetData("/hotels/AjaxRequestProxy.aspx?RequestType=getlogin&apno=" + apno);
         } else {
             status = GetData("/hotels/AjaxRequestProxy.aspx?RequestType=getlogin");
         }
         if (status != null && status == "0") {
             if (window.location.href.indexOf("www.elong.com") != -1 || window.location.href.indexOf("www.elong.net") != -1 || window.location.href.indexOf("localhost") != -1) 
             {
                if(window.location.href.indexOf("www.elong.com") != -1)
                {
                    window.top.UserLogin(querystr, "cn");
                }
                else if( window.location.href.toLowerCase().indexOf("big5.elong.com") != -1 )
                {
                    var q = querystr.replace("/smalllogin.aspx?","/login.aspx?");
                    window.location.href = q;
                }
                else
                {
                    window.top.UserLogin(querystr, "en");
                }               
                 
             } else {
                 if (window.parent != null && (window.location.href.indexOf("travel.elong.com") != -1 || window.location.href.indexOf("travel.elong.net") != -1)) {
                     window.parent.location.href = querystr;
                 } else {
                     window.location.href = querystr;
                 }
             }
         }
         else
	    {
	        var pp = Math.random();
	        document.HotSrch.action = "/hotels/order.aspx?xx=" + pp + "&hotelid=" + hid + "&roomtypeid=" + rid + "&CheckInDate=" + CheckInDate + "&CheckOutDate=" + CheckOutDate + "&PayType=" + payType;

	        //If this page is in a frame then open the page in top frame.
	        document.HotSrch.target = "_blank"; 
	        document.HotSrch.submit();
	    }
    }
		
//		var pp = Math.random();
//		document.HotSrch.action="confirm.aspx?xx="+pp + "&hotelid=" + hid + "&roomtypeid=" + rid + "&CheckInDate=" + CheckInDate + "&CheckOutDate=" + CheckOutDate + "&PayType=" + payType;

		//If this page is in a frame then open the page in top frame.
//		document.HotSrch.target="_blank"; //"_blank"
		//alert(document.all.roomid.value);
//		document.HotSrch.submit();
//	 }
}
//added by jianbo.liu 2008/01/29
//拆分订单
function Split(hotelid,roomtypeid,queryStr,apno)
{/*
	var pp = Math.random();
	document.HotSrch.action="split.aspx?xx="+pp + "&hotelid=" + hid + "&roomtypeid=" + rid + "&CheckInDate=" + arriveDate + "&CheckOutDate=" +leaveDate;
	document.HotSrch.submit();*/
    var pp = Math.random();
    document.HotSrch.roomid.value = queryStr;
    document.HotSrch.action = "split.aspx?xx=" + pp + "&hotelid=" + hotelid + "&roomtypeid=" + roomtypeid + "&campaign_id=" + apno;
    if (window.top != window.self) {
        document.HotSrch.target = "_top"; //"_blank"
    }
	document.HotSrch.submit();
}
//增加人：chiyubo
//增加日期：2008-01-07
//功能描述：判断用户预订房量是否大于第一天的剩余房量
function CheckRemnantRooms(hid , rid , start_date , roomNumber ,languageType)
{
	var roomRemnantSum = null;
	try
	{
		//获取剩余房量
		roomRemnantSum = GetData("Asp/GetRemnantRooms.asp?hotel_id="+hid+"&room_type_id="+rid+"&start_date="+start_date+"&room_num="+roomNumber);
	}
	catch(e)
	{
		roomRemnantSum = null;
	}
	
	if(roomRemnantSum != null && roomRemnantSum != "")
	{
		if(Number(roomRemnantSum) >= 0) //剩余房量为非正数(<= 0)时不作判断
		{
			if(Number(roomRemnantSum) < Number(roomNumber))
			{
				if(String(languageType) == "cn")
				{
					alert("抱歉，您的订房量超出酒店房型的剩余房量，请您选择其他房型或酒店。");
				}
				else //if(String(languageType) == "en")
				{
					alert("Sorry, the room amount you have selected has exceeded the remnant number of this room type.\r\nPlease choose another room type or hotel.");
				}
				return false;
			}
		}
	}
	return true;
}

//增加人：chiyubo
//增加日期：2008-01-07
//功能描述：判断用户预订房量是否大于酒店房型的总房量
function CheckSumRooms(hid , rid , roomNumber , languageType)
{
	var roomSum = null;
	try
	{
		//获取总房量
		roomSum = GetData("/hotels/AjaxRequestProxy.aspx?RequestType=gethotelrooms&hotel_id="+hid+"&room_id="+rid);
	}
	catch(e)
	{
		roomSum = null;
	}
	
	if(roomSum != null && roomSum != "")
	{
		if(Number(roomSum) > 0) //房量为非正数(<= 0)时不作判断
		{
			if(Number(roomSum) < Number(roomNumber))
			{
				if(String(languageType) == "cn")
				{
					alert("抱歉，您的订房量超出酒店房型的总量，请您选择其他房型或酒店。");
				}
				else //if(String(languageType) == "en")
				{
					alert("Sorry, the room amount you have selected has exceeded the number of this room type.\r\nPlease choose another room type or hotel.");
				}
				return false;
			}
		}
	}
	return true;
}

/*
24、window_onload()：360度全景展示
*/
function showVirtual(hid)
{
   return ;
  
  //alert("现在还没有! " + hid);
}

function ExpediaHotelDetails(hid,show)
	{			
				
		document.HotSrch.hotelid.value = hid;			
		if (show==null || show.length == 0)
		{						
			var pp = Math.random();
			var url = "http://www.elong.com/globalhotels/details.aspx?fo=gat&hotelid=" + hid;
			
		}
		else
		{
			var pp = Math.random();	
			var url = "http://www.elong.com/globalhotels/details.aspx?fo=gat&m="+show + "&hotelid=" + hid;
	
		}
		
		//alert(document.all.roomid.value);
		
		//If this page is in a frame then open the page in top frame.
		if (window.top != window.self)
		{
			window.top.location.href = url ;
		}
		else
		{
			document.location.href = url ;
		}
	}

function HotelDetails(hid,show,hoteltype,anchor,target,pos)
{
	if(hoteltype == "expedia")
	{
		ExpediaHotelDetails(hid,show);
		return;
	}
	
	//sina合作站点处理
	if(hoteltype == "sina")
	{
		document.HotSrch.action="http://data.travel.sina.com.cn/hotel_comment/hotel.php?elongid=" + hid;
		document.HotSrch.submit();
		return;
	}

	document.HotSrch.hotelid.value = hid;
	//document.HotSrch.pos.value = pos;
	try {
	    document.HotSrch.pos.value = pos;
	}
	catch (e) { }
	if (show==null)
	{						
		var pp = Math.random();
		document.HotSrch.action="/hotels/details.aspx?hotelid=" + hid;				
		//document.HotSrch.action="details.aspx?x=" + pp;				
	}
	else
	{
		var pp = Math.random();
		
		if (anchor != null && anchor.length > 0 )
		{
			document.HotSrch.action="/hotels/details.aspx?m="+show + "&hotelid=" + hid + "&x=" + pp + "#" + anchor;
		}
		else
		{
			document.HotSrch.action="/hotels/details.aspx?m="+show + "&hotelid=" + hid;
		}
	}
	
	if (target != null && target.length > 0)
	{
	  document.HotSrch.target = target;
	}
	else
	{
	  //If this page is in a frame then open the page in top frame.
	  if (window.top != window.self)
	  {
	    document.HotSrch.target="_top"; //"_blank"
	  }
	  //Show 360 page in new window at hotellist
	  if (show == "Image"){
	    document.HotSrch.target="_blank"; //"_blank"
	  }
	}

	document.HotSrch.submit();
	
	//朱志嘉2008-12-17修改 防止查看360后修改本页action影响到重新搜索
	  if (show == "Image"){
        var pp = Math.random();
	    document.HotSrch.action="/hotels/search.aspx?x="+pp;	
	    document.HotSrch.target="_self";	
	 }
}

//用于地图气泡页面
function HotelDetailsForMap(hid,show,hoteltype,anchor)
{
	if(hoteltype == "expedia")
	{
		ExpediaHotelDetails(hid,show);
		return;
	}

	document.HotSrch.hotelid.value = hid;			
	if (show==null)
	{						
		var pp = Math.random();
		document.HotSrch.action="/hotels/details.aspx?hotelid=" + hid;				
		//document.HotSrch.action="details.aspx?x=" + pp;				
	}
	else
	{
		var pp = Math.random();
		
		if (anchor != null && anchor.length > 0 )
		{
			document.HotSrch.action="/hotels/details.aspx?m="+show + "&hotelid=" + hid + "&x=" + pp + "#" + anchor;
		}
		else
		{
			document.HotSrch.action="/hotels/details.aspx?m="+show + "&hotelid=" + hid;
		}
	}
	
	document.HotSrch.target="_blank";
	document.HotSrch.submit();
}
	
function Radio_City_OnClick(obj)
{
	var formName = obj.form;
	obj.checked = true;
	document.HotSrch.raCityName.checked=false;
	document.HotSrch.raCityName.value='';
	document.HotSrch.InCityName.value	="";
	document.HotSrch.InCityName_input.value="";
}
function Radio_InputCity_Click(obj)
{
	for (var i=0;i<document.HotSrch.cityid.length;i++)
	{
		document.HotSrch.cityid[i].checked = false;
		//document.HotSrch.cityid[i].value = "";
	}
}

function Radio_Mark_OnClick(obj)
{
	var formName = obj.form;
	document.HotSrch.landmarkid[document.HotSrch.landmarkid.length - 1].value=-1;
	document.HotSrch.InLandMark.value='';	
}

function Radio_Spot_OnClick(obj)
{
	var formName = obj.form;
	document.HotSrch.sceneryid[document.HotSrch.sceneryid.length - 1].value=-1;
	document.HotSrch.InScenicSpot.value='';	
}

//****************************************************/
//新增以下两个方法Get XMLHTTPRequest和GetData()
//作者：chiyubo 
//日期：2007-12-15
//****************************************************/
function GetXMLHTTPRequest()
{
    var xmlHttp;
    try
    {
		xmlHttp = new XMLHttpRequest();
		if(xmlHttp.overrideMimeType)
		{
			xmlHttp.overrideMimeType("text/xml");
		}
    }
    catch(e)
    {
		try
		{
    		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");	
		}
		catch(e)
		{
    		try
    		{
    			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    		}
    		catch(e)
    		{
    			xmlHttp = false;
    		}
		}
    }
    if(!xmlHttp && typeof XMLHttpRequest != 'undefined')
    {
    	try
    	{
    		xmlHttp = new XMLHttpRequest();
    	}
    	catch(e)
    	{
    		xmlHttp = false;
    	}
    }
    return xmlHttp;
}
/*
    return data by url
*/
function GetData( url )
{
    var returnValue = "";
    var oReq = null;
    
    //获取异步调用对象
    oReq = GetXMLHTTPRequest();
    
    if ( oReq == null || Boolean(oReq) == false )
    {
        return returnValue;
    }
    
    if ( url.indexOf("?") > 0 )
    {
        url += "&random=" + Math.random();
    } 
    else
    {
        url += "?random=" + Math.random();
    }
    oReq.open("GET", url,false);
    oReq.setRequestHeader("Cache-Control", "no-cache");
    oReq.send("");
    
    if ( oReq.readyState == 4 )
    {
        returnValue = oReq.responseText;
    }
    oReq = null;
    return returnValue;
}

function HotelComments(hotelID)
{
	window.location.href = "http://bbs.elong.com/posthotel.php?action=post&hid="+hotelID;
}

function HotelNewComments(hotelID,hotelName)
{
	window.location.href = "http://dianping.elong.com/PostComment_" + hotelID + ".html";
}

function IsNotExpedia()
{
  if(typeof(JS_CONST_HEAD)!="undefined"){
  if(JS_CONST_HEAD.CARD_NO=="4917393"){
    var url = "http://expediacorporate.elong.com/pop.htm";
	window.open (url, "newwindow", "height=140, width=400, top=300, left=400, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no");
    return false;
    }
	else if(JS_CONST_HEAD.CARD_NO=="4946915"){
    var url2 = "http://expediacorporate.elong.net/popen.htm";
    window.open (url2, "newwindow", "height=140, width=400, top=300, left=400, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no");
    return false;
    }
   else
   {
    return true;
   }
   }
  else{
  return true;
  } 
}

/**************************************/

//验证是否合法城市
function validateLicitCity()
{
    var isLicitCity = document.getElementById("mustLicitCity");
    
    if (isLicitCity != null && isLicitCity.value == "True" && 
        document.HotSrch.InCityName != null &&
        document.HotSrch.InCityName.value != "")
    {
        var sCityName = document.HotSrch.InCityName.value;
        var excludeCityList = getExcludeCityList();
        if (excludeCityList != null && excludeCityList.length > 0)
        {
            for(var i = 0; i < excludeCityList.length; i++)
            {
                var eCity = excludeCityList[i];
                if (sCityName.indexOf(eCity.CityNameCN) > -1 || sCityName.indexOf(eCity.CityNameEN.toLowerCase()) > -1)
                {
                    alert("如果您想预订港澳台的酒店, 请访问http://www.hotels.cn。");
                    return false;
                    break;
                }
            }
        }
    }
    
    return true;
}

function getExcludeCityList()
{
    return [{CityNameCN:'香港',CityNameEN:'hong kong'},
            {CityNameCN:'澳门',CityNameEN:'macau'},
            {CityNameCN:'台湾',CityNameEN:'taiwan'},
            {CityNameCN:'台北',CityNameEN:'taibei'},
            {CityNameCN:'台中',CityNameEN:'taizhong'},
            {CityNameCN:'台山',CityNameEN:'taishan'},
            {CityNameCN:'高雄',CityNameEN:'gaoxiong'}];
}


/*******************宽屏列表JS开始*******************/
function HighlightLine(lineid, hotelid) {
    //getObj(lineid).className = "ht_item on";
	HighlightHotel(hotelid);
    mouseoverBgImage(hotelid);
}
function LostfocusLine(lineid, hotelid) {
    //getObj(lineid).className = "ht_item";
    mouseoutBgImage(hotelid);
}


//get element by id
function elt(id) {
    return document.getElementById(id);
}

//get element's css property
function gds(o) {
    return elt(o).currentStyle ? elt(o).currentStyle["top"] : document.defaultView.getComputedStyle(elt(o), false)["top"];
}

function hidev(idw) {
    elt(idw).style.display = "none";
    elt("search_fl").style.zIndex=1;
}
function showv(idw) {
    elt(idw).style.display = "block";
    elt(idw).style.zIndex = 2;
    elt("search_fl").style.zIndex=-1;
}

//mouse over/out
function hv(id, idw) {
    if (elt(id) && elt(idw)) {
        elt(id).onmouseover = function() {
            elt(idw).style.display = "block";
        }
        elt(id).onmouseout = function() {
            elt(idw).style.display = "none";
        }
    }
}


//关闭自定义价格窗口
function CloseCustomPriceForm() {
    //取消冒泡
    if (navigator.userAgent.indexOf('MSIE') >= 0) {
        event.cancelBubble = true;
    }
    else {
        CloseCustomPriceForm.caller.arguments[0].cancelBubble = true;
    }
    if (elt("apricew")) {
        elt("apricew").style.display = "none";
    }
}

//单击自定义价格，弹出自定义价格窗口
function OpenCustomPriceForm() {
    //取消冒泡
    if (navigator.userAgent.indexOf('MSIE') >= 0) {
        event.cancelBubble = true;
    }
    else {
        OpenCustomPriceForm.caller.arguments[0].cancelBubble = true;
    }
    if (elt("apricew") && elt("apricew").style.display == "none") {
        elt("apricew").style.display = "";
        this.className = "b";
        var price1 = elt('price1');
        price1.focus();
    }
    return false
}

//自定义价格搜索
function SubmitCustomPriceSearch(lng) {
    //取消冒泡
    if (navigator.userAgent.indexOf('MSIE') >= 0) {
        event.cancelBubble = true;
    }
    else {
        SubmitCustomPriceSearch.caller.arguments[0].cancelBubble = true;
    }

    var price1 = elt('price1');
    var price2 = elt('price2');
    var msg = elt("msg_prier");

    //这里增加验证，若用户未完成输入点确定按钮，则提示“请输入……”；若用户输入的下限大于上限，则提示“…………”
    try {
        p1 = 0;
        p2 = 0;
        if (price1.value != '')
            p1 = parseInt(price1.value);
        else {
            msg.style.display = "";
            msg.innerHTML = (lng == "cn") ? '请输入最低房价' : 'Please input minimum rate.';
            price1.focus();
            return;
        }
        if (price2.value != '')
            p2 = parseInt(price2.value);
        else {
            msg.style.display = "";
            msg.innerHTML = (lng == "cn") ? '请输入最高房价！' : 'Please input maximum rate.';
            price1.focus();
            return;
        }
        if (p2 == p1) {
            msg.style.display = "";
            msg.innerHTML = (lng == "cn") ? '请输入两个不同的房价！' : 'Please input two different rates.';
            price1.focus();
            return;
        }
        
        if (p2 < p1) {
            msg.style.display = "";
            msg.innerHTML = (lng == "cn") ? '最高房价必须大于最低房价！' : 'Invalid rate range.';
            price1.focus();
            return;
        }
        if (isNaN(price1.value) || isNaN(price2.value)) {
            msg.style.display = "";
            msg.innerHTML = (lng == "cn") ? '请输入数字！' : 'Please input number!';
            return;
        }
    } catch (ex) {
        msg.style.display = "";
        msg.innerHTML = (lng == "cn")?'请输入数字！':'Please input number!';
        return;
    }
    msg.style.display = "none";
    elt('apricew').style.display = 'none';
    CustomPriceSearch(price1.value + ',' + price2.value);
    //ShowProcessorBar();
}

//取消冒泡
function CancelBubble() {
    if (navigator.userAgent.indexOf('MSIE') >= 0) {
        event.cancelBubble = true;
    }
    else {
        CancelBubble.caller.arguments[0].cancelBubble = true;
    }
}

function SubmitToDianPing(cityid, cityname, star) {
    var frmDP = document.getElementById("frmDianPing");
    frmDP.raCityName_input.value = cityid;
    frmDP.raCityName.value = cityname;
    frmDP.Star.value = ((star != -1) ? star : "100");
    frmDP.submit();
}

function ShowProcessorBar() {
    document.getElementById("flashAd").innerHTML = document.getElementById("flashAd").innerHTML;
    document.getElementById("flashAd").style.display = "block"; //显示正在查询处理等待
    //解决屏幕居中问题 add by minjiang 09-10-23
    document.getElementById("flashAd").style.left = (document.body.clientWidth / 2 - 200).toString() + "px";
    document.getElementById("flashAd").style.top = (window.screen.availHeight / 2 - 200 + document.documentElement.scrollTop).toString() + "px";
    var s = "";
//    try {
//        document.getElementById("flashAd").style.left = (document.body.clientWidth / 2 - 200).toString() + "px";
//        document.getElementById("flashAd").style.top = (document.body.clientHeight / 2 + 100).toString() + "px";
//        //alert($(document).offset.left);

//    }
//    catch (e)
//		{ }
}

//tabs
function tabs(hid, tg, hb, tb, cur) {
    try {
        var thd = elt(hid).getElementsByTagName(tg),
	      cur = cur,
	      gthis = this;

        if (!thd) return;

        this.init = function() {
            for (var i = 0; i < thd.length; i++) {
                thd[i].nb = thd[i].id.substring(2);
                thd[i].onclick = function() {
                    elt(hb + cur) ? elt(hb + cur).className = "" : null;
                    elt(tb + cur) ? elt(tb + cur).style.display = "none" : null;
                    elt(hb + this.nb) ? elt(hb + this.nb).className = "on" : null;
                    elt(tb + this.nb) ? elt(tb + this.nb).style.display = "block" : null;
                    cur = this.nb;
                    PrintBrowseHotelListByPage(CurPage, LNG);
                    ScrollMap();
                }
            }
        }

        return this.init();
    }
    catch (e) { 
    //增加异常处理,seo用
    }
}

//地图移动
function ScrollMap() {
    var num = 0;
//    if (window.location.href.toLowerCase().indexOf("elong.net") != -1) num = 100;
    var slt = elt("search_rs").offsetHeight, flt = elt("search_fl").offsetHeight, fst = elt("search_rs").offsetParent.offsetTop;
    if (slt < flt) { elt("search_rs").style.height = flt + "px"; }
    var th = document.documentElement.scrollTop || document.body.scrollTop;
    var ftt = elt("hotelfoot").offsetTop;
    if (th > fst) {
        elt("search_fl").style.top = th - num + "px";
    } else {
        elt("search_fl").style.top = fst + "px";
    }
    elt("search_fl").style.left = elt("search_rs").offsetParent.offsetLeft + elt("pgs").offsetParent.offsetWidth + 10 + "px" ;
    if ((ftt - flt) < th) {
        if (slt > flt) {
            elt("search_fl").style.top = slt - flt + fst + "px";
            //            elt("search_fl").style.top = ftt - fst - flt - 20 + "px";
        } else elt("search_fl").style.top = fst + "px";
    }
}

/*******************宽屏列表JS结束*******************/
function SubmitSearch(event) {
    if (event.keyCode == 13) {
        var eleId = document.getElementById("DateNumCustPickerForSearch_KP1BtnSubmit");
        if (eleId != null) {
            if (jQuery.browser.msie) {
                eleId.click();
            } else {
                eleId.onclick();
            }
        }
    }
}
//回车自动搜索(首页专用) add by minjiang 09-8-10
function SubmitSearchDefault(event) {
    if (event.keyCode == 13) {
        var eleId = jQuery("#imgSearch");
        if (eleId != null) {
            eleId.click();
        }
    }
}