<%@Page Language="C#" AutoEventWireup="true" Inherits="Web.inherits.ViewPage" %>
<!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>
    <title>用户注册-<%=WebSiteConfig.SiteTitle%></title>
    <link href="/Aspx/blue/Css/common.css" rel="stylesheet" />
    <link href="/Aspx/blue/Css/web.css" rel="stylesheet" />
    <link href="/Aspx/blue/Css/user.css" rel="stylesheet" />
    <script src="/Js/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="/Js/bx.library.js"></script>
    <script src="/Js/data.js"></script> 
    <script src="/Js/client.validate.js"></script> 
    <script src="/Aspx/blue/js/web.js" type="text/javascript"></script>
    <script src="/Aspx/blue/js/user.js" type="text/javascript"></script>

</head>
<body>
<!--Create Time: 2015/1/2 22:43:01-->
    <!--head-->
    <div class="head">
    <div class="head_top">
        <div class="main bar">
            <span id="LoginStatus"><a href="/login/Default/">登录</a> | <a href="/login/register/">注册</a></span>
            <span class="right"><a href="javascript:void(0);" onclick="AddFavorite();">加入收藏</a>&nbsp;&nbsp;&nbsp;<a href="/Ashx/Desktop.ashx" target="_blank">桌面图标</a></span>
        </div>
    </div>
    <div class="main center">
        <div class="logo">
            <a href="<%=WebSiteConfig.DomainName%>">
                <img src="/Aspx/blue/images/common_logo.png" title="<%=WebSiteConfig.SiteName%>" alt="<%=WebSiteConfig.SiteName%>" /></a>
        </div>
        <div class="search">
            <div class="searchinput">
                <span>
                    <input class="searchbtn" id="btnSearch" type="button" value="" onclick="search();" />
                    <input class="releasebtn" id="Button2" type="button" value="" onclick="location.href = '/info/category'" />
                </span>
                <span>
                    <input id="txtKeywords" maxlength="10" class="keywordInput" type="text" />
                </span>

            </div>
            <div>热门搜索:
            <%foreach(var hword in GetSearchHotWordList()){%>
                <a href="/search/?keywords=<%=hword%>"><%=hword%></a> 
            <%}%>
            </div>
        </div>
    </div>
    <div class="menu">
        <div class="main">
            <ul>
                <li id="HeadMenuList">
                    <a href="/" matchstatus="home">首 页</a>
                    <a href="/gangcai/" matchstatus="gangcai">冶金钢材</a>
                    <a href="/suliao/" matchstatus="suliao">橡胶塑料</a>
                    <a href="/pige/" matchstatus="pige">纺织皮革</a>
                    <a href="/baozhuang/" matchstatus="baozhuang">包 装</a>
                    <a href="/wujin/" matchstatus="wujin">五 金</a>
                    <a href="/jixie/" matchstatus="jixie">机械工业</a>
                </li>
            </ul>

        </div>

    </div>
</div>
<div class="split">&nbsp;</div>
<script type="text/javascript">if (typeof (loadLoginStatus) != null) { loadLoginStatus(); }
    UrlStatus.changeDomSelectStatus("HeadMenuList", 1);
</script>

    <!--body-->
    <div class="body main">
        <form id="form1">
            <div class="register bordershadow">
                <div class="content">
                    <div class="righttitle">注册</div>
                    <div class="left">
                        <table>
                            <tr>
                                <td class="itemtitle">账号:</td>
                                <td class="itemcontent">
                                    <input id="txtAccount" maxlength="30" type="text" onfocus="checkInput(this,1)" onblur="checkInput(this,2)" />
                                </td>
                                <td id="txtAccountStatus" align="left">&nbsp;</td>
                            </tr>
                            <tr>
                                <td class="itemtitle">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码:</td>
                                <td class="itemcontent">
                                    <input id="txtPassword" maxlength="20" type="password" onfocus="checkInput(this,1)" onblur="checkInput(this,2)" />
                                </td>
                                <td id="txtPasswordStatus" align="left">&nbsp;</td>
                            </tr>
                            <tr>
                                <td class="itemtitle">重复密码:</td>
                                <td class="itemcontent">
                                    <input id="txtRepeatPassword" maxlength="20" type="password" onfocus="checkInput(this,1)" onblur="checkInput(this,2)" />
                                </td>
                                <td id="txtRepeatPasswordStatus" align="left">&nbsp;</td>
                            </tr> 
                            <tr>
                                <td class="itemtitle">验&nbsp;&nbsp;证&nbsp;&nbsp;码:</td>
                                <td class="itemcontent itemcontent2">
                                    <input id="VerificationCode" class="registervcode" type="text" size="6" onfocus="checkInput(this,1)" onblur="checkInput(this,2)" />
                                    <img id="imgVerification" src="/Images/common/loading1.gif" alt="验证码" title="刷新验证码" style="cursor:pointer;" />
                                </td>
                                <td id="VerificationCodeStatus" align="left">&nbsp;</td>
                            </tr>
                            <tr>
                                <td>&nbsp;</td>
                                <td>
                                    <input id="btnSubmitRegister" class="registerbutton" type="button" value="注    册" onclick="submitRegister(this);" />
                                    已有账号，<a href="/Login/default" style="color: blue;">从这里登录</a>
                                </td>
                                <td>&nbsp;</td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <!--foot-->
        <div class="split">&nbsp;</div>
    <div class="foot main">
        <div class="menu">
            <ul>
                <li><a href="/about/home" target="_blank" rel="nofollow">关于我们</a></li>
                <li>|</li>
                <li><a href="/about/message" target="_blank" rel="nofollow">建议意见</a></li>
                <li>|</li>
                <li><a href="/about/Contact" target="_blank" rel="nofollow">联系我们</a></li>
                <li>|</li>
                <li><a href="/about/Privacy" target="_blank" rel="nofollow">免责声明</a></li>
            </ul>
        </div>
        <div><%=WebSiteConfig.RecordNo%><%=WebSiteConfig.Copyright%></div>
        <div><%=WebSiteConfig.StatisticalCode%></div>
    </div>
