var isFirstShowTopMsg = true;
$(document).ready(function() {

	if (/mobile/i.test(navigator.userAgent) || /android/i.test(navigator.userAgent)) {
		$(".title-box").hide();
	}

	if ($.cookie("token") == null) {
		window.location.href = "login.html";
	}

	obj.AgentExten = $.cookie("extno");
	if (obj.AgentExten == undefined) {
		$(".Gnumbox").hide();
	}
	$(".Gnum").text(obj.AgentExten);
	// 获取顶部获取消息
	getTopMsgs();
	setInterval(function() {
		getTopMsgs();
	}, huayi.config.topMsgTime);
	$.getJSON(huayi.config.callcenter_url + 'UserAccount/GetNowUser', {
		"token": $.cookie("token")
	}, function(result) {
		if (result.state.toLowerCase() == "success") {
			// console.log(result);
			// $.cookie("userType", result.data.usertype, {
			// 	expires: 7
			// });

			$.cookie("userRoleId", result.data.role.F_RoleId, {
				expires: 7
			});
			
			$.cookie("userRoleCode", result.data.role.F_RoleCode, {
				expires: 7
			});

			$(".username").text(result.data.user.F_UserName);
			$('.user_code').text(result.data.user.F_WorkNumber);
			localStorage.setItem('F_UserCode', result.data.user.F_UserCode)
			$('.group').text(result.data.user.F_SeartGroup);
			if (result.data.role) {
				// console.log(result.data);
				$(".rolename").text(result.data.role.F_RoleName);
			}
			$(".yhtx").attr("src", huayi.config.callcenter_url.substr(0, huayi.config.callcenter_url.length - 1) + result.data
				.user.F_See);
			obj.AgentGroup = result.data.user.F_SeartGroupID;
			obj.AgentID = result.data.user.F_UserCode;
			//obj.AgentExten = result.data.user.F_WorkNumber;
			if (result.data.user.F_SeatFlag) {
				Connect();
				$("#top-search").show();
				$(".phoneBZ").show();
				$(".zts").show();
			}
		}
	})

	//分机号
	//话务相关
	$("#top-search li").click(function() {
		if ($(this).find("i").hasClass("active")) {
			if (obj.AgentID) {
				var fun = $(this).attr("datafun");
				obj.Type = fun;
				switch (fun) {
					case "Login":
						//									obj.AgentGroup = "364";
						obj.AgentType = "0";
						Send();
						break; //签入
					case "MakeCall":
						obj.Type = "SayFree";
						Send(); //备注：用户要求外呼立刻置闲
						$(".hidCallID").val("");
						$("#hidwhtype").val(fun);
						whtp();
						//obj.DestinationNumber = "1012";
						break; //外呼
					case "Meeting":
						$("#hidwhtype").val(fun);
						whtp();
						//obj.DestinationNumber = "1012";
						break; //多方通话
					case "Transfer":
						$("#hidwhtype").val(fun);
						whtp();
						//obj.DestinationNumber = "1012";
						break; //转移
					default:
						Send();
						break;

				}
			}
		}
	});

	//关闭外呼弹屏
	$(".closes").click(function() {
		$(".WH").removeClass("fadeInDown").addClass("fadeOutUp");
		$(".WH").addClass("hidens");
	})
	//键盘事件外呼
	document.onkeydown = function(e) {
		var theEvent = window.event || e;
		var code = theEvent.keyCode || theEvent.which;
		if (code == 13) {
			$(".CallOut").click();
		}
	}
	//外呼呼出
	$(".CallOut").click(function(event) {
		event.stopPropagation();
		if ($("#Result").val()) {
			$.ajax({
				type: "get",
				url: huayi.config.callcenter_url + "CallOutOpt/GetCallOutprefix",
				async: true,
				dataType: 'json',
				data: {
					token: $.cookie("token"),
					phone: $("#Result").val()
				},
				success: function(result) {
					//                		result = $.parseJSON(result);
					if (result.state.toLowerCase() == "success") {
						var guid = uuid();
						obj.Type = $("#hidwhtype").val();
						obj.DestinationNumber = result.data.phone;
						obj.Header = result.data.fix;
						top.obj.TaskType = "0"; //0:拨号外呼；1:95005回访外呼；2:电销回访外呼
						top.obj.TaskPhoneID = ""; //回访的电话ID
						top.obj.TaskID = guid; //回访记录编号
						Send();
						$('#Result').val('');
						$(".WH").addClass("hidens");
					}

				}
			});

			//						obj.Type = $("#hidwhtype").val();
			//						obj.DestinationNumber = $("#Result").val();
			//						Send();
		}
	})
	//外呼弹屏数字键盘样式
	$(".Num_ul div").mousedown(function() {
		$(this).addClass("actives");
		$(".img").removeClass("hidens");
	}).mouseup(function() {
		$(this).removeClass("actives");
	})
	//外呼弹屏数字键盘号码输入
	$(".Num_ul li div").click(function() {
		var rt = $("#Result").val() + "";
		if (rt.length < 18) {
			rt = rt + $(this).find("a").text();
			$("#Result").val(rt);
		}
	});
	//外呼弹屏数字键盘号码截取
	$(".img").click(function() {
		var Result = $("#Result").val() + "";
		Result = Result.substr(0, Result.length - 1);
		$("#Result").val(Result);
		if (Result.length == 0) {
			$(".img").addClass("hidens");
		}
	})
	//外呼电话列表
	$(".bg_title li").click(function() {
		$(this).addClass("lactive").siblings().removeClass("lactive");
		loadWH();
	})
	$(".ty").click(function() {
		loadWH();
	});

	//加载左侧导航菜单
	loadMenu();

	workcount();
	setInterval(function() {
		workcount();
	}, huayi.config.menuworktime);

	//修改密码开始
	$('.shezhi').click(function() {
		Dialog('dialogDrag', 'dialogMove');
		showDialog();
		//侦听浏览器窗口大小变化
		window.onresize = function() {
			if ($('#dialogMove').is(':visible')) {
				showDialog();
			}
		}
		$.ajax({
			type: "get",
			url: huayi.config.callcenter_url + "UserAccount/GetNowUser",
			async: true,
			dataType: 'json',
			data: {
				token: $.cookie("token")
			},
			success: function(result) {

				if (result.state.toLowerCase() == "success") {
					var con = result.data.user;
					// console.log(con)
					$('.mgh').val(con.F_UserId);
					$('.mn').val(con.F_UserName);
					$('.mobile').val(con.F_Mobile);
					$('.fenji').val($.cookie("extno"));
					//$('.wxno').val(con.F_WXNo);
					//		          		$('.spwd').val(con.F_Password);
				}
			}
		});

	})
	//tab切换
	$('.perTab li').click(function() {
		$(this).addClass('sel').siblings().removeClass('sel');
		var index = $(this).index();
		$('.perTab_con').children('div').eq(index).show().siblings().hide();
	})
	//编辑个人资料
	$('.grzl tbody>tr>td input.zhidu').attr('readonly', true);
	$('.grbj').click(function() {
		$('.grzl tbody>tr>td input.zhidu').attr('readonly', false);
		$('.grzl tbody>tr>td input.zhidu').css('border-bottom', "1px solid #b3b3b3");
		$('.grbtn').attr('disabled', false);
	})
	//取消编辑
	$('.grqx').click(function() {
		$('.grzl tbody>tr>td input.zhidu').attr('readonly', true);
		$('.grzl tbody>tr>td input.zhidu').css('border-bottom', "none");
		$('.grbtn').attr('disabled', true);
	})
	//关闭按钮
	$('.ptr').click(function() {
		hideDialog();
	})
	$('.grbtn').click(function() {
		var gh = $('.mgh').val();
		var xm = $('.mn').val();
		var ymm = $('.spwd').val();
		var xmm = $('.npwd').val();
		var qmm = $('.epwd').val();
		if (xmm !== qmm) {
			$('.wrong').show();
			$('.npwd').val('')
			$('.epwd').val('')
		} else if (xmm == '') {
			layer.msg("密码不允许为空！");
		} else {
			$('.wrong').hide();
			$('.grzl tbody>tr>td input').attr('readonly', true);
			$('.grzl tbody>tr>td input').css('border-bottom', "none");
			$.ajax({
				type: "post",
				url: huayi.config.callcenter_url + "UserAccount/UpdatePwd",
				async: true,
				dataType: 'json',
				data: {
					token: $.cookie("token"),
					usercode: gh,
					pwd: xmm,
					oldpwd: ymm,
					mobile: $('.mobile').val()
				},
				success: function(result) {
					//                		result = $.parseJSON(result);
					if (result.state.toLowerCase() == "success") {
						layer.msg("修改成功！");
					}
				}
			});
		}
	})

	//图片裁剪
	var o = $(".image-crop > img");
	$(o).cropper({
		aspectRatio: 1 / 1,
		resizable: false,
		dragCrop: false,
		preview: ".img-preview",
		done: function() {}
	});
	var r = $("#inputImage");
	if (window.FileReader) {
		r.change(function() {
			var e, i = new FileReader,
				t = this.files;
			if (t.length && (e = t[0], /^image\/\w+$/.test(e.type))) {
				i.readAsDataURL(e);
				i.onload = function() {
					r.val("");
					o.cropper("reset", !0).cropper("replace", this.result);
				}

			} else {
				alert("请选择图片文件");
			}
		});
		$("#setDrag").click(function() {
			o.cropper("setDragMode", "crop");
			var img = o.cropper("getDataURL");
			$.post(huayi.config.callcenter_url + "Index/UploadTX64", {
				dataurl: encodeURIComponent(img),
				"token": $.cookie("token")
			}, function(result) {
				result = $.parseJSON(result);
				if (result.state.toLowerCase() == "success") {
					$(".yhtx").attr("src", huayi.config.callcenter_url.substr(0, huayi.config.callcenter_url.length - 1) +
						result.data);
					layer.msg("上传成功");
					hideDialog();
				}
			})
		});
		$("#zoomIn").click(function() {
			o.cropper("zoom", .1)
		});
		$("#zoomOut").click(function() {
			o.cropper("zoom", -.1)
		});
		$("#rotateLeft").click(function() {
			o.cropper("rotate", 45)
		});
		$("#rotateRight").click(function() {
			o.cropper("rotate", -45)
		});
	} else {
		r.addClass("hide");
	}

})
//菜单数字
   function workcount() {
   	$.getJSON(huayi.config.callcenter_url + 'WorkOrderNew/GetWorkCount', {
   		"token": $.cookie("token")
   	}, function(result) {
   		if (result.state.toLowerCase() == "success") {
   			$(".assign").text(result.Assign); //待指派
   			$(".receipt").text(result.Receipt); //待接单
   			$(".accepted").text(result.Acceptedorders); //已接单（待处理）
   			$(".ovar").text(result.Ovar); //已完成的
   			$(".allocated").text(result.Allocated); //客服已分配
   			$(".tobevisited").text(result.Tobevisited); //待回访
   			$(".returnvisit").text(result.Returnvisit); //已回访
   			$(".tobefinished").text(result.Tobefinished); //待完结
   			$(".gcapproved").text(result.GCApproved); //高层待审批
   			$(".customer").text(result.CustomerWorkorder); //客户工单
   			$(".delays").text(result.Delays); //延期工单
   			$(".deWorkOrder").text(result.DeWorkOrder); //微信未通过工单
   			$(".approved").text(result.Approved); //已审批
   			$(".wechatOrder").text(result.WeChatWorkOrder); //微信业务员工单
   			$(".tobeApproved").text(result.tobeApproved); //大区经理分公司经理待审批
   			$(".createdbill").text(result.createdbill); //业务员大区经理分公司经理已创单
   			$(".backid").text(result.Backid); //退单
   		}
   	})
   }
