<%@ Page Language="C#" AutoEventWireup="true" Inherits="Sys_Template_Login, QianboCMS" EnableEventValidation="false" %>
<%@ Import Namespace="Qianbo.Common" %>
<script type="text/javascript">
function MyCheckLogin()
{
    var inputValue = $('txtUserName').value.trim();
    if(inputValue.length==0)
    {
        alert('用户名不能为空！');
        $('txtUserName').focus();
        return false;
    }
    inputValue = $('txtPwd').value.trim();
    if(inputValue.length==0)
    {
        alert('密码不能为空！');
        $('txtPwd').focus();
        return false;
    }
    try
    {
        if($("txtValidate").value.trim().length==0)
       {
           alert('验证码不能为空！');
           return false;
       }
    }
    catch(e)
    {}
    return true;
}
function IsCheckLogin()
{
    if(MyCheckLogin())
    {
        var UserName=document.getElementById("txtUserName").value;
        var PassWord=document.getElementById("txtPwd").value;
        var CookieType=document.getElementById("rbCookie").value;
        try{
            var txtValidate=document.getElementById("txtValidate").value;
        }
        catch(e)
        {}
        Sys_Template_Login.AjaxCheckLogin(UserName,PassWord,CookieType,txtValidate,Call_Back);
   }
}
function Call_Back(response)
{
    if(response.value=="True")
    {
        Tab2.style.display = '';
        Tab1.style.display = 'none';
        LabelUser_Name.innerText=document.getElementById("txtUserName").value;
    }
    else
    {
        alert(response.value);
    }
}
function LogOut()
{
    Sys_Template_Login.AjaxLouOut("",Call_BackLogOut)
}
function Call_BackLogOut(response)
{
    Tab1.style.display = '';
    Tab2.style.display = 'none';
}
function setFocus()
{
    if(event.keyCode==13)
    {
        IsCheckLogin();
    }
}
</script>
<form id="LoginForm" runat="server">
    <%
	if (LoginModel)
    {%>
    <table border="0" cellpadding="0" cellspacing="0" id="Tab1" width="100%">
        <tr>
            <td>用户名：</td>
            <td>
                <input type="text" id="txtUserName" name="txtUserName" maxlength="20" style="width: 120px;" onkeypress="setFocus()" />
			</td>
        </tr>
        <tr>
            <td>密　码：</td>
            <td>
                <input type="password" id="txtPwd" name="txtPwd" maxlength="20" style="width: 120px;" onkeypress="setFocus()" />
                <input type="hidden" id="rbCookie" name="rbCookie" value="No" />
			</td>
        </tr>
        <%
		if (isValidate)
		{%>
        <tr>
            <td>验证码：</td>
            <td>
                <input type="text" id="txtValidate" name="txtValidate" class="LoginInput" style="width: 50px;" onkeypress="setFocus()" />
                <img src='<%=ApplicationPath%>/Common/Code.aspx' id="IMG1" style="margin-top: 3px;" alt="换个验证码" style="cursor: hand;" align="absmiddle" onclick="this.src=this.src+'?'+Math.random();" />
			</td>
        </tr>
        <%}%>
        <tr>
            <td></td>
            <td>
                <input id="Button1" type="button" value="登陆" onclick="IsCheckLogin()" />
                <input type="button" value="注册" onclick="window.open('/User/Reg.aspx?TypeId=1');" />
			</td>
        </tr>
    </table>
    <%}
	else
    {%>
    <table border="0" cellpadding="0" cellspacing="0" id="Tab1" width="100%">
        <tr>
            <td height="28px">
				用户名：
				<input type="text" id="txtUserName" name="txtUserName" maxlength="20" style="width: 80px;" onkeypress="setFocus()" />
                密码：
				<input type="password" id="txtPwd" name="txtPwd" maxlength="20" style="width: 80px;" onkeypress="setFocus()" />
                <input type="hidden" id="rbCookie" name="rbCookie" value="No" />
                <%
				if (isValidate)
                {%>
                验证码：
				<input type="text" id="txtValidate" name="txtValidate" class="LoginInput" style="width: 50px;" onkeypress="setFocus()" />
                <img src='<%=ApplicationPath%>/Common/Code.aspx' id="IMG1" alt="换个验证码" style="cursor: hand;" align="absmiddle" onclick="this.src=this.src+'?'+Math.random();" />
                <%}%>
                <input id="Button2" type="button" value="登陆" onclick="IsCheckLogin()" />
                <input type="button" value="注册" onclick="window.open('/User/Reg.aspx?TypeId=1');" />
			</td>
        </tr>
    </table>
    <%}%>
    <%
	if (LoginModel)
    {%>
    <table border="0" cellpadding="0" cellspacing="0" id="Tab2" style="display: none;" width="100%">
        <tr>
            <td>
				用户名：<%=LabelUserName %>
                <div id="LabelUser_Name" style="display: none;"></div>
            </td>
        </tr>
        <tr>
            <td>
				<a href='<%=ApplicationPath%>/User/Main.aspx'>用户中心</a> | <a href="javascript:" onclick="LogOut()">退出登陆</a>
			</td>
        </tr>
    </table>
    <%}
	else
    {%>
    <table border="0" cellpadding="0" cellspacing="0" id="Tab2" style="display: none;" width="100%">
        <tr>
            <td height="28px">
				欢迎登录：<%=LabelUserName %><span id="LabelUser_Name"></span>
                <a href='<%=ApplicationPath%>/User/Main.aspx'>用户中心</a> | <a href="javascript:" onclick="LogOut()">退出登陆</a>
			</td>
        </tr>
    </table>
    <%}%>
</form>
<%
if (!IsLogin)
{
    Response.Write("<script>Tab1.style.display = '';</script>");
    Response.Write("<script>Tab2.style.display = 'none';</script>");
}
else
{
    Response.Write("<script>Tab2.style.display = '';</script>");
    Response.Write("<script>Tab1.style.display = 'none';</script>");
}
%>