﻿function login(urls, iscode) {
   
    var content = "<div style=\"text-align:center;z-index:9999\">用户：<input id=\"username_window\" name=\"username_window\" type=\"text\" class=\"f-text\" style=\"width:150px;\" /><br />";
    content += "密码：<input id=\"password_window\" name=\"password_window\" type=\"password\" class=\"f-text\" style=\"width:150px;\" />";
    //if (iscode == 1) {
        //content += "<br />答案：<img id=\"login_code_window\" src=\"" + RootDir + "/library/page/verifycode" + ExName + "\" align=\"absmiddle\" style=\"width:75px;height:30px;\" /><input id=\"vcode_window\" name=\"vcode_window\" type=\"text\" class=\"f-text\" style=\"width:74px;\" /> <a href=\"javascript:;\" onclick=\"document.getElementById('login_code_window').src='" + RootDir + "/library/page/verifycode" + ExName + "?v='+Math.random()+''\">换一个</a>";
    //}
   
    var W = WinTip("登录", content);
    W.ConfirmButton = "登 录";    
    W.Confirm = function() {
        var username = jQuery("#username_window").val();
        var password = jQuery("#password_window").val();
        if (username == "" || password == "") {
            alert("用户名和密码必须填写。"); return;
        }
        var vcode = "";
        // if (iscode == 1) {
        //  vcode = jQuery("#vcode_window").val();
        // if (vcode == "") {
        ////  alert("请填写验证答案。"); return;
        //  }
        //}
        // loading();
       
        $.ajax({
            url: "/json/snsUserLogin.aspx?flag=5",
            data: {
                username: username,
                password: password,
                vcode: vcode
            },
            type: 'POST',
            success: function(msg) 
            {
            var W1 = "";
            if (msg == "Succeed") 
            {                    
                    W1 = WinTip("登录成功", "登录成功…… 2秒后将刷新本页。");
                    W1.Create();
                    setTimeout(function() {
                        location.href = document.URL;
                        W1.Close();
                    }, 2000);
                 
             }
            else 
            {
                W1 = WinTip("登录失败", msg);
                W1.Create();
                //loadingclear();
                return;
            }
            }
        });
    }
    W.Create();
}


function logout() {
    $.ajax({
        url: "/json/user.aspx?type=6",
        type: 'POST',
        success: function(msg) {
            setTimeout(function() {
                location.href = document.URL;
            }, 1000);
        }
    });
}

function loginbt()
{
              
        var username = jQuery("#username_window").val();
        var password = jQuery("#password_window").val();
        if (username == "" || password == "")
        {
            alert("用户名和密码必须填写。"); return;
        }
        var vcode = "";
        
        $.ajax({
            url: "/json/snsUserLogin.aspx?flag=5",
            data: {
                username: username,
                password: password,
                vcode: vcode
            },
            type: 'POST',
            success: function(msg) 
            {
            var W1 = "";
            if (msg == "Succeed") 
            {                    
                    W1 = WinTip("登录成功", "登录成功…… 2秒后将刷新本页。");
                    W1.Create();
                    setTimeout(function() {
                        location.href = document.URL;
                        W1.Close();
                    }, 2000);
                 
             }
            else 
            {
                W1 = WinTip("登录失败", msg);
                W1.Create();
                //loadingclear();
                return;
            }
            }
        });    
    W.Create();
}
