var m_SelectPinYin = "";//输入的拼音
var m_IsNoRead = "";//选择的是否未读消息
var m_strSex = "";//选择的是否未读消息
var m_IsFirstLoad = true;//是否首次加载
var m_NowSelectPid = "";//当前选择的好友
var m_NowSelectUin = "";//当前选择UIN
//var m_NowSelectFriendHeadImgKey = "";//当前选择的好友头像KEY
var m_NowSelectFriendFinalName = "";//当前选中好友的最终名称（备注优先）
var m_EditorControl;            //编辑器
var m_IsBatch = false;          //当前是否群聊
var m_BusinessCheckStstus = "";//当前业务状态选中集合
var m_FriendGroup = "";//当前选中好友所属分组
var Sel, Range;//光标选中文本编辑框缓存
var m_SelectWechatKey = "";
var m_IsChangeWechat = true;//是否变更查询微信

var m_UrlParaWechatKey = "";//URL传参WechatKey
var m_UrlParaPid = "";  //URL传参PID
var m_MsgError = true;//当前发送消息是否成功（true，false）
var m_FontSize = 0;//聊天页面字体大小
var m_strNowDay = "";//当天时间
var m_HisMsgList = [];//历史记录缓存
var m_HisNowMsgList = [];//聊天框历史记录缓存]
var m_BisLoadTalkMsg = false;//默认是否加载对话记录（选择好友）
var M_nShowDangAOrQuick = "1";//1：显示档案 0：快捷回复

//查询重复好友使用
var m_SelFriendNickName = "";//所选好友昵称
var m_SeiFriendRemarkName = "";//所选好友备注
var m_SelFriendSign = "";//所选好友签名
//查询重复好友使用
            
$(function () {
    $(".input-group-lh input").focusin(function () {
        $(".input-group-lh button").css({
            "background-color": "#fff",
            "border": "#f2f3f5 1px solid",
            "border-left": "none",
        });
    })
    $(".input-group-lh input").focusout(function () {
        $(".input-group-lh button").css({
            "background-color": "#f2f3f5",
            "border": "#f2f3f5 1px solid",
            "border-left": "none",
        });
    })

    $(".check-tags>ul>li>a").click(function () {
        $(this).toggleClass("open").next().animate({
            height: 'toggle'
        });
    })
    $(function () { $("[data-toggle='tooltip']").tooltip(); });
    $('.tooltip-show').tooltip('show');
    talkcss();
    //$("#beizhu").modal("show");
    m_HisMsgList = [];
 
	//BdWechat
    ulLoadAllWechats();
	//Editor
    InitializationEditor();
	//Hot
    InitializationKey();

	//URL参数
    m_UrlParaWechatKey = getUrlParam("wechatkey");
    if (m_UrlParaWechatKey != null && m_UrlParaWechatKey != "undefined" && m_UrlParaWechatKey.length > 0) {
        m_UrlParaPid = getUrlParam("pid");
        if (m_UrlParaPid != null && m_UrlParaPid != "undefined" && m_UrlParaPid.length > 0) {
            //设置当前对话人员排序
            talkObj.seturlparapid(m_UrlParaWechatKey, m_UrlParaPid);
        }
    }
    //tag
    homeObj.gettagtree();

    //quick
    homeObj.getquicktree();

    //Talking
    talkObj.setistalkpage("1");

	changefriendgroupDataBind()

    $("body").attr("style", "-webkit-user-select: text;user-select: text;");
    //文本编辑框，右键黏贴
    $('.LREditor .Content').contextify(talkpasteoptions);

   // 绑定焦点
    $('#Content').on('click', function () {
        Sel = window.getSelection();
        Range = Sel.getRangeAt(0);
    });

	//Size
    GetWechatFontSize();

	//回访时间，默认明天
    $("#txtReturnVisitTime").val(homeObj.gettomorrowday());

	//当天时间
	m_strNowDay = homeObj.gettoday();

    //聊天历史记录日期控件加载
    customquery();
	//选择好友时是否默认拉取一次对话记录
    m_BisLoadTalkMsg = talkObj.getloadtalkhismsg();

    M_nShowDangAOrQuick = talkObj.getisshowcardorquick();
	//绑定待回访(时间)
    initTask();
    //获取部门
    //var paraJson = $.toJSON({
    //    type: "data"
    //});
    //homeObj.getdeptbyauth(paraJson);
});

$(function () {
    $('.talk-header-text h2 em').click(function () {
        var td = $(this); //为后面文本框变成文本铺垫
        var text = $(this).text();
        var input = $('<input type="text" id="txtDocFriendFinalName" value="' + text + '" class="form-control edit" style="width:200px; display:inline; margin:0; padding:0; height:18px;">');

        $(this).html(input);

        $('.edit').click(function () {
            return false;
        }); //阻止表单默认点击行为

        $('.edit').select(); //点击自动全选中表单的内容

        $('.edit').blur(function () {
            var nextxt = $(this).val();
            td.html(nextxt);
        }); //表单失去焦点文本框变成文本
    });
})

$(window).bind('beforeunload', function () {
    //告知后台现在离开对话窗体
    talkObj.setistalkpage("0");
});
//初始化控件
$(document).ready(function () {
	$('#txtReturnVisitTime').datetimepicker({
		language: "zh-CN",
		weekStart: 1,
		todayBtn: 1,
		autoclose: true,
		todayHighlight: 1,
		startView: 2,
		forceParse: 0,
		showMeridian: 1,
		minView: "month",
		format: "yyyy-mm-dd"
	});
});

function ShowQuickReply() {
    $("#popquickreplyModel").modal("show");
    $("#wrapper").unbind("click");
    setTimeout(function () {
        $("#wrapper").click(function () {
            $("#popquickreplyModel").modal("hide");
        });
    }, 300);
    $("div[class='modal-backdrop fade in']").each(function (i) {
        $(this).attr("class", "");
    });
}
//样式操作
function talkcss() {

	$(".left").css({
		height: $(window).height()
	});
	$(".right").css({
		height: $(window).height()
	});
	$(".left-box").css({
		height: $(window).height()
	});
	$(".middle-div").css({
		height: $(window).height()
	});
	$(".middle-height").css({
		height: $(window).height() - 50
	});

	$(".right-box").css({
		height: $(window).height()
	});
	$(".mes-box").css({
		height: $(window).height()
	});
	$(".talk-box").css({
		height: $(window).height()
	});

	$(".conversation-box").css({
		height: $(window).height() - 220
	});
	$(".customer-box>ul>li>a").click(function () {
		$(this).toggleClass("current").next().animate({
			height: 'toggle'
		});
		if ($(this).hasClass("current")) {
			$(".his-content").css({
				height: $(window).height() - 95
			});
		} else {
			$(".his-content").css({
				height: $(window).height() - 418 - 56
			});
		}
	})
	$(".quick-talk>ul>li>a").click(function () {
		$(this).toggleClass("open").next().animate({
			height: 'toggle'
		});
	})
	$(".rtheight").css({
		height: $(window).height() - $(".customer-box").height() - 56
	});

	$(".his-content").css({
		height: $(window).height() - $(".customer-box>ul").height() - 56
	});
	$(".conver-zhezhao").css({
		height: $(window).height()
	});
	$(".full-zh").css({
		width: $(window).width()
	});
}
$(window).resize(function () {
    talkcss();

});


//--------------------------------------------好友列表--------------------------------------------
function AsyncIsNoReadResult(json) {
    if (Number(json.newfriendcount) > 0) {
        $("#fontNewFriendNoRead").show();
        //新的好友，数量
        $("#fontNewFriendCount").html(json.newfriendcount);
        $("#fontNewFriendCount").show();
    } else {
        $("#fontNewFriendNoRead").hide();
        //新的好友，数量
        $("#fontNewFriendCount").html(0);
        $("#fontNewFriendCount").hide();
    }

    var bIsFriendNoRead = false;
    var bIsBatchNoRead = false;
    var wList = json.wechatnoreads;
    var MsgCount = "";
    for (var i = 0; i < wList.length; i++) {
        var wnoreadcount = wList[i].fnoreadcount + wList[i].bnoreadcount;
        if ($("#fLW" + wList[i].wechatkey).length > 0 && wnoreadcount > 0) {
            MsgCount = wnoreadcount > 999 ? "..." : wnoreadcount,
            $("#fLW" + wList[i].wechatkey).html(MsgCount);
            $("#fLW" + wList[i].wechatkey).show();
        } else {
            $("#fLW" + wList[i].wechatkey).hide();
        }

        if (m_SelectWechatKey.length == 0 || wList[i].wechatkey == m_SelectWechatKey) {
            if (wList[i].fnoreadcount > 0) {
                bIsFriendNoRead = true;
            }
            if (wList[i].bnoreadcount > 0) {
                bIsBatchNoRead = true;
            }
        }
    }

    if (bIsFriendNoRead) {
        $("#fontFriendMsgNoRead").show();
    } else {
        $("#fontFriendMsgNoRead").hide();
    }
    if (bIsBatchNoRead) {
        $("#fontBatchMsgNoRead").show();
    } else {
        $("#fontBatchMsgNoRead").hide();
    }
}

