var xmlHttp
function changearea(area)
{
	//var area=document.getElementById("area").value;
	var url="ajaxserver.asp?action=area&area="+area;
	xmlHttp=GetXmlHttpObject(stateChanged2);
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function changearea1(area)
{
	//var area=document.getElementById("area").value;
	var url="admin/ajaxserver.asp?action=area&area="+area;
	xmlHttp=GetXmlHttpObject(stateChanged3);
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function changevisa(continent){
	if (continent!=null&&continent!=""){
		var url="../ajaxserver.asp?action=visa&continent="+escape(continent);
		xmlHttp=GetXmlHttpObject(stateChangedvisa);
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}else{
		document.getElementById("country").options.length=0;
		document.getElementById("country").add(new Option("所有国家",""));
	}
}
function stateChangedvisa(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//document.getElementById("contactcontent").innerHTML=xmlHttp.responseText ;
		//alert(xmlHttp.responseText);
		var array1=xmlHttp.responseText.split(",");
		document.getElementById("country").options.length=0;
		document.getElementById("country").add(new Option("所有国家",""));
		for (i=0;i<array1.length;i++)
		{
			var subarray=array1[i].split("|");
			document.getElementById("country").add(new Option(subarray[0],subarray[0]));
			//document.getElementById("keyword").value=document.getElementById("city").value;
		}
		//alert(xmlHttp.responseText);
	} 
}
function changekeyword(keyword)
{
	//var area=document.getElementById("area").value;
	//document.getElementById("area").options['美洲'].selected=true;
	var url="ajaxserver.asp?action=keyword&keyword="+keyword;
	xmlHttp=GetXmlHttpObject(stateChanged);
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function get1jp(keyword){
	var url="ajaxserver.asp?action=top1jp&keyword="+keyword;
	xmlHttp=GetXmlHttpObject(stateChanged4);
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function stateChanged2() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//document.getElementById("contactcontent").innerHTML=xmlHttp.responseText ;
		var array1=xmlHttp.responseText.split(",");
		document.getElementById("city").options.length=0;
		for (i=0;i<array1.length;i++)
		{
			var subarray=array1[i].split("|");
			document.getElementById("city").add(new Option(subarray[0]+" "+subarray[1],subarray[0]));
			document.getElementById("keyword").value=document.getElementById("city").value;
		}
		//alert(xmlHttp.responseText);
	} 
}
function stateChanged3() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//document.getElementById("contactcontent").innerHTML=xmlHttp.responseText ;
		var array1=xmlHttp.responseText.split(",");
		document.getElementById("city").options.length=0;
		for (i=0;i<array1.length;i++)
		{
			var subarray=array1[i].split("|");
			document.getElementById("city").add(new Option(subarray[0]+" "+subarray[1],subarray[0]));
			//document.getElementById("keyword").value=document.getElementById("city").value;
		}
		//alert(xmlHttp.responseText);
	} 
}

function stateChanged4()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		if (xmlHttp.responseText!="Null"){
			var arrayjipao=xmlHttp.responseText.split("|||");
			document.getElementById("tuijiang2").value=arrayjipao[2];
			document.getElementById("staydate").value=arrayjipao[3];
			document.getElementById("hbh2").value=arrayjipao[4];
			document.getElementById("shichanjia2").value=arrayjipao[6];
			document.getElementById("tax").value=arrayjipao[7];
			document.getElementById("date2").value=arrayjipao[8];
			document.getElementById("shengjidate").value=arrayjipao[9];
			document.getElementById("xztj").value=arrayjipao[10];
			document.getElementById("cangwei").value=arrayjipao[11];
		}
		else
		{
			document.getElementById("tuijiang2").value="";
			document.getElementById("staydate").value="";
			document.getElementById("hbh2").value="";
			document.getElementById("shichanjia2").value="";
			document.getElementById("tax").value="";
			document.getElementById("date2").value="";
			document.getElementById("shengjidate").value="";
			document.getElementById("xztj").value="";
			document.getElementById("cangwei").value="";
		}
	}
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		//document.getElementById("contactcontent").innerHTML=xmlHttp.responseText ;
		if(xmlHttp.responseText=="NULL"){
			alert("找不到相应城市！");
			document.getElementById("keyword").value=document.getElementById("city").value;
			document.getElementById('keyword').focus();
			
		}
		else
		{
		var sel=0;
		var array1=xmlHttp.responseText.split(",");
		document.getElementById("city").options.length=0;
		for (i=0;i<array1.length;i++)
		{
			var subarray=array1[i].split("|");
			document.getElementById("city").add(new Option(subarray[0]+" "+subarray[1],subarray[0]));
			//document.getElementById("keyword").value=document.getElementById("city").value;
			if (subarray[2]=="Y"){
			sel=i;
			}
		}
		document.getElementById("city").options[sel].selected=true;
		}
		//alert(xmlHttp.responseText);
	} 
}

function GetXmlHttpObject(handler)
{ 
	var objXmlHttp=null
	if (navigator.userAgent.indexOf("Opera")>=0)
	{
		alert("This example doesnt work in Opera") 
		return; 
	}
	if (navigator.userAgent.indexOf("MSIE")>=0)
	{ 
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
			strName="Microsoft.XMLHTTP"
		} 
		try
		{ 
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler 
			return objXmlHttp
		} 
		catch(e)
		{ 
			alert("Error. Scripting for ActiveX might be disabled") 
			return 
		} 
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}
}

function setCookie(sName,sValue,expireHours) {
	var cookieString = sName + "=" + escape(sValue);
	//;判断是否设置过期时间
	if (expireHours>0) {
		 var date = new Date();
		 date.setTime(date.getTime + expireHours * 3600 * 1000);
		 cookieString = cookieString + "; expire=" + date.toGMTString();
	}
	document.cookie = cookieString;
}
//--- 获取cookie
function getCookie(sName) {
  var aCookie = document.cookie.split("; ");
  for (var j=0; j < aCookie.length; j++){
	var aCrumb = aCookie[j].split("=");
	if (escape(sName) == aCrumb[0])
	  return unescape(aCrumb[1]);
  }
  return null;
}

function setopenorclose(trname)
{
	var opentr;
	openstr=getCookie('show_tr')
	if (openstr!=null)
	{
		document.getElementById(openstr).style.display='none';
	}
	setCookie('show_tr',trname);
	document.getElementById(trname).style.display=document.getElementById(trname).style.display=='none'?'':'none';
	return false;
}