﻿/*
 NOTE:解决静态页面不能正常显示登录信息的问题
 AUTHOR:李杰
 TIME:2011-11-7
*/
document.writeln("<div class=\"login\" id=\"Login\">");
document.writeln("  <div class=\"loginF\">用户名：</div>");
document.writeln("  <div class=\"loginD\"><input type=\"text\" id=\"txtUName\" class=\"use\" onkeydown=\"return sub();\"/></div>");
document.writeln("  <div class=\"loginF\">密码：</div>");
document.writeln("  <div class=\"loginD\"><input type=\"password\" id=\"txtPassWord\" class=\"use\" onkeydown=\"return sub();\"/></div>");
document.writeln("  <div class=\"loginF\">验证码：</div>");
document.writeln("  <div class=\"loginD\">");
document.writeln("      <input type=\"text\" id=\"txtYZ\" class=\"use\" onkeydown=\"return sub();\"/>");
document.writeln("      <img alt=\"看不清？单击重新获取验证码\" id=\"Img\" title=\"看不清？单击重新获取验证码\" src=\"../Common/ValidateCode.aspx\" onclick=\"javascript:Img.src = 'Common/ValidateCode.aspx?' + Math.random();\" style=\"border-width: 0px; vertical-align: bottom; cursor: hand; margin-bottom: 5px;\" />");
document.writeln("  </div>");
document.writeln("  <div class=\"loginInt\">");
document.writeln("       <input type=\"button\" id=\"buttonLogin\"  class=\"butBase1\" value=\"登 录\" onclick=\"return YZ();\"/>");
document.writeln("  </div>");
document.writeln("  <div class=\"loginInt\">");
document.writeln("       <input type=\"button\" class=\"butBase1\" value=\"注 册\" onclick=\"Register();\" />");
document.writeln("  </div>");
//document.writeln("  <div class=\"read\">");
//document.writeln("        <input type=\"button\" class=\"readInp\"/>");
//document.writeln("  </div>");
/*
 NOTE:去掉免费订阅按钮图标
 AUTHOR:李杰1
 TIME:2011-11-16
 */
document.writeln("</div>");
document.writeln("<div class=\"login\" id=\"Welcome\" style=\"display:none;\">");
document.writeln("  <div class=\"loginL\">");
document.writeln("        欢迎您：<span id=\"lblUName\"></span>");
document.writeln("  </div>");
document.writeln("  <div class=\"loginR\">");
document.writeln("        级别：<img id=\"imgG\"/><a href=\"EMED/Index.aspx\">进入会员中心</a>");
document.writeln("  </div>");
document.writeln("</div>");



//判断是否登录
function choosechecklogins() {
    $.get("../AjaxLogin.aspx", { typeid: 1, Now: Math.random() }, checklogin);
}

function checklogin(name) {
    var info = name.toString().split('|');
    name = info[0];
    var url = info[1];
    if (name != "0") {
        $("#lblUName").html(name);
        $("#imgG").attr("src", url);
        document.getElementById("Welcome").style.display = "block";
        document.getElementById("Login").style.display = "none"; 
    }
    else {
        document.getElementById("Welcome").style.display = "none";
        document.getElementById("Login").style.display = "block"; 
    }
}

function loginInfo() {
    $("#txtUserName").val($("#txtUName").val());
    $("#txtPwd").val($("#txtPassWord").val());
    $("#txtYanZhen").val($("#txtYZ").val());
    $("#btnLogin").click();
}

function YZ() {   //登陆时验证用户名，密码不为空
    if ($("#txtUName").attr("value").length == 0) {
        alert("用户名不能为空！");
        return false;
    }
    if ($("#txtPassWord").attr("value").length == 0) {
        alert("密码不能为空！");
        return false;
    }
    if ($("#txtYZ").attr("value").length == 0) {
        alert("验证码不能为空！");
        return false;
    }

    loginInfo();
}

function sub() {
    if (event.keyCode == 13) {
        return false;
    }
}

window.onload = choosechecklogins;

        
            
               
           

            


            

        
        
       
            