function BindFriends() {
	var bIsChecked = false;
	if ($("#cbxQueryFriendsNoRead").attr("class") == "serch-active") {
		bIsChecked = true;
	}

	var objtxtQueryFriendsPoint = $("#txtQueryFriendsPoint");
	//是否有未读消息
	
	//性别
	var strChecked = 0;
	if ($("#cbxQueryFriendsMan").attr("class") == "serch-active") {
		strChecked = 1;
	} else if ($("#cbxQueryFriendsWoMan").attr("class") == "serch-active") {
		strChecked = 2;
	}

	if (!m_IsFirstLoad) {
		if (bIsChecked == m_IsNoRead && objtxtQueryFriendsPoint.val() == m_SelectPinYin && m_IsChangeWechat == false && strChecked == m_strSex) {
			//$(".loadingcover").hide();
			//$(".loading").hide();
			return;
		}
	}

    var strParaJson = $.toJSON({
    		wechatkey: m_SelectWechatKey,
    		isnoread: bIsChecked,
    		sex:strChecked,
    		point: objtxtQueryFriendsPoint.val(),
    		pageindex: 0,
    		pagesize: 100
    });
    talkObj.queryfriends(strParaJson);

    m_strSex = strChecked;
    m_IsNoRead = bIsChecked;
    m_SelectPinYin = objtxtQueryFriendsPoint.val();
}

//筛选好友数据回调方法
function AsyncQueryFriendsResult(jsonResult) {
	if (jsonResult.success) {
		var urlSelectItem = null;//URL传参绑定好友
		$("#ulFriendHeadList").empty();
		var strContent = "";
		for (var i = 0; i < jsonResult.list.length; i++) {
			var item = jsonResult.list[i];

			if (item.pid == m_UrlParaPid) {
				urlSelectItem = item;
			}

			//no read msg
			var strNoReadHtml = "";
			var noreadcount = "";
			if (m_NowSelectPid != item.pid && Number(item.noreadcount) > 0) {
				noreadcount = item.noreadcount > 99 ? "..." : item.noreadcount;
				strNoReadHtml = "</div><span class=\"talk-tips\" id=\"fontNRC" + item.pid + "\">" + noreadcount + "</span>";
			}
			//选中样式
			var strSelectHeadActive = "";
			if (m_NowSelectPid == item.pid) {
			    strSelectHeadActive = "list-active";
			}
			//备注名称+昵称
			var strFinalName = item.nickname;
			if (item.remarkname.length > 0) {
				strFinalName = item.remarkname;
			}
			if (strFinalName.indexOf("<span") > 0) {
				strFinalName = strFinalName.replace('"', "");
				var start = strFinalName.indexOf("<span");
				var end = strFinalName.indexOf("span>") + 4;
				var startstr = strFinalName.substring(0, start);
				var endstr = "";
				if (strFinalName.length > end - 1) {
					endstr = strFinalName.substring(end + 1, strFinalName.length);
				}
				strFinalName = startstr + endstr;
			}
			//选中样式
			var strSelectHeadActive = "";
			if (m_NowSelectPid == item.pid) {
				strSelectHeadActive = "list-active";
			}
			//置顶
			var strTopClass = item.order > 0 ? "top-active" : "";
			//选中优先
			strTopClass = strTopClass.length > 0 ? strTopClass : strSelectHeadActive;
			//右键
			var strFdRightKey = SetFdRightKey(strTopClass, item.contactflag, item.wechatkey, item.pid, item.username, item.remarkname, item.nickname);

			var lasttime = item.lastmsgsorttime == "00:00" ? "" : item.lastmsgsorttime;
			var strsexclass = "";
			if (item.sex == "1") {
				strsexclass = "icon iconfont icon-man";
			} else if (item.sex == "2") {
				strsexclass = "icon iconfont icon-woman";
			} else {
				strsexclass = "";
			}
			var strSendError = "";
			if (item.lastmsgcontent.indexOf("E1001发送失败！") != -1) {
				item.lastmsgcontent = item.lastmsgcontent.replace("E1001发送失败！", "");
				strSendError = "<span style=\"color:red;\">发送失败！</span>";
			}
			strContent += "<li id=\"liFriendHead" + item.pid + "\" class=\"" + strTopClass + "\"  onclick=\"SelectFriend('" + item.wechatkey + "','" + item.pid + "','" + item.username + "');\" >";
			strContent += "<div class=\"talk-header\">";
			strContent += "<img id=\"imgFlh" + item.pid + "\"  src=\"" + item.headlocalpath + "\" onerror=\"nofind();\"/>";
			strContent += "<i class=\"" + strsexclass + "\"></i>";
			strContent += "</div>";
			strContent += "<div class=\"talk-mes\">";
			strContent += "<span class=\"talk-name\" style=\"width:100px\">" + strFinalName + "</span>";
			strContent += "<span class=\"pull-right color-gry\">" + lasttime + "</span>";
			strContent += "<p class=\"pre-mess\">" + item.lastmsgcontent + "</p>";
			strContent += strNoReadHtml;

			strContent += "<div class=\"hover-btn\">";
			strContent += "<dl>";
			strContent += strFdRightKey;//up remark
			//strContent += friendtop;//sel top
			//strContent += strDelFd;//del
			//strContent += frienddisturb; //disturb
			strContent += "</dl>";
			strContent += "</div>";
			strContent += "</li>";

		}
		$("#ulFriendHeadList").html(strContent);
		$('#ulFriendHeadList i[data-rel=popover]').popover();
		//默认绑定URL好友
		if (m_IsFirstLoad && urlSelectItem != null) {
			SelectFriend(urlSelectItem.wechatkey, urlSelectItem.pid, urlSelectItem.username);
		}
	}
	//  遮罩隐藏
	$("#LoadFDZhezhao").css("display", "none");
	
}
function SyncFriendHead() {
    var objhidDocWechatKey = $("#hidDocWechatKey");
    var objhidDocPid = $("#hidDocPid");
    var strParaJson = $.toJSON({
        wechatkey: objhidDocWechatKey.val(),
        pid: objhidDocPid.val(),
    });
    talkObj.syncfriendheadimg(strParaJson);
}

//--------------------------------------------好友列表--------------------------------------------


//--------------------------------------------通讯录--------------------------------------------
var m_SelectMailNewKey = "";
var m_SelectMailListKey = "";
var m_SelectMailGroup = "";
var m_SelectMailFriendsPoint = "";

//选择通讯录KEY绑定好友
function BindMaillist(val) {
    m_SelectMailNewKey = val;
    $(".pactive").removeClass("pactive");
    if (val.length > 0) {
        if ($("#letterP" + val).length > 0) {
        	$("#letterP" + val).addClass("pactive");
        }
    } else {
    	$("#letterPAll").addClass("pactive");
    }
}
//新版 BindMail
function BindMail() {
	var objtxtMailQueryFriendsPoint = $("#txtMailQueryFriendsPoint");
	var objselectMailQueryGroup = $("#selectMailQueryGroup");
	var queryCondition = objselectMailQueryGroup.html() == "分组" ? "" : objselectMailQueryGroup.html();
	if (!m_IsFirstLoad) {
		if (m_SelectMailListKey == m_SelectMailNewKey
            && queryCondition == m_SelectMailGroup
            && objtxtMailQueryFriendsPoint.val() == m_SelectMailFriendsPoint
            && m_IsChangeWechat == false) {
			return;
		}
	}
	var strParaJson = $.toJSON({
		key: m_SelectMailNewKey,
		point: objtxtMailQueryFriendsPoint.val(),
		wechatkey: m_SelectWechatKey,
		groupname: queryCondition
	});
	talkObj.queryfriendsbykey(strParaJson);
	$("#ulMailList").empty();
	m_SelectMailListKey = m_SelectMailNewKey;
	m_SelectMailGroup = queryCondition;
	m_SelectMailFriendsPoint = objtxtMailQueryFriendsPoint.val();
}

function AsyncQueryFriendsByKeyResult(jsonResult) {

    var Space = RegExp(/^[ ]*$/);//空格正则表达式
    if (jsonResult.success) {
    	var strContent = "";

    	strContent += "<li onclick=\"ShowNewFriendList();\">";
    	strContent += "<img src=\"../img/addfriends.png\"  />";
    	strContent += "<p>新朋友<span class=\"new-count pull-right\" id=\"fontNewFriendCount\" style=\"display:none;\"></span></p>";

    	strContent += "</li>";

        for (var i = 0; i < jsonResult.list.length; i++) {
            var item = jsonResult.list[i];
            //备注名称+昵称
            var strFinalName = item.nickname;
            if (item.remarkname.length > 0) {
                strFinalName = item.remarkname;
            }
            //var strFriendClass = "";
            //if (strFinalName == "" || Space.test(strFinalName)) {
            //	strFriendClass = "padding-bottom:35px;";//
            //}
            strContent += "<li  id=\"MailFriendList" + item.pid + "\" onclick=\"SelectFriend('" + item.wechatkey + "','" + item.pid + "','" + item.username + "');\" data-name=\"" + strFinalName + "\" data-pid=\"" + item.pid + "\" data-wechatkey=\"" + item.wechatkey + "\" data-username=\"" + item.username + "\" data-groupname=\"" + item.groupname + "\">";
            strContent += "<img  id=\"imgFth" + item.pid + "\" src=\"" + item.headlocalpath + "\"  onerror=\"nofind();\" />";
            strContent += "<p id=\"hMailFinalName" + item.pid + "\">" + strFinalName + "</p>";
            strContent += "</li>";

        }
        $("#ulMailList").html(strContent);

        m_IsFirstLoad = false;
        m_IsChangeWechat = false;
    }
}

//--------------------------------------------通讯录--------------------------------------------