//上传头像
function uploadtx() {
	if (document.getElementById("upFile").files.length > 0) {
		var formData = new FormData();
		formData.append("upFile", document.getElementById("upFile").files[0]);
		formData.append("token", $.cookie("token"));
		$.ajax({
			url: huayi.config.callcenter_url + "Index/UploadTX",
			type: "POST",
			data: formData,
			/**
			 *必须false才会自动加上正确的Content-Type
			 */
			contentType: false,
			/**
			 * 必须false才会避开jQuery对 formdata 的默认处理
			 * XMLHttpRequest会对 formdata 进行正确的处理
			 */
			processData: false,
			success: function(result) {
				document.getElementById("upFile").outerHTML = document.getElementById("upFile").outerHTML;
				$("#upFile").change(function() {
					uploadtx();
				});
				var r = $.parseJSON(result);
				if (r.state.toLowerCase() == "success") {
					$(".yhtx").attr("src", huayi.config.callcenter_url.substr(0, huayi.config.callcenter_url.length - 1) + r.data);

					layer.msg("上传成功");
				}
			}
		});
	} else {
		layer.confirm('请上传文件！', {
			btn: ['确定']
		});
	}
}
//格式化呼叫状态
function GetCallState(val) {
	if (val == '1') {
		return '已接通';
	} else {
		return '未接通';
	}
}

