
var XMLHttpReq;
 	//XMLHttpRequest       
function createXMLHttpRequest() {
    if (window.XMLHttpRequest) { //Mozilla 
        XMLHttpReq = new XMLHttpRequest();
    } else {
        if (window.ActiveXObject) { // IE
            try {
                XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e) {
                try {
                    XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch (e) {
                }
            }
        }
    }
}
	//
function loadRequest() {
    createXMLHttpRequest();
    var url = "first";
    XMLHttpReq.open("GET", url, true);
    XMLHttpReq.onreadystatechange = processLoadResponse;//
    XMLHttpReq.send(null);  // 
}
	//
	function loginRequest(url) {
		createXMLHttpRequest();
		XMLHttpReq.open("GET",url, true);
     	XMLHttpReq.onreadystatechange = processLoginResponse;//
    	XMLHttpReq.send(null);  // 
	}
	
	
	// 
    function processLoginResponse() {
           
    	if (XMLHttpReq.readyState == 4) { // 
                
        	if (XMLHttpReq.status == 200) { // 
		var res=XMLHttpReq.responseXML.getElementsByTagName("res")[0].firstChild.nodeValue;			   
	        if (res==1){
                	window.alert("没有此账户!");                
                }
                else if (res==2){
                	window.alert("密码错误!");                
                }
                else if (res==3){
                //alert("验证码");
                	window.alert("验证码错误!");                
                }

                else if (res==0){
					//window.location.href="admin/main.jsp";
					
					window.location.href="new/index.jsp";
					
					//window.close();
				    //window.location.href="admin/main.jsp"
					//var sFeatures=" height=100, width=400,toolbar =no, menubar=no, scrollbars=no, resizable=no, location=no, status=no";
	               // window.showModalDialog('admin/clientinfo/person_switch.jsp','newwindow',sFeatures); 

	
					//window.open("admin/clientinfo/person_switch.jsp","_blank") 
					
					//window.open("admin/main.jsp","_blank") 
				
					//window.navigate(location)
          
                }
            } else { //
                window.alert("未知异常！");
                return;
            }
        }
    }
	//
    function userCheck() {
		uname = document.loginForm.uname.value;
		psw = document.loginForm.psw.value;
		type = document.loginForm.type.value;
		checkwd = document.loginForm.checkwd.value;
		
		//alert("checkwd:"+checkwd);
		
		if(uname=="") {
		
			window.alert("用户名不能为空！");
			
			document.loginForm.uname.focus();
			return false;
		}
		else {
			
			loginRequest("login?uname=" + uname + "&psw=" + psw + "&checkwd=" + checkwd+ "&type=" + type);
			return ;
			
		}
	}
	