//--------------------------------------------好友资料--------------------------------------------
function SetFriendShow() {
    //绑定默认日期
    $("#txtTimeFromQuery").val(homeObj.getmonthday());//默认开始日期
    $('#txtTimeFromQuery').datetimepicker('update');
    $("#txtTimeEndQuery").val(homeObj.gettoday());//设置默认当前日期

	//样式处理
    $(".mingpian-box ").css('display', 'block');//名片
	$("#talk_history").css('display', 'block');
	$(".talk-history").css('display', 'block');//历史记录
	if ($("#aFDCard").hasClass("current")) {
		$(".his-content").css({
			height: $(window).height() - 98
		});
	} else {
		$(".his-content").css({
			height: $(window).height() - 410 - 56
		});
	}
    $(".quick-talk-t").addClass("active");
    $(".talk-history").removeClass("active");
    $("#quick_talk").removeClass("tab-pane fade quick-talk his-content").addClass("tab-pane fade quick-talk his-content active in");
    $("#talk_history").removeClass("tab-pane fade his-content active in").addClass("tab-pane fade his-content");

    $("#PCollection").css('display', 'block');
    $("#InviteJoinBath").css('display', 'none');//显示邀请入群按钮
    $("#exportrecord").parent().css('display', 'block');//导出聊天记录显示
   
	//清空编辑器
    $("#Content").html("");
    $("#talk-file").parent().css('display', 'block');
    $("#divTalkContent").html("");
    $("#divTalkHistoryContent").html("");
}

function SetBatchShow() {
	//样式处理
	$(".mingpian-box ").css('display', 'none');//名片
	$("#talk_history").css('display', 'none');
	$(".talk-history").css('display', 'none');//历史记录
	//快捷回复
	
	$(".quick-talk-t").addClass("active");
	$(".talk-history").removeClass("active");
	$("#quick_talk").removeClass("tab-pane fade quick-talk his-content").addClass("tab-pane fade quick-talk his-content active in");
	$("#quick_talk").css("height","600");
	$("#talk_history").removeClass("tab-pane fade his-content active in").addClass("tab-pane fade his-content");
	$("#PCollection").css('display', 'none');//隐藏邀请入群按钮
	$("#InviteJoinBath").css('display', 'none');
	$("#exportrecord").parent().css('display', 'none')//导出聊天记录隐藏
	
	//清空编辑器
	$("#Content").html("");
	$("#talk-file").parent().css('display', 'none');

	$("#divTalkContent").html("");
}

//SelFd   ***新版
function SelectFriend(wechatkey, pid, username) { 
	m_IsBatch = false;
	m_NowSelectPid = pid;
	m_SelectWechatKey = wechatkey;
	$("#imgDocHead").attr("onclick", "imgfriendClickShowBig();");
	ResetHisMsgPara();
	SetFriendShow();
	//letf wechat
	$("#ulLoadAllWechats").each(function () {
		$(this).find('li').each(function () {
			$(this).removeClass("active");
		});
	});
	if (wechatkey == "") {
		$("#allfriends").addClass("active");
	} else {
		$("#wechat" + wechatkey).addClass("active");
	}

	var strParaJson = $.toJSON({
		wechatkey: wechatkey,
		username: username,
		pid: pid
	});
	talkObj.getfrienddoc(strParaJson);

	var objNoReadCountTag = $("#fontNRC" + pid);
	if (objNoReadCountTag.length > 0) {
		objNoReadCountTag.remove();
	}

	$(".list-active").removeClass("list-active");
	var objSelectHeadLi = $("#liFriendHead" + pid);
	if (objSelectHeadLi.length > 0) {
		objSelectHeadLi.addClass("list-active");
	}
	RestoreRecordcss();

	m_EditorControl.setFocusIn();
	////绑定光标Start'
	Sel = window.getSelection();
	Range = Sel.getRangeAt(0);
	//绑定光标End
	HeadError();
}

//  ***新版
function AsyncGetFriendsDocResult(jsonResult) {
    m_BusinessCheckStstus = "";
    if (jsonResult.success) {
        //设置好友消息为已读状态
        var fInfo = jsonResult.info;
        //m_NowSelectFriendHeadImgKey = fInfo.headimgkey;
        m_NowSelectFriendTags = fInfo.tagval;//缓存当前选中好友标签
        m_NowSelectFriendggTags = fInfo.tagggval == null ? "" : fInfo.tagggval;//缓存当前选中好友广告系统标签
        ResetFriendTagList();//绑定标签数据集

        //基本资料
        $("#hidDocWechatKey").val(fInfo.wechatkey);
        $("#hidDocUserName").val(fInfo.username);
        $("#hidDocUin").val(fInfo.uin);
        $("#hidDocPid").val(fInfo.pid);

		//微信号备注
        var strWecahtRemark = talkObj.getwechatremark(fInfo.wechatkey);

        
        m_NowSelectUin = fInfo.uin;
        //备注名称/昵称
        m_NowSelectFriendFinalName = fInfo.nickname;
        if (fInfo.remarkname.length > 0) {
            m_NowSelectFriendFinalName = fInfo.remarkname;
        }

        m_SelFriendNickName = fInfo.nickname;
        m_SeiFriendRemarkName = fInfo.remarkname;
        m_SelFriendSign = fInfo.sign;
        var headurl = fInfo.headlocalpath.length > 1 ? fInfo.headlocalpath : fInfo.headimgurl;
        $("#imgDocHead").attr("src", headurl);
        $("#TalkingfrdName").html(fInfo.nickname);
        $("#TalkingfrdRemarkName").html("(" + m_NowSelectFriendFinalName + ")");
        $("#TalkingfrdRemarkName").show();
        
        $("#spDocNickName").html(m_NowSelectFriendFinalName);

        m_CusWechatName = fInfo.wechatnickname;
        m_BusinessCheckStstus = fInfo.bisval;
        m_BusinessCheckGgStstus = "";
        var strgroupcolor = "";
        for (var i = 0; i < m_Groupitemjson.length; i++) {
        	if (m_Groupitemjson[i] == fInfo.groupname) {
        		if(m_Colorsitemjson.length > 0){
        			strgroupcolor =m_Colorsitemjson[i];
        		}
        	}
        }
        if (strgroupcolor.length > 0) {
        	$("#iNowSelGroup").css("color", strgroupcolor);
        } else {
        	$("#iNowSelGroup").css("color", "#fff");
        }
        
        $("#selectPersonDept").html(fInfo.groupname);
        if (fInfo.bisval.length > 0) {
            var showstatus = SuperReplace(m_BusinessCheckStstus, "|", "<span>-<span>");
        	//<span>已留电</span><span>-</span>
            $("#divDocFriendsSelectStatus").html(showstatus.substr(0, showstatus.length - 2));
        } else {
            $("#divDocFriendsSelectStatus").html("暂无状态");
        }
        //var strSexMark = "未知";
        //if (fInfo.sex == "1") {
        //    strSexMark = "男";
        //} else if (fInfo.sex == "2") {
        //    strSexMark = "女";
        //} 
        //$("#spDocSex").html(strSexMark);
    	//$("#spDocPoint").html(fInfo.province + "-" + fInfo.city);

		//广告
        //if (fInfo.ggtitle.length > 0) {
        //	$("#spggtitle").html(fInfo.ggtitle);
        //	$("#spggtitle").show();
        //}

        //可编辑资料
        $("#txtDocName").val(fInfo.name.length > 0 ? fInfo.name : "");
        $("#txtArea").val(fInfo.city.length > 0 ? fInfo.province + "-" + fInfo.city : fInfo.province)
        $("#txtDocAge").val(fInfo.age.length > 0 ? fInfo.age : "");
        $("#txtDocMobile").val(fInfo.mobile.length > 0 ? fInfo.mobile : "");
        $("#txtDocWXCode").val(fInfo.wxcode.length > 0 ? fInfo.wxcode : "");
        //$("#txtTagVal").val(fInfo.tagval);
        $("#txtBisVal").val(fInfo.bisval.length > 0 ? fInfo.bisval : "");
        var remark = fInfo.remark.length > 7 ? fInfo.remark.substring(0, 6) + ".." : fInfo.remark;
        $("#txtDocRemark").val(remark);
        $("#txtDocRemark").attr("remark", fInfo.remark);
        $(".modify-cusinfor").attr("readonly", "readonly");
        $(".modify-cusinfor").removeClass("dis-modify");

        if (M_nShowDangAOrQuick == "0") {
        	$("#aFDCard").addClass("current");
        	$("#UIlDangAn").css("display", "none");
        	$("#quick_talk").css("height", "600");
        }

        //$("#txtDocRemarkHidehide").html(fInfo.remark);
        ////业务状态
        //m_businessstatecache = jsonResult.fansstate;
        ////聊天记录
        var strContent = "<p><a id=\"btnLookMoreMsg\" href=\"javascript:void(0);\" class=\"moremessage-m\" onclick=\"GetHisMsg();\">更多聊天记录</a></p>";
        $("#divTalkContent").html(strContent);

        if (m_BisLoadTalkMsg) {
        	if (jsonResult.msgs.length > 0) {
        		AppendMsg(jsonResult.msgs);
        	} else {
        		SelectFriendFirstGetHisMsg(); //选择好友主动加载一次对话记录
        	} 
        } else {
        	//追加消息
        	AppendMsg(jsonResult.msgs);
        }
        $("#NoSelFdZheZhao").css("display","none");
    }

}

