$(document).ready(function() {
	$(".unlogin").show();
	$(".onlogin").hide();

	var footerHeight = $("footer").outerHeight(true);
	$('#container').css("padding-bottom", footerHeight + "px");
	//窗口大小变更事件
	$(window).resize(function() {
		footerHeight = $("footer").outerHeight(true);
		$('#container').css("padding-bottom", footerHeight + "px");
		//console.log(footerHeight)
	});
	//底部企业入驻
	var orgid = $.cookie('orgId');
	$("#cmpSet2").on("click", function() {
		if(orgid && orgid != "null" && orgid != null) {
			location.href = "cmp-portal/cmp-workspaces.html"
		} else {
			location.href = "cmp-portal/cmp-settled-reg.html"
		}
	})

});
//搜索框跳转页面

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

//enter绑定时间
$("#searchContent").keydown(function(e) {
	if(e.which == 13) {
		var searchContent = $("#searchContent").val();
		console.log(searchContent);
		location.href = "searchNew.html?searchContent=" + encodeURI(searchContent);
	}

})
$("#hsearchContent").keydown(function(e) {
	if(e.which == 13) {
		var searchContent = $("#hsearchContent").val();
		console.log(searchContent);
		location.href = "searchNew.html?searchContent=" + encodeURI(searchContent);
	}
})

$("#hsearch").on("click", function() {
	var searchContent = $("#hsearchContent").val();
	location.href = "searchNew.html?searchContent=" + encodeURI(searchContent);
});
/*向下滚动时,header背景变半透明*/
$(document).scroll(function() {
	var top = $(document).scrollTop();

	if(top == 0) {
		$(".navheader").removeClass("navhdown");
	} else {
		$(".navheader").addClass("navhdown");
	}

	if(top >= 300) {
		$(".content-left").css({
			"position": "fixed",
			"top": "80px"
		})
	} else {
		$(".content-left").css({
			"position": "static"
		})
	}

});

var userid;

function exit() {
	$.cookie('userid', null);
	$.cookie('userAuth', null);
	$.cookie('userEmail', null);
	$.cookie('userMobilePhone', null);
	$.cookie('userName', null);
	$.cookie('userType', null);
	location.href = "index.html"
}

function valUser() {
	var userid = $.cookie('userid');
	var userAuth = $.cookie('userAuth');
	if(userid == undefined || userid.length == 0 || userid == "null" || userAuth == false) {
		location.href = "login.html";
	}
}

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

/* function GetQueryString(name) { 
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
		var r = window.location.search.substr(1).match(reg);  //��ȡurl��"?"�����ַ�����ƥ��
		var context = ""; 
		if (r != null) 
			 context = r[2]; 
		reg = null; 
		r = null; 
		return context == null || context == "" || context == "undefined" ? "" : context; 
	}*/

function loginStatus() {
	userid = $.cookie('userid');
	userAuth = $.cookie('userAuth');
	authentication = $.cookie('authentication');
	if(userid && userid != "null" && userid != null) {
		if(userAuth == "false" && authentication == "null") {
			location.href = "loginInviteFirst.html";
		}
		if(userAuth == "true" && authentication == "null") {
			location.href = "fillinfo-select.html";
		}
		if(userAuth == "true" && authentication != "null") {
			$(".onlogin").show();
			$(".unlogin").hide();
			$(".portrait-p").attr("src", "/images/head/" + userid + "_m.jpg");
			$(".portrait-p").load(function() { //判断图片是否加载,加载不成功默认有默认的图像									
				})
				.error(function() {
					$(".portrait-p").attr("src", "/images/default-photo.jpg");
				});
		}
	} else {
		$(".unlogin").show();
		$(".onlogin").hide();
	}
}

//转换格式
function changeTime(dealtime) {
	var s = dealtime;
	//console.log(s);
	if(dealtime.length == 8) {
		var y = s.substr(0, 4);
		var m = s.substr(4, 2);
		var d = s.substr(6, 2);
		var formatTime = y + "-" + m + "-" + d;
		return formatTime;
	} else {
		var y = s.substr(0, 4);
		var m = s.substr(4, 2);
		var d = s.substr(6, 2);
		var h = s.substr(8, 2);
		var minute = s.substr(10, 2);
		var formatTime = y + "-" + m + "-" + d + " " + h + ":" + minute;
		return formatTime;
	}

}
//******过滤特殊字符*******//
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;
}
//**********************//

