<%--
  Created by IntelliJ IDEA.
  User: sqp
  Date: 2015-11-12
  Time: 11:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<head>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="chrome=1,IE=9">
    <meta charset="utf-8">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>重置密码</title>
    <link href="/resource/front/css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="wrapper">
    <div id="top"><IMG src="/resource/front/img/banner.png" width=1024 height=204 ></div>
    <div class="pp"></div>

    <table width="" border="0" cellpadding="0" cellspacing="0" style="width:100%;min-height:600px;">

            <div style="margin-left:200px;">
                <form id="form">
                <div style="margin-bottom:10px">
                    <label>邮&nbsp;&nbsp;&nbsp;&nbsp;箱:</label>
                    <input type="text" name="name" style="padding:2px 5px">
                </div>
                <div style="margin-bottom:10px">
                    <label>验证码:</label>
                    <input type="text" name="validateCode" style="padding:2px 5px">
                    <div style="margin-top:10px">
                        <img id="vald" src="/validate/code.do" onclick="changeCode()"/>
                        <a href="javascript:changeCode()">看不清，换一张</a>
                    </div>
                </div>
                </form>
                <div class="message" style="color:red;margin-bottom:10px;"></div>
                <input type="submit" id="submit" onclick="javascript:;" style="width:50px;height:25px;" value="重置密码">
            </div>


    </table>

    <div class="pp">
    </div>
    <div id="foot">
        <p>&copy;版权所有：中国国际贸易促进委员会（中国国际商会）培训中心 &nbsp;地址：北京市西城区桦皮厂胡同2号国际商会大厦2层 邮编：100035电话：010-82217206 传真：010-82217272<br>
            邮箱：training@ccpit.org &nbsp;技术支持：中贸促信息技术有限责任公司</p>
    </div>
</div>
<script src="/resource/front/js/jquery.min.js" type="text/javascript"></script>
<script src="/resource/front/js/jquery.form.min.js" type="text/javascript"></script>
<script language="JavaScript">
    function changeCode() {
        var link = "/validate/code.do";
        var param = "?" + Math.random();
        $("#vald").attr("src", link+param);
    }
    function getQueryString(name)
    {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }
    function showMessage(msg)
    {
        $(".message").html(msg);
    }
    $(function(){
        showMessage("");
       $("#submit").on("click",function(){
           $(this).val("请等待...");
           var type = getQueryString("type");
           var email = $("[name=name]").val();
           var code = $("[name=validateCode]").val();
           var url = "/training/resetPwd?email="+email+"&validateCode="+code+"&regType="+type;
           $.post(url,function(data){
               $("#submit").val("重置密码");
               if(!data.success){
                   showMessage(data.info);
               }else{
                   showMessage("邮件发送成功，请注意查收邮件。3秒后跳转到登录页...");
                   if(type=="true"){
                       setTimeout("location.href='/training/loginp'",3000);
                   }else{
                       setTimeout("location.href='/training/loginp2'",3000);
                   }
               }
           })
       });
    });

</script>
</body>
</html>