//打开设置备注框，赋值
function FriendDocBeizhuShow() {
    $("#txtBeizhu").val($.trim($("#txtDocRemark").attr("remark")));
}
//聊天备注
function SetFriendBeizhu() {
    var remarkV = $.trim($("#txtBeizhu").val()).length > 7 ? $.trim($("#txtBeizhu").val()).substring(0, 6) + ".." : $.trim($("#txtBeizhu").val());
    $("#txtDocRemark").val(remarkV);
    $("#txtDocRemark").attr("remark", $.trim($("#txtBeizhu").val()));
    $("#beizhu").modal("hide");
    SetFriendDoc();
}
//SETFDDOC
function SetFriendDoc() {
	RestoreRecordcss();
    var objhidDocWechatKey = $("#hidDocWechatKey");
    var objhidDocPid = $("#hidDocPid");
    var objtxtDocName = $("#txtDocName");
    var objtxtDocAge = $("#txtDocAge");
    var objtxtDocMobile = $("#txtDocMobile");
    var objtxtDocWXCode = $("#txtDocWXCode");
    //var objtxtTagVal = $("#txtTagVal");
    //var objtxtBisVal = $("#txtBisVal");
    var objtxtDocRemark = $("#txtDocRemark").attr("remark");
    var objselectPersonDept = $("#selectPersonDept");
    var objhidDocUin = $("#hidDocUin");
    objtxtDocAge.val($.trim(objtxtDocAge.val()));
    objtxtDocName.val($.trim(objtxtDocName.val()));
    objtxtDocMobile.val($.trim(objtxtDocMobile.val()));
    objtxtDocWXCode.val($.trim(objtxtDocWXCode.val()));
    //objtxtTagVal.val($.trim(objtxtTagVal.val()));
    //objtxtBisVal.val($.trim(objtxtBisVal.val()));

    var strParaJson = $.toJSON({
    	wechatkey: objhidDocWechatKey.val(),
    	pid: objhidDocPid.val(),
    	age: objtxtDocAge.val(),
    	name: objtxtDocName.val(),
    	fmobile: objtxtDocMobile.val(),
    	wxcode: objtxtDocWXCode.val(),
    	remark: objtxtDocRemark,
    	tagval: m_NowSelectFriendTags,
    	ggtagval: m_NowSelectFriendggTags,
    	bisval: m_BusinessCheckStstus,
    	ggbisval: m_BusinessCheckGgStstus,
    	groupname: objselectPersonDept.html(),
    	uin: objhidDocUin.val()
    });
    talkObj.setfrienddoc(strParaJson);
    ResetFriendTagList();//重新绑定标签数据
}

//Updatefdmark
function SetFriendRemarkName() {

    var objtxtDocFriendFinalName = $("#txtDocFriendFinalName");
    var objhidDocUserName = $("#hidDocUserName");
    var objhidDocWechatKey = $("#hidDocWechatKey");
    var objhidDocPid = $("#hidDocPid");

    objtxtDocFriendFinalName.val($.trim(objtxtDocFriendFinalName.val()));

    if (objhidDocWechatKey.val().length == 0
        || objhidDocPid.val().length == 0
        || objhidDocUserName.val().length == 0
        || objtxtDocFriendFinalName.val().length == 0
        || m_NowSelectFriendFinalName == objtxtDocFriendFinalName.val()) {
        return;
    }

    var strParaJson = $.toJSON({
        wechatkey: objhidDocWechatKey.val(),
        pid: objhidDocPid.val(),
        username: objhidDocUserName.val(),
        remarkname: objtxtDocFriendFinalName.val()
    });
    talkObj.setfriendsremarkname(strParaJson);

    m_NowSelectFriendFinalName = objtxtDocFriendFinalName.val();

    //html reset
    if ($("#hFriendFinalName" + objhidDocPid.val()).length > 0) {
        $("#hFriendFinalName" + objhidDocPid.val()).html(m_NowSelectFriendFinalName);
    }
    if ($("#hMailFinalName" + objhidDocPid.val()).length > 0) {
        $("#hMailFinalName" + objhidDocPid.val()).html(m_NowSelectFriendFinalName);
    }
}

//Result
function AsyncSetFriendsRemarkNameResult(jsonResult) {
    if (!jsonResult.success) {
        ShowError("myPageAlert", jsonResult.error);
    }
}

//UpdateRemark
function SetRightRemarkName() {
    var objhidRightRemarkNameBack = $("#hidRightRemarkNameBack");
    var objtxtDocFriendFinalName = $("#txtRightRemarkName");
    var objhidDocUserName = $("#hidRightRemarkNameUserName");
    var objhidDocWechatKey = $("#hidRightRemarkNameWechatKey");
    var objhidDocPid = $("#hidRightRemarkNamePid");

    objtxtDocFriendFinalName.val($.trim(objtxtDocFriendFinalName.val()));

    //if (objhidRightRemarkNameBack.val() == objtxtDocFriendFinalName.val()) {
    //    $("#rightRemarkNameModel").modal("hide");
    //    return;
    //}

    if (objhidDocWechatKey.val().length == 0
        || objhidDocPid.val().length == 0
        || objhidDocUserName.val().length == 0) {
        return;
    }
    var strParaJson = $.toJSON({
        wechatkey: objhidDocWechatKey.val(),
        pid: objhidDocPid.val(),
        username: objhidDocUserName.val(),
        remarkname: objtxtDocFriendFinalName.val()
    });
    talkObj.setfriendsremarkname(strParaJson);

    //html reset
    if (m_NowSelectPid == objhidDocPid.val()) {
        $("#spDocNickName").html(objtxtDocFriendFinalName.val());
    }
    if ($("#hFriendFinalName" + objhidDocPid.val()).length > 0) {
        $("#hFriendFinalName" + objhidDocPid.val()).html(objtxtDocFriendFinalName.val());
    }
    if ($("#hMailFinalName" + objhidDocPid.val()).length > 0) {
        $("#hMailFinalName" + objhidDocPid.val()).html(objtxtDocFriendFinalName.val());
    }
}

//--------------------------------------------好友资料--------------------------------------------

//--------------------------------------------消息--------------------------------------------
//SendMsg
function SendMsg() {
    var objhidDocWechatKey = $("#hidDocWechatKey");
    var objhidDocUin = $("#hidDocUin");
    var objhidDocUserName = $("#hidDocUserName");
    var objhidDocPid = $("#hidDocPid");
    var strTxtSendBody = m_EditorControl.getPlainTxt();

    strTxtSendBody = SuperReplace(strTxtSendBody, "&nbsp;", "");
    strTxtSendBody = SuperReplace(strTxtSendBody, "<div><br></div><div><br></div>", "");
    strTxtSendBody = $.trim(strTxtSendBody);

    if (objhidDocWechatKey.val().length == 0)
        return;
    if (objhidDocUin.val().length == 0)
        return;
    if (objhidDocUserName.val().length == 0)
        return;
    if (objhidDocPid.val().length == 0)
        return;
    if (strTxtSendBody.length == 0)
        return;

    var strParaJson = $.toJSON({
        wechatkey: objhidDocWechatKey.val(),
        uin: objhidDocUin.val(),
        username: objhidDocUserName.val(),
        pid: objhidDocPid.val(),
        msgtype: 1,
        isbatch: m_IsBatch,
        content: strTxtSendBody
    });
    talkObj.sendmsg(strParaJson);

    m_EditorControl.setContent("");
    m_EditorControl.clearContent();
}

//--------------------------------------------消息--------------------------------------------

//SETFDUP
function SetFriendTop(topnum, wechatkey, pid, usename, remarkname) {
	event.cancelBubble = true;//禁止触发父级div事件
    var strParaJson = $.toJSON({
        wechatkey: wechatkey,
        username:usename,
        pid: pid,
        type: topnum,
        remarkname: remarkname
    });
    talkObj.setfriendtop(strParaJson);
}

function AsyncSetFriendTopResult(jsonResult) {
    if (jsonResult.success) {
        ////重新绑定好友
        ////是否有未读消息
        //var bIsChecked = false;
        //if ($("#cbxQueryFriendsNoRead").prop("checked") == true) {
        //    bIsChecked = true;
        //}
        BindFriends();
    } else {
        ShowError("myPageAlert", "操作失败！");
    }
}

//NERFD
function ShowNewFriendList() {
    //模态框
    talkObj.bindnewfriends();
}

//NERFDMODEL
function AsyncBindNewFriendsResult(jsonResult) {
    if (jsonResult.success) {
        var strcontent = "";
        if (jsonResult.list.length > 0) {
            for (var i = 0; i < jsonResult.list.length; i++) {
                var sex = "";
                if (jsonResult.list[i].sex == "1") {
                    sex = "男";
                } else if (jsonResult.list[i].sex == "0") {
                    sex = "女";
                } else {
                    sex = "未知";
                }
                strcontent += '<li>\
                           <img src=' + jsonResult.list[i].bigheadimgurl + ' width="40" \\height="40" class="pull-left">\
                           <div class="talk-header-text talk-header-text01 pull-left">\
                               <div><span>' + jsonResult.list[i].nickname + '</span> 【来自：<span>' + jsonResult.list[i].wechatnickname + '</span>】&nbsp;<span>&nbsp;</span><span>' + sex + '</span>&nbsp;&nbsp;&nbsp;<span>' + jsonResult.list[i].province + "--" + jsonResult.list[i].city + '</span></div>\
                                <span>' + jsonResult.list[i].content + '</span>\
                            </div>';
                var already = jsonResult.list[i].iscomp == false ? "block" : "none";
                strcontent += "<button class=\"btn btn-success btn-sm pull-right\" id=\"FriendsRequest" + i + "\" onclick=\"AcceptFriend('" + jsonResult.list[i].username + "','" + jsonResult.list[i].wechatkey + "','" + jsonResult.list[i].ticket + "','" + i + "')\" style=\"display:" + already + "\">接受</button>\
                            <div class=\"clearfix\"></div>\
                        </li>";
            }
        } else {
            strcontent = "暂无好友请求验证信息！";
        }
        $("#FriendsRequest").html(strcontent);
        //显示模态框
        $("#addfriends").modal("show");
    }
}

//Accept 验证
function AcceptFriend(username, wechatkey, ticket, num) {
    $("#FriendsRequest" + num).hide();
    var strParaJson = $.toJSON({
        wechatkey: wechatkey,
        username: username,
        verifyuserticket: ticket
    });
    talkObj.acceptfriendrequest(strParaJson);
}

