function GetQueryString(name)
{ 
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 	
		var r = window.location.search.substr(1).match(reg);  
		var context = ""; 
		if (r != null) 
			 context = r[2]; 
		reg = null; 
		r = null; 
		return context == null || context == "" || context == "undefined" ? "" : decodeURI(context); 
}
var id=GetQueryString("id");
var namePass=false;
var orgPass=false;
$("#name").blur(function(){
	var name=$("#name").val();
	if(name.length==0 && name==""){
		$(".basicmsg1").text("请输入您的姓名");
	}else{
		$(".basicmsg1").text("");
		 namePass=true;
	}
});
$("#orgName").blur(function(){
	var org=$("#orgName").val();
	if(org.length==0 && org==""){
		$(".basicmsg2").text("请输入您的机构");
	}else{
		$(".basicmsg2").text("");
		orgPass=true;
	}
});
	
	$("#saveProfessor").on("click",	function() {
		var $data = {};
		$data.name = $("#name").val();				
		$data.orgName = $("#orgName").val();
		$data.title = $("#title").val();
		$data.department = $("#department").val();
		$data.address = $("#address").val();
		$data.id = id;
		if(orgPass&&namePass){
				$.ajax({"url" : "../ajax/professor",
					"type" :  "POST",
					"success" : function(rdata) {
						console.log(rdata);
						if (rdata.success) {									
								location.href="index.html";								
						} else {
							alert(rdata.msg);
						}
					},
					"data" : $data,
					"contentType" :"application/x-www-form-urlencoded",
					dataType : "json"
				});
		}
	});	
