function j(element){return document.getElementById(element);}

//删除字段中的空格
function Trimstr(str){
	String.prototype.Trim = function(){return this.replace(/(^\s*)|(\s*$)/g,"");}
	String.prototype.LTrim = function(){return this.replace(/(^\s*)/g,"");}   
	String.prototype.Rtrim = function(){return this.replace(/(\s*$)/g,"");} 
	return str.Trim();
}

function Ajax()
{
	var xhrObj=null;
	if(window.XMLHttpRequest)
	{
		xhrObj=new XMLHttpRequest();
	}
	else if(window.ActiveXObject){
		try{
			xhrObj=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e1){
			try{
				xhrObj=new ActiveXObject("MSXML2.XMLHTTP");
			}
			catch(e2){
				try{
					xhrObj=new ActiveXObject("MSXML3.XMLHTTP");
				}
				catch(e3){
					alert("创建Ajax失败："+e3)
				}
			}
		}
	}
	else{
		alert("未能识别的浏览器");
	}
	
	return xhrObj;
}

var xmlobj = new Ajax();

function Check_UserLogin(){
	var UserName=Trimstr(j("username").value);
	var UserPWD=Trimstr(j("password").value);
	if(UserName==""){
		alert('请填写用户名。');
		j("username").focus();
		return false;
	}else if(UserPWD==""){
		alert('请填写密码。');
		j("password").focus();
		return false;
	}else{
		var str;
		var Getstr;
		str = "p=test"
		xmlobj.open("POST", "/member/"+UserName+"&UserPWD="+UserPWD, true);
		xmlobj.setRequestHeader("Content-Length",str.length); 
		xmlobj.setRequestHeader("content-type","application/x-www-form-urlencoded");
		xmlobj.onreadystatechange = function() {
			if (xmlobj.readyState == 4 && xmlobj.status == 200) {
				if(xmlobj.responseText.split("|||")[0]=="0"){
					alert(xmlobj.responseText.split("|||")[1]);
					j("username").focus();
					return false;
				}else{
					window.location.href="/n_user/";
					//$("userlogindiv").innerHTML = xmlobj.responseText.split("|||")[1];
				}
			}
		}
		xmlobj.send(str);
	}
}

function UserOutlogin(){
	var str;
	str = "p=test"
	xmlobj.open("POST", "infor/useroutloginindex.asp", true);
	xmlobj.setRequestHeader("Content-Length",str.length); 
	xmlobj.setRequestHeader("content-type","application/x-www-form-urlencoded");
	xmlobj.onreadystatechange = function() {
		if (xmlobj.readyState == 4 && xmlobj.status == 200) {
			j("userlogindiv").innerHTML = xmlobj.responseText;
		}
	}
	xmlobj.send(str);
}