function AsyncAcceptFriendRequestResult(jsonResult) {
    if (jsonResult.success) {

    } else {
        ShowError("myPageAlert", "添加好友异常！" + jsonResult.error);
    }
}
//SAE FDTK Remark MODAL
function ShowTalkRemork() {
    $("#TalkRemaker").val($("#txtDocRemarkHidehide").html());
    $("#selectTalkRemakerModel").modal("show");
}
//SAE FDTK Remark
function SaveTalkRemaker() {
    var objhidDocWechatKey = $("#hidDocWechatKey");
    var objhidDocPid = $("#hidDocPid");
    var objtxtDocName = $("#txtDocName");
    var objtxtDocAge = $("#txtDocAge");
    var objtxtDocMobile = $("#txtDocMobile");
    var objtxtDocWXCode = $("#txtDocWXCode");
    //var objtxtTagVal = $("#txtTagVal");
    //var objtxtBisVal = $("#txtBisVal");
    var objtxtDocRemark = $("#TalkRemaker");
    var objselectPersonDept = $("#selectPersonDept");
    var objhidDocUin = $("#hidDocUin");
    objtxtDocAge.val($.trim(objtxtDocAge.val()));
    objtxtDocName.val($.trim(objtxtDocName.val()));
    objtxtDocMobile.val($.trim(objtxtDocMobile.val()));
    objtxtDocWXCode.val($.trim(objtxtDocWXCode.val()));
    //objtxtTagVal.val($.trim(objtxtTagVal.val()));
    //objtxtBisVal.val($.trim(objtxtBisVal.val()));

    var pattern = new RegExp("[~'$^&]");
    if (pattern.test(objtxtDocRemark.val())) {
        ShowMsg("myPageAlert", "聊天备注不可包含特殊字符！");
        return;
    }
    objtxtDocRemark.val($.trim(objtxtDocRemark.val()));
    var strParaJson = $.toJSON({
    	wechatkey: objhidDocWechatKey.val(),
    	pid: objhidDocPid.val(),
    	age: objtxtDocAge.val(),
    	name: objtxtDocName.val(),
    	fmobile: objtxtDocMobile.val(),
    	wxcode: objtxtDocWXCode.val(),
    	remark: objtxtDocRemark,
    	tagval: m_NowSelectFriendTags,
    	ggtagval: m_NowSelectFriendggTags,
    	bisval: m_BusinessCheckStstus,
    	ggbisval: m_BusinessCheckGgStstus,
    	groupname: objselectPersonDept.html(),
    	uin: objhidDocUin.val()
    });
    talkObj.setfrienddoc(strParaJson);
    ResetFriendTagList();//重新绑定标签数据

    $("#txtDocRemark").html(objtxtDocRemark.val());
    $("#txtDocRemarkHidehide").html(objtxtDocRemark.val());
    $("#selectTalkRemakerModel").modal("hide");
}

//BindWX
function ulLoadAllWechats() {
    homeObj.getwechatonlinelist();
}
//ResultWx   ***新版
function AsyncGetWechatOnlineListResult(jsonResult) {
	var BisWechatOnLine = false;

	var strcontent = "";
	strcontent += "<li onclick=\"Misstalk('')\" style=\"cursor:pointer;\"><i class=\"icon iconfont icon-today-dialoguesvg color-blue\"></i><span>今日对话</span></li>";
	strcontent += "<li style=\"cursor:pointer;\" onclick=\"WaitVisitShow()\"><i class=\"icon iconfont icon-wf-visit color-orange\" ></i><span>待回访</span></li>";
	strcontent += "<li onclick=\"ClickBindFriends('allfriends')\" id=\"allfriends\" ondblclick=\"PositioningNoReadMsg('allfriends')\"><i class=\"icon iconfont icon-wechat color-green\"></i><span>全部微信</span></li>";

    //$("#divNoLoginWechat").hide();
    if (jsonResult.success) {
    	if (jsonResult.wechats.length > 0) {
    		for (var j = 0; j < jsonResult.wechats.length; j++) {
    			if (jsonResult.wechats[j].loginstate >= 8) {
    				BisWechatOnLine = true;
    				break;
    			}
    		}
    		if (BisWechatOnLine) {
    			for (var i = 0; i < jsonResult.wechats.length; i++) {
    				var joitem = jsonResult.wechats[i];
    				var strNickNameMark = joitem.nickname;
    				var strWechatRemark = $.trim(joitem.remark) != "" ? joitem.remark : "";
    				if (strNickNameMark.length > 8) {
    					strNickNameMark = strNickNameMark.substring(0, 8) + "...";
    				}
    				if (joitem.loginstate != 8) {
    				    strcontent += "<li><div class=\"wename-tip\">" + strNickNameMark + "(异常)</div> <i><img src=\"" + joitem.headimgurl + "\" onerror=\"nofind();\" /> </i><span id=\"wechatname\"" + strWechatRemark + ">" + strNickNameMark + "(异常)</li>";
    				} else {
    				    strWechatRemark = strWechatRemark.length > 0 ? "<div class=\"wename-tip\">" + strWechatRemark + "</div> " : "";//有备注鼠标悬停才出现悬停提示
    				    strcontent += "<li id= wechat" + joitem.wechatkey + " onclick=\"_WechatClick('" + joitem.wechatkey + "')\" ondblclick=\"_WechatdbClick('" + joitem.wechatkey + "')\">" + strWechatRemark + "<i><img src=\"" + joitem.headimgurl + "\" / onerror=\"nofind();\" ></i><span id=\"wechatname\">" + strNickNameMark + "</span> <span class=\"new-tips\" id=\"fLW" + joitem.wechatkey + "\" style=\"display:none;\">2</span></li>";
    				}
    			}
    		} else {
    			$("#divNoLoginWechat").show();
    		}
    		$(".right-box").css('display', 'block');
    		$("#divNoWechatZheZhao").css('display', 'none');
    		$("#NoSelFdZheZhao").css('display', 'block');
    	} else {
    		$("#divNoLoginWechat").show();
    	}
    	$("#ulLoadAllWechats").html(strcontent);
    	ClickBindFriends(m_UrlParaWechatKey);
    	
    } else {
    	//$("#divNoLoginWechat").show();
    }
}
//ClickBindFriends
function ClickBindFriends(wechatkey) {
	if (BisRunDbClick) {
		return;
	}
	if (m_IsFirstLoad || m_SelectWechatKey != wechatkey) {
		ScreenFdCssClick("");
		ScreenBatchCssClick("");

		//$("#divLoadFriendszhezhao").show();
		//$("#iLoadFriendsTurn").show()
        m_IsChangeWechat = true;
        $("#ulLoadAllWechats").each(function () {
            $(this).find('li').each(function () {
                $(this).removeClass("active");
            });
        });
    		
        $("#LoadFDZhezhao").css("display","block");
        if (wechatkey == "") {
        	//不是通过首页微信号切换到对话
        	var strfirstechat = $("#ulLoadAllWechats li").eq(3)[0].id;
        	wechatkey = strfirstechat.replace("wechat", "");
        	$("#ulLoadAllWechats li").eq(3).addClass("active");
        }
        else if (wechatkey == "allfriends") {
        	$("#allfriends").addClass("active");
        	wechatkey = "";
        }
        else {
        	$("#wechat" + wechatkey).addClass("active");
        }
        m_SelectWechatKey = wechatkey;
        talkObj.setselectwechatkey(wechatkey);
        m_UrlParaWechatKey = wechatkey;

		//2018年03月12  注释掉 (默认加载全部微信号好友  ---  改为默认加载第一个微信号) Start 
		//if (wechatkey == "") {
		//	//$("#allfriends").addClass("active");
		//} else {
		//	$("#wechat" + wechatkey).addClass("active");
		//}
		//End
	}
	$("#myTabContent").animate({ scrollTop: $("#myTabContent").scrollTop() + $('#txtQueryFriendsPoint').offset().top - $("#myTabContent").offset().top - 20 }, 300); //--动画
}
//WaitVisit
function WaitVisitShow() {
	Bindhuifang();
	$("#modal-container-922727").modal("show");
}
//SETGROUP
function Deletefd(wechatkey, pid) {
	event.cancelBubble = true;//禁止触发父级div事件
	var strParaJson = $.toJSON({
		wechatkey: wechatkey,
		pid: pid,
	});
	talkObj.deletefriend(strParaJson);
}

//DElFD
function AsyncDeleteFriendResult(jsonResult) {
	if (jsonResult.success) {
		var objtxtMailQueryFriendsPoint = $("#txtMailQueryFriendsPoint");
		var objselectMailQueryGroup = $("#selectMailQueryGroup");
		var bIsChecked = false;
		if ($("#cbxQueryFriendsNoRead").prop("checked") == true) {
			bIsChecked = true;
		}
		//性别
		var strChecked = 0;
		if ($("#cbxQueryFriendsMan").prop("checked") == true) {
			strChecked = 1;
		} else if ($("#cbxQueryFriendsWoMan").prop("checked") == true) {
			strChecked = 2;
		}
		var strParaJson = $.toJSON({
			wechatkey: m_SelectWechatKey,
			isnoread: bIsChecked,
			sex: strChecked,
			point: $("#txtQueryFriendsPoint").val(),
			pageindex: 0,
			pagesize: 100
		});
		talkObj.queryfriends(strParaJson);
	}
}