//外呼弹屏
function whtp() {
	$("#Result").val("");
	if ($(".WH").hasClass("fadeOutUp")) {
		$(".WH").removeClass("fadeOutUp").addClass("fadeInDown");
	}
	$(".WH").removeClass("hidens");

	$('.first').removeClass('first');
	$('.WH').addClass('first');

	loadWH();
}
//加载外呼电话列表
function loadWH() {
	$(".phonediv").hide();
	var n = $(".bg_title .lactive").attr("itemid");
	switch (n) {
		case '0':
			var obj = $(".phonediv").eq(0);
			obj.show();

			//先销毁表格
			var table = obj.find(".phonelist");
			table.bootstrapTable('destroy');
			//初始化表格,动态从服务器加载数据
			table.bootstrapTable({
				method: "get", //使用get请求到服务器获取数据
				url: huayi.config.callcenter_url + "CallOutScreen/GetPhoneList", //获取数据的Servlet地址
				contentType: 'application/x-www-form-urlencoded',
				striped: true, //表格显示条纹
				pagination: true, //启动分页
				pageSize: 10, //每页显示的记录数
				pageNumber: 1, //当前第几页
				pageList: [10, 20, 50, 100], //记录数可选列表
				search: false, //是否启用查询
				showColumns: false, //显示下拉框勾选要显示的列
				showRefresh: false, //显示刷新按钮
				sidePagination: "server", //表示服务端请求
				//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
				//设置为limit可以获取limit, offset, search, sort, order
				queryParamsType: "undefined",
				queryParams: function queryParams(params) { //设置查询参数
					var param = {
						page: params.pageNumber,
						pagesize: params.pageSize,
						tel: $("#lastphone").val(),
						token: $.cookie("token")
					};
					return param;
				},
				onLoadSuccess: function() { //加载成功时执行
					//layer.msg("加载成功");
				},
				onLoadError: function() { //加载失败时执行
					//layer.msg("加载数据失败", { time: 1500, icon: 2 });
				}
			});
			break;
		case '1':
			var obj = $(".phonediv").eq(1);
			obj.show();
			getDepts(); //获取部门下拉

			var table = obj.find(".phonelist");
			table.bootstrapTable('destroy');
			//初始化表格,动态从服务器加载数据
			table.bootstrapTable({
				method: "get", //使用get请求到服务器获取数据
				url: huayi.config.callcenter_url + "CallOutScreen/GetUserList", //获取数据的Servlet地址
				contentType: 'application/x-www-form-urlencoded',
				striped: true, //表格显示条纹
				pagination: true, //启动分页
				pageSize: 10, //每页显示的记录数
				pageNumber: 1, //当前第几页
				pageList: [10, 20, 50, 100], //记录数可选列表
				search: false, //是否启用查询
				showColumns: false, //显示下拉框勾选要显示的列
				showRefresh: false, //显示刷新按钮
				sidePagination: "server", //表示服务端请求
				//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
				//设置为limit可以获取limit, offset, search, sort, order
				queryParamsType: "undefined",
				queryParams: function queryParams(params) { //设置查询参数
					var param = {
						page: params.pageNumber,
						pagesize: params.pageSize,
						zxzid: $('#s_department').val(),
						tel: $("#gsphone").val(),
						name: $("#gsname").val(),
						token: $.cookie("token")
					};
					return param;
				},
				onLoadSuccess: function() { //加载成功时执行
					//layer.msg("加载成功");
				},
				onLoadError: function() { //加载失败时执行
					//layer.msg("加载数据失败", { time: 1500, icon: 2 });
				}
			});
			break;
		case '2':
			var obj = $(".phonediv").eq(2);
			obj.show();

			var table = obj.find(".phonelist");
			table.bootstrapTable('destroy');
			//初始化表格,动态从服务器加载数据
			table.bootstrapTable({
				method: "get", //使用get请求到服务器获取数据
				url: huayi.config.callcenter_url + "CallOutScreen/GetCustomerList", //获取数据的Servlet地址
				contentType: 'application/x-www-form-urlencoded',
				striped: true, //表格显示条纹
				pagination: true, //启动分页
				pageSize: 10, //每页显示的记录数
				pageNumber: 1, //当前第几页
				pageList: [10, 20, 50, 100], //记录数可选列表
				search: false, //是否启用查询
				showColumns: false, //显示下拉框勾选要显示的列
				showRefresh: false, //显示刷新按钮
				sidePagination: "server", //表示服务端请求
				//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
				//设置为limit可以获取limit, offset, search, sort, order
				queryParamsType: "undefined",
				queryParams: function queryParams(params) { //设置查询参数
					var param = {
						page: params.pageNumber,
						pagesize: params.pageSize,
						tel: $("#khphone").val(),
						name: $("#khname").val(),
						token: $.cookie("token")
					};
					return param;
				},
				onLoadSuccess: function() { //加载成功时执行
					//layer.msg("加载成功");
				},
				onLoadError: function() { //加载失败时执行
					//layer.msg("加载数据失败", { time: 1500, icon: 2 });
				}
			});
			break;
	}
}
//格式化最近电话处理方式
function formatterDealType(val, row) {
	//处理方式0:IVR处理1骚扰电话2自助服务3转值班电话4留言5呼损6人工处理
	var str = '-';
	switch (val) {
		case 0:
			str = 'IVR处理';
			break;
		case 1:
			str = '骚扰电话';
			break;
		case 2:
			str = '自助服务';
			break;
		case 3:
			str = '转值班电话';
			break;
		case 4:
			str = '留言';
			break;
		case 5:
			str = '呼损';
			break;
		case 6:
			str = '人工处理';
			break;
	}
	return str;
}
//获取外呼公司电话下 部门下拉
function getDepts() {
	$.getJSON(huayi.config.callcenter_url + "SeatGroup/GetList", {
		token: $.cookie("token"),
	}, function(data) {
		if (data.rows && data.rows.length > 0) {
			$('#s_department').html('');
			$('#s_department').append('<option value="">请选择</option>');
			$.each(data.rows, function(i, v) {
				$('<option value="' + v.F_ZXZID + '">' + v.F_ZXZName + '</option>').appendTo($('#s_department'));
			});
		}
	});
}
//格式化 电话号码 分机号
function view(val) {
	var str = '';
	if (val) {
		str = '<a onclick="call(\'' + val + '\')">' + val + '</a>';
	}
	return str;
}

