<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../../common/init.jsp"%>
<!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>
<link rel='stylesheet' href='${ctx}/resources/css/user-center-style.css' type='text/css' media='screen' />
<%@ include file="../../common/top.jsp"%>
<%@ include file="../../common/validation.jsp"%>
<title>用户信息编辑</title>

</head>
<body>
	<%@ include file="../../common/header.jsp"%>
	<div id="content" class="content">
		<%@ include file="../../common/sub_menu.jsp"%>
		<div class="page" id="page" >
			<div class="page-header">个人信息  - 信息编辑</div>
			<div class="page-body">
			<form id="user-form" class="form" method="post" action="${ctx}/user/info/save">
				<input type="hidden" value="${user.id}" name="id" />
				<fieldset id="formset-base" class="form-page">
					<legend>基本信息</legend>
					<table class="form-table" >
						<tbody>
							<tr>
								<td class="label">原密码：</td>
								<td class="input">
									<input class="validate[ajax[ajaxCheckpassword]] text-input" type="password" name="oldpassword" id="oldpassword" /><font color="green">&nbsp;&nbsp;(修改密码，可选)</font>
								</td>
							</tr>
							<tr>
								<td class="label">新密码：</td>
								<td class="input">
									<input class="text-input" type="password"
									name="password" id="password" disabled="disabled" style="background-color: #f3f3f3;"/>
								</td>
							</tr>
							<tr>
								<td class="label">确认：</td>
								<td class="input">
									<input id="repassword" class="validate[equals[password]] text-input" type="password" disabled="disabled" style="background-color: #f3f3f3;"/>
								</td>
							</tr>
						</tbody>
					</table>
				</fieldset>
			</form>
			</div>
			<div class="page-footer">
				<input type="button" id="form-submit" class="btn" value="保存" />
				<input type="button" id="form-back" class="btn" value="返回" />
			</div>
		</div>   
		</div>
	
<script type="text/javascript">
	$('#form-submit').click(function(){
		$('#user-form').get(0).submit();
	});
	$('#form-back').click(function(){
		window.history.back();
	});
	
$("#user-form").validationEngine({
	rules:[
	{
		'ajaxCheckpassword':{
			"url": "${ctx}/user/checkpassword.json",
	        "alertTextOk": "* 密码正确",
	        "alertText": "* 密码错误，请重新输入",
	        "alertTextLoad": "* 正在验证密码，请稍等。。。",
			callback:function(s){
				if(s.status == true){
					$("#password").removeAttr("disabled");
					$("#repassword").removeAttr("disabled");
					$("#password").css("background-color","#fff");
					$("#repassword").css("background-color","#fff");
				}else{
					$("#password").attr("disabled","disabled");
					$("#repassword").attr("disabled","disabled")
					$("#password").css("background-color","#f3f3f3");
					$("#repassword").css("background-color","#f3f3f3");
					$("#password").val("");
					$("#repassword").val("");
				}
			}
		}
	}
	]
});	
</script>
</body>
</html>