//UpdateFriendRemark
function UpdateFriendRemark(name, pid, wechatkey, username, nickname) {
	event.cancelBubble = true;
	var strfriendremark = decodeURI(name);
	if (name.length > 0) {
		$("#txtRightRemarkName").val(strfriendremark);
	} else {
		$("#txtRightRemarkName").val(nickname);
	}
	
	if (nickname.length > 20) {
		nickname = nickname.substring(0,20);
	}

	$("#UpdateFirendRemarkNickname").html(nickname);
	$("#hidRightRemarkNamePid").val(pid);
	$("#hidRightRemarkNameWechatKey").val(wechatkey);
	$("#hidRightRemarkNameUserName").val(username);
	$("#rightRemarkNameModel").modal("show");
}
//SetFriendRemain
function SetFriendRemain(wechatkey, pid, type, username) {
	event.cancelBubble = true;//禁止触发父级div事件
    var strParaJson = $.toJSON({
        wechatkey: wechatkey,
        pid: pid,
        type: type,
        username: username
    });
    talkObj.setfriendremain(strParaJson);
}

//好友消息免打扰回调
function AsyncSetFriendRemainReadResult(jsonResult) {
    if (jsonResult.success) {
        BindFriends();//消息
        BindBatchs();//群组
        BindMail();//通讯录
    }
}

//好友头像变更刷新
function AsyncFriendHeadImg(pid, url) {
    if ($("#imgFlh" + pid).length > 0) {
        $("#imgFlh" + pid).attr("src", decodeURIComponent(url));
    }
    if ($("#imgFth" + pid).length > 0) {
        $("#imgFth" + pid).attr("src", decodeURIComponent(url));
    }
}


//ImportgExcle（导出历史记录）
function InputImportExcelCacheMsgItem(item) {
	var bIsHave = false;
	for (var i = 0; i < m_HisMsgList.length; i++) {
		if (m_HisMsgList[i].msgid == item.msgid) {
			bIsHave = true;
			break;
		}
	}

	if (!bIsHave)
		m_HisMsgList.push(item);
}

//当前聊天新消息添加到缓存（导出历史记录）
function InputImportNowExcelCacheMsgItem(item) {
	var bIsHave = false;
	for (var i = 0; i < m_HisNowMsgList.length; i++) {
		if (m_HisNowMsgList[i].msgid == item.msgid) {
			bIsHave = true;
			break;
		}
	}

	if (!bIsHave)
		if (m_HisNowMsgList.length > 0) {
			m_HisNowMsgList.unshift(item);
		} else {
			m_HisNowMsgList.push(item);
		}

}

function IsWritePage(item) {
	var bIsHave = true;
	for (var i = 0; i < m_HisNowMsgList.length; i++) {
		if (m_HisNowMsgList[i].msgid == item.msgid) {
			bIsHave = false;
		}
	}
	return bIsHave;
}
//修改聊天字体大小
function FontSize(size) {
	m_FontSize = size;
	
	$("#ulSizeMeun li").each(function () {
			$(this).removeClass("active");
	});
	if (m_FontSize == "0") {
		$("#liSizeNormal").addClass("active");
	} else if (m_FontSize == "1") {
		$("#liSizeBig").addClass("active");
	} else {
		$("#liBigBig").addClass("active");
	}
	

	if (m_FontSize == "1") {
		$("#divTalkContent .MsgRigth").each(function () {
			$(".MsgRigth").removeClass(" talkdetailedduihua-m-xxl").addClass(" talkdetailedduihua-m-xl");
		});
	} else if (m_FontSize == "2") {
		$("#divTalkContent .MsgRigth").each(function () {
			$(".MsgRigth").removeClass(" talkdetailedduihua-m-xl").addClass(" talkdetailedduihua-m-xxl");
		});
	} else {
		$("#divTalkContent .MsgRigth").each(function () {
			$(".MsgRigth").removeClass(" talkdetailedduihua-m-xl").removeClass(" talkdetailedduihua-m-xxl");
		});
	}

	var strParaJson = $.toJSON({
		size: size,
	});
	talkObj.setwechatfontsize(strParaJson);
}
function AsyncSetWechatFontSizeResult(jsonResult) {
	if (jsonResult.success) {
	} else {
		ShowError("myPageAlert", "改变字体大小异常！" + jsonResult.error);
	}
}

//Get Size
function GetWechatFontSize() {
	m_FontSize = talkObj.getwechatfontsize();

	$("#ulSizeMeun li").each(function () {
		$(this).removeClass("active");
	});
	if (m_FontSize == "0") {
		$("#liSizeNormal").addClass("active");
	} else if (m_FontSize == "1") {
		$("#liSizeBig").addClass("active");
	} else {
		$("#liBigBig").addClass("active");
	}
}

function AddTaskDivShow() {
	if ($("#divAddTask").css("display") == 'none') {
		$("#divAddTask").show();
	} else {
		$("#divAddTask").hide();
	}
	
}


function addtask() {
    var content = $("#txtTaskContent").val();
    if (content == "") {
        ShowError("myPageAlert", "回访描述不能为空！");
        return;
    }
    var strParaJson = $.toJSON({
        plantime: $("#txtReturnVisitTime").val(),
        taskcontent: content,
        pid: $("#hidDocPid").val(),
        uin: $("#hidDocUin").val()
    });
    homeObj.addtask(strParaJson);
}

function AsyncAddTaskResult(jsonResult) {
    if (jsonResult.success) {
        $("#txtTaskContent").val("");
        //回访时间，默认明天
        $("#txtReturnVisitTime").val(homeObj.gettomorrowday());
        ShowMsg("myPageAlert", "保存成功！");
        AddTaskDivShow();
    } else {
        ShowError("myPageAlert", "保存异常：" + jsonResult.error);
    }
}

//*************************************************待回访********************************************************
var taskIsfirst = true;
//回访相关控件初始化
function initTask() {
	$('#txtTimeFrom').datetimepicker({
		language: "zh-CN",
		weekStart: 1,
		todayBtn: 1,
		autoclose: true,
		todayHighlight: 1,
		startView: 2,
		forceParse: 0,
		showMeridian: 1,
		minView: "month",
		format: "yyyy-mm-dd"
	});
	$('#txtTimeTo').datetimepicker({
		language: "zh-CN",
		weekStart: 1,
		todayBtn: 1,
		autoclose: true,
		todayHighlight: 1,
		startView: 2,
		forceParse: 0,
		showMeridian: 1,
		minView: "month",
		format: "yyyy-mm-dd"
	});
	$('#txtReturnVisitTimemo').datetimepicker({
		language: "zh-CN",
		weekStart: 1,
		todayBtn: 1,
		autoclose: true,
		todayHighlight: 1,
		startView: 2,
		forceParse: 0,
		showMeridian: 1,
		minView: "month",
		format: "yyyy-mm-dd"
	});

	$('#txtTimeTo').val(homeObj.gettoday());
	$('#txtTimeFrom').val(homeObj.gettoday());
}

//选择时间段
function selectDate(section) {
	var myDate = new Date();
	switch (section) {
		case 1://今天
			$('#txtTimeFrom').val(homeObj.gettoday());
			$('#txtTimeTo').val(homeObj.gettoday());
			break;
		case 2://明天
			$('#txtTimeFrom').val(homeObj.gettomorrowday());
			$('#txtTimeTo').val(homeObj.gettomorrowday());
			break;
		case 3://本周
			$('#txtTimeFrom').val((myDate.getFullYear()) + "-" + Appendzero(myDate.getMonth() + 1) + "-" + Appendzero(myDate.getDate()));
			var nowTime = myDate.getTime();
			var day = myDate.getDay();
			var oneDayLong = 24 * 60 * 60 * 1000;
			var SundayTime = nowTime + (7 - day) * oneDayLong;
			var sunday = new Date(SundayTime);
			$('#txtTimeTo').val((sunday.getFullYear()) + "-" + Appendzero(sunday.getMonth() + 1) + "-" + Appendzero(sunday.getDate()));
			break;
		case 4://下周
			var nowTime = myDate.getTime();
			var day = myDate.getDay();
			var oneDayLong = 24 * 60 * 60 * 1000;
			var SundayTime = nowTime + (8 - day) * oneDayLong;
			var sunday = new Date(SundayTime);
			$('#txtTimeFrom').val((sunday.getFullYear()) + "-" + Appendzero(sunday.getMonth() + 1) + "-" + Appendzero(sunday.getDate()));
			var SundayTimeTo = nowTime + (14 - day) * oneDayLong;
			var sundayTo = new Date(SundayTimeTo);
			$('#txtTimeTo').val((sundayTo.getFullYear()) + "-" + Appendzero(sundayTo.getMonth() + 1) + "-" + Appendzero(sundayTo.getDate()));
			break;
		default:
			break;
	}
	Bindhuifang();
}
//获得本周的停止日期 
function getWeekEndDate() {
	var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek));
	return formatDate(weekEndDate);
}
function Appendzero(obj) {
	if (obj < 10) return "0" + "" + obj;
	else return obj;
}

function Bindhuifang() {
    var time1 = Date.parse(new Date("20" + $("#txtTimeFrom").val()));
    var time2 = Date.parse(new Date("20" + $("#txtTimeTo").val()));
    var diff = parseInt((time2 - time1) / 1000 / 3600 / 24);
    if (diff < 0) {
        ShowError("myPageAlert", "起始时间不能大于终止时间");
        return;
    }

	nPageIndex = 0;
	var strJson = $.toJSON({
		pageindex: nPageIndex,
		pagesize: nPageSize,
		starttime: $('#txtTimeFrom').val(),
		endtime: $('#txtTimeTo').val(),
		type: "0" //0代表未完成，1待定，2代表已完成
	});
	homeObj.gettakslist(strJson);
}