function call(val) {
	$("#Result").val(val);
	$(".img").removeClass("hidens");
}

function logout() {
	if (!$('.Logout').hasClass('active')) {
		$.ajax({
			url: huayi.config.callcenter_url + "Login/Logout",
			data: {
				token: $.cookie("token")
			},
			dataType: "json",
			success: function(res) {
				if (res.state) {
					location.href = "./login.html";
				}
			}
		});
	} else {
		layer.msg("退出失败！");
	}

}

//加载左侧导航菜单
function loadMenu() {
	$.ajaxSettings.async = false;
	$.getJSON(huayi.config.callcenter_url + 'Index/GetMenu', {
		"token": $.cookie("token")
	}, function(result) {
		$.ajaxSettings.async = true;
		if (result.state.toLowerCase() == "success") {
			var data = result.data;

			var _html = "";
			$.each(data, function(i) {
				var row = data[i];
				if (row.F_ParentID == "0") {
					_html += '<li>';
					_html += '<a  class="Click"data-id="Menu_' + row.F_ModuleId + '" href="' + row.F_OptUrl +
						'"><i class="fa iconfont">' + row.F_ImgUrl + '</i><span class="nav-label">' + row.F_ModuleName +
						'</span><span class="fa arrow"></span></a>';
					var childNodes = row.ChildNodes; //二级
					if (childNodes.length > 0) {
						_html += '<ul class="nav nav-second-level">';
						$.each(childNodes, function(i) {
							var subrow = childNodes[i];

							var childNodsThird = subrow.ChildNodes; //三级
							if (childNodsThird.length > 0) {
								_html += '<li>';
								_html += '<a href="' + subrow.F_OptUrl + '">';
								_html += '<span class="nav-label">' + subrow.F_ModuleName + '</span>';
								_html += '<span class="fa arrow"></span>';
								_html += '</a>';
								_html += '<ul class="nav nav-third-level">';
								$.each(childNodsThird, function(i) {
									var subrowThird = childNodsThird[i];
									_html += '<li>';
									_html += '<a class="J_menuItem" data-id="Menu_' + subrowThird.F_ModuleId + '" href="' + subrowThird.F_OptUrl +
										'" >' + subrowThird.F_ModuleName + '</a>';
									_html += '</li>';
								});
								_html += '</ul>';
							} else {
								_html += '<li>';
								_html += '<a class="J_menuItem" data-id="Menu_' + subrow.F_ModuleId + '" href="' + subrow.F_OptUrl +
									'" >' + subrow.F_ModuleName + '</a>';
								if (subrow.F_Button != '') {
									_html += '<span class="' + subrow.F_Button + '"></span>';
								}
								_html += '</li>';
							}

						});
						_html += '</ul>';
					}
					_html += '</li>';
				}
			});
			//			            $("#sidebar-nav ul").prepend(_html);
			$(_html).appendTo("#side-menu");
			//绑定点击事件 添加点击的样式
			$('#side-menu').find('.J_menuItem').on('click', function() {
				$(this).parent().addClass('sub_active').siblings().removeClass('sub_active');
			});
		} else {
			window.location.href = "/login.html";
		}
	})
}

