
	//var _widht = document.documentElement.clientWidth;  //屏幕宽
	var _height = document.documentElement.clientHeight; //屏幕高
	//var boxWidth = $(".login-first").width();
	var boxHeight = $(".login-first").height();
	$(".login-first").css({ top: (_height - boxHeight) / 2 +"px" });

//检查用户是否登陆
	$(function(){  
	    if($.cookie("userAuth") == true){
	    	
	    	location.href="index.html";
	    }else{
	    	var userid=$.cookie("userid");
	    	$.ajax({
	    		
	    		"url":"/ajax/professor/info/" + userid,
	    		"data":{"id":userid},
	    		"beforeSend":function(response){
	    			//alert("110");
	    			//console.log(response);
	    		},
	    		"success":function(response){
	    			
	    			$("#name").text(response.data.name);
	    			//console.log(response.data.name);
	    		},
	    		"error":function(error){
	    			$.MsgBox.Alert('message','fail');
	    		}
	    	})

	    }
	}); 
	var isPass = false;
	var isPass1=false;
	function valPassword(){
		var password = $("#password").val();
		if(password.length==0){
			 $(".msg1").text("密码不能为空");
		}else if(password.length<6){
			$(".msg1").text("密码长度过短,至少六位");
		}else{
			$(".msg1").text("");
			isPass1=true;
		}
	}

	function valPassword2(){
		var password = $("#password").val();
		var password2 = $("#password2").val();
		if(password2.length==0){
			 $(".msg2").text("密码不能为空");
		}else if(password2 != password){
			$(".msg2").text("两次输入密码不一致");
		}else{
			isPass = true;
			$(".msg2").text("");
		}
	}
	function savePassword(){
		valPassword();
		valPassword2();
		if(isPass&&isPass1){
			location.href = "index.html";
			$.ajax("/ajax/cp",{
					type:"POST",
					 async: false,
					success:function(data){  

						if(data.success){
							if(data.data == true){
								alert("1111");
								$.cookie("userAuth","true");
//								location.href = "index.html";
							}else{
								$(".msg3").text("设置错误!");
							}
						}else{
							$(".msg3").text("系统异常!");
							// alert("系统异常!");
						}
					},
					error:function(){$.MsgBox.Alert('message','fail')},
					data:{"id":$.cookie("userid"),"npw":$("#password").val() ,"onw":""},
				 	dataType: 'json'
				});
		}

	}