<%@ control language="C#" autoeventwireup="true" inherits="Controls_Login, Huibo.Net" %>

    <div id="login">
        <ul class="logintitle">
            <li style="margin-top: 5px;">
                <%--<asp:Image ID="LoginImage" ImageUrl="images/baby.png" runat="server" /></li>--%>
                <asp:Image ID="LoginImage" ImageUrl="~/TemHtml/Blank/images/baby.png" runat="server" /></li>
            <li>会员登录</li>
        </ul>
        <ul class="lgcontent" id="load" style="display:none;">
            <li>
                <img style="padding:30px 100px 15px 70px;" src="TemHtml/Blank/images/045.gif" alt="数据正在加载" />
            </li>
        </ul>
        <%--<% if (SessionOprate.SessionOprate.Shop == null)
           { %>--%>
        <ul class="lgcontent" id="login_Yz" runat="server">
            <li>会员名：<asp:TextBox ID="UserName" style="height:15px;" size="15" runat="server"></asp:TextBox></li>
            <li>密 &nbsp;码：<asp:TextBox ID="PassWord" style="height:15px;" size="15" runat="server" TextMode="Password"></asp:TextBox></li>
            <li><span style="display: block; float: left; text-align: left;">验证码：<asp:TextBox
                ID="Number" size="5" runat="server"></asp:TextBox></span> <span style="display: block;
                    float: left; margin-top:3px;">
                    <asp:Image ID="Image2" runat="server" Style="height: 18px; border: 1px solid #a0a0a0;margin-left: 3px; width: 40px;" 
                    ImageUrl="~/Code/Number.aspx" onclick="reloadWin();"  ToolTip="重新加载" />
                </span>
                </li>
        </ul>
        <ul class="lgcontent1" id="login_Dl" runat="server">
            <li>
                <%--<label>--%>
                    <%--<asp:Button ID="Login" runat="server" class="button2" Text="登录" OnClick="Login_Click" OnClientClick="return getParent();" />--%>
                    <input type="submit" class="button2" onclick="getParent();" value="登录" />
                    <%--<button class="button2" onclick="getParent();">登录</button>--%>
                <%--</label>--%>
            </li>
            <li>
                <%--<label>--%>
                    <%--<asp:Button ID="Register" class="button2" runat="server" Text="注册" />--%>
                    <input class="button2" value="注册" title="注册" type="button" onclick="window.open('Register.aspx','_self');" />
                    <%--<a href="Register.aspx" class="button2" title="注册">注册</a>--%>
                <%--</label>--%>
            </li>
        </ul>
        <%--<%}
          //else
          //{ 
               %>--%>
        <ul class="lgcontent" id="loginCont" style="display:none;" runat="server">
            <li>
                亲爱的 <asp:Label ID="ShopUserName" runat="server" Text="会员"></asp:Label> 您好！<br />
                您的会员等级：<asp:Label ID="GradeName" runat="server" Text=""></asp:Label><br />
                购物车商品数：<asp:Label ID="ProNum" runat="server" Text="{$CartProNum}"></asp:Label>件<br />
                商品总计金额：<asp:Label ID="TotalPrice" runat="server" Text=""></asp:Label>元<br/>
                <asp:LinkButton runat="server" ID="linkBut" OnClick="linkBut_OnClick" Text="退出登录" style="text-decoration:none;" ToolTip="退出登录"></asp:LinkButton></li>
        </ul>
        <%--<%} %>--%>
    </div>
    <script type="text/javascript">
        function reloadWin(){
//            document.getElementById("Image2").setAttribute("src","~/Code/Number.aspx",true);
              window.location.href="index.aspx";
        }
        window.onload=function(){
            if(document.getElementById("HuiboLogin_login_Yz").style.display=="none"){
                document.getElementById("topsubnav1").innerHTML="<a href='#' onclick=\"WinExit();\">退出</a>";
            }
        }
        function getParent(){
            var uName=document.getElementById("HuiboLogin_UserName").value;
            var uPwd=document.getElementById("HuiboLogin$PassWord").value;
            var yzm=document.getElementById("HuiboLogin$Number").value;
            var msg="";
            if(uName==''){
                msg="用户名不能为空!";
            }
            if(uPwd==""){
                msg=msg+"\n用户密码不能为空!";
            }
            if(yzm==""){
                msg=msg+"\n验证码不能为空!";
            }
            if(msg==""){
                document.getElementById("HuiboLogin_login_Yz").style.display="none";
                document.getElementById("HuiboLogin_login_Dl").style.display="none";
                document.getElementById("load").style.display="";

                var xmlHttp=null;
                if(window.ActiveXObject) {
	                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                } else {
	                xmlHttp = new XMLHttpRequest();
                }
                var url = 'Login.ashx?userName='+uName+'&userPwd='+uPwd+'&yzCode='+yzm;
                xmlHttp.open('GET', url, false);
                xmlHttp.send(null);
                
                if (4 == xmlHttp.readyState) {
	                if (200 == xmlHttp.status) {
		                var response = xmlHttp.responseText;
		                if (response == 'yzsb') {
			                alert("验证码错误!");
			                document.getElementById("HuiboLogin_login_Yz").style.display="";
                            document.getElementById("HuiboLogin_login_Dl").style.display="";
                            document.getElementById("load").style.display="none";
		                } else if(response=='loginFailure') {
        			        alert("登录失败!");
        			        document.getElementById("load").style.display="none";
        			        document.getElementById("HuiboLogin_login_Yz").style.display="";
                            document.getElementById("HuiboLogin_login_Dl").style.display="";
		                }else{
//		                    alert(response);
//		                    document.getElementById("load").style.display="none";
//                            document.getElementById("HuiboLogin_loginCont").style.display="";
//                            document.getElementById("topsubnav1").innerHTML="<a href='#' onclick=\"WinExit();\">退出</a>";
//                            var sArray=response.split('@#$');
//                            document.getElementById("HuiboLogin_ShopUserName").value=sArray[0];
//                            document.getElementById("HuiboLogin_GradeName").value=sArray[1];
//                            document.getElementById("HuiboLogin_ProNum").value=sArray[2];
//                            document.getElementById("HuiboLogin_TotalPrice").value=sArray[3];
                            window.location.href="index.aspx";
		                }
	                }
                }
                xmlHttp=null;
            }else{
                alert(msg);
                window.location.href="index.aspx";
            }
//            document.getElementById("topsubnav1").innerHTML="<a href='#' onclick=\"WinExit();\">退出</a>";
//            document.getElementById("login_Yz").style.display="none";
//            document.getElementById("login_Dl").style.display="none";
//            document.getElementById("load").style.display="";
//            return false;
        }
    </script>