//查询回访回调
function AsyncGetTaksListResult(jsonResult) {
    if (jsonResult.success) {
        $("#mytbody").empty();
		nPageCount = Math.ceil(Number(jsonResult.result.total) / (nPageSize));
		var list = jsonResult.result.list;
		//if (taskIsfirst) {
		$("#pForVisit").html("待回访");/*(" + list.length + ")*/
		taskIsfirst = false;
	    //}

        //回访数量大于0时，聊天页回访图片变成动图，并显示回访数量
		if (list.length > 0) {
		    $("#imgWaitVisit").attr("src", "../img/homeicon08.gif");
		    $("#huifangNumber").attr("style", "display: block;");
		    var number = list.length > 99 ? 99 : list.length;
		    $("#huifangNumber").html(number);
		} else {
		    $("#imgWaitVisit").attr("src", "../img/homeicon08.png");
		    $("#huifangNumber").attr("style", "display: none;");
		}
		if (list.length > 0) {
			$("#tbTask").show();
			$("#DivFooter").html(GetPageFootStr(nPageIndex, jsonResult.result.total));
			$("#DivFooter").show();
			$("#noneDataTipsTask").hide();
			//<td>' + item.pid + '</td>\
			for (var index in list) {
				var item = list[index];
				var trstr = '\
                    <tr>\
                        <td>' + (parseInt(index) + 1) + '</td>\
                        <td>' + item.uin + '</td>\
                        <td>' + item.nickname + '</td>\
                        <td>' + item.plantime + '</td>\
                        <td><p style="width:200px;">' + item.taskcontent + '</p></td>\
                        <td>\
                            <a class="a-btn" onclick="reVisit(\'' + item.id + '\',\'' + item.uin + '\',\'' + item.pid + '\');">回访</a>\
                            <a class="a-btn" onclick="showEditTask(\'' + item.id + '\',\'' + item.plantime + '\',\'' + item.taskcontent + '\');"\
                                 data-toggle="modal" data-target="#myModalEdit">修改</a>\
                            <a class="a-btn" onclick="deleteTask(\'' + item.id + '\');">忽略</a>\
                        </td>\
                    </tr>';
				$("#mytbody").append(trstr);
			}
		} else {
			$("#tbTask").hide();
			$("#DivFooter").hide();
			$("#noneDataTipsTask").show();
		}
	} else {
		$("#tbTask").hide();
		$("#DivFooter").hide();
		$("#noneDataTipsTask").show();
		ShowError("myPageAlert", "获取数据异常：" + jsonResult.error);
	}
}
//弹出修改窗口
function showEditTask(id, plantime, taskcontent) {
	$("#txtReturnVisitTimemo").attr("taskid", id);
	$("#txtReturnVisitTimemo").val(plantime);
	$("#txtTaskContentmo").val(taskcontent);
}
//修改回访
function editTask() {
	var content = $("#txtTaskContentmo").val();
	if (content == "") {
		ShowError("myPageAlert", "回访描述不能为空！");
		return;
	}
	var strJson = $.toJSON({
		id: $('#txtReturnVisitTimemo').attr("taskid"),
		plantime: $('#txtReturnVisitTimemo').val(),
		taskcontent: content
	});
	homeObj.edittask(strJson);
}
//修改回访回调
function AsyncEditTaskResult(jsonResult) {
	if (jsonResult.success) {
		ShowMsg("myPageAlert", "修改成功！");
		$("#myModalEdit").modal("hide");
		Bindhuifang();
	} else {
		ShowError("myPageAlert", "修改异常：" + jsonResult.error);
	}
}

//删除回访
function deleteTask(id) {
	var strJson = $.toJSON({
		id: id
	});
	homeObj.deletetask(strJson);
}
//删除回调
function AsyncDeleteTaskResult(jsonResult) {
	if (jsonResult.success) {
		ShowMsg("myPageAlert", "删除成功！");
		Bindhuifang();
	} else {
		ShowError("myPageAlert", "删除异常：" + jsonResult.error);
	}
}
//回访+完成
function reVisit(id, uin, pid) {
	var wechatkey = homeObj.getwechatkeybyuin(uin + "");
	if (wechatkey.length == 0) {
		ShowError("myPageAlert", "该微信不在线或者在其它客服处登录！");
	} else {
		var strJson = $.toJSON({
			id: id,
			taskresult: ""
		});
		homeObj.perfectiontask(strJson);
		window.location.href = "talk.html?wechatkey=" + wechatkey + "&pid=" + pid;
	}
}
//完成回调
function AsyncPerfectionTaskResult(jsonResult) {
	if (jsonResult.success) {
		BindData();
	} else {
		ShowError("myPageAlert", "操作异常：" + jsonResult.error);
	}
}

//******************************************今日对话**********************************************************
var m_TodayTalkCacheList = [];//今日对话缓存
var m_Userid = "";//存储切换客服页面选中人的userid，判断是否为本人，不是则不能跟进
var m_StrUserids = "";//选中人员的userid的集合，逗号分割
function ClickTodayTalkDay(val) {

    $("#btnTodayTalkQueryAll").attr("class", "");
    $("#btnTodayTalkQueryCS").attr("class", "");
    $("#btnTodayTalkUntreated").attr("class", "");
    if (val == 0) {
        $("#btnTodayTalkQueryAll").addClass("btn btn-success");
        $("#btnTodayTalkQueryCS").addClass("btn btn-default");
        $("#btnTodayTalkUntreated").addClass("btn btn-default");
    } else if (val == 1) {
        $("#btnTodayTalkQueryAll").addClass("btn btn-default");
        $("#btnTodayTalkQueryCS").addClass("btn btn-success");
        $("#btnTodayTalkUntreated").addClass("btn btn-default");
    } else if (val == 3) {
        $("#btnTodayTalkQueryAll").addClass("btn btn-default");
        $("#btnTodayTalkQueryCS").addClass("btn btn-default");
        $("#btnTodayTalkUntreated").addClass("btn btn-success");
    }
    BindTodayTalk();
}

//部门回调
function AsyncGetDeptByAuthResult(jsonResult) {
    if (jsonResult.success) {
        $("#selDept").empty();
        m_StrUserids = jsonResult.myself.userid + ",";
        var deptlist = jsonResult.deptlist;
        $("#selDept").append("<option value='" + jsonResult.myself.userid + "' tag='user' name='" + jsonResult.myself.username + "'>本人</option>");
        if (jsonResult.deptlist.length > 0) {
            for (var index in deptlist) {
                var item = deptlist[index];
                $("#selDept").append("<option value='" + item.dgid + "'>" + item.dgname + "</option>");
            }
        } else {
            $("#selDept").hide();
        }
        BindCompanyUsers();
    } else {
        ShowError("myPageAlert", "获取数据异常：" + jsonResult.error);
    }
    $(".loadingcover").hide();
    $(".loading").hide();
}

function BindCompanyUsers() {
    var paraJson;
    $("#selUser").empty();
    var selectDom = $("#selDept").find("option:selected");
    alluin = "";
    if (selectDom.attr("tag") == "user") {
        $("#selUser").append("<option value='" + selectDom.val() + "' tag='user' selected='true'>" + selectDom.attr("name") + "</option>");
        m_StrUserids = selectDom.val() + ",";
        BindTodayTalk();
    } else {
        $("#selUser").append("<option value=''>客服</option>");
        paraJson = $.toJSON({
            deptid: $("#selDept").val()
        });
        homeObj.getpersonbydeptid(paraJson);
    }
}

//绑定人员回调
function AsyncGetPersonByDeptidResult(jsonResult) {
    m_StrUserids = "";//清空人员userid集合
    var selUser = $("#selUser");
    if (jsonResult.success) {
        var jsonObj = jsonResult.user;
        var jsonList = jsonObj.list;
        var currentId = jsonObj.loginuid;
        for (var i = 0; i < jsonList.length; i++) {
            var item = jsonList[i];
            selUser.append("<option value='" + item.userid + "'>" + item.name + "</option>");
            m_StrUserids += item.userid + ",";
            BindTodayTalk();
        }
    } else {
        ShowError("myPageAlert", "获取数据异常：" + jsonResult.error);
    }
}

//今日对话modal层显示
function Misstalk(userid) {
    m_Userid = userid;
    //获取部门
    var paraJson = $.toJSON({
        type: "data"
    });
    homeObj.getdeptbyauth(paraJson);
    $("#misstalk").modal("show");
}

// 获取错失信息
function BindTodayTalk() {
    m_TodayTalkCacheList = [];//点击查看对话时清空今日对话对话缓存
    
    var strType = "0";
    if ($("#btnTodayTalkQueryCS").attr("class") == "btn btn-success") {
        strType = "1";
    } else if ($("#btnTodayTalkUntreated").attr("class") == "btn btn-success") {
        strType = "2";
    }
    
    $("#misstalk").modal("show");
    $("#iDataTalkTurn").show();
    $("#DataTalkzhezhao").show();
    $("#divMissTable").html("");
    var strUserid = m_StrUserids.substr(0, m_StrUserids.length - 1);
    if (strUserid == "") {
        $("#divMissTable").html("暂时没有数据！");
        $("#divMissTable").hide();
        $("#noneDataTips").show();
        $("#iDataTalkTurn").hide();
        $("#DataTalkzhezhao").hide();
        return;
    }
    var strJson = $.toJSON({
        userids: strUserid,
        type: strType//类型0全部，1错失  2未处理
    });
    // 获取今日对话信息  回调是:AsyncGetMissTalkResult
    homeObj.getmisstalk(strJson);
}

function AsyncGetMissTalkResult(jsonResult) {
    if (jsonResult.success) {
        if (jsonResult.list != null && jsonResult.list.length > 0) {
            m_TodayTalkCacheList = jsonResult.list;

            BindTodayTalkCacheList();
        } else {
            $("#missTable").hide();
            $("#noneDataTips").show();
        }
    } else {
        ShowError("myPageAlert", "获取数据异常：" + jsonResult.error);
    }
    $("#iDataTalkTurn").hide();
    $("#DataTalkzhezhao").hide();
}

