<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
   		 <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE" />
        <%@ include file="include/lib.jsp"%>
        <link rel="stylesheet" type="text/css" href="${base_url}/css/login.css" />
    </head>
    
    <body>
        <!--窗口框架，设背景-->
        <div id="window">
            <!--中间登录框-->
            <div id="middle">
                <!--登录框上部分（到底部版本信息之前）-->
                <div id="upside">
                    <form action="" method="post">
                    
                        <!--用户-->
                        <div id="user">
                            <input name="username" type="text" size="18" onblur="show(); "id="username" />
                            <span style="color:#F00;  top: -22px; left: 158px;" id="show">用户名不能为空</span>
                        </div>
                        <!--密码-->
                        <div id="password">
                            <input name="password" type="password" size="18" onblur="show1();" id="userpassword"/>
                            <span style="color:#F00;top: -20px; left: 158px;" id="show1">密码不能为空</span>

                        </div>
                        <!--验证码-->
                        <div id="verification">
						 <input name="check" id="check" type="text" size="4" style="float:left;" />
                            <img id="checkImg" src="verify" class="checkimage"/>
							<input name="verify" id="verify" type="hidden" value="" style="float:left;" />
                        </div>
                        <!--提交按钮-->
                        <div id="register">
                            <input name="register" type="button" onclick="sum()"/>
                        </div>
                    </form>
                </div>
                <!--底部版本信息-->
                <span style="font-size:16px; margin:auto; color:#999;">
                    版本信息﹕CMS-V3.0&nbsp;SP1正式版
                </span>
            </div>
        </div>
 <script type="text/javascript">
        	$("#show").hide();	
        	$("#show1").hide();	
        	
    $(function(){
		if (($.browser.msie) && ($.browser.version == "6.0")) {
			$.messager.confirm("浏览器错误","建议使用ie6以上版本的浏览器或者谷歌，火狐等浏览器",function(r){
				location.href = "${base_url}";
		    });
		}
	})
	
		//js监听回车键 
	document.onkeydown = function(e) {
		e = e ? e : window.event;
		var keyCode = e.which ? e.which : e.keyCode;
		if (keyCode == 13) {
			sum(); //按下“回车”键时调用表单验证函数 
		}
	}
	
        	//提示信息 用户名输入框为空则显示错误信息
			function show (){
				if($("#username").val().replace(/[ ]/g,"")==""){
					$("#show").show();	
				}else{
					$("#show").hide();	
				}
					
			}
			//提示信息 密码输入框为空则显示错误信息
			function show1 (){
				if($("#userpassword").val()==""){
					$("#show1").show();	
				}else{
					$("#show1").hide();	
				}	
			}
			//提交按钮
			function sum(){
				if($("#username").val().replace(/[ ]/g,"")==""){
					$("#show").show();	
				}else{
					$("#show").hide();	
				}
				if($("#userpassword").val()==""){
					$("#show1").show();	
				}else{
					$("#show1").hide();	
				}
				if($("#username").val().replace(/[ ]/g,"")!=""&&$("#userpassword").val()!=""){
					var userName = $('#username').val();
					var userPassword = $('#userpassword').val().replace(/[ ]/g,"");
					var check = $('#check').val();
					var verify = $('#verify').val();
						$.ajax( {
							type : "post",
							url : "${path}login",
							dataType : "json",
							data : "name=" + userName + "&password=" + userPassword + "&check="
									+ check + "&verify=" + verify,
							success : function(data) {
								switch (data.code) {
								case 100:
									showFormMsg(SYSTEM_TITLE, "登录成功!");
									location.href = "admin/index";
									break;
								case 101:
									showFormMsg(SYSTEM_TITLE, "用户名不正确");
									break;
								case 102:
									showFormMsg(SYSTEM_TITLE, "密码不正确");
									break;
								case 103:
									showFormMsg(SYSTEM_TITLE, "验证码不正确");
									break;
								case 104:
									showFormMsg(SYSTEM_TITLE, "用户名或密码不为空");
									break;
								case 105:
									showFormMsg(SYSTEM_TITLE, "验证码不为空");
									break;
								}
							},
							error : function(data) {
								showFormMsg(SYSTEM_TITLE, SYSTEM_ERR);
							}
						});
				}
			}
        </script>
    </body>

</html>
