<?php require APPPATH_MVC.'views/header.php'; ?>
<style>
.Validform_right{ display:none;}
</style>
<div class="w960 clearfix mt10 pepcenterBox">
    <?php require APPPATH_MVC.'views/left.php'; ?>
    <!--会员左侧 End-->
    <div class="user-main user-main02">
			<div class="hd-bar pos-r">
        	 <h2>修改密码</h2>
        </div>
    	<div class="user-main user-main03">
    	
        
        <form action="<?php echo USER_CENTER;?>user/edit_password" method="post" id="edit_password" name="edit_password" class="form">
        <table  border="0" cellspacing="0" cellpadding="0" class="means-table">
          <tr>
            <th width="80">原密码：</th>
            <td><input type="password" class="inpt-style" id="password" name="password" datatype="*6-16" nullmsg="请输入原密码。"  errormsg="密码范围在6~16位之间。"/> </td>
            <td width="400"><div class="Validform_checktip" id="js_errorBox"></div></td>
          </tr>
          <tr>
            <th>设置新密码：</th>
            <td><input type="password" class="inpt-style" name="newpassword" id="newpassword" datatype="s6-16" nullmsg="请输入新密码。" errormsg="密码范围在6~16位之间,或者有非法字符。"/></td>
            <td><div class="Validform_checktip"></div></td>
          </tr>
          <tr>
            <th>确认新密码：</th>
            <td><input type="password" class="inpt-style" name="againpassword" id="againpassword"  datatype="s6-16" recheck="newpassword" nullmsg="请再次输入新密码。" errormsg="2次新密码输入不一致，请重新输入。"/></td>
            <td><div class="Validform_checktip"></div></td>
          </tr>
          <tr>
            <th>&nbsp;</th>
			<input type="hidden" value="<?php echo $_SESSION['token'];?>" name="token">
            <td><input type="submit" value="提 交" class="btn2" /></td>
          </tr>
        </table>
        </form>
       
    </div>
		</div>
    <!--会员右侧 End-->
  
</div>
<!--会员中心主体 End-->




<script type="text/javascript">
$(function(){
	$(".form").Validform({
		tiptype:2, 
		callback:function(form){
			edit();
			return false;
		}
	});

	//$('#subBtn').click(function(){
//		pop_tip('恭喜你修改密码成功!')
//	})
})
</script>

<script type="text/javascript">
	function edit() {
           newpassword = $("#newpassword").val();
           againpassword = $("#againpassword").val();
           password = $("#password").val();
		 $.ajax({
            type: 'post',
            url : '<?php echo USER_CENTER;?>user/edit_password',
            data: 'newpassword='+newpassword+'&againpassword='+againpassword+'&password='+password,
            dataType:'html',
            success: function(msg){
                switch(msg){
                    case '1':
                        $('#war-text').html("密码修改成功。");
                        openWin('warning');
                         setTimeout("location.reload()",3000);
                        break;
                    case '2':
                         $('#war-text').html("2次新密码输入不一致。");
                         openWin('warning2');
                        break;
                    case '3':
                        $("#js_errorBox").empty();
                        $("#js_errorBox").removeClass("Validform_checktip Validform_right").addClass("Validform_checktip Validform_wrong")
		            	$("#js_errorBox").html("原密码输入错误，请重新输入。");
                        break;
                    case '4':
                         $('#war-text').html("修改密码失败。");
                         openWin('warning2');
                        break;
                    default:
                        $('#war-text').html("修改密码失败。");
                        openWin('warning2');
                        break;
                }
            }
        });
        return false;
        }

</script>

<script>
var openWin = function(obj){
	var winHeght = $(document).height() ;
	var winElemt = $('#'+ obj);
	
	var win = {
		
		height : function(){
			return winElemt.outerHeight();
		},
		
		width : function(){
			return winElemt.outerWidth();
		},
		
		show : function(){
			winElemt.css({
				'position':'absolute',
				'z-index':'9999902',
				'left':'50%',
				'margin-left':'-' + win.width() / 2 + 'px',
				'top':$(window).height()/2 - (win.height()/2) + $(window).scrollTop() + 'px'
			}).show();
		},
		
		hide : function(){
			winElemt.hide();
		}
	
	};
	win.show();
	$('.close-win').click(function(){
		win.hide();
	});
};
</script>
<div id="warning" class="pop" style=" display:none;z-index:100">
    <div class="hd">
    	<h2>提示</h2>
    	<a href="javascript:void(0)" class="close-win">关闭</a>
    </div>
    <div class="bd">
    	<div class="warning-inner">
        	<div class="war-bg" style="background:url(../images/pop-ico.gif) -2px -113px; no-repeat"></div>
        	<p class="war-text" id="war-text"></p>
        </div>
    	<div class="pop-btn-area"><a href="javascript:void(0);" class="close-win" style="background:#29B966;color:#fff;padding:7px 15px;margin:0 5px;border:1px solid #26AB5E">确定</a></div>
    </div>
</div>


<div id="warning2" class="pop" style=" display:none;z-index:100">
    <div class="hd">
    	<h2>提示</h2>
    	<a href="javascript:void(0)" class="close-win">关闭</a>
    </div>
    <div class="bd">
    	<div class="warning-inner">
        	<div class="war-bg" style="background:url(../images/pop-ico.gif)  0px 0px; no-repeat"></div>
        	<p class="war-text" id="war-text"></p>
        </div>
    	<div class="pop-btn-area"><a href="javascript:void(0);" class="close-win" style="background:#29B966;color:#fff;padding:7px 15px;margin:0 5px;border:1px solid #26AB5E">确定</a></div>
    </div>
</div>
<?php require APPPATH_MVC.'views/footer.php'; ?>