﻿var _idTab = "header_";
function LoadMess() {
   
   var h = '<table cellpadding="0" cellspacing="0" style="color:White;">';
   if (User == null) {
        h += '<tr>';
        h += '<td style="width:106px !important;width:100px;padding-top:4px;"><span>通行证 | 用户名：</span></td>';
        h += '<td style="width:70px"><input type="text" id="' + _idTab + 'Account" style="width:70px; margin-top:4px; height:12px;" /></td>';
        h += '<td style="padding-top:5px; padding-left:6px;width:40px"><span>密码：</span></td>';
        h += '<td style="width:80px"><input type="password" id="' + _idTab + 'Password" style="width:70px; height:12px; margin-top:4px;" onkeydown="chuf(event);"  /></td>';
        h += '<td style="padding-top:3px;width:50px;"><input type="button" id="' + _idTab + 'Loginid" value="登录" onclick="Header_Login()" style="height:19px;"  /></td>';
        h += '<td  style="padding-top:5px;width:30px;"><a onclick="zhuceurl()" style="cursor:pointer">注册</a></td>';
        h += '<td style="padding-top:5px;width:30px;"><a href="" target="_blank" style="color:White">帮助</a></td>';
        h += '</tr>';
    }
    else {
        h += '<tr style="padding-top:4px;"><td style="text-align:right;" ><div style="margin-top:2px !important;margin-top:0px;padding-left:200px !important; padding-left:0px;">欢迎:<a  onclick="usermessinfo()" style="cursor:pointer">' + User.UserAccount + '(个人中心)</a> | <a href="#" onclick="Header_Logout();return false;" style="color:White">退出</a></div></td>';
        h += '</tr>';
    }
    h += '</table>';
   
    document.write(h);
}
LoadMess();

function Header_Login() {
    var wtxtuserid = _idTab + "Account";
    var wtxtpasswordid = _idTab + "Password";
    var username = document.getElementById(wtxtuserid).value;
    var userpwd = document.getElementById(wtxtpasswordid).value;
    if (username.length > 0 && userpwd.length > 0) {
        PublicLogin.Login(username, userpwd, wUserLoginResult);
    }
    else {
        alert("请填写正确的帐号密码！");
    }

}
function wUserLoginResult(result) {
    
    if (result > 0) {
        alert("登陆成功");
            window.location.reload();
    }
    else {
        alert("帐号或者密码有误！");

    }
}

function Header_Logout() {

    PublicLogin.Logout(wUserLogoutResult)
}
function wUserLogoutResult(results) {
    if (results == 1) {
        window.location.reload();
    }
    else {
        alert("注销失败，请稍候再试...");
    }
}

function chuf(evt) {
    evt = (evt) ? evt : ((window.event) ? window.event : "") //兼容IE和Firefox获得keyBoardEvent对象
    var key = evt.keyCode ? evt.keyCode : evt.which; //兼容IE和Firefox获得keyBoardEvent对象的键值
    if (key == 13) {

        var Loginrewe = _idTab + "Loginid";
        if (window.navigator.userAgent.indexOf("MSIE") >= 1) //如果浏览器为IE
        {
            document.getElementById(Loginrewe).onclick();
        } else if (window.navigator.userAgent.indexOf("Firefox") >= 1) //如果浏览器为Firefox 
        {
            document.getElementById(Loginrewe).onclick();
        } else {
        document.getElementById(Loginrewe).focus();
        document.getElementById(Loginrewe).onclick();
        }

    }
}
function zhuceurl() {
    window.top.location.href = "http://my1.eic.org.cn/Passport/Register.aspx";
}

function usermessinfo()
{
 window.top.location.href="http://my1.eic.org.cn/UserInfo/Update.aspx";
}