//系统设置

var LHVAR_FlashPath = "http://crm.itlanhai.com/chat/images/com_min_vis.swf?timespan=" + (new Date()).getTime();
var LHVAR_ChatWinPath = "http://crm.itlanhai.com/chat/vchat.aspx";
var LHVAR_ChatWinStyle = "styledefault";

var LHVAR_ServiceIP = "crm.itlanhai.com";
var LHVAR_ServicePort = 1502;

//流量系统探针

var LHVAR_Analyse = "http://stat.itlanhai.com/statmodule/statprobe.aspx";

var LHVAR_SupportDataAnalyse = true;

//0: 离线
//1: 在线
var LHVAR_ConnectStat = 0;

var LHVAR_HeartBeatInterval = 60000;

var LHVAR_HeartBeatCounter = 0;

//最高心跳次数，0为无限多，用于控制访客超时时间
var LHVAR_HeartBeatMaxCount = 10;

//var LHVAR_HeartBeatMaxCount = 0;

//挂接到位置维护器的窗口对象
var LHVAR_ObjRelatePosArr = new Array();

//约定：
//LHOBJ_INVITE_BOARD 作为邀请窗口ID，而LHOBJ_FLOAT_BOARD 作为浮动窗口的ID

//用户基本信息

var LHVAR_AccountGUID = "fe91247f-d619-4fae-b1df-917c6f083594";

//Begin 浮动框的设置参数
//var LHVAR_FloatBoardWidth  = 112;
//var LHVAR_FloatBoardHeight  = 112;
var LHVAR_FloatBoardAlign  = 2;
var LHVAR_FloatBoardVAlign  = 0;

var LHVAR_FloatType  = "1";
var LHVAR_FloatStyle  = "styledefault";
var LHVAR_IsAutoInvite = "1";
var LHVAR_InviteStyleName = "styledefault";
//End   浮动框的设置参数

var LHVAR_VisitorGUID = "d2fb2892-46dd-4748-8b36-b5c511c1eeec";
var LHVAR_VisitorID = 1321063;
var LHVAR_VisitCount = 1;
var LHVAR_VisTicket = "";
var LHVAR_VisUrl = "";
var LHVAR_Refferer = "";

//获取浏览器信息

var LHVAR_Browser = "";
var LHVAR_OS = "";
var LHVAR_Lang = 437;				//默认使用简体中文
var LHVAR_SupportCookie = navigator.cookieEnabled;	//如果不支持Cookie，则不进行统计
var LHVAR_FlashVer = "";

function LHFUNC_SetCookie(name, value, tmpcookie, timeoutval)
{
	expires = "";
	if(typeof(tmpcookie) == "undefined" || !tmpcookie)
	{
		date = new Date();
		if(typeof(timeoutval) != "undefined" && timeoutval >= 0)
			date.setTime(date.getTime() + (timeoutval * 60 * 60 * 1000));		//timeoutval 小时后过期
		else
			date.setTime(date.getTime() + (365 * 24 * 60 * 60 * 1000));		//一年的过期期限
		expires = '; expires=' + date.toUTCString();
	}
	document.cookie = [name, "=", encodeURIComponent(value), expires, "", "", ""].join("");
}

function LHFUNC_Trim(val)
{
	return val.replace(/(^\s*)|(\s*$)/g, "");
}

/*function LHFUNC_LTrim(val)
{
	return val.replace(/(^\s*)/g, "");
}

function LHFUNC_RTrim(val)
{
	return val.replace(/(\s*$)/g, "");
}*/

function LHFUNC_GetCookie(name)
{
	cookieValue = null;
	if(document.cookie || document.cookie != "")
	{
		var cookies = document.cookie.split(';');
		for (var i = 0; i < cookies.length; i++) {
			var cookie = LHFUNC_Trim(cookies[i]);
			// Does this cookie string begin with the name we want?
			if (cookie.substring(0, name.length + 1) == (name + '=')) {
				cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
				break;
			}
		}
		return cookieValue;
	}
	return null;
}

function LHFUNC_GetSwfObject(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}

