<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Dd_register.aspx.cs" Inherits="HteamDd.Web.Web.Dd_register" %>

<!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>注册|海客轻微博</title>
    <link href="/css/login_register.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" language="javascript" src="/jscript/jquery-1.4.2.js"></script>
    <script type="text/javascript">
        var jq = jQuery.noConflict();
        var is_or_no = 0;
        var istrue = false;
        //email的onchange实践触发的函数，先判断邮箱格式，如果合法，再验证邮箱是否已被注册is_or_no变量记录是否已被注册，后边要用
        function get_email() {
            //            var reg = /^[a-zA-Z]([a-zA-Z0-9]*[-_.]?[a-zA-Z0-9]+)+@([\w-]+\.)+[a-zA-Z]{2,}$/;
            var reg = /^[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/;
            if (!reg.test(jq("#email").val())) {
                jq("#point_email").remove();
                jq("#have_register").replaceWith('<div id="have_register" class="reg-tip" style="visibility:visible;" >邮箱格式不正确</div>');
            } else {
                jq.get(
                        '/ashx/Dd_have_or_not_register.ashx',
                        {
                            email: jq("#email").val()
                        },
                        function (data) {
                            if (data == "0") {
                                jq("#point_email").remove();
                                jq("#have_register").replaceWith('<div id="have_register" class="reg-tip" style="visibility:visible;" >邮箱已被注册</div>');
                                jq("#have_register").show();
                                is_or_no = 0;
                            }
                            if (data == "1") {
                                jq("#have_register").hide();
                                is_or_no = 1;
                            }
                        }
                        );
            }
                }
                jq(document).ready(function () {
                    jq("#point_blogname").hide();
                    jq("#point_email").hide();
                    jq("#point_password").hide();
                    jq("#point_repassword").hide();
                    jq("#have_register").hide();

                    //input获得焦点里面的标签内容颜色变浅，显示提示信息
                    jq("#blogname").focus(function () {
                        jq("#point_blogname").show();
                        jq("#point_blogname").html("给你的博客起个名字")
                        //jq("#lable_blogname").fadeTo(0, 0.4);
                        jq("#lable_blogname").hide();

                    });
                    //input失去焦点，如果内容为空，标签内容变深，显示提示信息
                    jq("#blogname").blur(function () {
                        jq("#point_blogname").hide();
                        if (jq("#blogname").val() == "") {
                            //jq("#lable_blogname").fadeTo(0, 1);
                            jq("#lable_blogname").show();
                            jq("#point_blogname").show();
                        }
                        else {
                            jq.ajax({
                                type: 'get',
                                url: '/ashx/Dd_do_register.ashx',
                                data: { blogeName: jq("#blogname").val(), type: "check_blogName", time: new Date().getDate() },
                                success: function (data) {
                                    if (data == "11") {
                                        jq("#point_blogname").show();
                                        jq("#point_blogname").html("该昵称太受欢迎了，换个吧~");
                                        istrue = false;
                                    }
                                    else {
                                        istrue = true;
                                    }
                                },
                                error: function () {
                                    istrue = false;
                                }
                            });
                        }
                    });


                    jq("#email").focus(function () {
                        jq("#point_email").show();
                        //jq("#lable_email").fadeTo(0, 0.4);
                        jq("#lable_email").hide();
                    });
                    jq("#email").blur(function () {
                        jq("#point_email").hide();
                        if (jq("#email").val() == "") {
                            //jq("#lable_email").fadeTo(0, 1);
                            jq("#lable_email").show();
                            jq("#point_email").show();
                        }
                    });


                    jq("#password").focus(function () {
                        jq("#point_password").show();
                        //jq("#lable_password").fadeTo(0, 0.4);
                        jq("#lable_password").hide();
                    });
                    jq("#password").blur(function () {
                        jq("#point_password").hide();
                        if (jq("#password").val() == "") {
                            //jq("#lable_password").fadeTo(0, 1);
                            jq("#lable_password").show();
                            jq("#point_password").show();
                            jq("#point_password").html("设置登录密码(至少6位)");
                        }
                    });


                    jq("#repassword").focus(function () {
                        jq("#point_repassword").show();
                        //jq("#lable_repassword").fadeTo(0, 0.4);
                        jq("#lable_repassword").hide();
                    });
                    jq("#repassword").blur(function () {
                        jq("#point_repassword").hide();
                        if (jq("#repassword").val() == "") {
                            //jq("#lable_repassword").fadeTo(0, 1);
                            jq("#lable_repassword").show();
                            jq("#point_repassword").show();
                        }
                    });

                    //注册按钮提交  先判断四个input里是否为空，密码是否一致,如果都合法注册
                    jq("#submit").click(function () {
                        if (check() == true) {
                            jq.ajax({
                                type: 'post',
                                url: '/ashx/Dd_do_register.ashx',
                                data: { blogname: jq('#blogname').val(), email: jq('#email').val(), password: jq('#password').val(), type: "Reg" },
                                success: function (data) {
                                    if (data == "1") {
                                        is_or_no = 0;
                                        window.location.href = "/Web/Dd_Eamil_active/Dd_Email_send.aspx";
                                    }
                                    else {
                                        alert("注册失败");
                                        window.location.href = "/Web/Dd_register.aspx";
                                    }
                                },
                                error: function () {

                                }
                            });
                        }
                    });
                });
                function check() {           
                    if (jq("#blogname").val() != "") {
                        if (jq("#email").val() != "") {
                            if (jq("#password").val() != "") {
                                if (jq("#repassword").val() != "") {
                                    if (jq("#repassword").val().length >= 6) {
                                        if (jq("#password").val() == jq("#repassword").val()) {
                                            if (is_or_no == 1) {
                                                if (istrue) {
                                                    return true;
                                                }
                                                else {
                                                    return false;
                                                }
                                            }
                                            else {
                                                return false;
                                            }
                                        }
                                        else {
                                            jq("#point_repassword").show();
                                            return false;
                                        }
                                    }
                                    else {
                                        jq("#point_password").show();
                                        jq("#point_password").html("密码长度过短，换个长的吧~");
                                    }
                                }
                                else {
                                    return false;
                                }
                            }
                            else {
                                return false;
                            }
                        }
                        else {
                            return false;
                        }
                    }
                    else {
                        return false;
                    }
                }    
    </script>
</head>
<body>
    <div id="wrap" class="mini-mode">
       <div id="header" class="clearfix">
            <h1 class="logo">
                <a href="/Default.aspx">海客网</a>
            </h1>
            <a class="login-button" href="/Dd_login.aspx">登录</a>
       </div>
       <div class="other"></div>
       <div id="content">
            <div id="1" class="sliding-show" 
                style="position:relative; top: 0px; left: 0px;">
                <ul class="sliding-show-list" style="position:absolute;width:2000px;">
                    <li class="sliding-show-item" style="background-image: url(../images/register-bg-v3-1.$2287.png); display: block; float: left;"></li>
                    <li class="sliding-show-item" style="background-image: url(../images/register-bg-v3-1.$2287.png); display: block; float: left;"></li>
                    <li class="sliding-show-item" style="background-image: url(../images/register-bg-v3-1.$2287.png); display: block; float: left;"></li>
                </ul>
                <ul class="sliding-show-nav">
                    <li class="sliding-show-nav-active-item">1</li>
                    <li>2</li>
                    <li>3</li>
                    <li>4</li>
                </ul>
            </div>
            <div id="reg"  class="reg-action clearfix">
                <h3 class="reg-title">注册新账号</h3>
                
                    <div class="reg-item clearfix ">
                        <div class="reg-input-wrapper">
                            <input id="blogname" class="reg-input" type="text" name="blogname" style="overflow:hidden;"  />
                            <label id="lable_blogname"class="reg-label" for="blogname">博客名</label>
                        </div>
                        <div id="point_blogname" class="reg-tip" style="visibility:visible;">给你的博客起个名字</div>                        
                    </div>
                    <div class="reg-item clearfix ready">
                        <div class="reg-input-wrapper">
                            <input name = "email" id="email" class="reg-input" type="text" style="overflow:hidden;" onchange="get_email();" />
                            <label id="lable_email"class="reg-label" for="email">邮箱</label>
                        </div>
                        <div id="point_email" class="reg-tip" style="visibility:visible;" >填个常用邮箱作为登陆账号</div>
                        <div id="have_register" class="reg-tip" style="visibility:visible;">该邮箱已经注册</div>
                       <%-- <div id= "can_register" class="reg-tip" style="display:none;">恭喜！可以注册</div>
                        <div id= "email_null" class="reg-tip" style="display:none;">*邮箱不能为空</div>--%>
                    </div>
                    <div class="reg-item clearfix ">
                        <div class="reg-input-wrapper">
                            <input name="password" id="password" class="reg-input" type="password"  />
                            <label id="lable_password" class="reg-label" for="password">设置密码</label>
                        </div>
                        <div id="point_password" class="reg-tip" style="visibility:visible;">设置登录密码(至少6位)</div>
                    </div>
                    <div class="reg-item clearfix ">
                        <div class="reg-input-wrapper">
                            <input id="repassword" class="reg-input" type="password" name="repassword" />
                            <label id="lable_repassword"class="reg-label" for="repassword">确认密码</label>
                            
                        </div>
                        <div id="point_repassword" class="reg-tip" style="visibility:visible;">确认登录密码与上面一致</div>
                    </div>

                    <div class="clearfix reg-stage-holder">
                        <div class="reg-input-wrapper">
                            <label>
                                <input type="radio" name="1"/>我已工作
                            </label>
                            <label>
                                <input type="radio" name="1"/>在上大学
                            </label>
                            <label>
                                <input type="radio" name="1"/>不想说
                            </label>
                        </div>
                    </div>
                    <button id="submit" class="reg-submit style-two" >立即注册</button>
               
            </div>
       </div> 
       <div id="explore" class="clearfix"></div>
    </div>
    <div id="footer">
        <label id="user_reg"></label>
    </div>

</body>
</html>