//跳转
function Jumps() {
	//window.parent.frames[ "iframe0"].location.reload();
	$("iframe:visible")[0].src = "widgets.html"
	$(".J_menuTab").eq(0).addClass("active").text('首页');
	$(".J_menuTab").eq(0).attr("data-id", 'widgets.html');
	$(".J_mainContent .J_iframe0").attr("data-id", "widgets.html");
}

// 顶部消息
function showTopMsgs() {
	$('#top_notices_lists').toggle();
// 	if ($('#top_notices_lists').is(':visible')) {
// 		$('#top_notices_lists').hide();
// 	} else {
// 		$('#top_notices_lists').show();
// 	}
}

// 获取顶部消息（只展示未读消息 0未读 1已读）
function getTopMsgs() {
	$.getJSON(huayi.config.callcenter_url + 'Msg/GetServerMsg', {
		token: $.cookie("token")
	}, function(result) {
		if(result.state.toLowerCase() === 'success'){
			$('#top_notices_lists').empty();
			result = result.data;
			var str = '';
			if (result && result.length) {
				if(isFirstShowTopMsg){
					$('#top_notices_lists').show();
					isFirstShowTopMsg = false;
				}
				$('#top_notices_num').text(result.length);
				for (var i = 0; i < result.length; i++) {
					str += '<li class="top_notices_item">' +
						'<span class="top_notices_con">'+ result[i].Detail +'</span>' +
						'<button type="button" class="btn btn-primary btn-sm" onclick="signRead('+ result[i].ID +', event)">未读</button>' +
						'</li>' +
						'<li class="divider"></li>';
				}
			} else {
				str = '<li class="top_notices_item">' +
						'<span class="top_notices_con">暂无消息！</span>' +
						'</li>';
				$('#top_notices_num').text(0);
			}
			$('#top_notices_lists').append(str);
			$('#top_notices_lists').find('.divider:last').remove();
		}
	});
}

// 标记消息状态
function signRead(signid, e) {
	e.stopPropagation();
	layer.confirm('确认已读后该条消息将不再提示，请慎重', {
		icon: 7,
		btn: ['确认', '取消'] //按钮
	}, function(index) {
		$.ajax({
			type: "get",
			url: huayi.config.callcenter_url + "Msg/UpdateState",
			dataType: 'json',
			async: true,
			data: {
				ids: signid,
				state: 1, //状态，0未读 1已读
				token: $.cookie("token")
			},
			success: function(data) {
				if (data.state.toLowerCase() === "success") {
					// 更新顶部消息内容和数量
					getTopMsgs();
					$('#top_notices_lists').hide();
					layer.close(index);
				}
			}
		});
	});
}

$(document).click(function(e) {
	if($(e.target).is($('.top_notices_lists')) || $(e.target).is($('.top_notices_item')) || $(e.target).is($('.top_notices_con')) || $(e.target).is($('.divider'))) {
		$('#top_notices_lists').show();
	}
})
