<?php if (!defined('THINK_PATH')) exit();?><!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>
<meta http-equiv="X-UA-Compatible" content="IE=7;IE=9;IE=10" />
<link href="/Public/css/home.css?v=2" rel="stylesheet" type="text/css" />
<link href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<link href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap-theme.min.css" rel="stylesheet" />
<script src="//cdn.bootcss.com/jquery/3.0.0-alpha1/jquery.min.js"></script>
<script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<title>魔方 - 我的世界</title>

</head>
<body>
	<div class="header">
		<div class="con">
			<h1 class="logo">Mc魔方联机</h1>
		</div>
	</div>
	<div class="wrap">
		<div class="banner-show" id="js_ban_content">
			<div class="cell bns-01">
				<div class="con"></div>
			</div>
			<div class="cell bns-02" style="display: none;">
				<div class="con"></div>
			</div>
			<div class="cell bns-03" style="display: none;">
				<div class="con"></div>
			</div>
		</div>
		<div class="banner-control" id="js_ban_button_box">
			<a href="javascript:;" class="left">左</a> <a href="javascript:;"
				class="right">右</a>
		</div>
		
<div class="container">
	<div class="register-box">
		<div class="reg-slogan">
			<font size="5" face="微软雅黑">用户登录</font>
		</div>
		<form class="form-horizontal" action="<?php echo U('User/Login');?>" role="form" method="post">
			<div class="form-group">
				<label for="username" class="col-sm-offset-1 col-sm-3 control-label">用户名:</label>
				<div class="col-sm-6">
					<input type="text" class="form-control" id="username" name="username" placeholder="用户名" required />
				</div>
			</div>
			<div class="form-group">
				<label for="password" class="col-sm-offset-1 col-sm-3 control-label">密 &nbsp; &nbsp;码:</label>
				<div class="col-sm-6">
					<input type="password" class="form-control" id="password" name="password" placeholder="密码" required />
				</div>
			</div>
			<div class="form-group">
				<label for="verify" class="col-sm-offset-1 col-sm-3 control-label">验证码:</label>
				<div class="col-sm-6">
					<input type="text" class="form-control" id="verify" name="verify" placeholder="验证码" required />
				</div>
			</div>
			<div class="form-group">
				<label for="" class="col-sm-offset-1 col-sm-3 control-label"></label>
				<div class="col-sm-6">
					<img src="<?php echo U('Common/Verify');?>" class="verifyimg reloadverify" />
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-3 col-sm-7">
					<button id="submit" type="button" class="btn btn-primary btn-login">登陆</button>
				</div>
			</div>
			<div class="form-group">
				<p class="check-tips text-danger col-sm-offset-3 col-sm-7"></p>
			</div>
		</form>
	</div>
</div>
<script type="text/javascript">
	$(document).ready(function() {
		$("#submit").click(function() {
			var user = $("#username").val();
			var pass = $("#password").val();
			var verify = $("#verify").val();
			if (user == "") {
				alert("用户名不能为空！");
				return;
			}
			if (pass == "") {
				alert("密码不能为空！");
				return;
			}
			$.ajax({
				type : "POST",
				data : {
					username : user,
					password : pass,
					verify : verify
				},
				dataType : "json",
				url : "<?php echo U('User/Login');?>",
				success : function(rdata) {
					alert(rdata.info);
					window.location.href = rdata.url;
				}
			});
		});
	});
</script> 
	</div>
	<script type="text/javascript">
		(function() {
			var defaultInd = 0;
			var list = $('#js_ban_content').children();
			var count = 0;
			var change = function(newInd, callback) {
				if (count)
					return;
				count = 2;
				$(list[defaultInd]).fadeOut(400, function() {
					count--;
					if (count <= 0) {
						if (start.timer)
							window.clearTimeout(start.timer);
						callback && callback();
					}
				});
				$(list[newInd]).fadeIn(400, function() {
					defaultInd = newInd;
					count--;
					if (count <= 0) {
						if (start.timer)
							window.clearTimeout(start.timer);
						callback && callback();
					}
				});
			}
			var next = function(callback) {
				var newInd = defaultInd + 1;
				if (newInd >= list.length) {
					newInd = 0;
				}
				change(newInd, callback);
			}
			var start = function() {
				if (start.timer)
					window.clearTimeout(start.timer);
				start.timer = window.setTimeout(function() {
					next(function() {
						start();
					});
				}, 8000);
			}
			start();
			$('#js_ban_button_box').on('click', 'a', function() {
				var btn = $(this);
				if (btn.hasClass('right')) {
					//next
					next(function() {
						start();
					});
				} else {
					//prev
					var newInd = defaultInd - 1;
					if (newInd < 0) {
						newInd = list.length - 1;
					}
					change(newInd, function() {
						start();
					});
				}
				return false;
			});
		})();
	</script>
</body>
</html>