	var _commonCSS = "font:16px;text-align:center;font-weight:bold;width:100%;margin-top:40px;";
	$(document).ready(function(){
		var today=new Date();
		var hour=today.getHours();
		var year=today.getYear();
		var month=today.getMonth();
		var date=today.getDate();		
		var x = new Array("\u661f\u671f\u65e5", "\u661f\u671f\u4e00", "\u661f\u671f\u4e8c","\u661f\u671f\u4e09","\u661f\u671f\u56db", "\u661f\u671f\u4e94","\u661f\u671f\u516d");
       	day = today.getDay();
		var s = x[day];
		$("#date").html(year+"\u5e74"+(month+1)+"\u6708"+date+"\u65e5"+"   "+s);
		
		var msg=$("#login");
		$.getJSON("/fore/login_header.jsp?date="+new Date(),{method:"post",requestHeaders:["Cache-Control","no-cache"],requestHeaders:["Expires","0"],requestHeaders:["Pragma","no-cache"]},
        	function(json){
				if(json!=null){
					//msg.css("margin","36px 0px 0px 0px");
					msg.css("padding-left","0px");
					msg.html("<br/><p style=\""+_commonCSS+"\">"+json['username']+",\u6b22\u8fce\u60a8"+"</p>"+"<p style=\"width:100%;\"><input style=\"background: url('../images/login_button_03.gif');width:53px;height:23px;border:0px;cursor: hand;\" type=\"button\" onclick=\"javascript:window.location.href='/front/logout.do'\"> <input style=\"background: url('../images/login_button_05.gif');width:69px;height:23px;border:0px;cursor: hand;\" type=\"button\" onclick=\"javascript:window.location.href='/console/displayUserRoleList.do'\"></p>");
				}
			}
		);
	});
	
	function frontLogin(){
		$(document).ready(function(){
		 	var options = {
        	    beforeSubmit:  showRequest,  // pre-submit callback 
       		    success:       showResponse  // post-submit callback 
    	    }; 
         	$('#loginConsoleForm').ajaxSubmit(options);
		});     
	}
	
    var loginContent;
	function showRequest(formData, jqForm, options) {
	  	var login=$("#login");
		loginContent=login.html();
      	var str="<img style=\"margin-top:50px;\" src=\"../images/fore/login_waiting.gif\"></img>";
      	login.html(str);
      	return true;	
   	}
    
	function showResponse(responseText, statusText)  { 
 	 	var msg=$("#login");
	 	//msg.css("margin","36px 0px 0px 18px");	 	
	 	if(responseText=='2'){
	 	 	msg.html(loginContent);
		 	alert("\u7528\u6237\u4e0d\u5b58\u5728\uff01");
		 	$("#validateCode2").attr("src","/login/ValidateCodeServlet");
	 	}else if(responseText=='3'){
	 	 	msg.html(loginContent);
	 	 	alert("\u5bc6\u7801\u9519\u8bef\uff01");
	 	 	$("#validateCode2").attr("src","/login/ValidateCodeServlet");
	 	}else if(responseText=='4'){
	 	 	msg.html(loginContent);
	 		alert("\u7528\u6237\u6ca1\u5ba1\u6279\uff01");
	 		$("#validateCode2").attr("src","/login/ValidateCodeServlet");
	 	}else if(responseText=='5'){
	 	 	msg.html(loginContent);
	 		alert("\u7cfb\u7edf\u9519\uff01");
	 		$("#validateCode2").attr("src","/login/ValidateCodeServlet");
	 	}else if(responseText=='6'){
			msg.html(loginContent);			
			alert("\u9a8c\u8bc1\u7801\u4e0d\u6b63\u786e");
			$("#validateCode2").attr("src","/login/ValidateCodeServlet");
		}else if(responseText=='1'){
		  	$.getJSON("/fore/login_header.jsp?date="+new Date(),{method:"post",requestHeaders:["Cache-Control","no-cache,must-revalidate"],requestHeaders:["Expires","0"],requestHeaders:["Pragma","no-cache"]},
               	function(json){
					msg.css("padding-left","0px");
			   		msg.html("<br/><p style=\""+_commonCSS+"\">"+json['username']+",\u6b22\u8fce\u60a8"+"</p>"+"<p style=\"width:100%;\"><input style=\"background: url('../images/login_button_03.gif');width:53px;height:23px;border:0px;cursor: hand;\" type=\"button\" onclick=\"javascript:window.location.href='/front/logout.do'\"> <input style=\"background: url('../images/login_button_05.gif');width:69px;height:23px;border:0px;cursor: hand;\" type=\"button\" onclick=\"javascript:window.location.href='/console/displayUserRoleList.do'\"></p>");
          		}
     	);
	 }
  	} 
   
	function validate(){
		$("#validateCode2").attr("src","#");
   		if($("#userName").val()==''){
			alert('\u8bf7\u586b\u5199\u7528\u6237\u540d\uff01');
			$("#validateCode2").attr("src","/login/ValidateCodeServlet");
			return false;
		}
		if($("#password").val()==''){
			alert('\u8bf7\u586b\u5199\u5bc6\u7801\uff01');
			$("#validateCode2").attr("src","/login/ValidateCodeServlet");
			return false;
		}
		
		if($("#validateCode").val()==''){
			alert('\u8bf7\u8f93\u5165\u9a8c\u8bc1\u7801');
			$("#validateCode2").attr("src","/login/ValidateCodeServlet");
			return false;
		}
		
		frontLogin();
   	}			