//根据内容的多少获取高度给父级设置高度
function limitHeight() {
	var Length = $(".limitBox").length;
	for(var i = 0; i < Length; i++) {
		var limitheight = $(".limitwords").eq(i).height();
		console.log(limitheight);
		$(".limitBox").eq(i).css("height", limitheight);
	}

}

//根据用户输入的Email跳转到相应的电子邮箱首页  
var hash = {
	'qq.com': 'http://mail.qq.com',
	'gmail.com': 'http://mail.google.com',
	'sina.com': 'http://mail.sina.com.cn',
	'163.com': 'http://mail.163.com',
	'126.com': 'http://mail.126.com',
	'yeah.net': 'http://www.yeah.net/',
	'sohu.com': 'http://mail.sohu.com/',
	'tom.com': 'http://mail.tom.com/',
	'sogou.com': 'http://mail.sogou.com/',
	'139.com': 'http://mail.10086.cn/',
	'hotmail.com': 'http://www.hotmail.com',
	'live.com': 'http://login.live.com/',
	'live.cn': 'http://login.live.cn/',
	'live.com.cn': 'http://login.live.com.cn',
	'189.com': 'http://webmail16.189.cn/webmail/',
	'yahoo.com.cn': 'http://mail.cn.yahoo.com/',
	'yahoo.cn': 'http://mail.cn.yahoo.com/',
	'eyou.com': 'http://www.eyou.com/',
	'21cn.com': 'http://mail.21cn.com/',
	'188.com': 'http://www.188.com/',
	'ustb.edu.cn': 'http://mail.ustb.edu.cn/',
	'foxmail.coom': 'http://www.foxmail.com'
};
//轮播滚动函数
function Carousel(inde, num, show, childcount, obj, next, prev) {
	var tapnum = 0; //按钮可点击次数
	if(childcount > num) {
		next.css("display", "block");
		prev.css("display", "none");
	} else {
		next.css("display", "none");
		prev.css("display", "none");
	}
	next.click(function() {
		if(!obj.is(":animated")) {
			if(num < childcount) {
				tapnum++;
				prev.css("display", "block");
				if(tapnum == childcount - show) {
					next.css("display", "none");

				}
				num++;
				obj.animate({
					left: "-=212px"
				}, 600);
			}
		}
	});
	prev.click(function() {

		if(!obj.is(":animated")) {
			if(num > inde) {
				tapnum--;
				next.css("display", "block");
				if(tapnum == 0) {
					prev.css("display", "none");
				}
				num--;
				obj.animate({
					left: "+=212px"
				}, 600);
			}
		}
	});
}

//评价字数限制
//字数限制函数
function limitTextCountFn(TextAreaId, countContainerId, count) {
	var curLength = $(TextAreaId).val().length;
	if(curLength > count) {
		var num = $(TextAreaId).val().substr(0, count);
		$(TextAreaId).val(num);

	} else {
		$(countContainerId).text(count - $(TextAreaId).val().length);
	}
};

//咨询申请主题字数限制函数
function titleLimitFontCountFn() {
	var curLength = $("#consultTitle").val().length;

	if(curLength > 20) {
		var num = $("#consultTitle").val().substr(0, 20);
		$("#consultTitle").val(num);
	}

};

function showmenu() {
	$("#li_show").css("display", "block");
}

/*选择省份*/
$(document).on("click", "#Province li a", function() {
	var aVal = $(this).text();
	$(this).parent().parent().parent().find('.mr_show').text(aVal);
	$(this).parent().parent().parent().find('input[name=cho_Province]').val(aVal);

	if($("#oprovince").text() == "请选择省/直辖市") {
		$("#oprovince").removeClass("mr_select");
		$("#ocity").removeClass("mr_select");
	} else {
		$("#oprovince").addClass("mr_select");
		$("#ocity").removeClass("mr_select");
	}
});
/*选择城市填充js	*/
$(document).on("click", "#City li a", function() {
	var aVal = $(this).text();
	$(this).parent().parent().parent().find('.mr_show').text(aVal);
	$(this).parent().parent().parent().find('input[name=cho_City]').val(aVal);
	if($("#ocity").text() == "请选择城市") {
		$("#ocity").removeClass("mr_select");
	} else {
		$("#ocity").addClass("mr_select");
	}
});

