﻿// JScript 文件
//登录判断是否成功
function chkLogin(){
    var uname = document.getElementById("userName").value.trim();
    var pwd = document.getElementById("userPwd").value.trim();
    var code = document.getElementById("code").value.trim();
	if(uname.length<4){alert("用户名的长度必须在4位数以上"); return;}
    if(pwd.length<6){alert("登陆密码的长度必须在6位数以上"); return;}
    if(code.length<4){alert("验证码的长度必须在4位数以上"); return;}
    if(!chk_code(code)){alert("验证码输入错误!"); return;}
   if(!chk_uname(0,uname)){alert("用户名不正确，请重新输入!"); return;}
    if(!chk_pwd(0,uname,pwd)){alert("密码不正确,请重新输入!");  return;}
    if(!chk_enable(0,uname)){alert("您的帐号已经被禁用，请联系管理员处理!"); return;}
    else
    {
        var obj=new Array(uname,pwd);
        url="http://company.mcuol.com/TransLogin/TransLogin.aspx?Indexv="+obj;
        var str=createTextHttpRequest(url);
        if(str=="1")
        {
            alert("登录失败！");
        }
        else
        {
            var st=str.split(',');
            document.getElementById ("divNotLogin").style .display ="none";
            document.getElementById ("divLogin").style.display ="";
            document.getElementById ("lbUserNickName").innerHTML=st[1];
            document.getElementById ("hyMyBlog").setAttribute("href",st[2]);
            document.getElementById ("imgHeadUrl").setAttribute ("src",st[3]);
        }
    }
}
function chk_uname(type,uname){return AjaxMethod.GetUserName(type,uname).value;}
function chk_pwd(type,uname,pwd){return AjaxMethod.GetUserPwd(type,uname,pwd).value;}
function chk_code(code){return AjaxMethod.GetCode(code).value;}
function chk_enable(type,uname){return AjaxMethod.GetUserEnable(type,uname).value;}
function getimgcode(){var getimagecode = document.getElementById("getcode");getimagecode.src = "http://blog.mcuol.com/VerifyCode.aspx?x="+Math.random();}
String.prototype.trim = function(){ return this.replace(/(^\s*)|(\s*$)/g, "");}
function CheckIsLogin()
{
    var url="http://company.mcuol.com/TransLogin/TransLogin.aspx?type=0";
    return createTextHttpRequest(url);
}
function OpenLogin()
{
    openWindow('http://company.mcuol.com/TransLogin/login.aspx','280','180','会员登录','登录');
}
function IndexloginOut()
{
    ul="http://www.mcuol.com/aspx/logout.aspx?type=0";
    createTextHttpRequest(ul);
    document.getElementById ("divNotLogin").style .display ="";
    document.getElementById ("divLogin").style.display ="none";
    document.getElementById ("userName").value='';
    document.getElementById ("userPwd").value='';
    document.getElementById ("code").value='';
}