$(function() {
	loginStatus();//判断个人是否登录
	var userid = $.cookie("userid");
	var professorId = GetQueryString("professorId");
	var name,orgId,orgAuth;
	if(userid == professorId) {
		$("#conbtn,.attentBtn").hide();
	}
	if(professorId) {

		var subjectShow = function(data) {
			if(data != undefined && data.length != 0) {
				var subs = new Array();
				if(data.indexOf(',')) {
					subs = data.split(',');
				} else {
					subs[0] = data;
				}
				if(subs.length > 0) {
					for(var i = 0; i < subs.length; i++) {
						$("#subjectShow").append("<div class='acad'>" + subs[i] + "</div>");

					};
				}
			}
		}
		var industryShow = function(data) {

			if(data != undefined && data.length != 0) {

				var subs = new Array();
				if(data.indexOf(',')) {
					subs = data.split(',');
				} else {
					subs[0] = data;
				}

				if(subs.length > 0) {
					for(var i = 0; i < subs.length; i++) {

						$("#industryShow").append("<li>" + subs[i] + "</li>");

					};
				}
			}
		}
		var eduBgShow = function(data) {

			if(data.length > 0) {
				for(var i = 0; i < data.length; i++) {
					var showHtml = '<li><div class="h4Font h4tit">';
					if(data[i].college && data[i].major && data[i].degree) {
						showHtml += data[i].school + '-' + data[i].college + '-' + data[i].major + '-' + data[i].degree
					} else if(!data[i].college && data[i].major && data[i].degree) {
						showHtml += data[i].school + '-' + data[i].major + '-' + data[i].degree
					} else if(data[i].college && !data[i].major && data[i].degree) {
						showHtml += data[i].school + '-' + data[i].college + '-' + data[i].degree
					} else if(data[i].college && data[i].major && !data[i].degree) {
						showHtml += data[i].school + '-' + data[i].college + '-' + data[i].major
					} else if(!data[i].college && !data[i].major && data[i].degree) {
						showHtml += data[i].school + '-' + data[i].degree
					} else if(!data[i].college && data[i].major && !data[i].degree) {
						showHtml += data[i].school + '-' + data[i].major
					} else if(data[i].college && !data[i].major && !data[i].degree) {
						showHtml += data[i].school + '-' + data[i].college
					}
					if(typeof(data[i].year) !== "undefined") {

						showHtml += '<small class="h6Font">' + data[i].year + '</small>';
					} else {
						showHtml += "";
					}
					showHtml += "</div></li>";
					$("#eduBgShow").append(showHtml);
				}
			}
		}
		var timeJobShow = function(data) {

			if(data.length > 0) {
				for(var i = 0; i < data.length; i++) {
					var sDate = "";
					var eDate = "";
					if(data[i].department) {
						var dep = "-" + data[i].department;
					} else {
						var dep = ""
					}
					if(data[i].startMonth) {
						sDate = data[i].startMonth.substr(0, 4) + "-" + data[i].startMonth.substr(4, 6) + "-";
						if(data[i].stopMonth) {
							eDate = data[i].stopMonth.substr(0, 4) + "-" + data[i].stopMonth.substr(4, 6);
						} else {
							eDate = "至今";
						}
					}
					var JobHtml = '<li>';
					JobHtml += '<div class="h4Font h4tit">' + data[i].company + '-' + data[i].title + '' + dep + '<small class="h6Font">' + sDate + '' + eDate + '</small></div>';
					JobHtml += '</li>';

					$("#timeJobShow").append(JobHtml);
				}
			}
		}

		var projectShow = function(data) {
			if(data.length > 0) {
				for(var i = 0; i < data.length; i++) {
					if(!data[i].descp) {
						data[i].descp = "";
					}
					if(!data[i].startMonth) {
						data[i].startMonth = '';
						data[i].stopMonth = '';
					} else {
						data[i].startMonth = data[i].startMonth.substr(0, 4) + "-" + data[i].startMonth.substr(4, 6) + "-"
						if(!data[i].stopMonth) {
							data[i].stopMonth = '至今';
						} else {
							data[i].stopMonth = data[i].stopMonth.substr(0, 4) + "-" + data[i].stopMonth.substr(4, 6)
						}
					}
					var projectHtml = '<li class="paddingSpace">';
					projectHtml += '<div class="h4Font h4tit">' + data[i].name + '<small class="h6Font">' + data[i].startMonth + '' + data[i].stopMonth + '</small></div>';
					projectHtml += '<div class="h5Font pIndent">' + data[i].descp + '</div>';
					projectHtml += '</li>';

					$("#projectShow").append(projectHtml);
				}
			}
		}

		var paperShow = function(data) {
			if(data.length > 0) {
				for(var i = 0; i < data.length; i++) {
					if(!data[i].year) {
						data[i].year = "";
					}
					if(!data[i].descp) {
						data[i].descp = "";
					}
					if(!data[i].url) {
						data[i].url = "";
					}
					var paperHtml = '<li class="paddingSpace">';
					paperHtml += '<div class="h4Font h4tit">' + data[i].name + '<small class="h6Font">' + data[i].year + '</small></div>';
					paperHtml += '<div class="h5Font pIndent">' + data[i].descp + '</div>';
					paperHtml += '</li>';

					$("#paperShow").append(paperHtml);

				}
			}
		}

		var patentShow = function(data) {
			if(data.length > 0) {
				for(var i = 0; i < data.length; i++) {
					if(!data[i].year) {
						data[i].year = "";
					}
					if(!data[i].descp) {
						data[i].descp = "";
					}
					if(!data[i].url) {
						data[i].url = "";
					}
					var patentHtml = '<li class="paddingSpace">';
					patentHtml += '<div class="h4Font h4tit">' + data[i].name + '<small class="h6Font">' + data[i].year + '</small></div>';
					patentHtml += '<div class="h5Font pIndent">' + data[i].descp + '</div>';
					patentHtml += '</li>';

					$("#patentShow").append(patentHtml);

				}
			}
		}

		var honorShow = function(data) {
			if(data.length > 0) {
				for(var i = 0; i < data.length; i++) {
					if(!data[i].year) {
						data[i].year = "";
					}
					if(!data[i].descp) {
						data[i].descp = "";
					}
					var honorHtml = '<li class="paddingSpace">';
					honorHtml += '<div class="h4Font h4tit">' + data[i].name + '<small class="h6Font">' + data[i].year + '</small></div>';
					honorHtml += '<div class="h5Font pIndent">' + data[i].descp + '</div>';
					honorHtml += '</li>';

					$("#honorShow").append(honorHtml);

				}
			}
		}
		var researchAreaShow = function($datas, $datarecords) {
			if($datas != undefined && $datas.length != 0) {
				var html = [];
				for(var i = 0; i < $datas.length; ++i) {
					var $data = $datas[i];
					var $photos = [];
					//获取头像					
					if($datarecords.length > 0) {
						$photos = getRecords($datarecords, $data.caption);
					}
					var isAgree = -1;
					for(var j = 0; j < $photos.length; j++) {
						if(userid == $photos[j].id)
							isAgree++;
					}
					if(professorId != userid) {
						if(isAgree) {
							var showDiv = "<div class='listbox listbox-browse clear'><div class='list-browse favorBox' caption='" + $data.caption + "'><span class='like'>" + $data.count + "</span>" + $data.caption + "</div><span class='plus ' data-pid='" + $data.professorId + "' data-caption='" + $data.caption + "' data-isagree='" + isAgree + "' ></span><div class='like-num favorBox' caption='" + $data.caption + "'>";
						} else {
							var showDiv = "<div class='listbox listbox-browse clear'><div class='list-browse favorBox' caption='" + $data.caption + "'><span class='like'>" + $data.count + "</span>" + $data.caption + "</div><span class='plus' style=' background-position-y:-26px' data-pid='" + $data.professorId + "' data-caption='" + $data.caption + "' data-isagree='" + isAgree + "' ></span><div class='like-num favorBox' caption='" + $data.caption + "'>";
						}
					} else {
						var showDiv = "<div class='listbox listbox-browse clear'><div class='list-browse favorBox' caption='" + $data.caption + "'><span class='like'>" + $data.count + "</span>" + $data.caption + "</div><div class='like-num favorBox' caption='" + $data.caption + "'>";
					}
					if($photos.length < 6) {
						for(var j = 0; j < $photos.length; ++j) {
							if($photos[j].img) {
								showDiv += "<span class='like-people userRadius'><img class='like-h' src='../images/head/" + $photos[j].id + "_s.jpg'></span>";
							} else {
								showDiv += "<span class='like-people userRadius'><img class='like-h' src='../images/default-photo.jpg'></span>";
							}
						}
					} else {
						for(var j = $photos.length - 5; j < $photos.length; ++j) {
							if($photos[j].img) {
								showDiv += "<span class='like-people userRadius'><img class='like-h' src='../images/head/" + $photos[j].id + "_s.jpg'></span>";
							} else {
								showDiv += "<span class='like-people userRadius'><img class='like-h' src='../images/default-photo.jpg'></span>";
							}
						}
						showDiv += "<span class='like-people like-more userRadius'></span>";
					}
					showDiv += "</div></div></div>";
					html.push(showDiv);
				}
				document.getElementById("researchAreaShow").innerHTML = html.join('');
			}
		}
		var getRecords = function($researchAreaLogs, caption) {
			var ret = [];
			var t = 0;
			for(var i = 0; i < $researchAreaLogs.length; i++) {
				if(caption == $researchAreaLogs[i].caption) {
					ret[t] = {
						id: $researchAreaLogs[i].opreteProfessorId,
						img: $researchAreaLogs[i].hasHeadImage
					}
					t++;
				}
			}
			return ret;
		}
		var clFlag = 1;
		$("#researchAreaShow").on("click", ".plus", function() {
				if(userid && userid != null && userid != "null") {
					//点赞变化样式
					if(clFlag) {
						clFlag = 0;
					} else {
						return;
					}
					if($(this).data("isagree") > -1) {
						$(this).stop(true, true).animate({
							backgroundPositionY: 0
						}, 300); //变成未点赞样式
					} else {
						$(this).stop(true, true).animate({
							backgroundPositionY: -26
						}, 300); //变成点赞样式
					}

					$.ajax({
						"url": $(this).data("isagree") > -1 ? "/ajax/researchArea/unAgree" : "/ajax/researchArea/agree",
						"type": "POST",
						"data": {
							"targetId": $(this).data("pid"),
							"targetCaption": $(this).data("caption"),
							"opId": userid
						},
						"contentType": "application/x-www-form-urlencoded",
						"success": function($data) {
							if($data.success) {
								$.get("/ajax/professor/info/" + professorId, function($data) {
									if($data.success) {
										clFlag = 1;
										var $info = $data.data;
										if($info) {
											$("#researchAreaShow").empty("")
											if($info.researchAreas) {
												researchAreaShow($info.researchAreas, $info.editResearchAreaLogs);
											}
										}

									}
								})
							} else {
								$.MsgBox.Alert("message", $data.msg);
							}
						}
					});
				} else {
					$.MsgBox.Alert("消息", "请登录后点赞");
					/*location.href="login.html"*/
				}

			})
			/*研究方向点赞列表*/
			//关闭按钮
		$("#workclose").click(function() {
			$(".resAreaCover").fadeOut();
		    $("body").css("position", "");
		});
		$("#researchAreaShow").on("click", ".list-browse,.like-num", function() {
			var cap = $(this).attr("caption");
			//console.log(cap.length);
			$.ajax({
				url: "/ajax/researchAreaLog/ql",
				dataType: 'json', //数据格式类型
				type: 'GET', //http请求类型
				timeout: 10000, //超时设置
				data: {
					"professorId": professorId,
					'caption': cap,
					"rows": 10
				},
				success: function(data) {
					if(data.success) {
						$(".attentList").html("");
						var $info = data.data;
						$("#subArea").text(cap);
						$(".resAreaCover").fadeIn();
						$(".resAreaCon").show()
						if($info.length == 0) {
							$(".resAreaCon").hide();
							return;
						}
						for(var i = 0; i < $info.length; i++) {
							if($info[i].professor.hasHeadImage == 1) {
								var img = "/images/head/" + $info[i].professor.id + "_l.jpg";
							} else {
								var img = "../images/default-photo.jpg";
							}
							//认证
							var oSty=autho($info[i].professor.authType,$info[i].professor.orgAuth,$info[i].professor.authStatus);
							
							var title = "",
								office = "",
								orgName = "",
								address = '';
							if($info[i].professor.title && $info[i].professor.office && $info[i].professor.orgName && $info[i].professor.address) {
								title = $info[i].professor.title + ",";
								office = $info[i].professor.office + ",";
								orgName = $info[i].professor.orgName + " | ";
								address = $info[i].professor.address;
							} else if(!$info[i].professor.title && $info[i].professor.office && $info[i].professor.orgName && $info[i].professor.address) {
								office = $info[i].professor.office + ",";
								orgName = $info[i].professor.orgName + " | ";
								address = $info[i].professor.address;
							} else if($info[i].professor.title && !$info[i].professor.office && $info[i].professor.orgName && $info[i].professor.address) {
								title = $info[i].professor.title + ",";
								orgName = $info[i].professor.orgName + " | ";
								address = $info[i].professor.address;
							} else if($info[i].professor.title && $info[i].professor.office && !$info[i].professor.orgName && $info[i].professor.address) {
								title = $info[i].professor.title + ",";
								office = $info[i].professor.office + " | ";
								address = $info[i].professor.address;
							} else if($info[i].professor.title && $info[i].professor.office && $info[i].professor.orgName && !$info[i].professor.address) {
								title = $info[i].professor.title + ",";
								office = $info[i].professor.office + ",";
								orgName = $info[i].professor.orgName;
							} else if(!$info[i].professor.title && !$info[i].professor.office && $info[i].professor.orgName && $info[i].professor.address) {
								orgName = $info[i].professor.orgName + " | ";
								address = $info[i].professor.address;
							} else if(!$info[i].professor.title && $info[i].professor.office && !$info[i].professor.orgName && $info[i].professor.address) {
								office = $info[i].professor.office + " | ";
								address = $info[i].professor.address;
							} else if(!$info[i].professor.title && $info[i].professor.office && $info[i].professor.orgName && !$info[i].professor.address) {
								office = $info[i].professor.office + ",";
								orgName = $info[i].professor.orgName;
							} else if($info[i].professor.title && !$info[i].professor.office && !$info[i].professor.orgName && $info[i].professor.address) {
								title = $info[i].professor.title + " | ";
								address = $info[i].professor.address;
							} else if($info[i].professor.title && !$info[i].professor.office && $info[i].professor.orgName && !$info[i].professor.address) {
								office = $info[i].professor.title + ",";
								address = $info[i].professor.orgName;
							} else if($info[i].professor.title && $info[i].professor.office && !$info[i].professor.orgName && !$info[i].professor.address) {
								title = $info[i].professor.title + ",";
								office = $info[i].professor.office;
							} else if(!$info[i].professor.title && !$info[i].professor.office && !$info[i].professor.orgName && $info[i].professor.address) {
								address = $info[i].professor.address;
							} else if(!$info[i].professor.title && !$info[i].professor.office && $info[i].professor.orgName && !$info[i].professor.address) {
								orgName = $info[i].professor.orgName;
							} else if(!$info[i].professor.title && $info[i].professor.office && !$info[i].professor.orgName && !$info[i].professor.address) {
								office = $info[i].professor.office;
							} else if($info[i].professor.title && !$info[i].professor.office && !$info[i].professor.orgName && !$info[i].professor.address) {
								title = $info[i].professor.title;
							}
							var addw = '<li data-id="'+$info[i].professor.id+'" style="cursor:pointer">'
							addw += '<a class="proinfor clearfix">'
							addw += '<div class="headblock floatL"><img id="proHead" class="headimg userRadius" src="' + img + '"></div>'
							addw += '<div class="mediaBody">'
							addw += '<span class="listtit"><span id="proName">' + $info[i].professor.name + '</span><em class="authiconNew ' + oSty.sty + '" title="'+ oSty.title +'"></em></span>'
							addw += '<div class="listtit2">' + title + office + orgName + address + '</div>'
							addw += '</div></a></li>'

							$(".attentList").append(addw);
						}
						
					    $("body").css("position", "fixed");
					}
				},
				error: function() {}
			});
		});
/*研究方向点赞点击每一个点赞的用户进入点赞用户的浏览页面*/
$(".attentList").on("click","li",function(){
	var opid=$(this).attr("data-id");
	location.href="information-brow.html?professorId="+opid;
})
		$.get("/ajax/professor/info/" + professorId, function($data) {
			if($data.success) {
				var $info = $data.data;
				orgId=$info.orgId;
				orgAuth=$info.orgAuth;
				if(orgAuth==1){
					$("#orgNameS").css("cursor","pointer");
				}
				if($info) {
					if($info.authType == 1) {
						$(".yesshow").show();
						if(ass == 0){
							$('span:contains("合作历史及评价")').parents(".introduction").hide();
						}
						if(resou == 0 && ass == 0) {
								$('div:contains("合作机会")').parents(".menublock").hide();
							}
					} else {
						if($info.authentication == 3) {
							$("#office").hide();
							$("#titleS").hide();
						}
					}
					//修改浏览器title信息
					if($info.title) {
						var qtitle = " - " + $info.title;
					} else {
						var qtitle = "";
					}
					if($info.office) {
						var qoffice = " - " + $info.office;
					} else {
						var qoffice = "";
					}

					var llqtitle = $info.name + qtitle + qoffice + "-" + $info.orgName + "-科袖网";
					window.setInterval(function() {
						document.title = llqtitle;
					}, 500);

					//展示专家的信息
					//认证
					var oStyS=autho($info.authType,$info.orgAuth,$info.authStatus);
					$(".proModify").addClass(oStyS.sty);
					$(".proModify").attr("title",oStyS.title);
					
					$("#nameS").text($info.name);
					if($info.office) {
						if($info.title) {
							$("#office").text($info.office + ",");
						} else {
							$("#office").text($info.office);
						}

					}
					if($info.title) {
						$("#titleS").text($info.title);
					}
					if($info.department) {
						if($info.orgName) {
							$("#industryS").text($info.department + ",");
						} else {
							$("#industryS").text($info.department);
						}
					}
					if($info.orgName) {
						$("#orgNameS").text($info.orgName);
					}
					if($info.address) {
						$("#address").text($info.address);
					}
					if($info.hasHeadImage) {
						$("#headImage").attr("src", "/images/head/" + professorId + "_l.jpg");
					} else {
						$("#headImage").attr("src", "/images/default-photo.jpg");
					}
					$("#orgImage").attr("src", "/images/org/" + $info.orgId + ".jpg");
					$("#orgImage").load(function() {})
						.error(function() {
							$("#orgImage").attr("src", "/images/default-icon.jpg");
						});
					//显示专家信息到保存数据
					name = $info.name;
					if($info.descp == undefined && $info.subject == undefined && $info.researchAreas.length == 0 && $info.industry == undefined && $info.edus.length == 0 && $info.jobs.length == 0 && $info.projects.length == 0 && $info.papers.length == 0 && $info.patents.length == 0 && $info.honors.length == 0) {
						$("div:contains('个人信息')").parents(".menublock").hide();
					}
					if($info.descp) {
						$("#descpS").text($info.descp);
					} else {
						$("span:contains('个人简介')").parents(".introduction").hide();
						$("a:contains('个人简介')").hide();
					}
					//展示专家的学科	
					//alert($info.authentication);
					if($info.authType == 1) {
						if($info.subject) {
							subjectShow($info.subject);
						} else {
							$("span:contains('学术领域')").parents(".introduction").hide();
							$("a:contains('学术领域')").hide();
						}
					} else {
						if($info.authentication == 1) {
							if($info.subject) {
								subjectShow($info.subject);
							} else {
								$("span:contains('学术领域')").parents(".introduction").hide();
								$("a:contains('学术领域')").hide();
							}
						} else {
							$("span:contains('学术领域')").parents(".introduction").hide();
							$("a:contains('学术领域')").hide();
						}
					}

					//研究方向	
					if($info.authType == 1) {
						if($info.researchAreas.length) {
							researchAreaShow($info.researchAreas, $info.editResearchAreaLogs);
						} else {
							$("span:contains('研究方向')").parents(".introduction").hide();
							$("a:contains('研究方向')").hide();
						}
					} else {
						$("span:contains('研究方向')").parents(".introduction").hide();
						$("a:contains('研究方向')").hide();
					}

					//展示专家的行业
					if($info.authType == 1) {
						if($info.industry) {
							industryShow($info.industry);
						} else {
							$("span:contains('应用行业')").parents(".introduction").hide();
							$("a:contains('应用行业')").hide();
						}
					} else {
						if($info.authentication == 2) {
							if($info.industry) {
								industryShow($info.industry);
							} else {
								$("span:contains('应用行业')").parents(".introduction").hide();
								$("a:contains('应用行业')").hide();
							}
						} else {
							$("span:contains('应用行业')").parents(".introduction").hide();
							$("a:contains('应用行业')").hide();
						}
					}

					//教育北京						
					if($info.edus.length) {
						eduBgShow($info.edus);
					} else {
						$("span:contains('教育背景')").parents(".introduction").hide();
						$("a:contains('教育背景')").hide();
					}
					//兼职
					if($info.jobs.length) {
						timeJobShow($info.jobs);
					} else {
						$("span:contains('工作经历')").parents(".introduction").hide();
						$("a:contains('工作经历')").hide();
					}
					//项目
					if($info.projects.length) {
						projectShow($info.projects)
					} else {
						$("span:contains('项目经历')").parents(".introduction").hide();
						$("a:contains('项目经历')").hide();
					}

					//论文
					if($info.papers.length) {
						paperShow($info.papers);
					} else {
						$("span:contains('著作、论文、文章')").parents(".introduction").hide();
						$("a:contains('著作、论文、文章')").hide();
					}
					//专利
					if($info.patents.length) {
						patentShow($info.patents);
					} else {
						$("span:contains('专利')").parents(".introduction").hide();
						$("a:contains('专利')").hide();
					}
					//荣誉
					if($info.honors.length) {
						honorShow($info.honors);
					} else {
						$("span:contains('荣誉及奖项')").parents(".introduction").hide();
						$("a:contains('荣誉及奖项')").hide();
					}
//下滑滚动不覆盖底部 
	var d;
	var t;
	$(function() {
		var art_height;
		var isHidden=$("#reA").is(":hidden");//是否隐藏
		if(isHidden) {
			art_height=0;
		}else{
			art_height=$("#reA").outerHeight(true);
		}
		
		$(document).scroll(function() {
			var top3 = $(window).height();
			var top5 = $(".content-left").height();
			var top4 = $("#container").height() + art_height;
			//console.log(top5+","+top4+","+top3);
			var top1 = $(document).scrollTop();
			var top2 = $("#container").height() - top3 + (top3 - 80 - top5) - 10; //变成绝对定位	
			if(top1 >= 300) {
				$(".content-left").css({
					"position": "fixed",
					"top": "80px"
				});
				if(top1 >= top2) {
					$('.information-content').css("position", "static");
					$(".content-left").css("position", "absolute");
					$(".content-left").css("top", top4 - top5 - 10 + "px");
				} else {
					$('.information-content').css("position", "relative");
					$(".content-left").css({
						"position": "fixed",
						"top": "80px"
					});
				}
			} else {
				$(".content-left").css({
					"position": "static"
				});
			}

			//咨询框弹出
			var foot_height = $(".footerblock").height();
			if(top1 >= 180 && top1 < top4 - top3) {
				$(".coulstblock").slideDown();
				$(".coulstblock").css({
					"bottom": "0"
				});
			} else if(top1 >= top4 - top3) {
				$(".coulstblock").css({
					"bottom": -(top4 - top3 - top1 ) - art_height + "px"
				});
			} else {
				$(".coulstblock").slideUp();
				$(".coulstblock").css({
					"bottom": "0"
				});
			}

		})
	});
	//下滑滚动不覆盖底部 结束

				}
			}
		});
	}
	$("#hsearch").on("click", function() {
		var searchContent = $("#hsearchContent").val();
		location.href = "search.html?searchContent=" + searchContent;
	});

	
	
	//拿到点击的顺序,然后求出局文档的距离
	$(".subsidebar").mouseenter(function(){
		var dd=$(this)[0].className;
		if(dd!="subsidebar subcolor"){
			$(this).css("background","#efefef");
		}
	}).mouseleave(function(){
		$(this).css("background","")
	});
	//专家信息点击换背景颜色
	$(".subsidebar").click(function() {
		$(".subsidebar").removeClass("subcolor");
		$(".subsidebar").eq($(".subsidebar").index(this)).addClass("subcolor");
	});
	$(".subsidebar").click(function() {
		var index = $(".subsidebar").index(this)+1;
        //console.log(index)
		var offset = $(".introduction").eq(index).offset();
		$("body,html").animate({
			scrollTop: offset.top - 80 + "px" //��body��scrollTop����pos��top����ʵ���˹��� 
		}, 1000);
	}).mousedown(function(){
	  	$(this).css("background","");
	});
	
	
	/*科研文章*/
	$.ajax({
		url: "/ajax/article/qaPro",
		dataType: 'json', //数据格式类型
		type: 'GET', //http请求类型
		data: {
			"professorId": professorId
		},
		timeout: 10000, //超时设置
		success: function(data) {
			if(data.success) {
				var pp=ifUserType(professorId)
				if(!pp.authType2) {
					$("#reA").hide();
					return;
				} else {
					if(data.data.length == 0) {
						$("#reA").hide();
						return;
					}
					$("#reA").show();
					for(var i = 0; i < data.data.length; i++) {
						var add = '<li><a href="articalShow.html?articleId=' + data.data[i].articleId  + '" style="display:block;">'
						add += '<div class="art_topicBox"><div class="art_img" style=""></div>'
						add += '<div class="art_tbox"><h6 id="artical_topic" >' + data.data[i].articleTitle + '</h6></div>'
						add += '</div><div class="tagsBox"><span></span></div>'
						add += '</a></li>';
						$add = $(add);
						$("#reachArticle").append($add);
						$add.find('.tagsBox span').text(data.data[i].industry); //data.data[i].subject
						if(data.data[i].articleImg) {
							$add.find(".art_img").attr("style", "background: url(/data/article/" + data.data[i].articleImg + ") 0 0 no-repeat;background-size:cover;");
						}

					}
					//资源轮播
					var $content2 = $(".sharescrollbox.Acrollbox");
					var childcount2 = $content2.find(".otherRes.shareshow li").length;
					Carousel(3, 3, 3, childcount2, $content2, $(".articalbtn.resounext"), $(".articalbtn.resouprev"));
				}
			}
		},
		error: function() {
			return;
		}
	});
	var resou;
	
	//科研资源
	$.ajax({
		"url": "/ajax/resource/qapro",
		"type": "get",
		"async": false,
		"data": {
			"professorId": professorId
		},
		"success": function(data) {
			if(data.success) {
				var pp=ifUserType(professorId)
				if(!pp.authType2) {
					$("span:contains('研发资源')").parents(".introduction").hide();
					return;
				} else {
					resou = data.data.length;
					if(data.data.length == 0) {
						$("#infor-browse").css("display", "none");
						$("span:contains('研发资源')").parents(".introduction").hide();
						$("a:contains('研发资源')").hide();
						return;
					} else {
						$("span:contains('研发资源')").parents(".introduction").show();
					}
					if(data.data.length > 3) {
						$("#infor-browse").css("display", "block");
						$(".resoubtn").css("display", "block");
					}

					var add = "";
					for(var i = 0; i < data.data.length; i++) {
						add = '<div class="sharesrc">'
						add += '<div class="shareshow">'
						add += '<a href="resourceShow.html?resourceId=' + data.data[i].resourceId + '"class="remess" style="display:block;" resourceId=' + data.data[i].resourceId + '>'
						add += '<div class="ResImgBox" style="max-width:200px;width:200px;height: 200px;">'
						add += '<img class="resImg headRadius resourceImg" src="/images/resource/' + data.data[i].resourceId + '.jpg" />'
						add += '</div></a>'
						add += '<div class="shareopeart"><a class="sharebtn resourceConsult" professorId=' + data.data[i]["professorId"] + '>咨询</a><a class="sharebtn applicant" style="display:none">申请</a></div>'
						add += '</div>'
						add += '<p class="restit ellipsisSty">资源名称:<span class="presou consultTitleVal" resourceConsultTitle = "">' + data.data[i].resourceName + '</span></p>'
						add += '<p class="briefinfor ellipsisSty-2">应用用途:' + data.data[i].supportedServices + '</p>'
						add += '</div>'
						$("#sharescrollbox").append(add);
						$('.applicant').eq(i).attr("resourceId", data.data[i].resourceId);

						$(".resourceImg").eq(i).attr("src", "/images/resource/" + data.data[i].resourceId + ".jpg");
						$(".resourceImg").load(function() {})
							.error(function() {
								$(this).attr("src", "/images/default-resource.jpg");
							});

						add = "";
					}
					//资源轮播
					var $content = $("#sharescrollbox");
					var childcount = $content.find(".sharesrc").length;
					Carousel(3, 3, 3, childcount, $content, $(".resoubtn2.resounext"), $(".resoubtn2.resouprev"));
					//科研资源中点咨询
					$(".introduction").find(".resourceConsult").bind("click", clickResourceConsult);
				}

			} else {
				$.MsgBox.Alert("消息", "系统异常!");
			}
		},
		"error": function() {
			$.MsgBox.Alert('message', 'failddd')
		}
	});

	function getIdentity(professorId) {
		$.ajax({
			"url": "ajax/professor/" + professorId,
			"type": "get",
			"async": false,
			"success": function(data) {
				if(data.success) {
					//console.log(data);
					$("option")[0].value = data.data.name;
					$("option")[1].value = data.data.organization.name;
					//console.log($("option")[0].value);
					//console.log($("option")[1].value);
				} else {
					$.MsgBox.Alert("消息", "系统异常!");
				}
			},
			"error": function() {
				$.MsgBox.Alert('message', 'failddd')
			}
		})
	}
	//资源申请入口
	$('.introduction').on("click", '.applicant', function() {
		if(userid && userid != null && userid != "null") {
			ResourceApply(); //调用资源申请HTML创建函数
			$(".limitBox").removeClass("limitBox");
			$(".limitwords").removeClass("limitwords");
			$(".limitwordbox").removeClass("limitwordbox");
			//获取当前时间并且格式化时间
			var myDate = new Date();
			var nowYear = myDate.getFullYear();
			var nowMonth = myDate.getMonth() + 1;
			var nowDate = myDate.getDate();
			if(nowMonth < 10) {
				nowMonth = "0" + nowMonth.toString();
			}
			if(nowDate < 10) {
				nowDate = "0" + nowDate.toString();
			}
			var now = nowYear + "-" + nowMonth + "-" + nowDate;
			$("#datepicker").val(now);
			$("#datepicker").datepicker({
				"dateFormat": " yy-mm-dd"
			});
			$(".timelo").css("display", "none");
			$(".namecon").text(name);
			$(".applysure").hide();
			$(".btnboxup").hide();
			var index1 = $(this).parent().parent().parent().index();
			var resName = $('.presou').eq(index1).text();
			var resourceID = $(this).attr("resourceId");
			$.ajax({
				"url": "/ajax/resource/" + resourceID,
				"type": "get",
				"async": false,
				"success": function(info) {
					if(info.success) {
						if(info.data.images.length) {
							$(".resouImage").attr("src", "/images/resource/" + resourceID + ".jpg");
						} else {
							$(".resouImage").attr("src", "/images/default-resource.jpg");
						}
					}
				}
			})
			$(".log").text(resName);
			getIdentity(userid);
			$("#deliver").on("click", function() {

				var $data = {};
				$data.demandId = userid;
				$data.resourceId = resourceID;
				$data.detailDemand = $(".detail").val();
				//去除时间里面的-  和字符串前后的空格
				$data.deliverTime = replaceStr($.trim($(".dealTime").val()));
				//alert(replaceStr($.trim($(".dealTime").val())));
				//alert(replaceStr($.trim($(".dealTime").val())).length);

				$data.operationStatus = 1;
				$data.applysquare = $("select option:selected").val();
				//console.log($data.applysquare);

				$.ajax({
					"url": "/ajax/operation",
					"type": "POST",
					"success": function(rdata) {
						if(rdata.success) {
							$.MsgBox.Alert('message', '资源"' + resName + '"申请发送成功!');
							$("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
							$(".blackcover").remove();
							$("body").css("position", "");
							//location.reload(true);
						} else {
							$.MsgBox.Alert('message', '资源"' + resName + '"申请发送失败,请重新申请!');
						}
					},
					"data": $data,
					"beforeSend": function() { /*console.log(this.data)*/ },
					"contentType": "application/x-www-form-urlencoded",
					dataType: "json"
				});
			});
		} else {
			$.MsgBox.Alert("消息", "您还未登录,请登录之后进行资源申请");
		}
	});

	//科研资源中的咨询
	function clickResourceConsult() {
		if(userid && userid != null && userid != 'null' && userid != undefined && userid != 'undefined') {
			var professorId = $(this).attr("professorId");
			consultHandler();

			var liEle = $("ul.menucon").children();

			for(var i = 0; i < liEle.length; i++) {
				$(liEle[i]).removeClass('clicknow');
				$(liEle[1]).addClass("clicknow");
			};
			var item = $(this).parent().parent().parent();

			var consultTitleVal = item.find(".consultTitleVal").text();
			$("#consultTitle").val("关于" + consultTitleVal + "的咨询");
		} else {
			$.MsgBox.Alert("消息提醒", "请先登录再进行咨询");
			$("#mb_btn_ok").val("去登录");

			var aele = document.createElement('a');
			$("#mb_btnbox").append(aele);
			$("#mb_btnbox a").css({
				'display': "block",
				'width': '100%',
				'height': '40px',
				'position': 'absolute',
				'bottom': '-6px',
				'left': '0'
			});
			aele.setAttribute('href', '../login.html');
		}

	};

	//===============点击咨询==============
	var userid = $.cookie("userid"); //登陆人id====重复代码
	var professorId = GetQueryString("professorId"); //专家id====重复代码
	//点击科研资源的咨询
	$("#consultbtn,#conbtn").bind('click', consultHandler);

	function consultHandler() {
		if(userid && userid != null && userid != 'null' && userid != undefined && userid != 'undefined') {
			ConsultApply();
			concultProInfo(professorId);
			//点击的发送
			$("#sendConsultBtn").click(function() {
				sendConsultHandler($(this).attr("proId"));
			});
		} else {
			$.MsgBox.Alert("消息提醒", "请先登录再进行咨询");
			$("#mb_btn_ok").val("去登录");
			var aele = document.createElement('a');
			$("#mb_btnbox").append(aele);
			$("#mb_btnbox a").css({
				'display': "block",
				'width': '100%',
				'height': '40px',
				'position': 'absolute',
				'bottom': '-6px',
				'left': '0'
			});
			aele.setAttribute('href', '../login.html');

		}

	};
	//合作历史及评价
	var ass;
	$.ajax({
		"url": "/ajax/consult/pqAssessHis",
		"type": "get",
		"data": {
			"professorId": professorId
		},
		"async": false,
		"success": function(response) {
			if(response.success) {
				var $data = response.data.data;
				ass = $data.length;
				if($data.length == 0) {
					$("span:contains('合作历史及评价')").parents(".introduction").hide();
					$("a:contains('合作历史及评价')").hide();
				}
				for(var i = 0; i < $data.length; i++) {
					var add = "";
					var assessTime = $data[i]["assessTime"].substr(0, 4) + "-" + $data[i].assessTime.substr(4, 2) + "-" + $data[i].assessTime.substr(6, 2) + " " +
						$data[i].assessTime.substr(8, 2) + ":" + $data[i].assessTime.substr(10, 2);
					add += '<div class="evaluate2">'
					add += '<div class="lefteva">'
					add += '<a  class="evaimg userRadius">'
					if($data[i].professor.hasHeadImage) {
						add += '<img src="/images/head/' + $data[i].professor.id + '_l.jpg" width="100%" height="100%">'
					} else {
						add += '<img src="/images/default-photo.jpg" width="100%" height="100%">'
					}

					add += '</a>'
					add += '<p>' + $data[i].professor.name + '</p><p>'
						//                      if($data[i].professor.office) {
						//                      	 add+='<span>'+$data[i].professor.office+' ,</span>'
						//                      }
						//                     if($data[i].professor.title) {
						//                     	 add+='<span>'+$data[i].professor.title+'</span>'
						//                     }                     
					add += '</p><p>'
						//                      if($data[i].professor.department) {
						//                      	 add+='<span>'+$data[i].professor.department+' ,</span>'
						//                      }
						//                     if($data[i].professor.orgName) {
						//                     		add+='<span>'+$data[i].professor.orgName+'</span>'
						//                     }                            
					add += '</p>'
					add += '</div>'
					add += '<div class="righteva">'
					add += '<ul class="evasort">'
					add += '<li>咨询时间:<span>' + assessTime + '</span></li>'
					add += '</ul>'
					add += '<div class="evastarbox" id="evastarboxx" style="margin-left: -5px;">'
					add += '<span class="evastar"></span>'
					add += '<span class="evastar"></span>'
					add += '<span class="evastar"></span>'
					add += '<span class="evastar"></span>'
					add += '<span class="evastar"></span>'
					add += '</div>'
					if($data[i].assessContant) {
						add += '<p class="evabrief">' + $data[i].assessContant + ' </p>'
					}
					add += '</div>'
					add += '</div>'
					var $add = $(add);
					$(".shareabout2").append($add);
					$add.find(".evastar:lt(" + $data[i].assessStar + ")").addClass('staspan');
				}
				$(".evaluate2").eq($data.length - 1).css("border-bottom", "none");
			}
		}
	})
	proinfo(professorId);
	//底部咨询申请入口专家信息
	function proinfo(professorId) {
		$.ajax({
			url: "/ajax/professor/editBaseInfo/" + professorId,
			type: "get",
			data: {
				"id": professorId
			},
			contentType: "application/x-www-form-urlencoded",
			success: function(response) {

				var myData = response["data"];
				//console.log(myData);
				$("#foot_proname").html(myData["name"]);
				if(myData["address"]) {
					$("#foot_proaddress").html(' | ' + myData["address"]);
				}
				if(myData["title"]) {
					$("#foot_protitle").html(myData["title"]);
				}
				if(myData["department"]) {

					$("#foot_prodepar").html(myData["department"]);
				}
				if(myData["orgName"]) {
					if(myData["department"] == null || myData["department"] == '') {
						$("#foot_proorgname").html(myData["orgName"]);
					} else {
						$("#foot_proorgname").html(',' + myData["orgName"]);
					}
				}

				//认证
				var oStyT=autho(myData.authType,myData.orgAuth,myData.authStatus);
				$("#foot_promodify").addClass(oStyT.sty);
				$("#foot_promodify").attr("title",oStyT.title);

				//头像
				if(myData["hasHeadImage"] == 0) {
					$("#foot_proimg").attr("src", "images/default-photo.jpg");
				} else {
					$("#foot_proimg").attr("src", "images/head/" + myData["id"] + "_l.jpg");
				}

			},
			error: function(error) {
				$.MsgBox.Alert("message", "请求数据失败");
			}
		});
	}
/*点击机构名字进入企业浏览页面*/
$("#orgNameS").click(function(){
	if(orgAuth==1){
		location.href="companybrowinfor.html?orgId="+orgId;
	}
	
})
		
})