//咨询 专家信息接口函数
function concultProInfo(professorId) {
	$.ajax({
		url: "/ajax/professor/editBaseInfo/" + professorId,
		type: "get",
		data: {
			"id": professorId
		},
		contentType: "application/x-www-form-urlencoded",
		success: function(response) {
			//console.log(response);
			var myData = response["data"];

			$("#professorName").html(myData["name"]);
			if(myData["title"]) {
				$("#professorTitle").html(myData["title"] + ' ');
			}
			if(myData["department"]) {
				$("#profDepartment").html(myData["department"] + ' ');
			}
			if(myData["orgName"]) {
				$("#profOrganization").html(myData["orgName"] + ' ');
			}
			if(myData["address"]) {
				$("#profAdress").html(myData["address"]);
			}
			console.log(myData["consultCount"])
			if(!myData["consultCount"]) {
				$("#starLevel").hide();
			}
			$("#byConsultConut").html(myData["consultCount"]);
			$("#sendConsultBtn").attr("proId", myData["id"]);

			//星级 
			var startConut = parseInt(myData["starLevel"]);
			if(myData["consultCount"]) {
				if(!startConut) {
					$(".evastarbox2").hide();
				}
			}
			for(var i = 0; i < startConut; i++) {
				$("#starLevel .evastar2").eq(i).addClass("addStar");
			}

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

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

		},
		error: function(error) {
			$.MsgBox.Alert("message", "请求数据失败");
		}
	});
};

//发送咨询
function sendConsultHandler(professorId) {

	var professorId = professorId;
	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("消息提醒", "请填写完整");
	};
	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) {
				console.log(response);
			},
			"error": function() {
				$.MsgBox.Alert("消息提醒", "咨询申请失败");
			},

			"complete": function() {
				//$(".consultapply").remove();
				$(".blackcover").remove();
				$("body").css("position", "");
				$.MsgBox.Alert("消息提醒", "咨询申请成功");
				$("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
			},
		});
	}

};

/*标志*/
function autho() {
	if(arguments[0] == 1) {
		return {
			"sty": "authicon-pro",
			"title": "科袖认证专家"
		}
	} else {
		if(arguments[1] == 1) {
			return {
				"sty": "authicon-staff-ok",
				"title": "企业认证员工"
			}
		} else {
			if(arguments[2] == 3) {
				return {
					"sty": "authicon-real",
					"title": "实名认证用户"
				}
			} else {
				return {
					"sty": "e",
					"title": " "
				}
			}
		}
	}
}

//获取用户类型

var ifuser = ifUserType();

function ifUserType(pa) {
	if(pa) {
		var useridtype = pa;
	} else {
		var useridtype = $.cookie('userid');
	}
	var authType2, authentication2;
	if(useridtype && useridtype != "null" && useridtype != null) {
		$.ajax({
			"url": "/ajax/professor/auth",
			"type": "GET",
			"data": {
				"id": useridtype
			},
			"dataType": "json",
			"async": false,
			"success": function(data) {
				if(data.success) {
					authType2 = data.data.authType;
					authentication2 = data.data.authentication;
				}
			}
		});
	}
	return {
		"authType2": authType2,
		"authentication2": authentication2,
	}
}

//工作台判断用户类型显示用户权限
if($.cookie('userName') && $.cookie('userName') != "null" && $.cookie('userName') != null) {
	if(ifuser.authType2 == 0) {
		$("#repalyf").addClass("repalyf");
		/*点击未读咨询消息查看*/
		$("#gozixu").on("click", function() {
			window.location.href = "myConsult.html";
		})
	} else {
		$(".nohide").show();
		/*点击未读咨询消息查看*/
		$("#gozixu").on("click", function() {
			window.location.href = "consult.html";
		})
	}
}
/*多行文本框样式(带有限制数字)模拟focus效果*/
$(".msgContbox textarea").focus(function() {
	$(this).parent().css("border-color", "#ff9900");
}).blur(function() {
	$(this).parent().css("border-color", "#E5E5E5");
})