<!--隐藏内容-->
<div id="winpop" style="display:none;">
    <div class="rightwindow">
        <div class="title">公告<span class="close" onclick="win.slideWindow()">X</span></div>
        <div class="content">
            @msg
        </div>
    </div>
</div>
</body>
</html>
<script type="text/javascript">
    function id(data) { return document.getElementById(data); }
    function checkResult(idvalue, isError, msg) {
        if (isError) {
            id(idvalue + "Status").innerHTML = "<img src=\"/images/login/redstatus.gif\"/>" + (msg == null ? "" : msg);
            return false;
        }
        else {
            if (id(idvalue).value != "")
                id(idvalue + "Status").innerHTML = "<img src=\"/images/login/greenstatus.gif\"/>";
            else
                id(idvalue + "Status").innerHTML = "";
            return true;
        }
    }
    function inputTips(idvalue, value) {
        id(idvalue + "Status").innerHTML = "<label style=\"color: blue\"><img src=\"/images/login/bluestatus.gif\"/>" + value + "</label>";
        return false;
    }
    function checkInput(obj, v) {
        if (obj.id == "txtAccount") {
            var txtaccount = obj.value;
            if (v == 1) {
                return inputTips(obj.id, "请输入有效账号");
            }
            else {
                if (!Validator.digitLetter(txtaccount)) {
                    return checkResult(obj.id, true, "请输入有效账号");
                }
                else {
                    var exists = false;
                    exists = checkResult(obj.id, false);
                    return exists;
                }
            }
        }
        else if (obj.id == "txtPassword") {
            var txtpassword = obj.value;
            if (v == 1) {
                return inputTips(obj.id, "密码大于6位，由英文字母和数字组成");
            } else {
                if (txtpassword.length < 6 || txtpassword.length > 20)
                    return checkResult(obj.id, true, "密码大于6位，由英文字母和数字组成");
                else
                    return checkResult(obj.id, false);
            }
        }
        else if (obj.id == "txtRepeatPassword") {
            var txtpassword = obj.value;
            if (v == 1) {
                return inputTips(obj.id, "请再次输入你的密码");
            } else {
                if (txtpassword.length < 6 || txtpassword.length > 20 || txtpassword != id("txtPassword").value)
                    return checkResult(obj.id, true, "请再次输入你的密码");
                else
                    return checkResult(obj.id, false);
            }
        }
        else if (obj.id == "VerificationCode") {
            var txtreferrals = obj.value;
            if (v == 1) {
                return inputTips(obj.id, "请填写验证码");
            } else {
                if (txtreferrals.length != 4)
                    return checkResult(obj.id, true, "请填写验证码");
                else
                    return checkResult(obj.id, false);
            }
        }
    }
    var isSubmit = false;
    function submitRegister(obj) {
        isSubmit = true;
        if (!checkInput(id("txtAccount")) || !checkInput(id("txtPassword")) || !checkInput(id("txtRepeatPassword"))) {
            isSubmit = false;
            return false;
        }
        var vaccount = id("txtAccount").value;
        var vpassword = id("txtPassword").value;
        var vvericode = id("VerificationCode").value;
        User.register({ "account": vaccount, "password": vpassword, "code": vvericode }, function (result) {
            if (result.status == "success") {
                Alert("注册成功", function () {
                    window.location.href = "/login/default";
                }); 
            }
            else if (result.error == "code") {
                isSubmit = false;
                Alert("注册失败,原因:验证码错误");
            } else if (result.error == "existsaccount") {
                Alert("注册失败,原因:邮箱已被注册");
            } else {
                isSubmit = false;
                Alert("注册失败,请检查!");
            }
        })
    }
    window.onload = function () {
        RefreshVerification();
    }
</script>
