var islogin=false;var timeoutID=null;function showMsg(b,a){if(!b){return}if(!a||a=="pass"){b="<img style='vertical-align: middle;width:14px;height:14px;' src='resources/icons/success.png'/>&nbsp;"+b}else{if(a=="error"){b="<img style='vertical-align: middle;width:14px;height:14px;' src='resources/icons/fail.png'/>&nbsp;"+b}else{if(a=="info"){b="<img style='vertical-align: middle;width:14px;height:14px;' src='resources/icons/info.png'/>&nbsp;"+b}}}$("msg_content").innerHTML=b+"&nbsp;<a href=# onclick='clearMsg();return false;'><img src='resources/images/close.gif'/></a>";$("msg").style.display="block";if(timeoutID!=null){clearTimeout(timeoutID)}timeoutID=setTimeout("clearMsg()",30000)}function clearMsg(){$("msg").style.display="none";$("msg_content").innerHTML=""}function userlogout(){DWREngine.setAsync(false);Account.logout();cp.set("login_cookie",null);DWREngine.setAsync(true);$("account_content").innerHTML="<a href='#' onclick='showLoginWin();return false;'>登录</a>&nbsp;|&nbsp;<a href='index.action'>首页</a>&nbsp;|&nbsp;<a href='equipview.action'>设备查询系统</a>";showMsg("您已经成功注销，再次登录请<a href='javascript:;' onclick='showLoginWin();'>单击这里</a></span>");islogin=false;$("validate_img").src="image?"+Math.random();$("my-yuyue").style.visibility="hidden";$("my-shengpi").style.visibility="hidden";for(var a=tabPanel.items.length-1;a>=6;a--){var b=tabPanel.getItem(tabPanel.items.get(a).id);if(b){tabPanel.remove(b)}}tabPanel.setActiveTab(tabPanel.items.get(0))}function getWelcomeMessage(a){islogin=true;return accountHTML="欢迎 "+a+'&nbsp;|&nbsp;<a href="#" onclick="initUserAccount();return false;">我的帐户</a>&nbsp;|&nbsp;<a href="index.action">首页</a>&nbsp;|&nbsp;<a href="equipview.action">设备查询系统</a>&nbsp;|&nbsp;<a href="#" onclick="userlogout();return false;">退出</a>'}window.onresize=function(){if($("login_mask").style.visibility=="visible"){var a=getViewportInfo();$("login_mask").style.width=a.width+"px";$("login_mask").style.height=a.height+"px";$("login_box").style.left=(a.width-350)/2+"px";$("login_box").style.top=(a.height-350)/2+"px"}};function getViewportInfo(){var a=(window.innerWidth)?window.innerWidth:(document.documentElement&&document.documentElement.clientWidth)?document.documentElement.clientWidth:document.body.offsetWidth;var b=(window.innerHeight)?window.innerHeight:(document.documentElement&&document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.offsetHeight;return{width:a,height:b}}function showLoginWin(){var a=getViewportInfo();$("login_mask").style.width=a.width+"px";$("login_mask").style.height=a.height+"px";$("login_mask").style.visibility="visible";$("login_box").style.left=(a.width-350)/2+"px";$("login_box").style.top=(a.height-350)/2+"px";$("login_message").innerHTML="&nbsp;";$("login_box").style.visibility="visible";$("login_form").no.focus();$("cookie_saveCookie").checked=loadSaveCookie();$("login_box").onkeydown=keydown}function keydown(a){a=a||window.event;if(a.keyCode==13){userlogin()}}function hideLoginBox(){$("login_box").style.visibility="hidden";$("login_mask").style.visibility="hidden"}function observerKeyDown(a){var b=Event.element(a);if(a.keyCode==13){userlogin()}}function userlogin(){var e=$("login_form");var d=$("login_message");var h=e.no.value;var c=e.password.value;var g=e.validate.value;var f=e.saveCookie.checked;if(!h){showLoginMsg(true,"用户名 不能为空！");e.no.focus();return}if(!c){showLoginMsg(true,"密码 不能为空！");e.password.focus();return}if(!g){showLoginMsg(true,"验证码 不能为空！");e.validate.focus();return}showLoginMsg(false,"登录中,请稍候...");var b=loginValidator(g,h,c,f);$("validate_img").src="image?"+Math.random();if(b==null||b==""){e.validate.value="";showLoginMsg(true,"对不起，程序出现错误!");return}var a=Ext.decode(b);if(a.type==0){hideLoginBox();e.reset();if(f){cp.set("login_cookie",a.cookievalue)}else{cp.set("login_cookie",null)}$("account_content").innerHTML=getWelcomeMessage(a.message);$("my-yuyue").style.visibility="visible";$("my-shengpi").style.visibility="visible";getRecentLogsNotice()}else{e.validate.value="";showLoginMsg(true,a.message)}}function loginValidator(e,d,b,c){var a=null;DWRUtil.useLoadingMessage("处理中...");DWREngine.setAsync(false);Account.login(e,d,b,c,{callback:function(f){cancelLoadingMessage();a=f},errorHandler:function(f){cancelLoadingMessage();showLoginMsg(true,"对不起，程序出现错误!");DWREngine.setAsync(true)}});DWREngine.setAsync(true);return a}function showLoginMsg(b,c){var a=$("login_message");if(b){a.innerHTML="<font color=red>"+c+"</font>"}else{a.innerHTML="<font color=green>"+c+"</font>"}}function mouseOver(a,b){oldClass=a.className;a.className=b}function mouseOut(a,b){a.className=b}function getCookie(c){var d=document.cookie.indexOf(c+"=");var a=d+c.length+1;if((!d)&&(c!=document.cookie.substring(0,c.length))){return null}if(d==-1){return null}var b=document.cookie.indexOf(";",a);if(b==-1){b=document.cookie.length}return unescape(document.cookie.substring(a,b))}function setCookie(c,e,a,h,d,g){var b=new Date();b.setTime(b.getTime());if(a){a=a*1000*60*60*24}var f=new Date(b.getTime()+(a));document.cookie=c+"="+escape(e)+((a)?";expires="+f.toGMTString():"")+((h)?";path="+h:"")+((d)?";domain="+d:"")+((g)?";secure":"")}function rememberSaveCookie(){var a=$("cookie_saveCookie").checked;setCookie("cookie_saveCookie",a,30)}function loadSaveCookie(){var a=getCookie("cookie_saveCookie");if(a==null||a=="true"){return true}return false};