//遍历今日对话的好友信息
function BindTodayTalkCacheList() {
    //var cususerid = talkObj.getcususerid();
    var strType = "0";
    if ($("#btnTodayTalkQueryCS").attr("class") == "btn btn-success") {
        strType = "1";
    }

    var list = m_TodayTalkCacheList;
    var strContent = "";
    var nSelectRowCount = 0;
    if (list.length > 0) {
        strContent = "<table class=\"table table-bordered\"><tr><th>客服微信昵称</th><th>微信描述</th><th>好友ID</th><th>好友头像</th><th>备注/昵称</th><th>开始时间</th><th>好友消息数</th><th>客服消息数</th>";
        //if (cususerid == m_Userid || m_Userid == "") {
            strContent += "<th width=\"70\">操作</th>";
        //}
        strContent += '</tr>';
        for (index in list) {
            var item = list[index];

            if (strType == "1" && item.custalkcount != 0) {
                continue;
            }

            var datarow = '<tr>\
                            <td>' + item.wnickname + '</td>\
                            <td>' + item.wremark + '</td>\
                            <td>' + item.pid + '</td>\
                            <td><img src="' + item.headimgurl + '" width="40" onerror="nofind()" /></td>\
                            <td>' + item.nickname + '</td>\
                            <td>' + item.talkstarttime.substr(2, 14).replace("T", " ") + '</td>\
                            <td>' + item.friendtalkcount + '</td>\
                            <td>' + item.custalkcount + '</td>';
            //if (cususerid == m_Userid || m_Userid == "") {
                datarow += '<td><button class="btn btn-success"  onclick="gotoTalk(' + item.uin + "," + item.pid + ');">跟进</button></td>';
            //}
            datarow += '</tr>';

            strContent += datarow;
            nSelectRowCount++;
        }
        strContent += "</table>";
        $("#divMissTable").html(strContent);

        if (nSelectRowCount > 0) {
            $("#divMissTable").show();
            $("#noneDataTips").hide();
        } else {
            $("#divMissTable").hide();
            $("#noneDataTips").show();
        }
    } else {
        $("#divMissTable").html("暂时没有数据！");
        $("#divMissTable").hide();
        $("#noneDataTips").show();
    }
}

function gotoTalk(uin, pid) {
	$("#DivAllTab").hide();
	event.cancelBubble = true;//禁止触发父级div事件
	var wechatkey = homeObj.getwechatkeybyuin(uin + "");
	if (wechatkey.length == 0) {
		ShowError("myPageAlert", "该微信不在线或者在其它客服处登录！");
	} else {
		window.location.href = "talk.html?wechatkey=" + wechatkey + "&pid=" + pid;
	}
}

//消息列表筛选事件
function FriendMsgListTrem() {
	var strMsgListTrem = $("#divFriendMsgListTrem").is(':hidden');
	if (strMsgListTrem) {
		$("#divFriendMsgListTrem").show();
		$("#divFriendTremIcon").removeClass("glyphicon-triangle-bottom").addClass("glyphicon-triangle-top");
		$(".fanslist").css({
			height: $(window).height() - 167
		});
	} else {
		$("#divFriendMsgListTrem").hide();
		$("#divFriendTremIcon").removeClass("glyphicon-triangle-top").addClass("glyphicon-triangle-bottom");
		$("#ulFriendHeadList").css({
			height: $(window).height() - 101
		});
		$("#ulBatchHeadList").css({
        height: $(window).height() - 101
    });
	}
}

//消息列表筛选事件
function FriendBatchListTrem() {
	var strMsgListTrem = $("#divFriendBatchListTrem").is(':hidden');
	if (strMsgListTrem) {
		$("#divFriendBatchListTrem").show();
		$("#divBatchTremIcon").removeClass("glyphicon-triangle-bottom").addClass("glyphicon-triangle-top");
		$(".fanslist").css({
			height: $(window).height() - 150
		});
	} else {
		$("#divFriendBatchListTrem").hide();
		$("#divBatchTremIcon").removeClass("glyphicon-triangle-top").addClass("glyphicon-triangle-bottom");
		$("#ulBatchHeadList").css({
        height: $(window).height() - 101
    });
	}
}
//键盘向上向下好友选中
function KeyCodeUpAndDown(type){
	if (m_NowSelectPid.length < 0) {
		return;
	}
	if (type == "1") {
		if ($("#liFriendHead" + m_NowSelectPid).prev() != null) {
			setTimeout(function () { $("#liFriendHead" + m_NowSelectPid).prev("li").click(); },100);
		}
	} else {
		if ($("#liFriendHead" + m_NowSelectPid).next() != null) {
			setTimeout(function () { $("#liFriendHead" + m_NowSelectPid).next("li").click(); }, 100);
		}
	}
}

//修改好友档案css
function ChangePropertyCss(value) {
	if (value == "selectPersonDept") {
		$("#divselectPersonDept").removeClass("disabled");
		$("#divselectPersonDept").addClass("dis-modify");
	} else {
		if ($("#" + value).val() == "暂无") {
			$("#" + value).val("");
		}
		$("#" + value).addClass("dis-modify");
		$("#" + value).removeAttr("readonly");
		$("#" + value).removeAttr("disabled");
	}
}
//恢复档案样式
function RestoreRecordcss() {
	if ($("#txtDocName").hasClass("dis-modify")) {
		$("#txtDocName").removeClass("dis-modify")
		$("#txtDocName").attr("readonly", "readonly");
		$("#txtDocName").attr("disabled", "disabled");
	}
	if ($("#txtDocAge").hasClass("dis-modify")) {
		$("#txtDocAge").removeClass("dis-modify")
		$("#txtDocAge").attr("readonly", "readonly");
		$("#txtDocAge").attr("disabled", "disabled");
	}
	if ($("#txtDocWXCode").hasClass("dis-modify")) {
		$("#txtDocWXCode").removeClass("dis-modify")
		$("#txtDocWXCode").attr("readonly", "readonly");
		$("#txtDocWXCode").attr("disabled", "disabled");
	}
	if ($("#txtDocMobile").hasClass("dis-modify")) {
		$("#txtDocMobile").removeClass("dis-modify")
		$("#txtDocMobile").attr("readonly", "readonly");
		$("#txtDocMobile").attr("disabled", "disabled");
	}
	if ($("#txtDocRemark").hasClass("dis-modify")) {
		$("#txtDocRemark").removeClass("dis-modify")
		$("#txtDocRemark").attr("readonly", "readonly");
		$("#txtDocRemark").attr("disabled", "disabled");
	}
	if ($("#divselectPersonDept").hasClass("dis-modify")) {
		$("#divselectPersonDept").addClass("friends-dropdown disabled");
		$("#divselectPersonDept").removeClass("dis-modify");
	}
}
//消息列表筛选好友css
function ScreenFdCssClick(value) {
	//msg
	if (value == "cbxQueryFriendsAllMsg" || value == "cbxQueryFriendsNoRead") {
		$("#cbxQueryFriendsAllMsg").removeClass("serch-active");
		$("#cbxQueryFriendsNoRead").removeClass("serch-active");
		if (value == "cbxQueryFriendsAllMsg") {
			$("#cbxQueryFriendsAllMsg").addClass("serch-active");
		} else {
			$("#cbxQueryFriendsNoRead").addClass("serch-active");
		}
	}
	//sex
	if (value == "cbxQueryFriendsMan" || value == "cbxQueryFriendsWoMan" || value == "cbxQueryFriendsAllSex") {
		$("#cbxQueryFriendsMan").removeClass("serch-active");
		$("#cbxQueryFriendsWoMan").removeClass("serch-active");
		$("#cbxQueryFriendsAllSex").removeClass("serch-active");
		if (value == "cbxQueryFriendsMan") {
			$("#cbxQueryFriendsMan").addClass("serch-active");
		} else if (value == "cbxQueryFriendsWoMan") {
			$("#cbxQueryFriendsWoMan").addClass("serch-active");
		} else if (value == "cbxQueryFriendsAllSex") {
			$("#cbxQueryFriendsAllSex").addClass("serch-active");
		}
	}

	if (value == "") {
		$("#cbxQueryFriendsAllMsg").removeClass("serch-active");
		$("#cbxQueryFriendsNoRead").removeClass("serch-active");
		$("#cbxQueryFriendsMan").removeClass("serch-active");
		$("#cbxQueryFriendsWoMan").removeClass("serch-active");
		$("#cbxQueryFriendsAllSex").removeClass("serch-active");
		$("#cbxQueryFriendsAllMsg").addClass("serch-active");
		$("#cbxQueryFriendsAllSex").addClass("serch-active");
	}
}
//消息列表筛选群css
function ScreenBatchCssClick(value) {
	if (value == "cbxQueryBatchAllMsg" || value == "cbxQueryBatchNoRead") {
		$("#cbxQueryBatchAllMsg").removeClass("serch-active");
		$("#cbxQueryBatchNoRead").removeClass("serch-active");
	}
	if (value == "cbxQueryBatchAllMsg") {
		$("#cbxQueryBatchAllMsg").addClass("serch-active");
	} else {
		$("#cbxQueryBatchNoRead").addClass("serch-active");
	}

	if (value == "") {
		$("#cbxQueryBatchAllMsg").removeClass("serch-active");
		$("#cbxQueryBatchNoRead").removeClass("serch-active");
		$("#cbxQueryBatchAllMsg").addClass("serch-active");
	}
}