//时间显示规则
function commenTime(startTime) {
	//console.log(startTime)
	var nowTimg = new Date();
	var startdate = new Date();
	startdate.setFullYear(parseInt(startTime.substring(0, 4)));
	startdate.setMonth(parseInt(startTime.substring(4, 6)) - 1);
	startdate.setDate(parseInt(startTime.substring(6, 8)));
	startdate.setHours(parseInt(startTime.substring(8, 10)));
	startdate.setMinutes(parseInt(startTime.substring(10, 12)));
	startdate.setSeconds(parseInt(startTime.substring(12, 14)));
	var date3 = nowTimg.getTime() - startdate.getTime(); //时间差的毫秒数
	var hours = parseInt((date3 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
	var minutes = parseInt((date3 % (1000 * 60 * 60)) / (1000 * 60));
	if(date3 < 60000) {
		return "刚刚";
	} else if(date3 >= 60000 && date3 < 3600000) {
		return minutes + "分钟前";
	} else if(date3 >= 3600000 && date3 < 86400000) {
		return hours + "小时前";
	} else if(date3 >= 86400000) {

		if(nowTimg.getFullYear() == startTime.substring(0, 4)) {

			return startTime.substring(4, 6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6, 8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8, 10) + ":" + startTime.substring(10, 12);
		} else {

			return startTime.substring(0, 4) + "年" + startTime.substring(4, 6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6, 8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8, 10) + ":" + startTime.substring(10, 12);
		}
	}
}
/*时间转换*/
function TimeTr(dealtime) {
	var myDate = new Date();
	var s = dealtime;
	var y = s.substr(0, 4);
	var m = s.substr(4, 2);
	var d = s.substr(6, 2);
	var h = s.substr(8, 2);
	var minute = s.substr(10, 2);
	var formatTime;
	if(s.length <= 6) {
		formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月";
	} else if(s.length > 6 && s.length <= 8) {
		formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 ";
	} else {
		formatTime = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
		if(y != myDate.getFullYear()) {
			formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
		}
	}
	return formatTime;
}

/*判断是否收藏资源文章或者是否关注专家*/
function ifcollectionAbout(watchObject, num) {
	$.ajax('/ajax/watch/hasWatch', {
		data: {
			"professorId": userid,
			"watchObject": watchObject
		},
		dataType: 'json', //数据格式类型
		type: 'get', //http请求类型
		timeout: 10000,
		async: false,
		success: function(data) {
			if(data.success && data.data != null) {
				if(num == "1" || num == "6") { //已关注专家
					$("#attentBtn").addClass("attenedSpan");
					$("#attentBtn").text("已关注");
				} else { //已收藏资源或文章
					$("#collectBtn").removeClass("icon-collect");
					$("#collectBtn").addClass("icon-collected");
				}
			} else {
				if(num == "1" || num == "6") { //关注专家
					$("#attentBtn").removeClass("attenedSpan");
					$("#attentBtn").text("关注");
				} else { //收藏资源或文章
					$("#collectBtn").addClass("icon-collect");
					$("#collectBtn").removeClass("icon-collected");
				}
			}
		},
		error: function(data) {
			$.MsgBox.Alert('提示', "服务器链接超时");
		}
	});
}
/*收藏资源、文章或者关注专家*/
function collectionAbout(watchObject, num) {
	$.ajax('/ajax/watch', {
		data: {
			"professorId": userid,
			"watchObject": watchObject,
			"watchType": num
		},
		dataType: 'json', //数据格式类型
		type: 'POST', //http请求类型
		timeout: 10000,
		async: false,
		success: function(data) {
			if(data.success) {
				if(num == "1" || num == "6") { //关注专家
					$("#attentBtn").addClass("attenedSpan");
					$("#attentBtn").text("已关注");
				} else { //收藏资源或文章
					$("#collectBtn").removeClass("icon-collect");
					$("#collectBtn").addClass("icon-collected");
				}
			}
		},
		error: function(data) {
			$.MsgBox.Alert('提示', "服务器链接超时");
		}
	});
}
/*取消收藏资源、文章或者取消关注专家*/
function cancelCollectionAbout(watchObject, num) {
	$.ajax({
		url: '/ajax/watch/delete',
		data: {
			professorId: userid,
			watchObject: watchObject
		},
		dataType: 'json', //数据格式类型
		type: 'post', //http请求类型
		timeout: 10000,
		async: true,
		success: function(data) {
			console.log(data.success)
			if(data.success) {
				if(num == "1" || num == "6") { //关注专家
					$("#attentBtn").removeClass("attenedSpan");
					$("#attentBtn").text("关注");
				} else { //收藏资源或文章
					$("#collectBtn").addClass("icon-collect");
					$("#collectBtn").removeClass("icon-collected");
				}

			}
		},
		error: function(data) {
			$.MsgBox.Alert('提示', "服务器链接超时");
		}
	});
}
//企业规模
var orgSizeShow = {
	'1': '50人以内',
	'2': '50-100人',
	'3': '100-200人',
	'4': '200-500人',
	'5': '500-1000人',
	'6': '1000人以上'
}
//企业类型
var orgTypeShow = {
	"2": "上市企业",
	"3": "外资企业",
	"4": "合资企业",
	"5": "独资企业",
	"6": "个体经营",
	"7": "政府机构",
	"8": "公益组织",
	"9": "协会学会",
	"10": "新闻媒体",
	"11": "教育机构",
	"undefined":""
}
//学位
var eduDegree = {
	"1": "博士",
	"2": "硕士",
	"3": "学士",
	"4": "大专",
	"5": "其他"
}
//反馈意见成功
function backSuccessed(){
	$(".correctCon").val("");
	$(".correctSubmit").attr("disabled",true);
	$(".correctSubmit").parents(".correctBlock").fadeOut();
	$.MsgBox.Alert('提示', '您的纠错反馈意见已经收录,感谢您的支持!');
	$("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
}

function hotKey(sel, num) {

	$(sel).bind({
		paste: function(e) {
			var pastedText;
			if (window.clipboardData  &&  window.clipboardData.getData)  {  // IE
				            
				pastedText  = $(this).val() +  window.clipboardData.getData('Text');          
			} 
			else  {            
				pastedText  = $(this).val() +  e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
				          
			}
			$(this).val(pastedText);

			var $this = $(this);
			setTimeout(function() {
				if($this.val().trim()) {
					$this.siblings("button").show();
				} else {
					$this.siblings("button").hide();
				}
			}, 1);
			e.preventDefault();
		},
		cut: function(e) {
			var $this = $(this);
			setTimeout(function() {
				if($this.val().trim()) {
					$this.siblings("button").show();
				} else {
					$this.siblings("button").hide();
				}
			}, 1);
		},
		blur: function() {
			var $this = $(this);
			setTimeout(function() {
				$this.siblings(".keydrop").hide();
			}, 500)
		},
		focus: function() {
			$(this).siblings(".keydrop").show();
		},
		keyup: function(e) {
			if($(this).val().trim()) {
				$(this).siblings("button").show();
				var lNum = $.trim($(this).val()).length;
				if(0 < lNum) {
					var $this = $(this)
					$("#addKeyword").show();
					$.ajax({
						"url": "/ajax/dataDict/qaHotKey",
						"type": "GET",
						"success": function(data) {
							console.log(data);
							if(data.success) {
								if(data.data.length == 0) {
									$this.siblings(".keydrop").addClass("displayNone");
									$this.siblings(".keydrop").find("ul").html("");
								} else {
									$this.siblings(".keydrop").removeClass("displayNone");
									var oSr = "";
									for(var i = 0; i < data.data.length; i++) {
										oSr += '<li>' + data.data[i].caption + '<div class="closeThis"></div></li>';
									}
									$this.siblings(".keydrop").find("ul").html(oSr);
								}
							} else {
								$this.siblings(".keydrop").addClass("displayNone");
								$this.siblings(".keydrop").find("ul").html("");
							}
						},
						"data": {
							"key": $(this).val()
						},
						dataType: "json",
						'error': function() {
							$.MsgBox.Alert('提示', '服务器连接超时!');
						}
					});
				}
			} else {
				$(this).siblings("button").hide();
				$(this).siblings(".keydrop").addClass("displayNone");
				$(this).siblings(".keydrop").find("ul").html("");
			}
		}
	})
	$(".keydrop").on("click", "li", function() {
		var oValue = $(this).text();
		var oJudge = $(this).parents(".col-w-12").siblings().find("ul.ulspace li");
		var addNum = $(this).parents(".keydrop").siblings("input").attr("data-num");

		for(var i = 0; i < oJudge.length; i++) {
			if(oValue == oJudge[i].innerText) {
				$.MsgBox.Alert('提示', '添加内容不能重复');
				return;
			}
		}
		$(this).parents(".col-w-12").siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
		$(this).parents(".keydrop").siblings("input").val("");
		$(this).parents(".keydrop").siblings("button").hide();
		if(oJudge.length == addNum - 1) {
			$(this).parents(".keydrop").siblings("input").val("");
			$(this).parents(".col-w-12").hide();
		}
		$(this).parent("ul").html("")
	})
	if(num == 1) {
		return;
	} else {
		/*添加*/
		$(".addButton").click(function() {
			var oValue = $(this).siblings("input").val().trim();
			var oJudge = $(this).parent().siblings().find("ul.ulspace li");
			var addContent = $(this).siblings("input").attr("data-pro");
			var addNum = $(this).siblings("input").attr("data-num");
			var addfontSizeNum = $(this).siblings("input").attr("data-fontSizeN");
			if(!oValue) {
				$.MsgBox.Alert('提示', '请先填写内容');
				return;
			}
			if(oValue.length > addfontSizeNum) {
				$.MsgBox.Alert('提示', addContent);
				return;
			}
			for(var i = 0; i < oJudge.length; i++) {
				if(oValue == oJudge[i].innerText) {
					$.MsgBox.Alert('提示', '添加内容不能重复');
					return;
				}
			}
			$(this).parent().siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
			$(this).hide();
			$(this).siblings("input").val("");
			if(oJudge.length == addNum - 1) {
				$(this).val("").parents(".col-w-12").hide();
			}
			$(this).siblings(".keydrop").find("ul").html("");
		})
	}

}

var r64 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "-", "_"];
		var d64 = {
			"0": 0,
			"1": 1,
			"2": 2,
			"3": 3,
			"4": 4,
			"5": 5,
			"6": 6,
			"7": 7,
			"8": 8,
			"9": 9,
			"A": 10,
			"B": 11,
			"C": 12,
			"D": 13,
			"E": 14,
			"F": 15,
			"G": 16,
			"H": 17,
			"I": 18,
			"J": 19,
			"K": 20,
			"L": 21,
			"M": 22,
			"N": 23,
			"O": 24,
			"P": 25,
			"Q": 26,
			"R": 27,
			"S": 28,
			"T": 29,
			"U": 30,
			"V": 31,
			"W": 32,
			"X": 33,
			"Y": 34,
			"Z": 35,
			"a": 36,
			"b": 37,
			"c": 38,
			"d": 39,
			"e": 40,
			"f": 41,
			"g": 42,
			"h": 43,
			"i": 44,
			"j": 45,
			"k": 46,
			"l": 47,
			"m": 48,
			"n": 49,
			"o": 50,
			"p": 51,
			"q": 52,
			"r": 53,
			"s": 54,
			"t": 55,
			"u": 56,
			"v": 57,
			"w": 58,
			"x": 59,
			"y": 60,
			"z": 61,
			"-": 62,
			"_": 63
		};
		function s16to64(s) {
			var out, idx, n1, n2, n3;
			idx = s.length - 1;
			out = "";
			while(idx >= 0) {
				n1 = d64[s.charAt(idx--)];
				if(idx < 0) {
					out = r64[n1] + out;
					break;
				}
				n2 = d64[s.charAt(idx--)];
				if(idx < 0) {
					out = r64[(n2 >>> 2)] + r64[((n2 & 0x3) << 4) + n1] + out;
					break;
				}
				n3 = d64[s.charAt(idx--)];
				out = r64[(n2 >>> 2) + (n3 << 2)] + r64[((n2 & 0x3) << 4) + n1] + out;
			}
			return out;
		}

		function s64to16(s) {
			var out, idx, n1, n2;
			idx = s.length - 1;
			out = "";
			while(idx >= 0) {
				n1 = d64[s.charAt(idx--)];
				if(idx < 0) {
					out = r64[n1 >>> 4] + r64[n1 & 0xF] + out;
					break;
				}
				n2 = d64[s.charAt(idx--)];
				out = r64[(n2 >>> 2)] + r64[(n1 >>> 4) + ((n2 & 0x3) << 2)] + r64[n1 & 0xF] + out;
			}
			if(out.length>32) {
				return out.substring(1);
			}
			return out;
		}