﻿var LC_winmode = "width=640px,height=520px,status=no,resizable=no,menubar=no,toolbar=no,status=no" + ",top=" + (screen.height - 520) / 2 + "px," + "left=" + (screen.width - 840) / 2 + "px";
var LC_Url = { encode: function (string) { return escape(this._utf8_encode(string)); }, decode: function (string) { return this._utf8_decode(unescape(string)); }, _utf8_encode: function (string) { string = string.replace(/\r\n/g, '\n'); var utftext = ''; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if ((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }, _utf8_decode: function (utftext) { var string = ''; var i = 0; var c = c1 = c2 = 0; while (i < utftext.length) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if ((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i + 1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i + 1); c3 = utftext.charCodeAt(i + 2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } }
var LC_Title = encodeURIComponent(document.title);
var LC_Location = encodeURIComponent(document.URL);
var LC_Referrer = "";
try {
	LC_Referrer = encodeURIComponent(parent == self ? window.document.referrer : top.document.referrer);
}
catch (x) { }
var LC_UserLang = navigator.appName == "Netscape" ? navigator.language : navigator.userLanguage;
var LC_VisitorName = "";
var LC_VisitorEmail = "";
var LC_Companys = new Array();
var LC_InviteShow = false;
var LC_LiveChat = "即时语|即時語|LiveChat";
var LC_ServerError = "错误的服务器地址，请设置正确的服务器路径，或联系服务供应商！|錯誤的伺服器位址，請設置正確的伺服器路徑，或聯繫服務供應商！|Invalid server url, please verify server url and try again or contact service provider.";
var LC_SettingNotFound = "没有找到设置信息，请检查引用代码或联系管理员！|沒有找到設置資訊，請檢查引用代碼或聯繫管理員！|Setting not found, please check the Page Code or contact administrator.";
var LC_WebSiteNotFound = "没有找到指定公司网站，请检查引用代码或联系管理员！|沒有找到指定公司網站，請檢查引用代碼或聯繫管理員！|Web Site not found, please check the Page Code or contact administrator.";
var LC_CompanyNotFound = "没有找到指定公司，请检查引用代码或联系管理员！|沒有找到指定公司，請檢查引用代碼或聯繫管理員！|Company not found, please check the Page Code or contact administrator.";
var LC_PageSettingNotFound = "没有找到页面设置信息，请检查引用代码或联系管理员！|沒有找到頁面設置資訊，請檢查引用代碼或聯繫管理員！|Page setting not found, please check the Page Code or contact administrator.";
var LC_ParameterError = "公司初始化错误，缺少参数！|公司初始化錯誤，缺少參數！|Company object initializing failed, not enough parameters!";
var LC_IPRejectedPrompt = "对不起，您的IP被过滤！|對不起，您的IP被過濾！|You have been banned!";
var LC_OpenedWinPrompt = "您已经打开聊天窗口或者打开的间隔太短！|您已經打開聊天視窗或者打開的間隔太短！|You have already opened the chat window or You open up window period very shortly";
var LC_InvitePrompt = "即时语在线客服邀您对话|即時語線上客服邀您對話|LiveChat";
var LC_AcceptInvitePrompt = "开始交谈|開始交談|Accept";
var LC_RejectInvitePrompt = "暂不交谈|暫不交談|Refuse";
var LC_InitError = "错误|錯誤|Error";
var LC_ServerADD = "服务器地址|伺服器地址|Server Url";
var LCUserStatus_Online = "在线|線上|Online";
var LCUserStatus_WebOnline = "在线|線上|Online";
var LCUserStatus_Busy = "忙碌|忙碌|Busy";
var LCUserStatus_Offline = "离线|離線|Offline";
var LCUserStatus_Away = "离开|離開|Away";
var LCUser_Select = "选择客服|選擇客服|Select Service";
var LCUser_ShowUserList = "即时语在线客服|即時語線上客服|LiveChat Service";
var LC_DIV = "";
var LC_InviRefreshTime = 10;
var LC_SystemIgnoreTag = 0;
var LC_InitLang = "";    //新增 页面访问默认语言 
var LC_IsGroup = "";    //新增 是否使用分组列表

function LC_Company() {
	this.LC_OutPutDiv = null;
	this.LC_CompanyID = 0;
	this.LC_WebSiteID = 0;
	this.LC_VisitorID = "";
	this.LC_VisitorLang = "";
	this.LC_VisitorName = "";
	this.LC_VisitorEmail = "";
	this.LC_BaseUrl = "";
	this.LC_InviteUrl = "";
	this.LC_WebRoot = "";
	this.LC_CompanyName = "";
	this.LC_ContactName = "";
	this.LC_ContactEmail = "";
	this.LC_UserProcess = true;
	this.LC_SystemInvite = "";
	this.LC_SystemInviteText = "";
	this.LC_ServiceInviteText = "";
	this.LC_ServiceType = 0;
	this.LC_InviteBox_Height = 250;
	this.LC_InviteBox_Width = 200;
	this.LC_InviteBox_Top = 200;
	this.LC_InviteBox_Left = 100;
	this.LC_ShowAD = 1;
	this.LC_IPRejected = false;
	this.LC_SystemIgnore = 0;
	this.LC_DisplayUsers = "";
	this.ToParameters = function () { return this.LC_VisitorID; };
	this.InitUserList = function (outputdivid) {
		LC_Companys.push(this);
		if (outputdivid && outputdivid != "") {
			var t_div = document.getElementById(outputdivid);
			if (t_div) {
				this.LC_OutPutDiv = t_div;
			}
			else {
				var d = document.createElement('div');
				d.id = outputdivid;
				this.LC_OutPutDiv = d;
				document.body.appendChild(d);
			}
		}
		var outHTML = "";
		var inviteframe = document.getElementById("scrInvitation");
		if (!inviteframe && !this.LC_IPRejected) {
			outHTML += this.GetUserList();
			outHTML += "<script id='scrInvitation'></script><div id='lcUserlistTip' style='display:none'><img src='" + this.LC_WebRoot + "V40/images/tip.png' style='cursor:pointer' onclick='LC_SetUserList(2)' title='" + getPromptStringByLang(this.LC_VisitorLang, LCUser_ShowUserList) + "'/></div>";
			this.LC_OutPutDiv.innerHTML = outHTML;
		}

		if (typeof (LCLinkIcon_Fly) != "undefined") {
			if (LCLinkIcon_Fly == "1") {
				this.LC_OutPutDiv.style.position = "absolute";
				InitshowLinkIcon(this.LC_OutPutDiv.id);
			}
			else if (LCLinkIcon_Fly == "2") {
				//position:absolute;right:0px;
				this.LC_OutPutDiv.style.position = "absolute";
				this.LC_OutPutDiv.style.right = "0px";
				InitshowLinkIconTips(this.LC_OutPutDiv.id);
			}
		}
		if (this.LC_VisitorID != "") this.LoadInviteFrame();
		/*
		if(this.LC_SystemInvite==1 && get_cookie("chatwindowopened")!="1" && get_cookie("rejectinvite")!="1")
		setTimeout("ReceivedInvite(" + this.LC_CompanyID + ",0,'')", this.LC_SystemInviteTimespan * 1000);
		*/
		if (this.LC_SystemInvite != "0") {
			if (get_cookie("chatwindowopened") != "1" && get_cookie("rejectinvite") != "1" && get_cookie("rejectAutoinvite") != "1")
				setTimeout("ReceivedInvite(" + this.LC_CompanyID + ",0,'');if('" + this.LC_SystemInvite + "'!='1'){document.cookie = 'rejectAutoinvite=1;';}", this.LC_SystemInviteTimespan * 1000);
		}
	};
	this.GetUserList = function () {
		var out = "<div onmouseover='LC_SetUserList(0)' id=\"group-box\" style=\"width: 170px; position: relative; border: 1px solid #93b5dc; font-size: 12px; color: #1d2956; font-family: '宋体','Microsoft YaHei'; background: #fff  url(" + this.LC_WebRoot + "V40/images/group-bg.png) repeat-x;padding: 10px 0 10px 0;\">";
		out += "<h2 style=\"font-size: 12px; font-weight: normal; line-height: 18px; height: 18px; padding: 0; margin: 0 0 8px 0;\"><img src=\"" + this.LC_WebRoot + "V40/images/e.gif\" style=\" width:14px; height: 14px; list-style: none; margin: 0; padding: 0; border: none;background:  url(" + this.LC_WebRoot + "V40/images/group.png)  no-repeat; margin:2px 3px 0 6px; float: left;\">" + getPromptStringByLang(this.LC_VisitorLang, LCUser_Select) + "</h2>";
		if (typeof (LCLinkIcon_Fly) == "undefined" || LCLinkIcon_Fly == 0)
			out += "<div id=\"close\" style=\"cursor:pointer; position: absolute; top: 15px; right: 10px;\"><img onclick=\"LC_toggleUserList()\" src=\"" + this.LC_WebRoot + "V40/images/close_icon.png\"></div>";
		out += "<ul style=\"margin: 0 0 0 8px;zoom:1;list-style: none; padding: 0; border: none;\">";
		for (var i = 0; i < this.LC_DisplayUsers.length; i++) {
			out += "<li style=\"cursor:pointer;color: #656b82; line-height: 18px; text-indent: 13px; font-weight: bold; color: #656b82; background: url('" + this.LC_WebRoot + "V40/images/group-drop.png') no-repeat 0 5px;\" onclick=\"LC_showHideGroup('" + this.LC_WebRoot + "','li" + i + "','ol" + i + "');\" tag=\"open\" id=\"li" + i + "\">" + getByteVal(htmlencode(getPromptStringForRead(this.LC_VisitorLang, LC_Url.decode(this.LC_DisplayUsers[i].Group.gname))), 10);
			out += "<ol id=\"ol" + i + "\" style=\"font-weight: normal; margin: 5px 0; list-style: none;margin: 0; padding: 0; border: none;color: #5d5d5d;\">";
			var OnlineList = "";
			var OtherList = "";
			for (var j = 0; j < this.LC_DisplayUsers[i].Service.length; j++) {
				var status = this.CheckServiceStatus(this.LC_DisplayUsers[i].Service[j]);
				var uname = this.LC_DisplayUsers[i].Service[j].uname;
				if (status != "Online" && status != "WebOnline") {
					OtherList += "<li onclick=\"LC_showHideGroup('" + this.LC_WebRoot + "','li" + i + "','ol" + i + "');\"><a style=\"text-decoration: none;color: " + (status == "Online" || status == "WebOnline" ? "blue" : "#656b82;") + "\" href=\"javascript:;\" onclick=\"LC_GoOfflineMessage('" + this.LC_WebRoot + "'," + this.LC_CompanyID + "," + this.LC_WebSiteID + "," + this.LC_DisplayUsers[i].Group.gid + ");\" title=\"" + this.GetUserStatus(status) + "\">" +
			        getByteVal(getPromptStringForRead(this.LC_VisitorLang, LC_Url.decode(uname)), 10) + "</a></li>";
				}
				else {
					OnlineList += "<li onclick=\"LC_showHideGroup('" + this.LC_WebRoot + "','li" + i + "','ol" + i + "');\"><a style=\"text-decoration: none;color: " + (status == "Online" || status == "WebOnline" ? "blue" : "#656b82;") + "\" href=\"javascript:;\" onclick=\"LC_RequestService(" + this.LC_CompanyID + "," + this.LC_DisplayUsers[i].Group.gid + "," + this.LC_DisplayUsers[i].Service[j].aid + ");\" title=\"" + this.GetUserStatus(status) + "\">" +
			        getByteVal(getPromptStringForRead(this.LC_VisitorLang, LC_Url.decode(uname)), 10) +"</a></li>";
				}

			}
			out += OnlineList + OtherList;
			out += "</ol></li>";
		}
		out += "</ul></div>";
		return out;
	};
	this.CheckServiceStatus = function (s) {
		if (s.type) {
			if (s.status == "Online" || s.status == "WebOnline") {
				if (s.type == 1) {
					if (s.waiting >= s.maxwait) return "Busy";
				}
				else {
					if (s.chatting >= s.maxconn) return "Busy";
				}
			}
		}
		return s.status;
	}
	this.GetUserStatus = function (s) {
		switch (s) {
			case "Online":
				return getPromptStringForRead(this.LC_VisitorLang, LCUserStatus_Online);
			case "WebOnline":
				return getPromptStringForRead(this.LC_VisitorLang, LCUserStatus_WebOnline);
			case "Busy":
				return getPromptStringForRead(this.LC_VisitorLang, LCUserStatus_Busy);
			case "Away":
				return getPromptStringForRead(this.LC_VisitorLang, LCUserStatus_Away);
			default:
				return getPromptStringForRead(this.LC_VisitorLang, LCUserStatus_Offline);
		}
	};
	this.InitCompany = function (outputdivid) {
		LC_SystemIgnoreTag = this.LC_SystemIgnore;
		this.LC_IPRejected = false;
		if (outputdivid && outputdivid != "") {
			var t_div = document.getElementById(outputdivid);
			if (t_div) {
				this.LC_OutPutDiv = t_div;
			}
			else {
				var d = document.createElement('div');
				d.id = outputdivid;
				this.LC_OutPutDiv = d;
				document.body.appendChild(d);
			}
		}
		LC_Companys.push(this);
		if (this.LC_ServiceType == 1) this.LC_ShowAD = 0;
		if (LC_IsGroup == "") {
			this.ShowLinkIcon();
		}
		else {
			var inviteframe = document.getElementById("scrInvitation")
			if (!inviteframe && !this.LC_IPRejected)
				this.LC_OutPutDiv.innerHTML += "<script id='scrInvitation'></script>";

			if (this.LC_SystemInvite != "0") {
				if (get_cookie("chatwindowopened") != "1" && get_cookie("rejectinvite") != "1" && get_cookie("rejectAutoinvite") != "1")
					setTimeout("ReceivedInvite(" + this.LC_CompanyID + ",0,'');if('" + this.LC_SystemInvite + "'!='1'){document.cookie = 'rejectAutoinvite=1;';}", this.LC_SystemInviteTimespan * 1000);
			}

			if (typeof (LCLinkIcon_Fly) != "undefined") {
				if (LCLinkIcon_Fly == "1") {
					this.LC_OutPutDiv.style.position = "absolute";
					InitshowLinkIcon(this.LC_OutPutDiv.id);
				}
				if (LCLinkIcon_Fly == "2") {
					//position:absolute;right:0px;
					this.LC_OutPutDiv.style.position = "absolute";
					this.LC_OutPutDiv.style.right = "0px";
					InitshowLinkIconTips(this.LC_OutPutDiv.id);
				}
			}
			this.LoadInviteFrame();
		}
	};
	this.InitRejectedIPUser = function (outputdivid) {
		LC_SystemIgnoreTag = this.LC_SystemIgnore;
		this.LC_IPRejected = true;
		if (outputdivid && outputdivid != "") {
			var t_div = document.getElementById(outputdivid);
			if (t_div) {
				this.LC_OutPutDiv = t_div;
			}
			else {
				var d = document.createElement('div');
				d.id = outputdivid;
				this.LC_OutPutDiv = d;
				document.body.appendChild(d);
			}
		}
		LC_Companys.push(this);
		this.ShowLinkIcon();
	};
	this.ShowLinkIcon = function () {
		if (this.LC_ShowAD == 1) {
			//var mj=new JsLoader();
			//mj.load(this.LC_WebRoot + "Images/LiveChatAD.js", null);
		}
		var outHTML = "";
		if (this.LC_OutPutDiv) {
			this.LC_OutPutDiv.style.zIndex = 9999999;
			outHTML = "<a onclick='LC_ClickLink(" + this.LC_CompanyID + ");' style='cursor:pointer'><img id=linkicon src='" + this.LC_WebRoot + "Images/LinkIcon_" + this.LC_CompanyID + ".gif' border='0'/></a>";
			var inviteframe = document.getElementById("scrInvitation");
			if (!inviteframe && !this.LC_IPRejected) outHTML += "<script id='scrInvitation'></script>";
			this.LC_OutPutDiv.innerHTML = outHTML;


			if (typeof (LCLinkIcon_Fly) != "undefined") {
				if (LCLinkIcon_Fly == "1") {
					this.LC_OutPutDiv.style.position = "absolute";
					InitshowLinkIcon(this.LC_OutPutDiv.id);
				}
				if (LCLinkIcon_Fly == "2") {
					//position:absolute;right:0px;
					this.LC_OutPutDiv.style.position = "absolute";
					this.LC_OutPutDiv.style.right = "0px";
					InitshowLinkIconTips(this.LC_OutPutDiv.id);
				}
			}
		}
		else {
			if (this.LC_IPRejected) return;
			var inviteframe = document.getElementById("scrInvitation");
			if (!inviteframe) {
				var mj = new JsLoader();
				mj.load("", "scrInvitation");
			}
		}
		if (!this.LC_IPRejected) {
			if (this.LC_VisitorID != "") this.LoadInviteFrame();
			/*
			if(this.LC_SystemInvite==1 && get_cookie("chatwindowopened")!="1" && get_cookie("rejectinvite")!="1")
			setTimeout("ReceivedInvite(" + this.LC_CompanyID + ",0,'')", this.LC_SystemInviteTimespan * 1000);
			*/
			if (this.LC_SystemInvite != "0") {
				if (get_cookie("chatwindowopened") != "1" && get_cookie("rejectinvite") != "1" && get_cookie("rejectAutoinvite") != "1")
					setTimeout("ReceivedInvite(" + this.LC_CompanyID + ",0,'');if('" + this.LC_SystemInvite + "'!='1'){document.cookie = 'rejectAutoinvite=1;';}", this.LC_SystemInviteTimespan * 1000);
			}
		}
	};
	this.LoadInviteFrame = function () {
		var inviteframe = document.getElementById("scrInvitation");
		if (inviteframe) {
			if (!LC_InviteShow) {
				LC_InviteShow = true;
				LC_InviteUrl = this.LC_WebRoot + "V40/GetInvite.livechat?companyid=" + this.LC_CompanyID + "&websiteid=" + this.LC_WebSiteID;
				EnableInviteChecker = true;
				setTimeout("StartInviteChecker()", LC_InviRefreshTime * 1000);
			}
		}
	};
	this.StopInviteFrame = function () {
		StopInviteChecker();
		/*socket
		var inviteframe = document.getElementById("scrInvitation");
		if(inviteframe)
		{
		//inviteframe.src = "about:blank";
		}*/
	};
	this.Request = function (groupid) {
		if (!this.LC_IPRejected) {
			var url = this.LC_WebRoot + "V40/Chat.aspx?companyid=" + this.LC_CompanyID + "&websiteid=" + this.LC_WebSiteID +
	        "&visitorname=" + LC_Url.encode(this.LC_VisitorName) + "&visitoremail=" + LC_Url.encode(this.LC_VisitorEmail) + "&groupid=" + groupid + "&browserLang=" + GetLanguage() + "&r=" + Math.random();
			window.open(url, "", LC_winmode);
		}
		else {
			alert(getPromptStringByLang(this.LC_VisitorLang, LC_IPRejectedPrompt));
		}
	};
	this.RequestService = function (groupid, serviceid) {
		if (!this.LC_IPRejected) {
			var url = this.LC_WebRoot + "V40/Chat.aspx?companyid=" + this.LC_CompanyID + "&websiteid=" + this.LC_WebSiteID +
	        "&visitorname=" + LC_Url.encode(this.LC_VisitorName) + "&visitoremail=" + LC_Url.encode(this.LC_VisitorEmail) + "&groupid=" + groupid + "&browserLang=" + GetLanguage() + "&serviceNo=" + serviceid + "&r=" + Math.random();
			window.open(url, "", LC_winmode);
		}
		else {
			alert(getPromptStringByLang(this.LC_VisitorLang, LC_IPRejectedPrompt));
		}
	};
	this.Click = function () {
		document.cookie = "rejectinvite=0;";
		var inviteBoxDiv = document.getElementById('c35ComLiveChat');
		if (inviteBoxDiv) {
			inviteBoxDiv.style.display = 'none';
		}
		if (get_cookie("chatwindowopened") == "1") {
			alert(getPromptStringByLang(this.LC_VisitorLang, LC_OpenedWinPrompt));
			return;
		}
		if (this.LC_IPRejected) {
			alert(getPromptStringByLang(this.LC_VisitorLang, LC_IPRejectedPrompt));
			return;
		}
		//document.cookie = "rejectinvite=1;";
		if (this.LC_UserProcess && this.LC_UserProcess > 0) {
			//修改前
			//	        	        var url = this.LC_WebRoot + "V40/Group.aspx?companyid=" + this.LC_CompanyID + "&websiteid=" + this.LC_WebSiteID + "&browserLang=" + GetLanguage() + "&r=" + Math.random();
			//修改后
			var url = this.LC_WebRoot + "V40/Chat.aspx?companyid=" + this.LC_CompanyID + "&websiteid=" + this.LC_WebSiteID + "&browserLang=" + GetLanguage() + "&r=" + Math.random();

			if (typeof (LiveChatShowGroup) != "undefined") {
				if (LiveChatShowGroup != "")
					url += "&showgroup=" + encodeURIComponent(LiveChatShowGroup);
			}

			window.open(url, "", LC_winmode);
		}
		else {
			window.open(this.LC_WebRoot + "V40/Chat.aspx?companyid=" + this.LC_CompanyID + "&websiteid=" + this.LC_WebSiteID + "&browserLang=" + GetLanguage() + "&r=" + Math.random(), "", LC_winmode);
		}

	};
	this.ProcessInvite = function (serviceid, word) {
		word = LC_Url.decode(word);
		var inviteBoxDiv = document.getElementById('c35ComLiveChat');
		if (inviteBoxDiv) {
			if (word != "") {
				var sw = document.getElementById("InviteWord");
				if (sw) sw.innerHTML = word;
			}
			if (serviceid > 0) {
				var btn_a = document.getElementById("Btn_LCAcceptInvite");
				if (btn_a) {
					btn_a.setAttribute("sid", serviceid);
				}
				var btn_r = document.getElementById("Btn_LCRejectInvite");
				if (btn_r) {
					btn_r.setAttribute("sid", serviceid);
				}
			}
			inviteBoxDiv.style.display = '';
		}
		else {
			var m_top = (this.LC_InviteBox_Top * 1);
			var m_left = (this.LC_InviteBox_Left * 1);
			inviteBoxDiv = document.createElement('div');
			inviteBoxDiv.id = 'c35ComLiveChat';
			inviteBoxDiv.name = 'c35ComLiveChat';
			inviteBoxDiv.frameBorder = '0';
			inviteBoxDiv.style.position = 'absolute';
			inviteBoxDiv.style.top = m_top + 'px';
			inviteBoxDiv.style.left = m_left + 'px';

			if (this.LC_InviteBox_Width < 100) this.LC_InviteBox_Width = 250;
			if (this.LC_InviteBox_Height < 100) this.LC_InviteBox_Height = 100;

			inviteBoxDiv.style.width = ((this.LC_InviteBox_Width * 1) + 4) + 'px';
			inviteBoxDiv.style.height = ((this.LC_InviteBox_Height * 1) + 30) + 'px';
			inviteBoxDiv.innerHTML = "";
			inviteBoxDiv.style.zIndex = 999999;
			document.body.appendChild(inviteBoxDiv);

			inviteBoxDiv.style.display = '';
			var testad;
			var mheight = 0;
			var mweight = ((this.LC_InviteBox_Width * 1) + 2);
			var adhtm = "";
			var addivid = "LiveChat" + this.LC_CompanyID + "AD1";

			var testHeight = document.compatMode == "CSS1Compat" ? 0 : 30;
			/*
			if(this.LC_ShowAD==1)
			{
			adhtm = "<iframe style='position:absolute;z-index:-1;width:100%;height:30px;' scrolling='no' frameborder='0'></iframe><div style='z-index:999999;border:1px solid #283564;background:#FFFFFF none repeat scroll 0 0;'><div id='" + addivid + "'></div></div>";
			mheight=((this.LC_InviteBox_Height*1) + testHeight);
			}
			else
			{
			adhtm = "";
			mheight=((this.LC_InviteBox_Height*1) + testHeight);
			}
			*/
			var html = '<iframe style="position:absolute;z-index:-1;width:100%;height:100%;top:e­xpression(' + m_top + ');left:e­xpression(' + m_left + ');" scrolling="no" frameborder="0"></iframe>';
			html += '<div id="divMain" style="width:' + mweight + 'px;height:' + mheight + 'px;"><div style="background:#D8D8D8 none repeat scroll 0 0;position:absolute;">';
			html += '<div style="height:' + (this.LC_InviteBox_Height * 1 + 2) + 'px;position:relative;width:' + ((this.LC_InviteBox_Width * 1) + 4) + 'px;">';
			html += '<div style="background:transparent url(' + this.LC_WebRoot + 'Style0/skin/chat_top_bg.gif) repeat scroll 0 0;clear:both;color:#FFFFFF;height:25px;">';
			html += '<div style="background:transparent url(' + this.LC_WebRoot + 'Style0/skin/chat_topr_bg.gif) no-repeat scroll right center;float:right;height:25px;width:9px;"></div>';
			html += '<div style="font-size:12px;background:transparent url(' + this.LC_WebRoot + 'Style0/skin/chat_topl_bg.gif) no-repeat scroll 0 0;line-height:25px;padding-left:32px;">';
			html += getPromptStringByLang(this.LC_VisitorLang, LC_InvitePrompt) + '</div></div><div style="clear:both;"></div>';
			html += '<div style="background:#849FE4 none repeat scroll 0 0;border-color:-moz-use-text-color #283564 #283564;border-style:none solid solid;border-width:0 1px 1px;padding:1px;">';
			html += '<div style="background:transparent url(' + this.LC_WebRoot + 'images/RequestPicture_' + this.LC_CompanyID + '.gif) repeat scroll 0 0;border:1px solid #0A3869;">';
			html += '<table width="' + (this.LC_InviteBox_Width * 1 - 2) + '" border="0" cellpadding="0" cellspacing="0" height="' + (this.LC_InviteBox_Height * 1) + '" style="table-layout:fixed;">';
			html += '<tbody><tr><td width="135" style="border:0">&nbsp;</td><td style="border:0"><div id="InviteWord" style="font-size:12px;color:#020202;line-height:32px;padding-left:20px!important;padding-left:0px;padding-top:20px;word-break:break-all;height:' + (this.LC_InviteBox_Height - 68) + 'px!important;height:' + (this.LC_InviteBox_Height - 42) + 'px;overflow:auto;">';
			html += (word == "" ? getPromptStringByLang(this.LC_VisitorLang, LC_Url.decode(this.LC_SystemInviteText)) : word) + '</div></td></tr><tr><td height="40" style="border:0" colspan="2"><table width="180" align="right" border="0" cellpadding="0" cellspacing="0" style="border:0"><tbody><tr><td width="92" style="border:0">';
			var btn = '<div style="color:#FFFFFF;cursor:pointer;height:18px!important;line-height:16px!important;line-height:18px;padding-top:4px;text-indent:20px;vertical-align:top;width:80px;font-size:12px;';
			btn += 'background:transparent url(' + this.LC_WebRoot + 'Style0/skin/button_request.gif) repeat scroll 0 0;" ';
			btn += ' onmouseover="this.style.background=\'transparent url(' + this.LC_WebRoot + 'Style0/skin/button_request_over.gif) ';
			btn += ' repeat scroll 0 0\'" onmouseout="this.style.background=\'transparent url(' + this.LC_WebRoot + 'Style0/skin/button_request.gif) ';
			btn += ' repeat scroll 0 0\'" onmousedown="this.style.background=\'transparent url(' + this.LC_WebRoot + 'Style0/skin/button_request_down.gif) ';
			btn += ' repeat scroll 0 0\'" onmouseup="this.style.background=\'transparent url(' + this.LC_WebRoot + 'Style0/skin/button_request.gif) ';
			btn += ' repeat scroll 0 0\'" ';
			html += btn + ' id="Btn_LCAcceptInvite" sid=' + serviceid + ' onclick="javascript:AcceptCompanyInvite(' + this.LC_CompanyID + ',this.getAttribute(\'sid\'));">' + getPromptStringByLang(this.LC_VisitorLang, LC_AcceptInvitePrompt) + '</div></td><td style="border:0">';
			html += btn + ' id="Btn_LCRejectInvite" sid=' + serviceid + ' onclick="javascript:RejectCompanyInvite(' + this.LC_CompanyID + ',this.getAttribute(\'sid\'));">' + getPromptStringByLang(this.LC_VisitorLang, LC_RejectInvitePrompt) + '</div></td></tr></tbody></table></td></tr></tbody></table></div></div>' + adhtm + '</div></div></div>';
			inviteBoxDiv.innerHTML += html;
			/*
			if(this.LC_ShowAD==1)
			{
			if(typeof(LIVECHATAD) != "undefined")
			{
			eval("var x=new LIVECHATAD();x.RunSlideText(1,GetLanguage(),addivid,mweight)");
			}
			}*/
			if (typeof (LCInviteBox_Fly) != "undefined") {
				if (LCInviteBox_Fly == "1") {
					InitshowInviteBox('c35ComLiveChat');
				}
				if (LCInviteBox_Fly == "2") {
					InitshowInviteTips('c35ComLiveChat', this.LC_InviteBox_Top, this.LC_InviteBox_Left);
				}
			}
		}
	};
	this.AcceptInvite = function (serviceid) {
		if (!this.LC_IPRejected) {
			document.cookie = "rejectAutoinvite=1;";
			if (serviceid > 0) {
				AcceptInvite(this.LC_WebRoot, this.LC_CompanyID, this.LC_WebSiteID, this.LC_VisitorID, serviceid);
			}
			else {
				if (this.LC_UserProcess && this.LC_UserProcess == 1) {
					//window.open(this.LC_WebRoot + "V40/Group.aspx?companyid=" + this.LC_CompanyID + "&websiteid=" + this.LC_WebSiteID + "&browserLang=" + GetLanguage() + "&r=" + Math.random(), "", LC_winmode);
					window.open(this.LC_WebRoot + "V40/Chat.aspx?companyid=" + this.LC_CompanyID + "&websiteid=" + this.LC_WebSiteID + "&browserLang=" + GetLanguage() + "&r=" + Math.random(), "", LC_winmode);

				}
				else {
					window.open(this.LC_WebRoot + "V40/Chat.aspx?companyid=" + this.LC_CompanyID + "&websiteid=" + this.LC_WebSiteID + "&browserLang=" + GetLanguage() + "&r=" + Math.random(), "", LC_winmode);
				}
			}
		}
		else {
			alert(getPromptStringByLang(this.LC_VisitorLang, LC_IPRejectedPrompt));
		}
	};
	this.RejectInvite = function (serviceid) {
		document.cookie = "rejectinvite=1;";
		document.cookie = "rejectAutoinvite=1;";
		var rejectEle = rejectEle = document.createElement('img');
		rejectEle.id = "c35ComLiveChatImg";
		rejectEle.name = "c35ComLiveChatImg";
		rejectEle.style.display = "none";
		rejectEle.src = this.LC_WebRoot + "V40/rejectinvite.live?companyid=" + this.LC_CompanyID + "&websiteid=" + this.LC_WebSiteID;
	};
}
var EnableInviteChecker = true;
var LC_InviteUrl = "";
function StartInviteChecker() {
	if (LC_SystemIgnoreTag == 0 && get_cookie("chatwindowopened") != "1"
        && get_cookie("rejectinvite") != "1" && EnableInviteChecker && LC_InviteUrl != "") {
		var inviteframe = document.getElementById("scrInvitation");
		if (inviteframe) {
			var _parentElement = inviteframe.parentNode;
			if (_parentElement) {
				_parentElement.removeChild(inviteframe);
			}
		}
		var mj = new JsLoader();
		var u = LC_InviteUrl + "&r=" + Math.random();
		mj.load(u, "scrInvitation");
	}
}
function StopInviteChecker() {
	EnableInviteChecker = false;
}
function GetLanguage() {
	var language;

	//更改 设置页面访问默认语言   
	if (typeof (LC_InitLang) != "undefined" && LC_InitLang != "") {
		if (LC_InitLang.toLowerCase() == "zh-cht") LC_InitLang = "zh-TW";
		return LC_InitLang;
	}
	else {
		if (navigator.appName == 'Netscape')
			language = navigator.language;
		else
			language = navigator.browserLanguage;
		language = language.toLowerCase();

		if (language.indexOf('cn') > -1 || language.indexOf('chs') > -1)
			language = "zh-CN";
		else if (language.indexOf('zh') > -1)
			language = "zh-TW";
		else
			language = "en-US";
	}
	return language;
}

function AcceptCompanyInvite(companyid, serviceid) {
	var com = GetCompanyObject(companyid);
	if (com)
		com.AcceptInvite(serviceid);
	var inviteBoxDiv = document.getElementById('c35ComLiveChat');
	if (inviteBoxDiv) {
		inviteBoxDiv.style.display = 'none';
	}
}
function RejectCompanyInvite(companyid, serviceid) {
	var com = GetCompanyObject(companyid);
	if (com)
		com.RejectInvite(serviceid);
	var inviteBoxDiv = document.getElementById('c35ComLiveChat');
	if (inviteBoxDiv) {
		inviteBoxDiv.style.display = 'none';
	}
}
function AcceptInvite(webroot, companyid, websiteid, visitorid, serviceNo) {
	if (!this.LC_IPRejected) {
		window.open(webroot + "V40/chat.aspx?action=AcceptInvite&companyid=" + companyid + "&websiteid=" + websiteid + "&serviceNo=" + serviceNo + "&visitorid=" + visitorid + "&browserLang=" + GetLanguage() + "&r=" + Math.random(), "_blank", LC_winmode);
	}
	else {
		alert(getPromptStringByLang(this.LC_VisitorLang, LC_IPRejectedPrompt));
	}
}
var LC_CompanyLoadedCount = 0;
function InitCompany(companyid, websiteid, outputdivid) {
	if (typeof (LiveChatServer) != "undefined" && LiveChatServer != "") {
		if (!LiveChatServer.endWith("/"))
			LiveChatServer += "/";
	}
	else {
		alert(getPromptStringByLang(GetLanguage(), LC_ParameterError));
		return;
	}
	InitCompanyV2(companyid, websiteid, outputdivid, LiveChatServer);
}
function InitCompanyV2(companyid, websiteid, outputdivid, webroot) {
	if (CheckCompanyExist(companyid)) {
		return;
	}
	LC_DIV = outputdivid;
	if (webroot && webroot != "") {
		if (!webroot.endWith("/"))
			webroot += "/";
	}
	else {
		alert(getPromptStringByLang(GetLanguage(), LC_ParameterError));
		return;
	}
	var cookie = get_cookie('VisitorInfo_Name');
	if (cookie != null && cookie != '') {
		var cookieValue = cookie.substring(cookie.indexOf('=') + 1, cookie.length);
		if (cookieValue != null || cookieValue != '') {
			LC_VisitorName = unescape(cookieValue);
		}
	}
	cookie = get_cookie('VisitorInfo_Email');
	if (cookie != null && cookie != '') {
		cookieValue = cookie.substring(cookie.indexOf('=') + 1, cookie.length);
		if (cookieValue != null || cookieValue != '') {
			LC_VisitorEmail = unescape(cookieValue);
		}
	}
	try {
		var showUserList = false;
		if (typeof (LCUserList) != "undefined" && LCUserList != "") {
			showUserList = true;
		}
		else {
			LCUserList = "";
		}

		if (LC_CompanyLoadedCount == 0) {
			LC_CompanyLoadedCount++;
			var jsurl = webroot + "V40/" + companyid + "-" + websiteid + ".live?t=" + LC_Title + "&u=" + LC_Location + "&r=" + LC_Referrer +
			"&name=" + escape(LC_VisitorName) + "&email=" + LC_VisitorEmail + "&d=" + outputdivid + "&browserLang=" + GetLanguage() + "&random=" + Math.random() + "&showUserList=" + showUserList + "&LCUserList=" + LCUserList;
			var mj = new JsLoader();
			mj.load(jsurl, "LC_CompanyJS_" + companyid);
		}
		else {
			LC_CompanyLoadedCount++;
			var url = webroot + "V40/" + companyid + "-" + websiteid + ".live?t=" + LC_Title +
							"&u=" + LC_Location + "&r=" + LC_Referrer + "&name=" + escape(LC_VisitorName) + "&email=" + LC_VisitorEmail + "&d=" + outputdivid + "&browserLang=" + GetLanguage() + "&random=" + Math.random() + "&showUserList=" + showUserList + "&LCUserList=" + LCUserList;
			setTimeout(function () {
				var mj = new JsLoader();
				mj.load(url, "LC_CompanyJS_" + companyid);
			}, 3000);
		}
	}
	catch (e) {
		alert(e.message);
	}
}
function CheckCompanyExist(companyid) {
	for (var i = 0; i < LC_Companys.length; i++) {
		if (LC_Companys[i].LC_CompanyID == companyid)
			return true;
	}
	return false;
}
function GetCompanyObject(companyid) {
	for (var i = 0; i < LC_Companys.length; ++i) {
		if (LC_Companys[i].LC_CompanyID == companyid)
			return LC_Companys[i];
	}
	return null;
}
function LC_ClickLink(companyid) {
	var com = GetCompanyObject(companyid);
	if (com)
		com.Click();
}
function LC_RequestGroup(companyid, groupid) {
	var com = GetCompanyObject(companyid);
	if (com)
		com.Request(groupid);
}
function LC_RequestService(companyid, groupid, serviceid) {
	var com = GetCompanyObject(companyid);
	if (com)
		com.RequestService(groupid, serviceid);
}
function LC_GoOfflineMessage(webroot, companyid, websiteid, groupid) {
	var com = GetCompanyObject(companyid);
	if (com && !com.LC_IPRejected) {
		window.open(webroot + "V40/OfflineMessage.aspx?companyid=" + companyid + "&websiteid=" + websiteid + "&groupid=" + groupid, "_blank", LC_winmode);
	}
}
var LC_TryOpenInvite = 0;

function OpenInvite(companyid) {
	var inviteBoxDiv = document.getElementById('c35ComLiveChat');
	if (inviteBoxDiv) inviteBoxDiv.style.display = 'none';
	document.cookie = "rejectinvite=0;";

	if (companyid && typeof (companyid) != "undefined" && companyid != "") {
		if (LC_TryOpenInvite > 10) return;
		var com = GetCompanyObject(companyid);
		if (com) {
			com.ProcessInvite(0, "");
		}
		else {
			LC_TryOpenInvite++;
			setTimeout("OpenInvite(" + companyid + ")", 1000);
		}
	}
}

function ReceivedInvite(companyid, serverid, word) {
	if (serverid > 0) {
		var inviteBoxDiv = document.getElementById('c35ComLiveChat');
		if (inviteBoxDiv) inviteBoxDiv.style.display = 'none';
		document.cookie = "rejectinvite=0;";
	}
	if (get_cookie("chatwindowopened") == "1" || get_cookie("rejectinvite") == "1")
		return;

	if (companyid && typeof (companyid) != "undefined" && companyid != "") {
		var com = GetCompanyObject(companyid);
		if (com) {
			word = word.replace("\\/g", "\\\\");
			com.ProcessInvite(serverid, word);
		}
		else {
			if (this.LC_VisitorLang == "") this.LC_VisitorLang = GetLanguage();
			alert(getPromptStringByLang(this.LC_VisitorLang, LC_ParameterError));
		}
	}
}
String.prototype.endWith = function (oString) {
	var reg = new RegExp(oString + "$");
	return reg.test(this);
}
function getPromptStringAuto(str) {
	var langcookie = GetLanguage();
	var lang = 0;
	switch (langcookie.toLowerCase()) {
		case "zh-cn":
			break;
		case "zh-tw":
			lang = 1;
			break;
		case "zh-cht":
			lang = 1;
			break;
		case "zh-hk":
			lang = 1;
			break;
		default:
			lang = 2;
			break;
	}
	var items = str.split('|');
	if (items.length > 1)
		return items[lang];
	else
		return items[0];
}
function getPromptString(companyyid, str) {
	var langcookie = get_cookie(companyyid + ".VisitorCard.Language");
	if (!langcookie) langcookie = GetLanguage();
	var lang = 0;
	switch (langcookie.toLowerCase()) {
		case "zh-cn":
			lang = 0;
			break;
		case "zh-tw":
			lang = 1;
			break;
		case "zh-cht":
			lang = 1;
			break;
		case "zh-hk":
			lang = 1;
			break;
		default:
			lang = 2;
			break;
	}
	var items = str.split('|');
	if (items.length > 1)
		return items[lang];
	else
		return items[0];
}
function getPromptStringByLang(langstr, str) {
	if (!langstr || langstr == "") langstr = GetLanguage();
	var lang = 0;
	switch (langstr.toLowerCase()) {
		case "zh-cn":
			lang = 0;
			break;
		case "zh-tw":
			lang = 1;
			break;
		case "zh-cht":
			lang = 1;
			break;
		case "zh-hk":
			lang = 1;
			break;
		default:
			lang = 2;
			break;
	}
	var items = str.split('|');
	if (items.length > 1)
		return items[lang];
	else
		return items[0];
}
function getPromptStringForRead(langstr, str) {
	var curLang = getPromptStringByLang(langstr, str);
	if (curLang == "" && langstr.toLowerCase() == "zh-cn") {
		return getPromptStringForRead("zh-tw", str);
	}
	if (curLang == "" && (langstr.toLowerCase() == "zh-tw" || langstr.toLowerCase() == "zh-cht")) {
		return getPromptStringForRead("en-us", str);
	}
	if (curLang == "" && langstr.toLowerCase() == "en-us") {
		var items = str.split('|');
		curLang = items[0];
		if (curLang == "") return items[1];
	}
	return curLang;
}
var get_cookie = function (Name) {
	var search = Name + "="
	var returnvalue = "";
	if (document.cookie.length > 0) {
		var offset = document.cookie.indexOf(search)
		if (offset != -1) {
			offset += search.length
			var end = document.cookie.indexOf(";", offset);
			if (end == -1)
				end = document.cookie.length;
			returnvalue = unescape(document.cookie.substring(offset, end))
		}
	}
	return returnvalue;
}
function LoadJs(id, jsurl) {
	var oHead = document.getElementsByTagName('HEAD').item(0);
	var newFrame = document.createElement('SCRIPT');
	newFrame.id = id;
	newFrame.src = jsurl;
	oHead.appendChild(newFrame);
}
function JsLoader() {
	this.load = function (url, eid) {
		var ss = document.getElementsByTagName("script");
		for (i = 0; i < ss.length; i++) {
			if (ss[i].src && ss[i].src.indexOf(url) != -1) {
				this.onsuccess();
				return;
			}
		}
		s = document.createElement("script");
		if (eid) s.id = eid;
		s.type = "text/javascript";
		s.src = url;
		var head = document.getElementsByTagName("head")[0];
		head.appendChild(s);
		var self = this;
		s.onload = s.onreadystatechange = function () {
			if (this.readyState && this.readyState == "loading")
				return;
			self.onsuccess();
		}
		s.onerror = function () {
			head.removeChild(s);
			self.onfailure();
		}
	};
	this.onsuccess = function () { };
	this.onfailure = function () { };
}
function ShowServerErrorMessage(str, comserver) {
	var d = document.getElementById(LC_DIV);
	if (d) {
		d.innerHTML = "<a href='javascript:void(0)' onclick='alert(&quot;" + getPromptStringAuto(LC_LiveChat) + getPromptStringAuto(LC_InitError) + "\\r\\n\\r\\n" + str + "\\r\\n\\r\\n" + (typeof (LiveChatServer) != 'undefined' && LiveChatServer ? LiveChatServer : "LiveChatServer") + " " + getPromptStringAuto(LC_InitError) + (comserver == "" ? "" : "(" + getPromptStringAuto(LC_ServerADD) + comserver + ")") + "&quot;);'>" + getPromptStringAuto(LC_LiveChat) + getPromptStringAuto(LC_InitError) + "</a>";
	}
	else {
		alert(getPromptStringAuto(LC_LiveChat) + getPromptStringAuto(LC_InitError) + "\r\n\r\n" + str + "\r\n\r\n" + (typeof (LiveChatServer) != 'undefined' && LiveChatServer ? LiveChatServer : "LiveChatServer") + " " + getPromptStringAuto(LC_InitError) + (comserver == "" ? "" : "(" + getPromptStringAuto(LC_ServerADD) + comserver + ")"));
	}
}

/******************************** 网页滚动函数 *************************************/
/**************************** 随屏幕上下滚动而滚动 *********************************/
var LC_theTop = 80; /*这是默认高度,越大越往下*/
var LC_Old = 0; //LC_theTop

function moveTips() {
	var tt = 0;
	if (window.innerHeight) {
		pos = window.pageYOffset
	} else if (document.documentElement && document.documentElement.scrollTop) {
		pos = document.documentElement.scrollTop
	} else if (document.body) {
		pos = document.body.scrollTop;
	}

	pos = pos - tips.offsetTop + LC_theTop;
	pos = tips.offsetTop + pos / 10;
	if (pos < LC_theTop) pos = LC_theTop;
	if (pos != LC_Old) {
		tips.style.top = pos + "px";
		tt = 0;
	}
	LC_Old = pos;
	setTimeout(moveTips, tt);
}


/************************************** 撞墙浮动 **************************************/
// JScript 文件 
var LCTemp_d;   //用于来得到层对象

// 下面可根据需要自行修改 
var LCIcon_x = 7; //浮动层的初始位置，分别对应层的初始X坐标和Y坐标 
var LCIcon_y = 7;
var LCIcon_xin = true; //判断层的X坐标和Y坐标是否在在控制范围之内，LCIcon_xin为真是层向右移动，否则向左；LCIcon_yin为真是层向下移动，否则向上 
var LCIcon_yin = true;
var LCIcon_z = 1; //层移动的步长，值越大移动速度越快 
//漂浮速度
var setTime = 10; //层移动的时间间隔,单位为毫秒，值越小移动速度越快
var LCInvite_x = 7;
var LCInvite_y = 7;
var LCInvite_z = 1;
var LCInvite_xin = true;
var LCInvite_yin = true;
function InitshowAds(outputdivid) {
	LCTemp_d = document.getElementById(outputdivid);
	var itl = setInterval("floatAD()", setTime);
	LCTemp_d.onmouseover = function () { clearInterval(itl) }
	LCTemp_d.onmouseout = function () { itl = setInterval("floatAD()", setTime) }
}

function floatAD() {
	var L = T = 0;
	var tmp_H = document.compatMode == "CSS1Compat" ? document.documentElement.clientHeight : document.body.clientHeight;
	var tmp_W = document.compatMode == "CSS1Compat" ? document.documentElement.clientWidth : document.body.clientWidth;
	var tmp_SL = document.compatMode == "CSS1Compat" ? document.documentElement.scrollLeft : document.body.scrollLeft;
	var tmp_ST = document.compatMode == "CSS1Compat" ? document.documentElement.scrollTop : document.body.scrollTop;

	var R = tmp_W - LCTemp_d.offsetWidth;
	var B = tmp_H - LCTemp_d.offsetHeight;
	LCTemp_d.style.left = (LCIcon_x + tmp_SL) + "px";
	LCTemp_d.style.top = (LCIcon_y + tmp_ST) + "px";
	LCIcon_x = LCIcon_x + LCIcon_z * (LCIcon_xin ? 1 : -1);
	if (LCIcon_x < L) { LCIcon_xin = true; LCIcon_x = L }
	if (LCIcon_x > R) { LCIcon_xin = false; LCIcon_x = R }
	LCIcon_y = LCIcon_y + LCIcon_z * (LCIcon_yin ? 1 : -1);
	if (LCIcon_y < T) { LCIcon_yin = true; LCIcon_y = T }
	if (LCIcon_y > B) { LCIcon_yin = false; LCIcon_y = B }
}
var m_LCInviteBox;
function InitshowLinkIcon(outputdivid) {
	InitshowAds(outputdivid);
}
function InitshowLinkIconTips(outputdivid) {
	tips = document.getElementById(outputdivid);
	moveTips();
}
function InitshowInviteBox(outputdivid) {
	m_LCInviteBox = document.getElementById(outputdivid);
	var itl = setInterval("floatInviteBox()", setTime);
	m_LCInviteBox.onmouseover = function () { clearInterval(itl) }
	m_LCInviteBox.onmouseout = function () { itl = setInterval("floatInviteBox()", setTime) }
}
function floatInviteBox() {
	var L = T = 0;
	var R = document.body.clientWidth - m_LCInviteBox.offsetWidth;
	var B = document.body.clientHeight - m_LCInviteBox.offsetHeight;
	m_LCInviteBox.style.left = (LCInvite_x + document.body.scrollLeft) + "px";
	m_LCInviteBox.style.top = (LCInvite_y + document.body.scrollTop) + "px";
	LCInvite_x = LCInvite_x + LCInvite_z * (LCInvite_xin ? 1 : -1);
	if (LCInvite_x < L) { LCInvite_xin = true; LCInvite_x = L }
	if (LCInvite_x > R) { LCInvite_xin = false; LCInvite_x = R }
	LCInvite_y = LCInvite_y + LCInvite_z * (LCInvite_yin ? 1 : -1);
	if (LCInvite_y < T) { LCInvite_yin = true; LCInvite_y = T }
	if (LCInvite_y > B) { LCInvite_yin = false; LCInvite_y = B }
}
function InitshowInviteTips(outputdivid, initop, initleft) {
	StartInviteTips(outputdivid, initop, 0);
}
function StartInviteTips(m_outputdivid, m_top, m_last) {
	var m_div = document.getElementById(m_outputdivid);
	if (!m_div) return;
	var tt = 0;
	if (window.innerHeight) {
		pos = window.pageYOffset
	}
	else if (document.documentElement && document.documentElement.scrollTop) {
		pos = document.documentElement.scrollTop
	}
	else if (document.body) {
		pos = document.body.scrollTop;
	}

	pos = pos - m_div.offsetTop + m_top;
	pos = m_div.offsetTop + pos / 10;
	if (pos < m_top) pos = m_top;
	if (pos != m_last) {
		m_div.style.top = pos + "px";
		tt = 0;
	}
	m_last = pos;
	setTimeout("StartInviteTips('" + m_outputdivid + "'," + m_top + "," + m_last + ")", tt);
}

/*************************分组列表**********************************/
function LC_showHideGroup(weburl, idli, idol) {
	var li = document.getElementById(idli);
	var tag = li.getAttribute("tag");
	var ol = document.getElementById(idol);
	li.setAttribute("tag", (tag == "open" ? "close" : "open"));
	if (document.all) {
		li.style.fontWeight = (tag == "open" ? "normal" : "bold");
		li.style.color = (tag == "open" ? "#656b82" : "#5d5d5d");
		li.style.lineHeight = "18px";
		li.style.background = "url('" + weburl + "V40/images/" + (tag == "open" ? "group-normal.png" : "group-drop.png") + "') no-repeat 0 5px";
		li.style.textIndent = "13px";
	}
	else {
		if (tag == "open")
			li.setAttribute("style", "cursor:pointer;line-height:18px;text-indent:13px;font-weight:normal;color:#656b82;background:url(" + weburl + "V40/images/group-normal.png) no-repeat 0 5px");
		else
			li.setAttribute("style", "cursor:pointer;line-height:18px;text-indent:13px;font-weight:bold;color:#5d5d5d;background: url(" + weburl + "V40/images/group-drop.png) no-repeat 0 5px");
	}
	ol.style.display = (tag == "open" ? "none" : "");
}
function LC_toggleUserList() {
	if (LC_SetUserList_Toggle) return;
	theObj = document.getElementById('group-box').style;
	if (theObj.display == "none") {
		theObj.display = "none";
	}
	else {
		theObj.display = "none";
	}
	if (typeof (LCLinkIcon_Fly) != "undefined" && LCLinkIcon_Fly != 0) {
		var lcUserlistTip = document.getElementById("lcUserlistTip");
		lcUserlistTip.style.display = "";
	}
};
function LC_ShowUserList() {
	theObj = document.getElementById('group-box').style;
	theObj.display = "";

	var lcUserlistTip = document.getElementById("lcUserlistTip");
	lcUserlistTip.style.display = "none";
};
var LC_SetUserList_Toggle = false;
function LC_SetUserList(id) {
	switch (id) {
		case 0:
			if (typeof (LCLinkIcon_Fly) != "undefined" && LCLinkIcon_Fly != 0) {
				LC_SetUserList_Toggle = true;
				var g = document.getElementById('group-box');
				if (g) {
					if (document.all) {
						window.attachEvent('onmouseleave', function () {
							LC_SetUserList(1)
						});
					}
					else {
						g.onmouseout = function () { LC_SetUserList(1) };
					}
				}
			}
			break;
		case 1:
			if (LC_SetUserList_Toggle) {
				LC_SetUserList_Toggle = false;
				if (typeof (LCLinkIcon_Fly) != "undefined" && LCLinkIcon_Fly != 0)
					setTimeout(LC_toggleUserList, 500);
			}
			break;
		case 2:
			setTimeout(LC_ShowUserList, 10);
			break;
		default:
			break;
	}
}
function htmlencode(s) {
	s = s.replace(/</g, "&lt;");
	s = s.replace(/>/g, "&gt;");
	//s = s.replace(/"/g, "&quot;");
	return s;
}
function getByteVal(val, max) {
	try {
		var returnValue = '';
		var byteValLen = 0;
		for (var i = 0; i < val.length; i++) {
			if (val.substring(i, i + 1).match(/[^\x00-\xff]/ig) != null)
				byteValLen += 2;
			else
				byteValLen += 1;

			if (byteValLen > max)
				break;

			returnValue += val.substring(i, i + 1);
		}
		if (val.length > max) {
			return returnValue + "...";
		}
		return returnValue;
	} catch (x) {
		return val;
	}
} 
