﻿var loginIPop = {
    show: function () {
        $("#waitPopDiv").css({ "opacity": "0.5" });
        $("#waitPopDiv").fadeIn(500);
        $("#popLoginDiv").fadeIn(10);
        this.center();
    },
    center: function () {
        var windowWidth = document.documentElement.clientWidth;
        var windowHeight = document.documentElement.clientHeight;
        var popupHeight = $("#popLoginDiv").height();
        var popupWidth = $("#popLoginDiv").width();
        //居中设置   
        $("#popLoginDiv").css({
            "position": "absolute",
            "top": "160px",
            "left": windowWidth / 2 - popupWidth / 2
        });
        //以下代码仅在IE6下有效       
    },
    hide: function () {
        $("#waitPopDiv").fadeOut("slow");
        $("#popLoginDiv").fadeOut("slow");
    }
}


function loginFun(redirecturl) {
    $.ajax({
        type: "POST",
        url: "loginJson.ashx",
        success: function (msg) {
            if (msg == "sessionhave") {
                window.location.href=redirecturl;
            }
            else {
               loginDiv.show();
            }
        }
    });
}

var loginDiv = {
    show: function (showMssage) {
        $("#waitPopDiv").css({ "opacity": "0.5" });
        $("#waitPopDiv").fadeIn(500);
        $("#loginDiv").fadeIn(10);
        this.center();
    },
    center: function () {
        var windowWidth = document.documentElement.clientWidth;
        var windowHeight = document.documentElement.clientHeight;
        var popupHeight = $("#loginDiv").height();
        var popupWidth = $("#loginDiv").width();
        //居中设置   
        $("#loginDiv").css({
            "position": "absolute",
            "top": "160px",
            "left": windowWidth / 2 - popupWidth / 2
        });
        //以下代码仅在IE6下有效       
    },
    hide: function () {
        $("#waitPopDiv").fadeOut("slow");
        $("#loginDiv").fadeOut("slow");
    }
}

function checkLoginClient()
{
    var userName=document.getElementById("txtLoginName");
        var userPwd=document.getElementById("txtLoginPwd");
        
        if(userName && userPwd)
        {
            if(userName.value=="")
            {
                alert("用户名不能为空！");
                userName.focus();
                return false;
            }
            
            if(userPwd.value=="")
            {
                alert("密码不能为空！");
                userPwd.focus();
                return false;
            }
        }
        return true;
}