function LHFUNC_SetPermenantCookie(name, val)
{
	if(LHFUNC_GetSwfObject("LHSWF_ComSocket") == null || typeof(LHFUNC_GetSwfObject("LHSWF_ComSocket").SetFlashCookie) == "undefined")
		return false;	//Flash不支持该接口

	return LHFUNC_GetSwfObject("LHSWF_ComSocket").SetFlashCookie(name, val);
}

function LHFUNC_GetPermenantCookie(name)
{
	if(LHFUNC_GetSwfObject("LHSWF_ComSocket") == null || typeof(LHFUNC_GetSwfObject("LHSWF_ComSocket").GetFlashCookie) == "undefined")
		return null;	//Flash不支持该接口

	cvar = LHFUNC_GetSwfObject("LHSWF_ComSocket").GetFlashCookie(name);

	if(typeof(cvar) == "undefined")
		return null;
	return cvar;
}

function LHFUNC_ConnectToServer()
{
	if(typeof(LHFUNC_GetSwfObject("LHSWF_ComSocket").ConnectToServer) == "undefined")
	{
		setTimeout(LHFUNC_ConnectToServer, 1000);
		return;
	}

	LHFUNC_GetSwfObject("LHSWF_ComSocket").ConnectToServer(LHVAR_ServiceIP, LHVAR_ServicePort);
	return false;
}

function cb4f1edb69a543db862a03def475afdd_OnConnect(success)
{
	if(success)
	{
		LHVAR_ConnectStat = 1;
		//在此发送客户端相关信息
		xcmd = new LHFUNC_XmlDataTable();
		dr = xcmd.NewRow();
		dr["ActionVerb"] = "visitorsignin";
		dr["AccountGUID"] = LHVAR_AccountGUID;
		dr["VisitorGUID"] = LHVAR_VisitorGUID;
		dr["VisitorID"] = LHVAR_VisitorID;
		dr["VisTicket"] = LHVAR_VisTicket;
		dr["VisUrl"] = LHVAR_VisUrl;
		dr["Refferer"] = LHVAR_Refferer;
		dr["Browser"] = LHVAR_Browser;
		dr["OS"] = LHVAR_OS;
		dr["Lang"] = LHVAR_Lang;
		dr["FlashVer"] = LHVAR_FlashVer;
		dr["VisitCount"] = LHVAR_VisitCount;
		dr["FloatBoardType"] = LHVAR_FloatType;
		dr["FloatStyleName"] = LHVAR_FloatStyle;
		dr["IsAutoInvite"] = LHVAR_IsAutoInvite;
		dr["InviteStyleName"] = LHVAR_InviteStyleName;
		LHFUNC_GetSwfObject("LHSWF_ComSocket").SendData(xcmd.ToXml());
	}
}

function cb4f1edb69a543db862a03def475afdd_OnClose()
{
	LHVAR_ConnectStat = 0;
}

function LHFUNC_URLDecode(strInput)
{
//	strInput = strInput.toLowerCase();
	strInput = strInput.replace(/\+/g, ' ');
	strInput = strInput.replace(/\%40/g, '@');
	strInput = strInput.replace(/\%23/g, '#');
	strInput = strInput.replace(/\%24/g, '$');
	strInput = strInput.replace(/\%26/g, '&');
	strInput = strInput.replace(/\%2b/g, '+');
	strInput = strInput.replace(/\%2B/g, '+');
	strInput = strInput.replace(/\%3d/g, '=');
	strInput = strInput.replace(/\%3D/g, '=');
	strInput = strInput.replace(/\%3b/g, ';');
	strInput = strInput.replace(/\%3B/g, ';');
	strInput = strInput.replace(/\%3a/g, ':');
	strInput = strInput.replace(/\%3A/g, ':');
	strInput = strInput.replace(/\%2f/g, '/');
	strInput = strInput.replace(/\%2F/g, '/');
	strInput = strInput.replace(/\%3f/g, '?');
	strInput = strInput.replace(/\%3F/g, '?');
	strInput = strInput.replace(/\%2c/g, ',');
	strInput = strInput.replace(/\%2C/g, ',');
	return decodeURI(strInput);
}

