var Request = new Object();
Request.send = function(url, callback) {
	var req;
	if(window.XMLHttpRequest){
		req = new XMLHttpRequest();
	}else if(window.ActiveXObject){
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	req.onreadystatechange = function() {
		if(req.readyState == 4){
			if (req.status < 400) {
				callback(req);
			}else{
				alert("\u670d\u52a1\u5668\u7e41\u5fd9\uff0c\u8bf7\u7a0d\u5019\u518d\u8bd5\uff01");
			}
		}
	}
	req.open("GET", url, true);
	req.send(null);
	return req;
}

Request.sendGET = function(url, callback) {
	return Request.send(url, callback);
}
function bs1(method){
var f=document.oa_LoginForm;
	if(f.username.value.length==0){
		alert("\u7528\u6237\u540d\u4e3a\u7a7a");
		f.username.focus();
		return false;
	}
	if(f.passwd.value.length==0){
		alert("\u5bc6\u7801\u4e3a\u7a7a");
		f.passwd.focus();
		return false;
	}
	if(f.authImag.value.length==0){
		alert("\u9a8c\u8bc1\u7801\u4e3a\u7a7a");
		f.authImag.focus();
		return false;
	}
	var url="/oa_login.do?method="+method+"&username="+encodeURI(f.username.value)+"&passwd="+f.passwd.value+"&authImag="+f.authImag.value;	
	Request.sendGET(url,login);	
}

function oa_login(method){
var f=document.oa_LoginForm;
	if(f.username.value.length==0){
		alert("\u7528\u6237\u540d\u4e3a\u7a7a");
		f.username.focus();
		return false;
	}
	if(f.passwd.value.length==0){
		alert("\u5bc6\u7801\u4e3a\u7a7a");
		f.passwd.focus();
		return false;
	}
	if(f.authImag.value.length==0){
		alert("\u9a8c\u8bc1\u7801\u4e3a\u7a7a");
		f.authImag.focus();
		return false;
	}
	var url="/oa_login.do?method=oa_login&type="+method+"&username="+encodeURI(f.username.value)+"&passwd="+f.passwd.value+"&authImag="+f.authImag.value;	
	Request.sendGET(url,login);	
}

function login(req) {
		try{
			var xmlobj = req.responseXML;
			var root = xmlobj.getElementsByTagName('login')[0];
			var content = root.getElementsByTagName('content')[0].firstChild.nodeValue;
			var login=document.getElementById("login");
			try{
			document.getElementById("item").style.display="none";
			}catch(err1){}
			document.getElementById("nologin").style.display="none";
			login.style.display="block";	
			login.innerHTML=content;
		}catch(err){
			alert("\u7528\u6237\u540d\u3001\u5bc6\u7801\u6216\u9a8c\u8bc1\u7801\u9519\u8bef\uff01\n\u8bf7\u91cd\u65b0\u8f93\u5165\u540e\u767b\u5f55\uff01");
		}			
} 

function oa_logout(method){
var url="/oa_login.do?method=oa_logout&type="+method;
Request.sendGET(url,out1);
}

function logout(method){
var url="/oa_login.do?method="+method;
Request.sendGET(url,out1);
}

function out(){
	try{
		var f=document.oa_LoginForm;
		f.username.value="";
		f.authImag.value="";
		f.passwd.value="";		
		document.getElementById("nologin").style.display="block";
		document.getElementById("login").style.display="none";
		}catch(err){
		}
}
function out1(){
	try{
		var f=document.oa_LoginForm;
		f.username.value="";
		f.authImag.value="";
		f.passwd.value="";		
		document.getElementById("nologin").style.display="block";
		document.getElementById("login").style.display="none";
		document.getElementById("item").style.display="block";
		}catch(err){
		}
}