$(function() {
	var userid = $.cookie("userid");
	if(userid && userid != "null" && userid != null) {
		$(".myWorkspace").attr("href", "workspaces.html?" + userid);
		loginStatus();
	}

	//登陆个人信息下拉菜单
	$('.head-portrait').hover(function() {
		$(".personal-infor").stop(true, false).slideDown(500);
	}, function() {
		$(".personal-infor").stop(true, false).slideUp(500);
	});
	$(document).scroll(function() {
		var top = $(document).scrollTop();
		if(top != 0) {
			$(".searchbox").fadeIn(1000);

		} else {
			$(".searchbox").fadeOut(1000);
		}
	});
	var newc = GetQueryString("lookFor");
	if(newc == 0 || newc == "") {
		var c = 0;
	} else {
		var c = 1;
		// $(".lookwho option[value='1']").attr("selected","selected");
		$("#div_select").text("找资源");
	}
	/*
	 * var lookFor2 = 0; $("#lookFor2 ul li").on("click",function(){
	 * lookFor2=$(this).index(); }); //enter绑定时间
	 * $("#searchContent").keydown(function(e){ if(e.which==13) { synContent(2);
	 * synContent(1); var searchContent = $("#searchContent").val(); if(lookFor2 =
	 * 1){ $("#div_select").text("找资源"); location.href =
	 * "search.html?searchContent=" + encodeURI(searchContent); } }
	 *  })
	 */

	var userid = $.cookie("userid");
	var subject;
	var subb = $.trim(GetQueryString("subject"));
	var industry;
	var pageSize;
	var sub = "SUBJECT";
	var indu = "INDUSTRY";
	var address = $("#address .colorbg")[0].title;
	$("#searchContent").val(GetQueryString("searchContent"));
	$("#hsearchContent").val(GetQueryString("searchContent"));
	var key = $("#searchContent").val();
	var getData = function(key, subject, industry, pageSize, pageNo, isbind,
		add) {
		if(c == 0) {
			$
				.ajax({
					"url": "/ajax/professor/pqBaseInfo",
					"type": "GET",
					"data": {
						"key": key,
						"subject": subject,
						"industry": industry,
						"pageSize": pageSize,
						"pageNo": pageNo,
						"address": add
					},
					"contentType": "application/x-www-form-urlencoded",
					"success": function($data) {
						if($data.success) {
							// console.log($data);
							$("#professorList").html("");
							for(var i = 0; i < $data.data.data.length; i++) {
								// 创建HTML标签
								var dataHtml = "<div class='item'>";
								dataHtml += "<a  class='infoi'  href='information-brow.html?professorId=" +
									$data.data.data[i].id +
									"' ><div class='photo1 headRadius'>"
								if($data.data.data[i].hasHeadImage) {
									dataHtml += "<img class='images' style='width:100%;'  src='/images/head/" +
										$data.data.data[i].id +
										"_l.jpg'/></div></a>";
								} else {
									dataHtml += "<img class='images' style='width:100%;'  src='/images/default-photo.jpg'/></div></a>";
								}
								dataHtml += "<div class='synopsis'>";
								dataHtml += "<a href='javascript:void();' class='named'>";
								if(typeof($data.data.data[i].name) !== "undefined") {
									dataHtml += $data.data.data[i].name;
								}
								dataHtml += "</a><a href='information-brow.html?professorId=" +
									$data.data.data[i].id +
									"' class='modify'></a>";
								dataHtml += "<div class='position'>";
								if($data.data.data[i].office) {
									dataHtml += $data.data.data[i].office +
										", ";
								}
								if($data.data.data[i].title) {
									dataHtml += $data.data.data[i].title +
										", ";
								}
								if($data.data.data[i].department) {
									dataHtml += $data.data.data[i].department +
										", ";
								}
								if($data.data.data[i].orgName) {
									dataHtml += $data.data.data[i].orgName;
								}
								if($data.data.data[i].address) {
									dataHtml += " | " +
										$data.data.data[i].address;
								}
								dataHtml += "</div>";
								dataHtml += "<div class='ellipsisbox science'>";
								if(typeof($data.data.data[i].subject) !== "undefined") {
									dataHtml += "<p>学术领域：" +
										$data.data.data[i].subject +
										"</p>";
								}
								dataHtml += "</div>";
								dataHtml += "<div class='ellipsisbox industry'>";
								if(typeof($data.data.data[i].industry) !== "undefined") {
									dataHtml += "<p>应用行业：" +
										$data.data.data[i].industry +
										"</p>";
								}
								
								if($data.data.data[i].researchAreas.length) {
									dataHtml += "<p>研究方向：" 
									for(var m = 0; m < $data.data.data[i].researchAreas.length; m++) {
										dataHtml += $data.data.data[i].researchAreas[m].caption;
										if(m<$data.data.data[i].researchAreas.length-1){
											dataHtml += " , "
										}
									}	
									dataHtml += "</p>";
								}
								
								dataHtml += "</div>";
								dataHtml += "</div>";
								if($data.data.data[i].id != userid) {
									dataHtml += "<div class='operbox'><span class='operbtn onlyConsultbtn' id='" +
										$data.data.data[i]['id'] +
										"'>咨询</span></div>";
								}
								var $datahtml = $(dataHtml);
								$("#professorList").append(dataHtml);
								var photoHeight = $(".photo1").eq(i).height();
								var middleHeight = $(".synopsis").eq(i).height();
								if(middleHeight < photoHeight) {
									$(".synopsis").eq(i).height(photoHeight);
								}
								if($data.data.data[i].authType) {
									$(".modify").eq(i).addClass("authicon authicon-cu");
								} else {
									if($data.data.data[i].authStatus==3) {
										if($data.data.data[i].authentication == 1) {
											$(".modify").eq(i).addClass("authicon2 authicon-mana");
											//$(".modify").eq(i).html("<span>科研</span>");										
										} else if($data.data.data[i].authentication == 2) {
											$(".modify").eq(i).addClass("authicon2 authicon-staff");
											//$(".modify").eq(i).html("<span>企业</span>");										
										} else {
											$(".modify").eq(i).addClass("authicon2 authicon-stu");
											//$(".modify").eq(i).html("<span>学生</span>");										
										}
									}
								}
								// 点击查看当前信息
								(function(i) {
										$('.synopsis')
											.eq(i)
											.click(
												function() {
													location.href = 'information-brow.html?professorId=' +
														$data.data.data[i].id;
												})
									}

								)(i);

							}
							//找专家点击咨询
							$(".onlyConsultbtn").bind("click", clickSeachProConsultHandler);

							if(isbind == true) {
								$(".tcdPageCode").createPage({
									pageCount: Math.ceil($data.data.total / pageSize),
									current: $data.data.pageNo,
									backFn: function(p) {
										getData(key, subject, industry, pageSize, p, false);
									}
								});
							}

						} else {
							$.MsgBox.Alert("message", $data.msg);
						}
					}
				});
		} else {
			//查询我的所有资源
			$.ajax({
				"url": "/ajax/resource/pq",
				"type": "get",
				"data": {
					"key": key,
					"subject": subject,
					"industry": industry,
					"pageSize": pageSize,
					"pageNo": pageNo,
					"address": add
				},
				"contentType": "application/x-www-form-urlencoded",
				"success": function(data) {
					console.log(data);
					if(data.success) {
						$("#professorList").html("");
						var $da = data.data.data;
						for(var i = 0; i < $da.length; i++) {
							var add = '<div class="item"><div class="remess" resourceId=' + $da[i].resourceId + '>'
							add += '<div class="clearfix"><a class="resourcephoto headRadius" ><div class="ResImgBox" style="background:#ffffff;"><img class="resImg headRadius resourceImg" src="" /></div></a>'
							add += '<div class="synopsis" style="width:66%;">'
							add += '<div class="cousultName"><a class="resouname" href="javascript:void();">' + $da[i].resourceName + '</a></div>'
							if($da[i].editProfessor.name) {
								add += '<div class="belongname"><a style="float:left;display:block;">' + $da[i].editProfessor.name + '</a><a class="modicon" style="display:block;top:2px;left:2px;"></a></div>'
							}
							if($da[i].editProfessor.title == undefined) {
								$da[i].editProfessor.title = "";
							}
							if($da[i].editProfessor.department == undefined) {
								$da[i].editProfessor.department = "";
							}
							if($da[i].editProfessor.orgName == undefined) {
								$da[i].editProfessor.orgName = "";
							}
							add += '<div style="clear:both"></div><div class="positionbox">'
							if($da[i].editProfessor.title && $da[i].editProfessor.department && $da[i].editProfessor.orgName) {
								add += $da[i].editProfessor.title + "," + $da[i].editProfessor.department + "," + $da[i].editProfessor.orgName;
							} else if(!$da[i].editProfessor.title && $da[i].editProfessor.department && $da[i].editProfessor.orgName) {
								add += $da[i].editProfessor.department + "," + $da[i].editProfessor.orgName;
							} else if($da[i].editProfessor.title && !$da[i].editProfessor.department && $da[i].editProfessor.orgName) {
								add += $da[i].editProfessor.title + "," + $da[i].editProfessor.orgName;
							} else if($da[i].editProfessor.title && $da[i].editProfessor.department && !$da[i].editProfessor.orgName) {
								add += $da[i].editProfessor.title + "," + $da[i].editProfessor.department;
							} else if(!$da[i].editProfessor.title && !$da[i].editProfessor.department && $da[i].editProfessor.orgName) {
								add += $da[i].editProfessor.orgName
							} else if(!$da[i].editProfessor.title && $da[i].editProfessor.department && !$da[i].editProfessor.orgName) {
								add += $da[i].editProfessor.department
							} else if($da[i].editProfessor.title && !$da[i].editProfessor.department && !$da[i].editProfessor.orgName) {
								add += $da[i].editProfessor.title
							}
							add += '</div>'
							if($da[i].subject) {
								add += '<div class="ellipsisbox sciencebox"><p>学术领域：' + $da[i].subject + '</p></div>'
							}
							if($da[i].industry) {
								add += '<div class="ellipsisbox industrybox"><p>应用行业：' + $da[i].industry + '</p></div>'
							}
							if($da[i].supportedServices) {
								add += '<div class="ellipsisbox provideservice"><p>应用用途：' + $da[i].supportedServices + '</p></div></div>'
							}
							add += "</div>"
							if(userid == $da[i]["editProfessor"]["id"]) {
								add += '<div class="operbox"><span class="operbtn consultbtn" id="' + $da[i]["editProfessor"]["id"] + '" style="display:none;">咨询</span><span style="display: none;" class="operbtn applybtn appl" resourceId=' + $da[i].resourceId + ' resourceName=' + $da[i].resourceName + ' editProfessor=' + $da[i].editProfessor.name + '>申请</span></div>'
							} else {
								add += '<div class="operbox"><span class="operbtn consultbtn" id="' + $da[i]["editProfessor"]["id"] + '">咨询</span><span style="display: none;" class="operbtn applybtn appl" resourceId=' + $da[i].resourceId + ' resourceName=' + $da[i].resourceName + ' editProfessor=' + $da[i].editProfessor.name + '>申请</span></div>'
							}
							add += '</div></div>'
							var $add = $(add);
							$("#professorList").append($add);
							if($da[i].editProfessor.authType) {
								$add.find(".modicon").addClass("authicon authicon-cu");
							} else {
								if($da[i].editProfessor.authStatus==3) {
									if($da[i].editProfessor.authentication == 1) {
										$add.find(".modicon").addClass("authicon2 authicon-mana");
										//$add.find(".modicon").html("<span style='top:35%'>科研</span>");										
									} else if($da[i].editProfessor.authentication == 2) {
										$add.find(".modicon").addClass("authicon2 authicon-staff");
										//$add.find(".modicon").html("<span style='top:35%'>企业</span>");										
									} else {
										$add.find(".modicon").addClass("authicon2 authicon-stu");
										//$add.find(".modicon").html("<span style='top:35%'>学生</span>");										
									}
								}
							}
							if(data.data.data[i].images.length) {
								$add.find(".resourceImg").attr("src", "/images/resource/" + $da[i].resourceId + ".jpg");
							} else {
								$add.find(".resourceImg").attr("src", "/images/default-resource.jpg");
							}
						}
						if(isbind == true) {
							$(".tcdPageCode").createPage({
								pageCount: Math.ceil(data.data.total / pageSize),
								current: data.data.pageNo,
								backFn: function(p) {
									getData(key, subject, industry, pageSize, p, false);
								}
							});
						}
					} else {
						$.MsgBox.Alert("消息提醒", "请先登录再进行咨询");
						$("#mb_btn_ok").val("去登录");

					}

					//资源中点击咨询
					//$(".consultbtn").bind("click",clickResouceConsultHandler);

				},
			});
		}

	}
	$(".about").on("click", '.consultbtn', function(e) {
		e.stopPropagation(); //阻止事件冒泡，影响点击咨询
		e.cancelBubble = true; // ie下阻止冒泡
		clickResouceConsultHandler($(this), $(this).attr('id'));

	});
	var subjectList = function() {
		$.get("../ajax/dataDict/qaDictCode", {
			dictCode: "SUBJECT"
		}, function(data) {
			if(data.success) {
				console.log(data);
				/*if (data.data.length <= 10) {
					$(".andmore").eq(0).hide();
				}*/
				$("#subject").find(".sub").remove();
				for(var i = 0; i < data.data.length; i++) {
					$("#subject").append(
						"<a href='#' class='sub'title='" +
						data.data[i].caption + "'>" +
						data.data[i].caption + "</a>");
					if(subb) {
						if(subb == data.data[i].caption) {
							$('.sub').eq(i).addClass('colorbg').siblings()
								.removeClass("colorbg");
						}
					}
					if(i > 20)
						break;
				}
			} else {
				$.MsgBox.Alert("message", data.msg);
			}
		})
	}
	var Address = function() {
		$.get("../ajax/dataDict/qaCity", {
			dictCode: "ADDRESS"
		}, function(data) {
			if(data.success) {
				$("#address").empty();
				$("#address").prepend('<a href="#" class="colorbg no3" title="">不限</a>');
				/*if (data.data.length <= 10) {
					$(".andmore").eq(2).hide();
				}*/
				for(var i = 0; i < data.data.length; i++) {
					$("#address").append(
						"<a href='#' title='" + data.data[i].caption + "'>" +
						data.data[i].caption + "</a>");
					if(i > 20)
						break;
				}
			} else {
				$.MsgBox.Alert("message", data.msg);
			}
		})
	}
	var industryList = function() {
		$.get("../ajax/dataDict/qaDictCode", {
			dictCode: "INDUSTRY"
		}, function(data) {
			console.log(data);
			if(data.success) {
				/*if (data.data.length <= 10) {
					$(".andmore").eq(1).hide();
				}*/
				$("#industry").find(".indu").remove();
				for(var i = 0; i < data.data.length; i++) {
					$("#industry").append(
						"<a href='#' class='indu'title='" +
						data.data[i].caption + "'>" +
						data.data[i].caption + "</a>");
					if(i > 20)
						break;
				}
			} else {
				$.MsgBox.Alert("message", data.msg);
			}
		})
	}
	var findProfessor = function() {
			if(subb) {
				subject = subb;
			} else {
				subject = $("#subject .colorbg")[0].title;
			}
			industry = $("#industry .colorbg")[0].title;
			pageSize = 10;
			getData(key, subject, industry, pageSize, 1, true, address);
		}
		// enter键搜索
	function synContent(type) {
		if(type == 1) {
			$("#searchContent").val($("#hsearchContent").val());
		} else {
			$("#hsearchContent").val($("#searchContent").val());
		}
	}
	$("#hsearchContent").blur(function() {
		synContent(1);
	});
	$("#searchContent").blur(function() {
		synContent(2);
	});
	$("#searchContent").keydown(function(e) {
		if(e.which == 13) {
			synContent(2);
			key = $("#searchContent").val();
			$("#professorList").remove();
			$(".aboutpro").append(
				'<div class="about-in" id="professorList"></div>')
			$(".tcdPageCode").remove();
			$(".aboutpro").append('<div class="tcdPageCode"></div>');
			getData(key, subject, industry, 10, 1, true, address);
		}

	})
	$("#hsearchContent").keydown(function(e) {
		if(e.which == 13) {
			synContent(1);
			key = $("#searchContent").val();
			$("#professorList").remove();
			$(".aboutpro").append(
				'<div class="about-in" id="professorList"></div>')
			$(".tcdPageCode").remove();
			$(".aboutpro").append('<div class="tcdPageCode"></div>');
			getData(key, subject, industry, 10, 1, true, address);
		}
	})
	$("#search1").on(
		"click",
		function() {
			$("#hsearchContent").val($("#searchContent").val());
			key = $("#searchContent").val();
			$("#professorList").remove();
			$(".aboutpro").append(
				'<div class="about-in" id="professorList"></div>')
			$(".tcdPageCode").remove();
			$(".aboutpro").append('<div class="tcdPageCode"></div>');
			getData(key, subject, industry, 10, 1, true, address);
		})
	$("#hsearch1").on(
		"click",
		function() {
			$("#searchContent").val($("#hsearchContent").val());
			key = $("#hsearchContent").val();
			$("#professorList").remove();
			$(".aboutpro").append(
				'<div class="about-in" id="professorList"></div>')
			$(".tcdPageCode").remove();
			$(".aboutpro").append('<div class="tcdPageCode"></div>');
			getData(key, subject, industry, 10, 1, true, address);
		})

	subjectList();
	industryList();
	findProfessor();
	Address();
	$(".class1").eq(0).on(
		"click",
		"a",
		function() {
			$(this).addClass("colorbg").siblings().removeClass("colorbg");
			key = $("#searchContent").val();
			subject = $(this).attr('title');
			$("#professorList").remove();
			$(".aboutpro").append(
				'<div class="about-in" id="professorList"></div>')
			$(".tcdPageCode").remove();
			$(".aboutpro").append('<div class="tcdPageCode"></div>');
			getData(key, subject, industry, 10, 1, true, address);

		});
	$(".class1").eq(1).on(
		"click",
		"a",
		function() {
			$(this).addClass("colorbg").siblings().removeClass("colorbg");
			industry = $(this).attr('title');
			key = $("#searchContent").val();
			$("#professorList").remove();
			$(".aboutpro").append(
				'<div class="about-in" id="professorList"></div>')
			$(".tcdPageCode").remove();
			$(".aboutpro").append('<div class="tcdPageCode"></div>');
			getData(key, subject, industry, 10, 1, true, address);
		});
	$(".class1").eq(2).on(
		"click",
		"a",
		function() {
			$(this).addClass("colorbg").siblings().removeClass("colorbg");
			address = $(this).attr('title');
			key = $("#searchContent").val();
			$("#professorList").remove();
			$(".aboutpro").append(
				'<div class="about-in" id="professorList"></div>')
			$(".tcdPageCode").remove();
			$(".aboutpro").append('<div class="tcdPageCode"></div>');
			getData(key, subject, industry, 10, 1, true, address);
		});
	/* 搜索分类展开 */
	var listi = 0;
	$(".andmore").click(function() {
		$(this).find(".updown").css("background-position", "left");
		$(this).parent().css("height", "48px");
		if(listi % 2 == 0) {

		} else {
			$(this).find(".updown").css("background-position", "right");
			$(this).parent().css("height", "auto");

		}
		listi++;
	})

	/*搜索分类背景切换*/
	$(".class1").on("click", "a", function() {
		$(this).addClass("colorbg").siblings().removeClass("colorbg");
	})

	/*专家、资源菜单切换*/
	//	$(".lookwho").change(function(){
	//		//$(this).addClass("tabcurrent").siblings().removeClass("tabcurrent");
	//		//$(".aboutcon").eq($(this).index()).show().siblings().hide();
	//		if($(this).value == "0"){
	//			$(".aboutpro").show();
	//			$(".aboutresou").hide();	
	//		}
	//		else{
	//			$(".aboutresou").show();
	//			$(".aboutpro").hide();
	//		}
	//		
	//	})

	//判断是搜寻专家还是资源
	$(".lishow li").on(
		"click",
		function() {
			c = $(this).index();

			$("#industry").find(".no2").addClass("colorbg").siblings()
				.removeClass("colorbg");
			$("#subject").find(".nox").addClass("colorbg").siblings()
				.removeClass("colorbg");
			key = $("#searchContent").val();
			industry = "";
			subject = "";
			address = "";
			if(c == 0) {
				sub = "SUBJECT";
				indu = "INDUSTRY";
			} else {
				sub = "SUBJECT";
				indu = "INDUSTRY";

			}
			industryList();
			subjectList();
			Address();
			$("#professorList").remove();
			$(".aboutpro").append(
				'<div class="about-in" id="professorList"></div>')
			$(".tcdPageCode").remove();
			$(".aboutpro").append('<div class="tcdPageCode"></div>');
			getData(key, subject, industry, pageSize, 1, true, address);
		});
	// 查询资源详细信息
	$('.about')
		.on(
			"click",
			'.remess',
			function() {
				var resourceID = $(this).attr("resourceId");
				location.href = "resourceInfo.html?resourceId=" + resourceID;
				//ResourceMessage();
				//				$
				//					.ajax({
				//						"url": "/ajax/resource/" + resourceID,
				//						"type": "get",
				//						"async": true,
				//						"success": function(info) {
				//							if(info.success) {
				//								$("#resourceName").text(
				//									info.data.resourceName);
				//								$("#supportedServices")
				//									.text(
				//										info.data.supportedServices);
				//								$("#hopePayMethod").text(
				//									info.data.hopePayMethod);
				//								$("#cooperationNotes").text(
				//									info.data.cooperationNotes);
				//								$("#subject").text(
				//									info.data.subject);
				//								$("#industry").text(
				//									info.data.industry);
				//								$("#descp").text(info.data.descp);
				//								$("#professor").text(
				//									info.data.professor.name);
				//								$(".resouImage").attr(
				//									"src",
				//									"/images/resource/" +
				//									resourceID +
				//									".jpg");
				//								$(".resouImage")
				//									.load(function() {})
				//									.error(
				//										function() {
				//											$(this)
				//												.attr(
				//													"src",
				//													"/images/default-resource.jpg");
				//										});
				//								limitHeight();
				//							} else {
				//								$.MsgBox.Alert('消息提醒', "系统异常!");
				//							}
				//						},
				//						"error": function() {
				//							$.MsgBox.Alert('message', 'failed')
				//						}
				//					});
			})
		// 资源申请
	function getIdentity(professorId) {
		$
			.ajax({
				"url": "ajax/professor/" + professorId,
				"type": "get",
				"async": false,
				"success": function(data) {
					if(data.success) {
						$(".frmtype option")[0].value = data.data.name;
						$(".frmtype option")[1].value = data.data.organization.name;
					} else {
						$.MsgBox.Alert("消息提醒", "系统异常!");
					}
				},
				"error": function() {
					$.MsgBox.Alert('message', 'failddd')
				}
			})
	}

	function replaceStr(s) {
		var pattern = new RegExp("-");
		var rs = "";
		for(var i = 0; i < s.length; i++) {
			rs = rs + s.substr(i, 1).replace(pattern, '');
		}
		return rs;
	}
	$('.aboutpro')
		.on(
			"click",
			'.appl',
			function() {
				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");
				var resName = $(this).attr("resourcename");
				var name = $(this).attr("professor");
				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");
								}
							}
						}
					})
				$(".namecon").text(name);
				$(".applysure").hide();
				$(".btnboxup").hide();
				$(".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()));
							$data.operationStatus = 1;
							$data.applysquare = $(
									".frmtype option:selected")
								.val();
							$
								.ajax({
									"url": "/ajax/operation",
									"type": "POST",
									"success": function(
										rdata) {
										if(rdata.success) {
											$.MsgBox
												.Alert(
													'消息提醒',
													'资源"' +
													resName +
													'"申请发送成功!');
											$(".blackcover")
												.remove();
											$("body")
												.css(
													"position",
													"");
											// location.reload(true);
										} else {
											$.MsgBox
												.Alert(
													'消息提醒',
													'资源"' +
													resName +
													'"申请发送失败，请重新申请!');
										}
									},
									"data": $data,
									"beforeSend": function() { /* console.log(this.data) */ },
									"contentType": "application/x-www-form-urlencoded",
									dataType: "json"
								});
						});
			});

	// 找专家中 点击咨询处理函数
	function clickSeachProConsultHandler() {

		if(userid != null && userid != 'null' && userid != undefined && userid != 'undefined') {
			var professorId = $(this).attr("id");

			ConsultApply();
			//点击的发送
			$("#sendConsultBtn").click(function() {
				sendConsultHandler($(this).attr("proId"))
			});
			concultProInfo(professorId);

		} 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');
		}

	};

	//找资源中 点击咨询 obj点击对象
	function clickResouceConsultHandler(obj, professorId) {

		if(userid && userid != null && userid != 'null' && userid != undefined && userid != 'undefined') {

			//			var professorId = $(this).attr("id");
			ConsultApply();
			//默认选中资源咨询和标题
			for(var i = 0; i < $("ul.menucon").children().length; i++) {
				$("ul.menucon").children().eq(i).removeClass("clicknow");
				$("ul.menucon").children().eq(1).addClass("clicknow");
			}

			var item = obj.parent().parent().parent();
			var consultTitleVal = item.find(".resouname").text();

			$("#consultTitle").val("关于" + consultTitleVal + "的咨询");
			//点击的发送
			$("#sendConsultBtn").click(function() {
				sendConsultHandler($(this).attr("proId")); //common.js中
			});
			concultProInfo(professorId); //common.js中

		} 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');
		}

	};

	/* function sendConsultHandler(){
		 	var professorId = $(this).attr("proId");
			var consult_type = $(".clicknow").text();//咨询类型
			var consult_title = $("#consultTitle").val();//咨询主题
			var consult_content = $("#consultcontent").val();//咨询内容
			var consultStr = {
					"consultType":consult_type,
					"consultTitle":consult_title,
					"consultContant":consult_content,
					"professorId":professorId,
					"consultantId":userid
			};
			
			if(consult_type == '' || consult_title == '' || consult_content == ''){
				$.MsgBox.Alert("message","请填写完整");
			};
			if(consult_type == ''){
				$.MsgBox.Alert("消息","请选择联系目的");
			}
			if(consult_title == ''){
				$.MsgBox.Alert("消息","请填写咨询目的");
			}
			if(consult_content == ''){
				$.MsgBox.Alert("消息","请填写咨询内容");
			}
			
			if(userid && userid != null && userid != "null" && consult_type != '' &&
					consult_title != '' && consult_content != ''
			){
				
				$.ajax({
					"url" :"/ajax/consult",
					"type" : "post",
					//传值：咨询类型、主题、内容、专家id、申请人id
					"data" : consultStr,				
					"contentType" : "application/x-www-form-urlencoded",
					"dataType" : "json",
					"success" : function(response) {
						consultId = response.data;//咨询id
						
						
					},
					"error":function (){
						$.MsgBox.Alert("消息","咨询申请失败");
					},
					
					"complete":function(){
						//$(".consultapply").remove();
						$(".blackcover").remove();
						$("body").css("position","");
						$.MsgBox.Alert("消息","咨询申请成功");
					},
				});
			}

		}*/

});