var nt=null;
function doLogin(evt){
		var theEvt = evt || window.event;
		Event.element(theEvt).focus();
		if (nt!=null) {nt.clear(); nt=null;}
		nt=JsMessBox("正在登陆，请稍候... ... ",$("logonbutton"));
		new Ajax.Request("behind/login.aspx",{postBody:"username="+encodeURIComponent($F("u"))+"&password="+encodeURIComponent($F("p"))+"&validatecode=",onLoading:loadLogon,onComplete:completeLogon});
	};
	function doLogout(evt){
		var theEvt = evt || window.event;
		Event.element(theEvt).focus();
		if (nt!=null) {nt.clear(); nt=null;}
		nt=JsMessBox("正在退出，请稍候... ... ",$("logoutbutton"));
		new Ajax.Request("behind/logout.aspx",{onComplete:completeLogout,onFailure:logoutError});
	};
	function logoutError(ccc){
		//alert(ccc.responseText);
	}
	function loadLogon(){
	}
	function completeLogon(ccc){
		logtime = new Date();
		if (nt!=null) {nt.clear(); nt=null;}
		var rt=ccc.responseXML;
		var row = rt.selectNodes('//user');
		if (row.length>0){
			if (nt!=null) {nt.clear(); nt=null;}
			if(elementAttrib(row[0],'type')=='0'||elementAttrib(row[0],'type')=='1')
			{
			  $("Top1_logout").innerHTML='<span>欢迎<b>'+elementAttrib(row[0],'username')+'</b>进入龙牡电子期刊阅览室</span><input id="logoutbutton" class="button" type="submit" value="注销">';
			  Element.hide($("Top1_login"));
			  Element.show($("Top1_logout"));
			  role = elementAttrib(row[0],'type');
			  if($("logoutbutton"))
				$("logoutbutton").onclick=doLogout;
			}
			else
			{
			  alert("登录失败!原因："+elementAttrib(row[0],'errMsg'));
			  Element.show($("Top1_login"));
			  Element.hide($("Top1_logout"));
			}
			//$('role').value=elementAttrib(row[0],'type');
			//showLogoffNotice();
		}
		
	}
	function completeLogout(ccc){
	 
		logtime = new Date();
		if (nt!=null) {nt.clear(); nt=null;}
		if (ccc.responseText=="True"){
			Element.hide($("Top1_logout"));
			Element.show($("Top1_login"));
			Form.reset("loginF");
		}
	}
	
var xmlurl='behind/accesslog.aspx';
var myAjax=new Ajax.Request(xmlurl,{method: 'get', asynchronous: true,parameters: ''});

