﻿var state = "";
var text;

var action0 = "http://www.xxp001.com/Login.html";
var action1 = "/Login.html";

function GetContent() {
    $.ajax({
        url: "Default.aspx?random=" + Math.random(),
        data: "state=5",
        success: function(msg) {
            state = msg;
            if (state != null && state != "") {
                var items = state.split(")(");
                text = "<div id='LoginSuccess'>";
                text += "<ul class='succ'>";
                text += "<li><span><strong id='labelUserName'>&nbsp;&nbsp;用户名：" + items[0] + "</strong></span></li>";
                text += "<li>&nbsp;上次登录：<span id='labelLastTime'>" + items[2] + "</span></li>";
                text += "<li>&nbsp;本次登录IP：<span id='labelIP'>" + items[1] + "</span></li>";
                text += "</ul>";
                text += "<p class='reg'>";
                text += "[<a href='/User.html'>个人中心</a>] [<a href='/UptPassword.html'>修改密码</a>] [<a href='Default.aspx?state=4'>退出登录</a>]</p>";
                text += "</div>";
                document.getElementById("divUser").innerHTML = text;

            }
            else {
                text = "<div id='NoLogin'>";
                text += "<form name='form1' id='form1' action='/Login.html' method='post'>";
                text += "<ul>";
                text+="<li style='color:red;'>提示:xuxupie.com 的用户可直接登录</li>";
                text += "<li>";
                text += "<label for='user'>用户名：</label><input class='inputE' id='UserName' name='UserName' maxlength='30' /></li>";
                text += "<li>";
                text += "<label for='pass'>密 码：</label><input class='inputE' onkeydown='SubmitForm()' id='UserPWD' type='password' name='UserPWD' maxlength='20' /></li></ul>";
                text += "<p>";
                text += "<a target='_self' href='#' onclick='return checklogin();'>";
                text += "<img alt='' src='Common/Images/login_bt.jpg' /></a> <a href='/GetPassword.html'>忘记密码？</a></p>";
                text += "<p class='reg'>";
                text += "<a href='/Register.html' class='btn_login'>立即注册</a>";
                text += "</p>";
                text += "</form>";
                text += "</div>";
                document.getElementById("divUser").innerHTML = text;
            }
        }
    });
}




function checklogin() {
    var user = document.getElementById("UserName").value;
    var pwd = document.getElementById("UserPWD").value;
    if (user.length < 2 || user.length > 15) {
        alert("用户名必须在2到15位之间！")
        return false;
    }
    if (pwd.length < 2 || pwd.length > 15) {
        alert("密码必须在2到15位之间！")
        return false;
    }
    document.form1.submit();
}


function SubmitForm()
{
    if(event.keyCode==13)
    {
        return checklogin();
    }
}

















