<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="TopWinCMS.WebUI.Member.Login" %>

<%@ Register Src="../UserControl/Footer.ascx" TagName="Footer" TagPrefix="uc1" %>
<%@ Register Src="../UserControl/Header.ascx" TagName="Header" TagPrefix="uc2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="{StylePath}/Base.css" rel="stylesheet" type="text/css" media="all" />
    <link href="../TopWinCMS.css" rel="stylesheet" type="text/css" media="all" />

    <script language="javascript" type="text/javascript" src="../JS/Ajax/Ajax.js"></script>

    <script language="javascript" type="text/javascript" src="../JS/TopWinCMS.js"></script>

    <script language="javascript" type="text/javascript">
      
        function PostLogin()
        {
            var u = document.getElementById("<%=TB_UserName.ClientID %>").value;
            var w = document.getElementById("<%=TB_PSW.ClientID %>").value;
            var p = document.getElementById("<%=TB_PassCode.ClientID %>").value;
            var k = document.getElementById("<%=DDL_KeepLong.ClientID %>");
            var r = Request.QueryString("redirectURL");
            if (u == "")
            {
                alert("请输入用户名");
                return;
            }
            if (w == "")
            {
                alert("请输入密码");
                return;
            }

            var getvalue = k.options[k.selectedIndex].value; //被选中项的值
            
            
            var Ajax = new AjaxClass();
            Ajax.RequestUrl = "../AjaxPostBack.ashx?Action=PostUserLogin";
            Ajax.Method = "post";
            Ajax.IsAsyn = true;
            Ajax.ContentType = "application/x-www-form-urlencoded";
            Ajax.StateChangeEvent = function()
            {
                if (Ajax.XmlHttp.readyState == 4)
                {
                    if (Ajax.XmlHttp.status == 200)
                    {
                        var s = Ajax.XmlHttp.responseText;
                        if (s == "1")
                        {
                            if (Request.QueryString("redirectURL") == '')
                                window.location = "Default.aspx";
                            else
                                window.location.href = DecodeURI(Request.QueryString("redirectURL"), false);
                        }
                        else
                        {
                            alert(s);
                            document.getElementById("BT_Login").disabled = false;
                            document.getElementById("BT_Login").value = "登录";
                        }
                    }
                    else
                    {
                        alert("服务器连接失败。错误代码为：[" + Ajax.XmlHttp.status + "]," + Ajax.XmlHttp.statusText);
                    }
                }
                else
                {
                    document.getElementById("BT_Login").disabled = true;
                    document.getElementById("BT_Login").value = "登录中......";
                }

            };

            var parameters = "&UserName=" + escape(u);
            parameters += "&UserPSW=" + escape(w);
            parameters += "&PassCode=" + p;
            parameters += "&KeepLong=" + getvalue;
            parameters += "&redirectURL=" + escape(r);
            Ajax.Content = parameters;
            Ajax.SendRequest();
        }
      

        function PassCodeInit()
        {
            if (document.getElementById('div_ValidateCode'))
                document.getElementById('div_ValidateCode').style.display = "block";
            else
                alert("控件不存在");
        }
    </script>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Pragma" content="No-cach" />
</head>
<body>
    <uc2:Header ID="Header1" runat="server" />
    <form id="form1" runat="server">
    <div style="margin-top: 20px; margin-bottom: 20px; margin-left: auto; margin-right: auto;
        width: 280px;">
        <div class="divPanel_title">
            <div class="titleDiv1">
                &nbsp;</div>
            <div class="titleDiv3">
                会 员 登 录</div>
            <div class="titleDiv2">
                &nbsp;</div>
        </div>
        <div class="divPanel_Content" onmouseover="this.className='divPanel_Content_Red'"
            onmouseout="this.className='divPanel_Content'" style="text-align: left">
            <table style="width: 100%;" id="UserLogin">
                <tr>
                    <td>
                        用户名：
                    </td>
                    <td>
                        <asp:TextBox ID="TB_UserName" runat="server" onfocus="PassCodeInit();" Width="120"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        密码：
                    </td>
                    <td>
                        <asp:TextBox ID="TB_PSW" runat="server" onfocus="PassCodeInit();" Width="120" TextMode="Password"></asp:TextBox>
                    </td>
                </tr>
                <tr id="div_ValidateCode" style="display: block">
                    <td>
                        验证码：
                    </td>
                    <td>
                        <asp:TextBox ID="TB_PassCode" runat="server" Width="60px"></asp:TextBox>
                        <asp:Image ID="Image1" runat="server" onclick="this.src='../PassCode.ashx?n=+ Math.random();'"
                            ToolTip="点击刷新验证码。" align="absmiddle" ImageUrl="../PassCode.ashx" Style="cursor: pointer" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Cookies：
                    </td>
                    <td>
                        <asp:DropDownList ID="DDL_KeepLong" runat="server">
                            <asp:ListItem Value="0" Selected="True">不保存</asp:ListItem>
                            <asp:ListItem Value="1">一天</asp:ListItem>
                            <asp:ListItem Value="30">一月</asp:ListItem>
                            <asp:ListItem Value="999">永久</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" style="text-align: center">
                        <input class="btn" onclick="PostLogin();" id="BT_Login" type="submit" value="登录"
                            name="Submit">
                        <input class="btn" id="Reset" type="reset" value="清除" name="Reset">
                        <hr noshade>
                        <a href="Reg.aspx">免费注册</a> <a href="GetPassword.aspx">忘记密码？</a>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    </form>
    <uc1:Footer ID="Footer1" runat="server" />
</body>
</html>
