//talk
function InitializationEditor() {
	//初始化
	m_EditorControl = LREditor.load("LREditor");

	//collection
	m_EditorControl.plugs_add({
		"name": "collection", "class": "collection", "id": "collection", "title": "收藏", "showTip": true
	}, function (element) {
		element.onclick = function () {
			CollectionShow();
		};
	});

	// SELIMG
	m_EditorControl.plugs_add({ "name": "image", "class": "image", "id": "image", "title": "图片", "showTip": true }, function (element) {
		element.onclick = function () {
			SelectImageMsg();
		};
	});

	//注册语音发送
	//m_EditorControl.plugs_add({ "name": "sound", "class": "sound", "id": "sound", "title": "语音录制", "showTip": true }, function (element) {
	//    element.onclick = function () {
	//        ShowSound();
	//    };
	//});

	//SELFILE
	m_EditorControl.plugs_add({
		"name": "news", "class": "file", "id": "news", "title": "文件(3M以内)", "showTip": true
	}, function (element) {
		element.onclick = function () {
			Selectfile();
		};
	});
	//SELFILE
	m_EditorControl.plugs_add({
		"name": "bigfile", "class": "talk-file", "id": "talk-file", "title": "大文件(100M以内)", "showTip": true
	}, function (element) {
		element.onclick = function () {
			BindHisSendFile();

		};
	});

	//cutimg
	m_EditorControl.plugs_add({ "name": "cutimg", "class": "news", "id": "cutimg", "title": "截图(ctrl+alt+D)", "showTip": true }, function (element) {
		element.onclick = function () {
			CutImage();
		};
	});

	//address
	m_EditorControl.plugs_add({ "name": "address", "class": "address", "id": "address", "title": "地理位置", "showTip": true }, function (element) {
		element.onclick = function () {
			//MapAddress();
			var objhidDocUserName = $("#hidDocUserName").val();
			var objhidDocPid = $("#hidDocPid").val();
			var objhidDocUin = $("#hidDocUin").val();
			ShowMap(objhidDocUserName, objhidDocPid, objhidDocUin);
		};
	});

	$('div[data-rel=popover]').popover();
}

//热键
function InitializationKey() {
	//热键
	document.onkeydown = function () {
		//焦点
		var currkeycode = "";
		var keycode = window.event.keyCode
		if (window.event.ctrlKey) currkeycode = "17";
		if (window.event.altKey) currkeycode = "18";
		if (window.event.shiftKey) currkeycode = "10";
		currkeycode += keycode;

		if ($("#Content").is(":focus")) {
			if (currkeycode == "1713") {
				m_EditorControl.addContent("<div><br/><div/>");
			}
			else if (currkeycode == "13") {
				SendMsg();
				setTimeout(function () { m_EditorControl.setContent(""); }, 200);
			} else if (window.autoreplay_shortcuts[currkeycode] != undefined) {
				//Qucik
				m_EditorControl.setContent(window.autoreplay_shortcuts[currkeycode]);
			} else if (currkeycode == "1786") {
				// Paste
				talkObj.pasteimgtext();
			}
			else if (keycode == "38" && m_EditorControl.getPlainTxt().length == 0) {
				//UP
				if (m_SelectMsgBatchMail == "1") {
					KeyCodeUpAndDown(1);
				}
			} else if (keycode == "40" && m_EditorControl.getPlainTxt().length == 0) {
				//Dow
				if (m_SelectMsgBatchMail == "1") {
					KeyCodeUpAndDown(2);
				}
			}
		} else {
			if (keycode == "38") {
				//UP
				if (m_SelectMsgBatchMail == "1") {
					KeyCodeUpAndDown(1);
				}
			} else if (keycode == "40") {
				//Dow
				if (m_SelectMsgBatchMail == "1") {
					KeyCodeUpAndDown(2);
				}
			}
		}
	}

}

//FdRightKey
function SetFdRightKey(top, nomsg, wechatkey, pid, username, remarkname, nickname) {
	var strcontent = "";
	//remark
	strcontent += "<dd><i data-toggle=\"tooltip\" title=\"12323\" data-placement=\"left\" class=\"icon iconfont icon-modify\" onclick=\"UpdateFriendRemark('" + encodeURI(remarkname) + "','" + pid + "','" + wechatkey + "','" + username + "','" + nickname + "');\"></i><div class=\"btnhover\">备注</dd>";
	//top
	if (top == "") {
	    strcontent += "<dd><i class=\"icon iconfont icon-zhiding\" onclick=\"SetFriendTop('1','" + wechatkey + "','" + pid + "','" + username + "','" + remarkname + "')\" data-trigger=\"hover\" data-placement=\"top\" data-content=\"121212\" data-original-title=\"\" title=\"\"></i> <div class=\"btnhover\">置顶</dd>";
	} else {
	    strcontent += "<dd><i class=\"icon iconfont icon-notop\" onclick=\"SetFriendTop('0','" + wechatkey + "','" + pid + "','" + username + "','" + remarkname + "')\"  data-trigger=\"hover\" data-placement=\"top\" data-content=\"121212\" data-original-title=\"\" title=\"\"></i><div class=\"btnhover\">取消置顶</dd></dd>";
	}
	//del
	strcontent += "<dd onclick=\"Deletefd('" + wechatkey + "','" + pid + "')\"><i class=\"icon iconfont icon-delete1\"></i><div class=\"btnhover\">删除</dd></dd>";
	//nomsg
	if (nomsg == "0") {
	    strcontent += "<dd><i class=\"icon iconfont icon-notx\" onclick=\"SetFriendRemain('" + wechatkey + "','" + pid + "','0','" + username + "')\"></i><div class=\"btnhover\">取消勿扰</dd></dd>";
		
	} else {
	    strcontent += "<dd><i class=\"icon iconfont icon-tx1\" onclick=\"SetFriendRemain('" + wechatkey + "','" + pid + "','1','" + username + "')\"></i><div class=\"btnhover\">勿扰</dd></dd>";
		
	}
	return strcontent;
}