function LHFUNC_URLEncode(strInput)
{
	strTmp = encodeURI(strInput);
	strTmp = strTmp.replace(/\ /g, '+');
	strTmp = strTmp.replace(/\@/g, '%40');
	strTmp = strTmp.replace(/\#/g, '%23');
	strTmp = strTmp.replace(/\$/g, '%24');
	strTmp = strTmp.replace(/\&/g, '%26');
	strTmp = strTmp.replace(/\+/g, '%2B');
	strTmp = strTmp.replace(/\=/g, '%3D');
	strTmp = strTmp.replace(/\;/g, '%3B');
	strTmp = strTmp.replace(/\:/g, '%3A');
	strTmp = strTmp.replace(/\//g, '%2F');
	strTmp = strTmp.replace(/\?/g, '%3F');
	strTmp = strTmp.replace(/\,/g, '%2C');
	return strTmp;
}

function cb4f1edb69a543db862a03def475afdd_OnXmlData(src)
{
	xcmd = new LHFUNC_XmlDataTable();
	xcmd.FromXml(LHFUNC_URLDecode(src));

	if(xcmd.Rows == null || xcmd.Rows.Count <= 0)
		return;

	switch(xcmd.Rows[0]["ActionVerb"])
	{
		case "invitevisitor":
		{
			LHFUNC_ShowDialog("LHOBJ_INVITE_BOARD", xcmd.Rows[0]["InviteTemplate"], false);
			window.focus();
			break;
		}
		case "visitorfloatboard":
		{
			if(parseInt(xcmd.Rows[0]["FloatBoardType"]) > 0)
			{
				LHFUNC_ShowDialog("LHOBJ_FLOAT_BOARD", xcmd.Rows[0]["FloatBoard"], LHVAR_FloatBoardAlign, LHVAR_FloatBoardVAlign, false);
			}
			break;
		}
	}
}

//初始化通讯用的Flash对象

document.write("<div style=\"background:none;width:1px;height:1px;position:absolute;overflow:hidden;left:-2px;top:-2px;\"><object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"1\" height=\"1\" align=\"middle\" id=\"LHSWF_ComSocket\">");
document.write("	<param name=\"allowScriptAccess\" value=\"always\" />");
document.write("	<param name=\"movie\" value=\"" + LHVAR_FlashPath + "\" />");
document.write("	<param name=\"quality\" value=\"high\" />");
document.write("	<param name=\"bgcolor\" value=\"#ffffff\" />");
document.write("	<embed src=\"" + LHVAR_FlashPath + "\" quality=\"high\" bgcolor=\"#ffffff\" width=\"1\" height=\"1\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" name=\"LHSWF_ComSocket\" />");
document.write("</object></div>");

LHVAR_VisUrl = document.location;
LHVAR_Refferer = document.referrer;

//获取浏览器信息
useragentstr = navigator.userAgent;
if(useragentstr.indexOf("MSIE 6.0") >= 0)
	LHVAR_Browser = "MSIE 6.0";
else if(useragentstr.indexOf("Firefox") >= 0)
	LHVAR_Browser = "Firefox";
else if(useragentstr.indexOf("MSIE 8.0") >= 0)
	LHVAR_Browser = "MSIE 8.0";
else if(useragentstr.indexOf("MSIE 7.0") >= 0)
	LHVAR_Browser = "MSIE 7.0";
else if(useragentstr.indexOf("Chrome") >= 0)
	LHVAR_Browser = "Chrome";
else if(useragentstr.indexOf("Opera") >= 0)
	LHVAR_Browser = "Opera";
else if(useragentstr.indexOf("Netscape") >= 0)
	LHVAR_Browser = "Netscape";
else if(useragentstr.indexOf("Safari") >= 0)
	LHVAR_Browser = "Safari";
else if(useragentstr.indexOf("MSIE 5.5") >= 0)
	LHVAR_Browser = "MSIE 5.5";
else if(useragentstr.indexOf("MSIE 5.01") >= 0)
	LHVAR_Browser = "MSIE 5.01";
else if(useragentstr.indexOf("MSIE 5.0") >= 0)
	LHVAR_Browser = "MSIE 5.0";
else if(useragentstr.indexOf("MSIE") >= 0)
	LHVAR_Browser = "MSIE";
else
	LHVAR_Browser = "Unknown";

/*		//获取语言版本
userlangstr = (navigator.language || window.navigator.userLanguage).toLowerCase();

if(userlangstr != null && userlangstr.length > 0)
{
	if(userlangstr == "zh" || userlangstr == "zh-cn" || userlangstr == "zh-sg")
		LHVAR_Lang = 936;
	else if(userlangstr == "zh" || userlangstr == "zh-cn" || userlangstr == "zh-sg")
		LHVAR_Lang = 950;
	else if(userlangstr.indexOf("en") >= 0)
		LHVAR_Lang = 437;
	else if(userlangstr.indexOf("zh") >= 0)
		LHVAR_Lang = 936;
	else
		LHVAR_Lang = 936;
}*/

//获取操作系统版本

if(useragentstr.indexOf("Windows NT 5.1") >= 0)
	LHVAR_OS = "Windows NT 5.1"
else if(useragentstr.indexOf("Windows NT 6.0") >= 0)
	LHVAR_OS = "Windows NT 6.0"
else if(useragentstr.indexOf("Windows NT 6.1") >= 0)
	LHVAR_OS = "Windows NT 6.1"
else if(useragentstr.indexOf("Windows NT 5.2") >= 0)
	LHVAR_OS = "Windows NT 5.2"
else if(useragentstr.indexOf("Windows NT 5.01") >= 0)
	LHVAR_OS = "Windows NT 5.01"
else if(useragentstr.indexOf("Windows NT 5.0") >= 0)
	LHVAR_OS = "Windows NT 5.0"
else if(useragentstr.indexOf("Windows NT 4.0") >= 0)
	LHVAR_OS = "Windows NT 4.0"
else if(useragentstr.indexOf("Windows 98; Win 9x 4.90") >= 0)
	LHVAR_OS = "Windows 98; Win 9x 4.90"
else if(useragentstr.indexOf("Windows 98") >= 0)
	LHVAR_OS = "Windows 98"
else if(useragentstr.indexOf("Windows 95") >= 0)
	LHVAR_OS = "Windows 95"
else if(useragentstr.indexOf("Windows CE") >= 0)
	LHVAR_OS = "Windows CE"
else
	LHVAR_OS = "Unknown"

//检查Flash版本信息

if(LHVAR_Browser.indexOf("MSIE") >= 0)
{
	try
	{
		var swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
		LHVAR_FlashVer = swf.GetVariable("$version").split(" ")[1].split(",")[0];
	}
	catch (ex)
	{
		LHVAR_FlashVer = "unknown";
	}
}
else
{
	try
	{
		if(navigator.plugins && navigator.plugins.length)
		{
			var p = navigator.plugins['Shockwave Flash'];

			if(typeof(p) == "object")
			{
				LHVAR_FlashVer = p.description.split(" ")[2].split(".")[0];
			}
		}
	}
	catch (ex)
	{
		LHVAR_FlashVer = "unknown";
	}
}

//Begin 统计系统用代码

if(LHVAR_SupportDataAnalyse && LHFUNC_GetCookie("LHVAR_LastVisPage") != LHVAR_VisUrl)
{
	var dtime = new Date();
	sdate = dtime.getFullYear() + "," + (dtime.getMonth() + 1) + "," + dtime.getDate();

	isvisreturn = true;
	if(LHFUNC_GetCookie("LHVAR_ASVisitorGUID") == null)
	{
		isvisreturn = false;
		LHFUNC_SetCookie("LHVAR_ASVisitorGUID", LHVAR_VisitorGUID, false);
	}

	LHVAR_StrProbeParams = "AccountGUID=" + LHVAR_AccountGUID + "&VisitorGUID=" + LHFUNC_GetCookie("LHVAR_ASVisitorGUID") + "&VisUrl=" + LHFUNC_URLEncode(LHVAR_VisUrl) + "&Refferer=" + LHFUNC_URLEncode(LHVAR_Refferer) + "&Browser=" + LHFUNC_URLEncode(LHVAR_Browser) + "&OS=" + LHFUNC_URLEncode(LHVAR_OS) + "&FlashVer=" + LHFUNC_URLEncode(LHVAR_FlashVer);

	LHVAR_StrProbeParams += "&TodayLogin=" + (LHFUNC_GetCookie("LHVAR_LastLogin") != sdate?0:1);
	LHVAR_StrProbeParams += "&VisReturn=" + (isvisreturn?1:0);
	LHVAR_StrProbeParams += "&IsEntry=" + (LHFUNC_GetCookie("LHVAR_SignInTag") == 1?0:1);
	LHVAR_StrProbeParams += "&SupportCookie=" + (LHVAR_SupportCookie?1:0);

	LHFUNC_SetCookie("LHVAR_LastLogin", sdate, false);

	document.write("<iframe style=\"display:none;\" src=\""+LHVAR_Analyse + "?" + LHVAR_StrProbeParams+"\" id=\"LHIFRAME_AnalyseContainer\"></iframe>");
	LHFUNC_SetCookie("LHVAR_LastVisPage", LHVAR_VisUrl, true);
}
//End   统计系统用代码

function LHFUNC_InitBasicInfo()
{
	if(!LHVAR_SupportCookie)
		return false;		//浏览器不支持Cookie

	try
	{
		vtmpvar = LHFUNC_GetPermenantCookie("LHVAR_VisitorGUID" + LHVAR_AccountGUID);
		if(typeof(vtmpvar) == "undefined" || vtmpvar == null)
		{
			if(!LHFUNC_SetPermenantCookie("LHVAR_VisitorID" + LHVAR_AccountGUID, LHVAR_VisitorID))
				return false;
			if(!LHFUNC_SetPermenantCookie("LHVAR_VisitorGUID" + LHVAR_AccountGUID, LHVAR_VisitorGUID))
				return false;
			if(!LHFUNC_SetPermenantCookie("LHVAR_VisitCount" + LHVAR_AccountGUID, LHVAR_VisitCount))
				return false;
		}
		else
		{
			LHVAR_VisitorGUID = LHFUNC_GetPermenantCookie("LHVAR_VisitorGUID" + LHVAR_AccountGUID);
			LHVAR_VisitCount = LHFUNC_GetPermenantCookie("LHVAR_VisitCount" + LHVAR_AccountGUID);
			if(LHVAR_VisitCount == null || LHVAR_VisitCount.length <= 0)
				LHVAR_VisitCount = 0;

			LHVAR_VisitorID = LHFUNC_GetPermenantCookie("LHVAR_VisitorID" + LHVAR_AccountGUID);
			if(LHVAR_VisitorID == null || LHVAR_VisitorID.length <= 0)
				LHVAR_VisitorID = 0;

			vtickettmp = LHFUNC_GetPermenantCookie("LHVAR_VisTicket" + LHVAR_AccountGUID);
			if(vtickettmp != null)
				LHVAR_VisTicket = vtickettmp;

			if(LHFUNC_GetCookie("LHVAR_SignInTag") == null)
			{
				++LHVAR_VisitCount;

				LHFUNC_SetPermenantCookie("LHVAR_VisitCount" + LHVAR_AccountGUID, LHVAR_VisitCount);
			}
		}

		if(LHFUNC_GetCookie("LHVAR_ASVisitorGUID") != LHVAR_VisitorGUID)
			LHFUNC_SetCookie("LHVAR_ASVisitorGUID", LHVAR_VisitorGUID, false);

		LHFUNC_SetCookie("LHVAR_SignInTag", 1, true);

	}
	catch (outerex)
	{
		alert(outerex);
		return false;
	}

	return true;
}

function LHFUNC_XmlDataTable()
{
	this.DataSetName = "NewDataSet";
	this.DataTableName = "Table1";

	this.docTypeDecl = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";

	this.Rows = new Array();
}

LHFUNC_XmlDataTable.prototype.FromXml = function (xml)
{
	this.Rows = new Array();

	var dom = null;
	var dataset = null;

	if(window.ActiveXObject)
	{
		dom = new ActiveXObject("Microsoft.XMLDOM");
		dom.loadXML(xml);
		if(dom.childNodes[0].nodeType != 7)
			dataset = dom.childNodes[0];
		else
			dataset = dom.childNodes[1];
	}
	else if(DOMParser)
	{
		var oParser = new DOMParser();
		dom = oParser.parseFromString(xml,"text/xml");
		if(dom.childNodes.length != 1)
			return false;
		dataset = dom.childNodes[0];
	}
	else
		return false;

	this.DataSetName = dataset.nodeName;

	if(dataset.childNodes.length <= 0)
		return true;		//没有任何行，收工

	var tablename = dataset.childNodes[0];

	this.DataTableName = tablename.nodeName;

	//接下来，提取出所有数据

	irow = 0;
	for(i=0;i<dataset.childNodes.length;++i)
	{
		var row = dataset.childNodes[i];
		if(row.nodeType != 1)
			continue;

		this.Rows[irow] = new Array();
		for(icol=0;icol<row.childNodes.length;++icol)
		{
			if(window.ActiveXObject)
			{
				if(row.childNodes != null && typeof(row.childNodes[icol]) != "undefined")
				{
					this.Rows[irow][row.childNodes[icol].nodeName] = row.childNodes[icol].text;
				}
			}
			else if(DOMParser)
			{
				if(typeof(row.childNodes[icol]) != "undefined" && typeof(row.childNodes[icol].childNodes[0]) != "undefined")
				{
					k = 0;
					strtmp = "";

					do
					{
						strtmp += row.childNodes[icol].childNodes[k++].nodeValue;
					}
					while (row.childNodes[icol].childNodes.length > k && row.childNodes[icol].childNodes[k].nodeValue != null);

					this.Rows[irow][row.childNodes[icol].nodeName] = strtmp;
				}
			}
		}
		++irow;
	}

	return true;
}

LHFUNC_XmlDataTable.prototype.ToXml = function ()
{
	//生成XML

	var dom = null;

	if(window.ActiveXObject)
	{
		dom = new ActiveXObject("Microsoft.XMLDOM");
	}
	else if(DOMParser)
	{
		dom = document.implementation.createDocument("", "", null);
	}
	else
		return null;

	var dataset = dom.createElement(this.DataSetName);

	dom.appendChild(dataset);

	var row = null;
	var col = null;
	var txtnode = null;

	for(irow = 0;irow<this.Rows.length;++irow)
	{
		row = dom.createElement(this.DataTableName);

		for(var key in this.Rows[irow])
		{
			col = dom.createElement(key);
			txtnode = dom.createTextNode(this.Rows[irow][key]);
			col.appendChild(txtnode);

			row.appendChild(col);
		}

		dataset.appendChild(row);
	}

	if(window.ActiveXObject)
	{
		return this.docTypeDecl + dom.xml;
	}
	else if(DOMParser)
	{
		var oSerializer = new XMLSerializer();
		return this.docTypeDecl + oSerializer.serializeToString(dom);
	}
	else
		return null;
}

LHFUNC_XmlDataTable.prototype.NewRow = function ()
{
	newrow = new Array();
	this.Rows[this.Rows.length] = newrow;

	return newrow;
}

LHFUNC_XmlDataTable.prototype.Clear = function ()
{
	this.Rows = new Array();
}

function LHFUNC_SocketHeartBeat()
{
	if(LHVAR_HeartBeatMaxCount <= 0 || LHVAR_HeartBeatCounter < LHVAR_HeartBeatMaxCount)
	{
		if(LHVAR_ConnectStat == 1)
		{
			//正常链接，需要发送心跳包
			LHFUNC_GetSwfObject("LHSWF_ComSocket").SendData("<heart-beat-package/>");
		}
		setTimeout(LHFUNC_SocketHeartBeat, LHVAR_HeartBeatInterval);		//每分钟一次心跳包
		LHVAR_HeartBeatCounter++;
	}
}

function LHFUNC_ShowDialog(id, html, align, top, biframe)
{
	if(document.getElementById(id + "_dlg") == null)
	{
		var bgObj = null;

		if(typeof(biframe) == "undefined" || biframe == true)
		{
			bgObj=document.createElement("iframe"); 
			bgObj.frameBorder = "0";
			bgObj.setAttribute('id', id + "_bg"); 
			bgObj.style.position="absolute"; 
			bgObj.src = "about:blank";
			bgObj.style.background="#FFFFFF"; 
			bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)"; 
			bgObj.style.opacity="0";
//			bgObj.style.width= w + "px"; 
//			bgObj.style.height= h + "px"; 
			
	//		bgObj.style.width="100%"; 
	//		bgObj.style.height= (document.documentElement.scrollHeight <document.documentElement.clientHeight?document.documentElement.clientHeight:document.documentElement.scrollHeight) + "px"; 
			bgObj.style.zIndex = "10000"; 
			
			document.body.appendChild(bgObj); 
		}
		
		var dlgObj = document.createElement("div");
		dlgObj.setAttribute("id", id + "_dlg");
		dlgObj.style.position="absolute"; 
//		dlgObj.style.width= w + "px"; 
//		dlgObj.style.height= h + "px"; 
//		dlgObj.style.border = "1px solid #CCC";
		dlgObj.style.zIndex = "10001";
//		dlgObj.style.border = "1px solid #CCCCCC";
		
		document.body.appendChild(dlgObj); 
		document.getElementById(id + "_dlg").innerHTML = html;

		//定一个初始坐标
		
		if(typeof(align) == "undefined" || align == 0)
		{
			if(bgObj != null)
			{
				bgObj.style.left = "50%";
//				bgObj.style.marginLeft = "-" + (w/2) + "px";
			}
			dlgObj.style.left = "50%";
//			dlgObj.style.marginLeft = "-" + (w/2) + "px";
		}
		else
		{
			if(align == 1)	//left
			{
				if(bgObj != null)
					bgObj.style.left = "5px";
				dlgObj.style.left = "5px";
			}
			if(align == 2)
			{
				if(bgObj != null)
					bgObj.style.right = "5px";
				dlgObj.style.right = "5px";
			}
		}
		
		y = 0;
		if(typeof(top) == "undefined" || (top > -5 && top < 5))
		{
			y = ((window.innerHeight || (document.documentElement.clientHeight ||document.body.clientHeight)) - dlgObj.offsetHeight)/2;
			LHVAR_ObjRelatePosArr[id] = 0;
		}
		else if(top <= -5)
		{
			y = (window.innerHeight || (document.documentElement.clientHeight ||document.body.clientHeight)) - dlgObj.offsetHeight + top;
			LHVAR_ObjRelatePosArr[id] = top;
		}
		else
		{
			y = top;
			LHVAR_ObjRelatePosArr[id] = top;
		}
			
		if(bgObj != null)
			bgObj.style.top = y + "px";
		dlgObj.style.top = y + "px";
		
//		LHVAR_ObjRelatePosArr[id] = y;

		if(typeof(align) == "undefined" || align == 0)
		{
			dlgObj.style.marginLeft = "-" + (dlgObj.offsetWidth/2) + "px";
			if(bgObj != null)
				bgObj.style.marginLeft = "-" + (dlgObj.offsetWidth/2) + "px";
		}

		if(typeof(biframe) == "undefined" || biframe == true)
		{
			bgObj.style.width = dlgObj.offsetWidth + "px";
			bgObj.style.height = dlgObj.offsetHeight + "px";
		}
	}
	else
	{
		if(document.getElementById(id + "_bg") != null)
			document.getElementById(id + "_bg").style.display = "";
		document.getElementById(id + "_dlg").style.display = "";
		document.getElementById(id + "_dlg").innerHTML = html;
		document.getElementById(id + "_dlg").style.marginLeft = "-" + (document.getElementById(id + "_dlg").offsetWidth/2) + "px";
	}

	return false;
}

function LHFUNC_HideDialog(id)
{
	if(document.getElementById(id + "_bg") != null)
		document.getElementById(id + "_bg").style.display = "none";
	if(document.getElementById(id + "_dlg") != null)
		document.getElementById(id + "_dlg").style.display = "none";
}

function LHFUNC_MainTainPos()
{
	yscrolltop = 0;
	
	if (document.documentElement && document.documentElement.scrollTop)
		yscrolltop = document.documentElement.scrollTop;
	else if(document.body)
		yscrolltop = document.body.scrollTop;
	for(var key in LHVAR_ObjRelatePosArr)
	{
		if(document.getElementById(key + "_dlg") != null)
		{
			if(parseInt(document.getElementById(key + "_dlg").style.top.toLowerCase().replace("px", "")) != yscrolltop + LHVAR_ObjRelatePosArr[key])
			{
				//启动特效移动
				irelatepos = LHVAR_ObjRelatePosArr[key];

				if(irelatepos > -5 && irelatepos < 5)
					irelatepos = ((window.innerHeight || (document.documentElement.clientHeight ||document.body.clientHeight)) - document.getElementById(key + "_dlg").offsetHeight)/2;
				else if(irelatepos <= -5)
					irelatepos = (window.innerHeight || (document.documentElement.clientHeight ||document.body.clientHeight)) - document.getElementById(key + "_dlg").offsetHeight + irelatepos;

				distance = (yscrolltop + irelatepos) - parseInt(document.getElementById(key + "_dlg").style.top.toLowerCase().replace("px", ""));
				
			
				if(Math.abs(distance) > 5)
				{
					if(document.getElementById(key + "_bg") != null)
						document.getElementById(key + "_bg").style.top = (parseInt(document.getElementById(key + "_bg").style.top.toLowerCase().replace("px", "")) + distance/5) + "px";
					document.getElementById(key + "_dlg").style.top = (parseInt(document.getElementById(key + "_dlg").style.top.toLowerCase().replace("px", "")) + distance/5) + "px";
				}
				else
				{
					if(document.getElementById(key + "_bg") != null)
						document.getElementById(key + "_bg").style.top = (yscrolltop + irelatepos) + "px";
					document.getElementById(key + "_dlg").style.top = (yscrolltop + irelatepos) + "px";
				}
			}
		}
	}
	
	setTimeout(LHFUNC_MainTainPos, 100);
}

LHFUNC_MainTainPos();

function LHFUNC_RefuseTalk()
{
	xcmd = new LHFUNC_XmlDataTable();
	dr = xcmd.NewRow();
	dr["ActionVerb"] = "refuseinvite";
	dr["VisitorGUID"] = LHVAR_VisitorGUID;
	LHFUNC_GetSwfObject("LHSWF_ComSocket").SendData(xcmd.ToXml());
	LHFUNC_HideDialog("LHOBJ_INVITE_BOARD");
	return false;
}

function LHFUNC_StartTalk(fromuserguid, isaccept)
{
	fromuser = "";

	if(typeof(fromuserguid) != "undefined" && fromuserguid != null)
		fromuser = fromuserguid;

	chaturl = LHVAR_ChatWinPath + "?AccountGUID=" + LHVAR_AccountGUID + 
		"&VisitorGUID=" + LHVAR_VisitorGUID + 
		"&FromUserGUID=" + fromuser + 
		"&ChatWinStyle=" + LHVAR_ChatWinStyle;

	if(typeof(isaccept) != 'undefined' && isaccept == true)
		chaturl += "&IsAcceptInvite=1";
	else
		chaturl += "&IsAcceptInvite=0";

	LHFUNC_HideDialog("LHOBJ_INVITE_BOARD");
	window.open(chaturl, "_blank", "height=460,width=580,toolbar=no,menubar=no,scrollbar=no,status=no,resizable=yes");

	return false;
}

function LHFUNC_TryToInit()
{
	if(typeof(LHFUNC_GetSwfObject("LHSWF_ComSocket").SendData) != "undefined")
	{
		if(LHFUNC_InitBasicInfo())
		{
			LHFUNC_ConnectToServer();
			LHFUNC_SocketHeartBeat();
		}
		else
			setTimeout(LHFUNC_TryToInit, 1000);
	}
	else
		setTimeout(LHFUNC_TryToInit, 1000);
}

//navigator.appName

//alert(LHFUNC_GetSwfObject("LHSWF_ComSocket"));

LHFUNC_TryToInit();