var xhr;
function getXHR(){	
	try{		
		xhr=new ActiveXObject("Msxml2.XMLHTTP");		
	}
	catch(e){		
		try{			
			xhr=new ActiveXObject("Microsoft.XMLHTTP");				
		}
		catch(e){			
			xhr=false;			
		}
	}
	if(!xhr&&typeof XMLHttpRequest!='undefined'){		
		xhr=new XMLHttpRequest();		
	}
	return xhr;		
}

function loadXML(method,url,callback){	
	getXHR();	
	xhr.open(method,url);	
	xhr.setRequestHeader("Content-Type","text/xml");	
	xhr.setRequestHeader("Content-Type","GBK");	
	
	xhr.onreadystatechange=function (){

		if(xhr.readyState!=4)return ;
		callback(xhr);		
		
	}
	xhr.send(null);	
}

//增大字体
function ChangeSize(size){	var objSize=document.getElementById('congame');objSize.style.fontSize=size+"px";}


//添加收藏
function AddFav(){	window.external.AddFavorite(window.document.location.href, document.title)}


//滑动
function setTab(name,cursel,n){
	for(i=1;i<=n;i++){
		var menu=document.getElementById(name+i);
		var con=document.getElementById("con_"+name+"_"+i);
		menu.className=i==cursel?"hover":"";
		con.style.display=i==cursel?"block":"none";
	}
}


//头部搜索去除搜索框加的一些代码
function toptext(){
	var text1;
	text1=document.topform.keytext.value;
	text1=text1.replace(/\'/g,"")
	text1=text1.replace(/\;/g,"")
	text1=text1.replace(/\"/g,"")
	text1=text1.replace(/\</g,"")
	text1=text1.replace(/\>/g,"")
	text1=text1.replace(/\%/g,"")
	text1=text1.replace(/\&/g,"")
	text1=text1.replace(/\*/g,"")
	text1=text1.replace(/\^/g,"")
	text1=text1.replace(/\#/g,"")
	document.topform.keytext.value=text1;
}


//判断非法字符
function textIsNull(str){   
	var patrnn=/['|*|%]/; 
	if (!patrnn.exec(str)) return false 
	return true
} 


//头部验证搜索
function topcheack(){
	var text=document.getElementById("topform");
	if (text.keytext.value.replace(/ /g,"")==""){
		alert("搜索内容不能为空,请输入搜索内容");
		text.keytext.focus();
		return false;
		}
	if (text.keytext.value.replace(/ /g,"").length>40){
		alert("搜索内容有点长了,为了方便准确的搜索出您所想要的信息,请正确输入搜索内容");
		text.keytext.focus();
		return false;
		}	
	if (textIsNull(text.keytext.value)){
		alert("搜索内容有非法字符，请正确输入您要搜索的内容");
		text.keytext.focus();
		return false;
		} 
	if (text.action.value==""){
		alert("搜索栏目不能为空,请选择一个正确搜索栏目，这样方便您快速的查找到您所要找的信息");
		text.action.focus();
		return false;
		}
return true;	
}


//头部ajax登录验证
function topregot(){
	window.location.href = lywurl+"/user/reg.html";
}

//头部找回密码
function toplostpass(){
	window.location.href = lywurl+"/user/lostpassword.html";
}

//会员中心退出
function userclear(){
	if(confirm("确定要退出吗？")){		
		loadXML("get",lywurl+"/deal/deal.asp?actions=userclearlogin&n="+Math.random(),ajaxuserclear)
		return true;//确定
	}
	else{
		return false;	//取消
	}
}

function ajaxuserclear(xmlDom) {
	var requestrss = unescape(xmlDom.responseText);
	alert("成功退出");
	window.location.href = "/";
}

//头部退出
function topclear(){
	if(confirm("确定要退出吗？")){		
		loadXML("get",lywurl+"/deal/deal.asp?actions=clearlogin&n="+Math.random(),ajaxclear)
		return true;//确定
	}
	else{
		return false;	//取消
	}
}

function ajaxclear(xmlDom) {
	var requestrss = unescape(xmlDom.responseText);
	var divs=document.getElementById("logindiv2");
	alert("成功退出");
	divs.innerHTML = "<span class='topwcome'>您好，欢迎您到连云港旅游！</span><div class='toplogin'><form name='loginfrom' id='loginfrom' method='post' action=''><ul class='headleft'><li>用户名:</li><li><input type='text' id='usename' name='usename' class='i1'></li><li>密码:</li><li><input type='password' id='pwd' name='pwd' class='i2'></li><li><input type='button' class='isubmit1' value='登陆' onclick='toplogin();'></li><li><input type='button' class='isubmit2' value='注册' onclick='topregot();'></li><li><input type='button' class='isubmit3s' value='忘记密码' onclick='toplostpass();'></li></ul></form></div>";
}

//头部ajax登录验证
function toplogin(){
	var from=document.getElementById("loginfrom");
	var usename=from.usename;
	var pwd=from.pwd;
	if(usename.value.replace(/ /g,"")==""){
		alert("请填写用户名");
		usename.focus();
		return false
	}
	if(pwd.value.replace(/ /g,"")==""){
		alert("请填写密码");
		pwd.focus();
		return false
	}		
	loadXML("get",lywurl+"/deal/deal.asp?actions=login&usename="+usename.value+"&pwd="+pwd.value+"&n="+Math.random(),ajaxlogin)
}

function ajaxlogin(xmlDom) {
	var requestrss = unescape(xmlDom.responseText);
	var r=requestrss.split("|");
	var divs=document.getElementById("logindiv2");
	if(r[0] == "0" ){
			alert(r[1]);
		}
	if(r[0] == "1" ){
			alert(r[1]);
			divs.innerHTML = r[2];
		}
	if(r[0] == "2" ){
			alert(r[1]);
			window.location.href = r[2];
		}
}

function get_Code(){
	var getcode = document.getElementById("yianzcode");
	if (getcode.className != "codes2"){
			getcode.className = "codes2"
			getcode.src=lywurl+"/inc/code.asp?"+Math.random()
		}
}

function tnavblock(){
	document.getElementById("topmgs").style.display = "block";
	}
function tnavhidden(){
	document.getElementById("topmgs").style.display = "none";
	}

function gailou(objs){
	document.getElementById("gails").value = objs;
}

//单独信息搜索
function lxstextcheack(){
	var text=document.searchform;				
	if (text.keytext.value.replace(/ /g,"")==""){
		alert("搜索内容不能为空,请输入搜索内容");
		text.keytext.focus();
		return false;
		}
	if (text.keytext.value.replace(/ /g,"").length>40){
		alert("搜索内容有点长了,为了方便准确的搜索出您所想要的信息,请正确输入搜索内容");
		text.keytext.focus();
		return false;
		}	
	if (textIsNull(text.keytext.value)){
		alert("搜索内容有非法字符，请正确输入您要搜索的内容");
		text.keytext.focus();
		return false;
		} 

	return true;	
}
