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;
					
	if ( document.HotSrch.srh_type[0].checked==true)
	{			
		returnValue = Page_ClientValidate(Page_CityName_Validators);					
	} 
	
	else if (document.HotSrch.srh_type[1].checked==true)
	{		
		  returnValue = Page_ClientValidate(Page_ScenicSpot_Validators);		  
	}
	
	else if (document.HotSrch.srh_type[2].checked==true)
	{			
		returnValue = Page_ClientValidate(Page_LandMark_Validators);				          
	}
	
	
	if(returnValue == true)
	{
		var pp = Math.random();
		
		document.HotSrch.action="search.aspx?x="+pp;					
		document.HotSrch.submit();	
	}

}

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="search.aspx?f=fix"
			document.HotSrch.submit();
		}		  
}



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")
	{*/
		if (compareDate(strServerDate,strCheckInDate,60))
	    {
		if (Theme=="eLongEn")
		{
		   alert(HOTEL_REQUEST_COMPARE_IN60);
		}
		else
		{
		   alert(HOTEL_REQUEST_COMPARE_TODAY_IN30_F + strCheckInDate + HOTEL_REQUEST_COMPARE_TODAY_IN30_B);
		}
		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,21))
	    {
		alert(HOTEL_REQUEST_COMPARE_IN_OUT20);
		return false;
	    }
	
	return true;		

}

function CheckRequestValue()
{
	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 revalue = document.HotSrch.CheckInDate.value+document.HotSrch.CheckOutDate.value+document.HotSrch.HotelName.value + document.HotSrch.Star.value + price;
	
	if(revalue == document.HotSrch.RequestValue.value)
	{
		return false;
	}
	return true;

}
function CheckLeftBox(obj,strServerDate,Theme)
{
	if(!CheckRequestValue())
	{
	return false;
	}
	if (!CheckInOutDate(document.HotSrch.CheckInDate,document.HotSrch.CheckOutDate,strServerDate,Theme))
	{ 
	   return false;
	}
		
	if (!CheckSafeString(document.HotSrch.HotelName,HOTEL_REQUEST_HOTEL_NAME_SAFESTIRNG))
	{
	  return false;
	}		
	return true;
}


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;
			}
		}
	} 
}

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(' + "images/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("images/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(' + "images/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 InCityNameFocus(obj)
{
	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 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.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 + "'";	
function onBooking(hoteltype,hid,rid,id,ruleid)
{
	
	if(hoteltype !="eLong")
	{
		BookingExpedia(hid,rid,id,ruleid);
	}
	else
	{	
		document.HotSrch.hotelid.value = hid;
		document.HotSrch.roomtypeid.value = rid;
		document.HotSrch.roomid.value = id;

		var pp = Math.random();
		document.HotSrch.action="confirm.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"
		}
	
		//alert(document.all.roomid.value);
		document.HotSrch.submit();
	}

}

/*
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)
{
	if(hoteltype == "expedia")
	{
		ExpediaHotelDetails(hid,show);
		return;
	}

	document.HotSrch.hotelid.value = hid;			
	if (show==null)
	{						
		var pp = Math.random();
		document.HotSrch.action="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="details.aspx?m="+show + "&hotelid=" + hid + "&x=" + pp + "#" + anchor;
		}
		else
		{
			document.HotSrch.action="details.aspx?m="+show + "&hotelid=" + hid;
		}
	}
	
	//If this page is in a frame then open the page in top frame.
	if (window.top != window.self)
	{
		document.HotSrch.target="_top"; //"_blank"
	}
	
	//alert(document.all.roomid.value);
	document.HotSrch.submit();
}
	
function Radio_City_OnClick(obj)
{
	var formName = obj.form;
	document.HotSrch.raCityName[document.HotSrch.raCityName.length - 1].value=-1;
	document.HotSrch.raCityName.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='';	
}