//SetBatchRigthKey
function SetBatchRigthKey(top, nomsg, wechatkey, username, remarkname) {
	var strcontent = "";
	if (top == "") {
	    strcontent += "<dd><i class=\"icon iconfont icon-zhiding\" onclick=\"SetGroupTop('1','" + wechatkey + "','" + username + "','" + remarkname + "')\"></i><div class=\"btnhover\">置顶</dd></dd>";
	} else {
	    strcontent += "<dd><i class=\"icon iconfont icon-notop\" onclick=\"SetGroupTop('0','" + wechatkey + "','" + username + "','" + remarkname + "')\"></i><div class=\"btnhover\">取消置顶</dd></dd>";
	}
	if (nomsg == "0") {
	    strcontent += "<dd><i class=\"icon iconfont icon-notx\" onclick=\"SetBatchRemain('" + wechatkey + "','1','" + username + "','" + remarkname + "')\"></i><div class=\"btnhover\">取消勿扰</dd></dd>";
	} else {
	    strcontent += "<dd><i class=\"icon iconfont icon-tx1\" onclick=\"SetBatchRemain('" + wechatkey + "','0','" + username + "','" + remarkname + "')\"></i><div class=\"btnhover\">勿扰</dd></dd>";
	}
	return strcontent;
}

// Talk End

//通用

//Load HeadError
function HeadError() {
	$("#imgDocHead").on("error", function () {
		var img = event.srcElement;
		img.src = "../img/user.png";
		img.onerror = null; //控制不要一直跳动
	});
}

//company system mewnu show
function ClickShowCompanyMenu() {
	var display = $('#divConpanyAVerson').css('display');
	if (display == 'none') {
		//初始化加载企业信息
		CompanyMessage();
		//绑定登录人员信息
		BindLoginUserMessageShow();
		$("#divConpanyAVerson").show();
	} else {
		$("#divConpanyAVerson").hide();
	}

}
//BindCompany
function CompanyMessage() {
	var companyitem = $.parseJSON(homeObj.getcompanyinfo());
	var resultcompanyname = "";
	if (companyitem.companyname.length > 12) {
		resultcompanyname = companyitem.companyname.substring(0, 12) + "...";
	} else {
		resultcompanyname = companyitem.companyname;
	}
	$("#CompanyID").html(companyitem.companyid);
	$("#CompanyName").html(resultcompanyname);
	$("#WXMaxCount").html(companyitem.wxcount);
	$("#ZXMaxCount").html(companyitem.zxcount == "0" ? "不限" : companyitem.zxcount);
	$("#Company").html(companyitem.companyname);
	$("#CreatTime").html(companyitem.regtime.replace("T", " "));
	$("#EndTime").html(companyitem.maxtime.replace("T", " "));
	$("#CompanyPersion").html(companyitem.contactname);
	$("#phone").html(companyitem.mobile);
}
//BindUser 
function BindLoginUserMessageShow() {
	var username = homeObj.getloginmessage();
	$("#LoginUserName").html(username);
}

//company modalshow
function CompanyMessageShow() {
	$("#modalCompanyMessage").modal("show");
	$("#divConpanyAVerson").hide();
}

//通用 End
//单机代理事件
var timerClick = null;
var BisRunDbClick = false;//默认没有执行
function _WechatClick(wechatkey) {
	timerClick = window.setTimeout("ClickBindFriends('" + wechatkey + "')", 300);
}
//双击代理事件
function _WechatdbClick(wechatkey) {
	BisRunDbClick = true;
	if (timerClick) {
		window.clearTimeout(timerClick);
		
	}
	
	//timerClick = null;
	window.setTimeout("PositioningNoReadMsg('" + wechatkey + "')", 200);
}


//定位
function PositioningNoReadMsg(wechatkey) {
	if (wechatkey == m_SelectWechatKey) {
		$("#myTabContent").animate({ scrollTop: $("#myTabContent").scrollTop() + $('.talk-tips').offset().top - $("#myTabContent").offset().top }, 300); //--动画
	}
	BisRunDbClick = false;
}
