
var HOTEL_IMAGES_PATH_HTTPSERVER="http://www.17167.com/hotel/js/images/" ;

//封装返回酒店查询时的商业区行政区,quid选择框id
		function cityhotel_change(cc1,quid,cc2,lx)
		{
				city(document.getElementById(cc1).value,quid,cc2);
				
		}
//封装返回单选城市酒店查询时的商业区行政区,quid选择框id
		function cityhotelradio_change(cc1,quid,cc2)
		{
			city(cc1,quid,cc2);
		}
//返回商业区行政区选择值
		function checkxc(){
var ckstr;
for(i = 0; i < document.HotSrch.checkarea.length; i++)
{
 if(document.HotSrch.checkarea[i].checked)
 {
 ckstr=document.HotSrch.checkarea[i].value;
 break;
 }
}
if (ckstr=="0")
{return "hsyq"; 
}
else if(ckstr=="1")
{
return "hxzq"; 
}
}

//封装返回城市或者省份id
function getprid(obj,id)
{
document.getElementById(obj).value=id;	
	
}

//截去字符串头尾的空格字符

function ValidatorTrim(s) {
    var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
    return (m == null) ? "" : m[1];
}
function HiddenErrDIV(divid)
{
	getObj( divid+'_err').style.visibility = 'hidden';
}
 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];}
}

//获取指定ID的控件的值

function ValidatorGetValue(id) 
{
    var strValue = "";
    var obj = document.getElementById(id);
    if(obj == null)
    {
        return strValue ;
    }
    strValue = ValidatorTrim(obj.value );
    return strValue ;
}

 
function DisplayHtml(val,html)
{
	var heardHtml = "<img src='"+HOTEL_IMAGES_PATH_HTTPSERVER+"Info.gif' border=0 align=absMiddle>&nbsp;"
	if(val != null)
	{
	
		var obj = document.getElementById(val);
		if(obj != null  )	
		{
		
			try
			{		
				obj.focus();
			}
			catch(ex)
			{	
				var val = false;
				 return false; 
			}
			
			
		}
		if(html.length == 0) heardHtml="";
		obj.className = "ValidatorDisplayStyle";
		obj.innerHTML = heardHtml + html;
		return false;
	}
}


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 option_select(s1,s1_value)
	{
		
		for (i=0;i<s1.length;i++)
		{
			if (s1.options[i].value==s1_value)
			{
				s1.selectedIndex=i;
			}			
		}
	}
	
function SubmitForm(obj)
{        
  var returnInDate = false;
  var returnOutDate=false;
  var returnHotel=false;
		
		returnInDate = ValidatorCheckInDate("CheckInDate","VaCheckInDate");		
		returnOutDate = ValidatorCheckOutDate("CheckOutDate","VaCheckOutDate");	
		returnHotel = ValidatorHotelName("HotelName","VaHotelName");				
	
	
	
	if(returnInDate == true && returnOutDate == true  && returnHotel == true )
	{
		var pp = Math.random();
		
		document.HotSrch.action="hotel.asp?x="+pp;					
		document.HotSrch.submit();	
	}

}


//验证CheckOutDate, 不可为空
function ValidatorCheckOutDate(valstr,val) {

	var strCheckOutDate = ValidatorGetValue(valstr);
	if (ValidatorTrim(strCheckOutDate).length == 0) 
	{
		DisplayHtml(val,HOTEL_REQUEST_OUT_ISDATE);	 		
        return false;
    }
     
   if ((!IsDate(strCheckOutDate))||(strCheckOutDate=="yyyy-mm-dd")||(strCheckOutDate=="")||(strCheckOutDate=="mm/dd/yyyy"))		
		{
			
			DisplayHtml(val,HOTEL_REQUEST_OUT_ISDATE);
			return false;
		}
	
	DisplayHtml(val,"");
	return true;

}

//验证CheckInDate, 不可为空
function ValidatorCheckInDate(valstr,val) {
	var strCheckInDate = ValidatorGetValue(valstr);
	
	if (ValidatorTrim(strCheckInDate).length == 0) 
	{
		DisplayHtml(val,HOTEL_REQUEST_IN_ISDATE);	 		
        return false;
    }
    
	if ((!IsDate(strCheckInDate))||(strCheckInDate=="yyyy-mm-dd")||(strCheckInDate=="")||(strCheckInDate=="mm/dd/yyyy"))		
		{
			DisplayHtml(val,HOTEL_REQUEST_IN_ISDATE);
			//objCheckInDate.focus();
			return false;
		}
	
	DisplayHtml(val,"");
	return true;

	       
}

//验证酒店名, 可为空
function ValidatorHotelName(valstr,val) {

	var value = ValidatorGetValue(valstr);
	if (ValidatorTrim(value).length == 0) 
	{			 
		DisplayHtml(val,"");
        return true;
    }
    	
    if(!ValidatorStringNum(value))
    {     
		DisplayHtml(val,HOTEL_REQUEST_HOTEL_NAME_SAFESTIRNG);	 
		return false;    
     }
	DisplayHtml(val,"");
	return true;
}

//验证有效字符串.
function ValidatorStringNum(value) {
	var ErrStr;
	var ErrChar;
	var ArryErrStr;
		
	 if (value.length == 0) 
        return false;

	ErrChar="!@#$%^&*()_+|=\\~`;'[]{}\"':;,/<>?～！@#￥％^&×（）……＋|－＝、〔〕｛｝：“；‘《》？，。、";
	ErrStr="虚拟,傻冒,先生,小姐,代订";
	
	ArryErrStr = ErrStr.split(",");
	
	//是否含有非法字符
	for(var k=0;k<value.length;k++){
		if(ErrChar.indexOf(value.charAt(k))>-1){
			return false;
		}
	}
	//是否含有非法字符串
	for (k=0; k<ArryErrStr.length; k++){
		if (value.indexOf(ArryErrStr[k])>-1){
			return false;
		}
	}
	return true;
}


//页面校验函数
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 select_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='';
		var oSel = document.getElementById(obj);
		var strvalue=oSel.options[oSel.selectedIndex].value;
		document.HotSrch.currCityName.value=strvalue;
		changeSelect(document.HotSrch.area_id, strvalue);
	//}
}

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.area_id !=undefined && document.HotSrch.currCityName != undefined)
		  {		
			changeSelect(document.HotSrch.area_id,document.HotSrch.currCityName.value);
	      }			
	      return;
		
	 	
	 
}



