<?php
if (empty ( $_SESSION ['username'] ))
	header ( 'Location:' . Url ( 'index', 'login' ) );
?>
<!DOCTYPE html>
<html>
<head>
<title><?=$title?></title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<!-- bootstrap -->
<link href="View/public/css/bootstrap/bootstrap.css" rel="stylesheet" />
<link href="View/public/css/bootstrap/bootstrap-responsive.css"
	rel="stylesheet" />
<link href="View/public/css/bootstrap/bootstrap-overrides.css"
	type="text/css" rel="stylesheet" />

<!-- libraries -->
<link href="View/public/css/lib/bootstrap-wysihtml5.css" type="text/css"
	rel="stylesheet" />
<link href="View/public/css/lib/uniform.default.css" type="text/css"
	rel="stylesheet" />
<link href="View/public/css/lib/select2.css" type="text/css"
	rel="stylesheet" />
<link href="View/public/css/lib/bootstrap.datepicker.css"
	type="text/css" rel="stylesheet" />
<link href="View/public/css/lib/font-awesome.css" type="text/css"
	rel="stylesheet" />

<!-- global styles -->
<link rel="stylesheet" type="text/css" href="View/public/css/layout.css" />
<link rel="stylesheet" type="text/css"
	href="View/public/css/elements.css" />
<link rel="stylesheet" type="text/css" href="View/public/css/icons.css" />

<!-- this page specific styles -->
<link rel="stylesheet" href="View/public/css/compiled/form-showcase.css"
	type="text/css" media="screen" />

<!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>

	<!-- navbar -->
<?=load('header')?>
    <!-- end navbar -->

	<!-- sidebar -->
 <?=include 'left.php';?>
    <!-- end sidebar -->


	<!-- main container -->
	<div class="content">

		<div class="container-fluid col-xs-12">
			<div id="pad-wrapper" class="form-page">
				<div class="row-fluid form-wrapper">
					<!-- left column -->
					<div class="span8 column ">
						<form>
							<div class="field-box">
								<label>游戏帐号:</label> <input class="span8 inline-input"
									id="username" type="text" disabled="disabled"
									value="<?=$_SESSION['username']?>" />
							</div>
							<div class="field-box">
								<label>旧游戏密码:</label> <input class="span8 inline-input"
									id="oldpass" placeholder="" type="text" />
							</div>
							<div class="field-box">
								<label>新游戏密码:</label> <input class="span8 inline-input"
									id="newpass" type="password" value="" />
							</div>
							<div class="field-box">
								<label>重复输入游戏密码:</label> <input class="span8 inline-input"
									id="cfmpass" type="text" value="" />
							</div>
							<button type="button" id='cpass'
								class="btn-glow primary btn-next">更改游戏密码</button>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- end main container -->

	<!-- scripts for this page -->
	<script src="View/public/js/wysihtml5-0.3.0.js"></script>
	<script src="View/public/js/jquery-latest.js"></script>
	<script src="View/public/js/bootstrap.min.js"></script>
	<script src="View/public/js/bootstrap-wysihtml5-0.0.2.js"></script>
	<script src="View/public/js/bootstrap.datepicker.js"></script>
	<script src="View/public/js/jquery.uniform.min.js"></script>
	<script src="View/public/js/select2.min.js"></script>
	<script src="View/public/js/theme.js"></script>
	<script>
	window.onload = function(){
		$.ajax({
			type:"GET",
			dataType:"json",
			data:{user:"<?=$_SESSION['username']?>"},
			url:"<?=Url('mail_status','stat')?>",
			success:function(check){
			     $.each(check.info,function(i,o){
					  switch(check.status){
					       case "success": 						    
							    switch(o.statu) {
							       case "1" : return true; break;
                                   case "0" : alert("无权操作此页面"); location.href='<?=Url('index','index')?>'; break;
                                }							  
						   break;
					       case "error": alert("读取验证状态失败"); break;
				    }
				})
			}
		})
	}
	$("#cpass").click(function(){
		if($("#oldpass").val() == ""){
			alert("请输入密码");
			return false;
		}else if($("#newpass").val() == ""){
			    alert("请输入密码");
			    return false;	
		}else if($("#cfmpass").val() == ""){
			    alert("请输入密码");
			    return false;
		}
		$.ajax({ type:"POST",
			url:"<?=Url('user_public','pass')?>", data:{ user:$("#username").val(), pass:$("#oldpass").val(), newpass:$("#newpass").val()}, dataType:"json"	,
            success:function(rdata){
			switch(rdata.status){
				case "success": alert(rdata.info); window.location.href = "<?=Url('index','login')?>"; break;
				case "error": alert(rdata.info); return false; break;
			    }
		    }			
		})
	})
	</script>
</body>
</html>