var IE=!!(window.attachEvent && !window.opera);
var htHtp =  function() {
	if(!arguments.callee.single){
		var fns = [
			function () { return new XMLHttpRequest(); },
			function () { return new ActiveXObject('Msxml2.XMLHTTP'); },
			function () { return new ActiveXObject('Microsoft.XMLHTTP'); },
		];
		for (var i = 0,n=fns.length; i < n; i++) {
			try {
				fns[i]();
				arguments.callee.single = fns[i];
				break;
			}catch(e){}
		}
		return arguments.callee.single();
	}
	else{
		return arguments.callee.single();
	}
}

var g={
	oHttpGuide:htHtp(),
	oHttpClient:htHtp(),
	oHttpReName:htHtp(),
	oHttpUnload:htHtp(),
	oHttpSend:htHtp(),
	oHttpGetMessage:htHtp(),
	oHttpGetClient:htHtp(),
	oHttpGetClientInfo:htHtp()
}
var htBlnCurPageFocus=true;
var blnWindowFocus=true;
function htClientInfo(b)	//获得客户信息
	{
		//<clientInfo>
		//	<client>
		//		<name></name>
		//		<ip></ip>
		//		<position></position>
		//		<clientID></clientID>
		//	</client>
		//	<client>
		//		<name></name>
		//		<ip></ip>
		//		<position></position>
		//		<clientID></clientID>
		//	</client>
		//</clientInfo>

		var oTable=$('tableClient'),arrClient=new Array(),arrDel=new Array();

		if(b.hasChildNodes()){
			for (var i=0; i<b.childNodes.length; i++) {
				var oClient=b.childNodes[i];
				var oName=oClient.childNodes[0];
				var oIP=oClient.childNodes[1];
				var oPosition=oClient.childNodes[2];
				var oClientID=oClient.childNodes[3];

				//将数据加入到arrClient中
				var arrName=new Array(3);
				arrName[0]=oName.firstChild.nodeValue;
				arrName[1]=oIP.firstChild.nodeValue;
				arrName[2]=oPosition.hasChildNodes() ? oPosition.firstChild.nodeValue : '';
				arrName[3]=oClientID.hasChildNodes() ? oClientID.firstChild.nodeValue : '';
				arrClient.push(arrName);
			}
		}

		//debugger;

		//开始写入或修改table中的内容
		deal:{
			//如果b没有子对象，则将oTable的子对象清空，然后跳出deal
			if(b.hasChildNodes()==false){
				while (oTable.rows.length>1) {
					oTable.rows[oTable.rows.length-1].parentNode.removeChild(oTable.rows[oTable.rows.length-1]);
				}
				break deal;
			}

			//如果b有子对象，则删掉oTable中有的，arrClient没有的记录
			var colRows=oTable.rows;
			if(colRows.length>1){
				for (var i=1; i<colRows.length; i++) {
					var oRow=colRows[i];
					var oCell=oRow.cells[0];
					var bln=false;
					for (var j=0; j<arrClient.length; j++) {
						var clientName=arrClient[j][0];
						if(clientName==oCell.firstChild.nodeValue){bln=true;break;}
					}
					if(bln==false){
						arrDel.push(oRow);
					}
				}
				if(arrDel.length>0){
					for (var i=0; i<arrDel.length; i++) {
						var oRow=arrDel[i];
						oRow.parentNode.removeChild(oRow);
					}
				}
			}

			//将arrClient中的内容添加到oTable中
			if(arrClient.length>0){

				for (var i=0; i<arrClient.length; i++) {
					var arrName=arrClient[i];
					var clientName=arrName[0];
					var ip=arrName[1];
					var position=arrName[2];
					var clientID=arrName[3];
					var bln=false;
					for (var j=1; j<oTable.rows.length; j++) {
						var oRow=oTable.rows[j];
						var oCell=oRow.cells[0];
						if(oCell.firstChild.nodeValue==clientName){
							//如果在oTable中找到和arrClient匹配的记录，则更新记录

							var oTxt=document.createTextNode(ip);
							var curCell=$(oRow.cells[1]);
							curCell.removeAllChildren();
							curCell.appendChild(oTxt);
							var oTxt=document.createTextNode(position);
							var curCell=$(oRow.cells[2]);
							curCell.removeAllChildren();
							curCell.appendChild(oTxt);

							var curCell=$(oRow.cells[3]);
							curCell.removeAllChildren();
							oTxt=document.createTextNode(clientID);
							if(clientID.length==0){
								curCell.appendChild(oTxt);
							}
							else{
								var oLink=document.createElement('a');
								oLink.setAttribute('href',clientID,0);
								oLink.setAttribute('target','_blank',0);
								oLink.appendChild(oTxt);
								curCell.appendChild(oLink);
							}

							bln=true;
							break;
						}
					}
					//如果没有在oTable中找到记录，则添加一条记录
					if(bln==false){
						var oRow=oTable.insertRow();
						var oCell=oRow.insertCell();
						var oTxt=document.createTextNode(clientName);
						oCell.appendChild(oTxt);

						oCell=oRow.insertCell();
						oTxt=document.createTextNode(ip);
						oCell.appendChild(oTxt);

						oCell=oRow.insertCell();
						oTxt=document.createTextNode(position);
						oCell.appendChild(oTxt);

						oCell=oRow.insertCell();
						oTxt=document.createTextNode(clientID);
						if(clientID.length==0){
							oCell.appendChild(oTxt);
						}
						else{
							var oLink=document.createElement('a');
							oLink.setAttribute('href',clientID,0);
							oLink.setAttribute('target','_blank',0);
							oLink.appendChild(oTxt);
							oCell.appendChild(oLink);
						}


					}
				}
			}
		}
		//setTimeout('htGetRemote("",8)',6000);
		setTimeout(function ()
			{
				htGetRemote(g.oHttpGetClientInfo,'',8);
			},6000);
	}

function htAddMessage(pName,toName,sayTime,blnPrivate,c)	//显示信息
	{
		var selfName=$('ihName').value,p,oAPName,oAToName,oText,strTime;
		//var objContent=(selfName==pName || selfName==toName || toName.length==0) ? $('ddPrivateContent') : $('ddContent');
		var objContent=(selfName==pName || selfName==toName || toName.length==0) ? $('ddPrivateContent') : null;
		if(objContent==null){return;}

		p=document.createElement('p');

		//插入时间
		if(sayTime.length==0){
			var objTime=new Date(remoteTime(disTime));
		}
		else {
			var objTime=new Date(sayTime);
		}
		strTime=objTime.getHours().toString().fm(0,Array('0',2))+':'+objTime.getMinutes().toString().fm(0,Array('0',2))+':'+objTime.getSeconds().toString().fm(0,Array('0',2));
		oText=document.createTextNode(strTime+' ');
		p.insertBefore(oText,null);

		//插入发送人
		oAPName=document.createElement('a');
		oText=document.createTextNode(pName);
		oAPName.insertBefore(oText,null);
		IE ? oAPName.attachEvent('onclick',function(){htSelectFocus(oAPName.firstChild.nodeValue);return false;}) : oAPName.addEventListener('click',function(){htSelectFocus(oAPName.firstChild.nodeValue);return false;},true);
		p.insertBefore(oAPName,null);

		//插入字符串
		oText=document.createTextNode(' '+((toName.length>0) ? ' to ' : ''));
		p.insertBefore(oText,null);

		//插入接收人
		if(toName.length>0){
			oAToName=document.createElement('a');
			oText=document.createTextNode(toName);
			oAToName.insertBefore(oText,null);
			IE ? oAToName.attachEvent('onclick',function(){htSelectFocus(oAToName.firstChild.nodeValue);return false;}) : oAToName.addEventListener('click',function(){htSelectFocus(oAToName.firstChild.nodeValue);return false;},true);
			p.insertBefore(oAToName,null);
		}

		//插入字符串
		//oText=document.createTextNode(' 说'+(blnPrivate=='0' ? '： ' : '（不公开）： ')+c);
		//p.insertBefore(oText,null);
		oText=document.createTextNode(' 说'+(blnPrivate=='0' ? '： ' : '（不公开）： '));
		p.insertBefore(oText,null);

		//插入内容
		insertStringUrl(p,c);
		//oText=document.createTextNode(c);
		//p.insertBefore(oText,null);
		//更新c，如果有超级链接，则转换为超级链接格式
		//var re=/(https?:\/\/[0-9a-z.?#/_\-&=%+]+)/ig;
		//var cc=c.replace(re,'<a href="$1" target="_blank">$1</a>');
		//p.innerHTML=p.innerHTML+cc;

		objContent.insertBefore(p,null);
		objContent.scrollTop=objContent.scrollHeight;
		if(selfName!=pName){
			htFlashTitle(0,pName);
		}
	}

function htGetMessage(b)	//获得信息
	{
		//信息格式
			//		'<root>
			//			'<content>
			//				'<c>
			//					'<pName>张三</pName>
			//					'<toName>王五</toName>
			//					'<time>2008-5-21 10:08:08</time>
			//					'<blnPrivate>0</blnPrivate>
			//					'<message>您有什么问题吗？</message>
			//				'</c>
			//			'</content>
			//			'<lastNumber>8</lastNumber>
			//		'</root>
		var a;
		deal:{
			if(b.hasChildNodes()==false){break deal;}
			if(b.childNodes.length!=2){break deal;}
			$('ihMessageNumber').value=b.lastChild.firstChild.nodeValue;
			if(b.firstChild.hasChildNodes()==false){break deal;}

			//将数据从XML节点中提取出来，调用函数：htAddMessage，将信息显示出来
			for (var i=0; i<b.firstChild.childNodes.length; i++) {
				a=b.firstChild.childNodes[i];
				htAddMessage(a.childNodes[0].firstChild.nodeValue,a.childNodes[1].hasChildNodes() ? a.childNodes[1].firstChild.nodeValue : '',a.childNodes[2].firstChild.nodeValue,a.childNodes[3].firstChild.nodeValue,a.childNodes[4].firstChild.nodeValue);
			}
		}

		//setTimeout('htGetRemote("'+$('ihMessageNumber').value+'",6)',500);
		setTimeout(function ()
			{
				htGetRemote(g.oHttpGetMessage,$('ihMessageNumber').value,6);
			},500);

	}

function htSendMessage()	//发送信息
	{
		if(g.oHttpSend.readyState!=0 && g.oHttpSend.readyState!=4){alert('不好意思，网速太慢，上一句还在发送过程中，请稍等，谢谢。');return;}
		var a=$('itContent'),b=$('select'),objContent,p,txt;
		a.value=a.value.trim();
		if(a.value.length==0){alert('请填写内容，谢谢。');a.focus();return false;}
		//htGetRemote(Array(a.value,b[b.selectedIndex].text,0),5);
		htGetRemote(g.oHttpSend,Array(a.value,b[b.selectedIndex].text,0),5);
		//htAddMessage($('itName').value,b.selectedIndex>0?b[b.selectedIndex].text:'','',d.checked?1:0,a.value);
		a.value='';
		a.focus();
	}

function htClientNameAdded(b)	//添加了新的客户
	{
		if(b.hasChildNodes()==false){	//如果添加不成功
			alert('请刷新页面，谢谢。');
			return;
		}
		var clientName=b.firstChild.nodeValue;
		$('ihName').value=$('itName').value=clientName;
		htGetRemote(g.oHttpGuide,'',1);	//获得guide名单
		htGetRemote(g.oHttpClient,'',2);	//获得客户名单
		$('divMask').style.visibility='hidden';
		htGetRemote(g.oHttpGetMessage,$('ihMessageNumber').value,6);

		if(htBlnGuide){htGetRemote(g.oHttpGetClientInfo,'',8);}
	}

function htClientNameUpdate(d,n)	//更新客户昵称
	{
		var a=$('itName'),b=$('ihName'),button=$('buttonChangeName');
		switch (n) {
			case 0:		//提交到服务器端之前进行处理
				a.value=a.value.trim();
				if(a.value.length<2){alert('名称最少为2个字符，谢谢。');a.value=b.value;a.focus();return false;}
				htGetRemote(g.oHttpReName,a.value,3);
				a.disabled=true;
				button.disabled=true;
				break;
			case 1:		//从服务器返回信息后，进行处理，此时d为XML对象
				a.disabled=false;
				button.disabled=false;
				if(d.firstChild.nodeValue=='1'){
					b.value=a.value;
					alert('您的名称成功更改，谢谢。');
					$('itContent').focus();
				}
				else{
					alert('您填写的名称已经被其他人使用，请另外填写一个，谢谢。');
					a.value=b.value;
					a.focus();
				}
				break;
		}
	}

function htListUpdate(b,c)			//更新名单，b是XML对象，其内容类似<guide><name>aaa</name><name>bbb</name></guide>
	{
		var a=$(c),d,str,aArray,strA,curHour=new Date().getHours();

		deal:{
			//如果b没有子对象，则清空a对象的子对象，然后break;
			if(b.hasChildNodes()==false){
				while (a.hasChildNodes()) {
					a.removeChild(a.firstChild);
				}
				if(c!='ddClient'){
					if(htBlnGuide){
						self.location.reload();
						return false;
					}
					var oElement=document.createElement('p');
					oElement.innerHTML='导购'+(curHour>9 && curHour<17 ? '忙线中' : '已下班')+'<a href="/help/question.asp#postQuestion" target="_blank">请点此留言</a>谢谢';
					oElement.style.color='#CCC';
					a.appendChild(oElement);
				}
				else{
					//如果c为ddClient，如果是客户端，则需要刷新本页面
					if(htBlnGuide==false){self.location.reload();return false;}
					var oElement=document.createElement('p');
					oElement.innerHTML='无客户';
					oElement.style.color='#CCC';
					a.appendChild(oElement);
				}
				break deal;
			}

			//将b对象中的子对象结合成字符串，然后循环a对象，如果有b对象中没有的，则在a中删除该子对象
			if(a.hasChildNodes()){
				str='';
				aArray=new Array();
				for (var i=0; i<b.childNodes.length; i++) {
					str=str+b.childNodes[i].firstChild.nodeValue+'"';
				}
				for (var i=0; i<a.childNodes.length; i++) {
					strA=a.childNodes[i].firstChild.nodeValue;
					if(str.test(Array(a.childNodes[i].firstChild.nodeValue,'"'),0)==false){aArray.push(a.childNodes[i]);}
				}
				if(aArray.length>0){
					for (var i=0; i<aArray.length; i++) {
						a.removeChild(aArray[i]);
					}
				}
			}

			//如果a对象没有子对象，则将b对象的子对象添加到a对象中，然后退出
			if(a.hasChildNodes()==false){
				for(var i=0; i<b.childNodes.length; i++){
					insert(Array(a,b.childNodes[i].firstChild.nodeValue),0);
				}
				break deal;
			}

			//其次将a对象中的子对象结合成字符串，然后循环b对象，如果有a对象中没有的，则在a对象中添加该子对象
			str='';
			for (var i=0; i<a.childNodes.length; i++) {
				str=str+a.childNodes[i].firstChild.nodeValue+'"';
			}
			for (var i=0; i<b.childNodes.length; i++) {
				strA=b.childNodes[i].firstChild.nodeValue;
				if(str.test(Array(strA,'"'),0)==false){insert(Array(a,strA),0);}
			}

		}

		htSelectTo();

		//循环读取客户名单
		//if(c=='ddGuide'){setTimeout('htGetRemote("",1)',5000);}
		if(c=='ddGuide'){setTimeout(function ()
			{
				htGetRemote(g.oHttpGuide,'',1);
			},5000);}
		//if(c=='ddClient'){setTimeout('htGetRemote("",2)',5000);}
		if(c=='ddClient'){setTimeout(function ()
			{
				htGetRemote(g.oHttpClient,'',2);
			},5000);}
	}

function htSelectTo()			//根据ddGuide和ddClient中的内容更新Select的内容
	{
		var oGuide=$($('ddGuide'),15),oClient=$($('ddClient'),15),oSelect=$('select'),strGuide='',strClient='',c='',listArray,selfName='';
		var colOptions=$(oSelect,15);

		//循环读取导购名单
		if(oGuide.length>0){
			for (var i=0; i<oGuide.length; i++) {
				strGuide=strGuide+htUpdateStr(oGuide[i].firstChild.nodeValue)+'\n';
			}
		}

		//循环读取客户名单
		if(oClient.length>0){
			for (var i=0; i<oClient.length; i++) {
					strClient=strClient+htUpdateStr(oClient[i].firstChild.nodeValue)+'\n';
			}
		}

		str=htBlnGuide ? strClient : strGuide;

		if(str.length>0){
			str=str.substring(0,str.length-1);
		}
		listArray=str.split('\n');

		if(colOptions.length>=1){
			//如果options中没有listArray中的内容，则从oSelect中删除
			for (var i=0; i<colOptions.length; i++) {
				var txtOption=colOptions[i].firstChild.nodeValue;
				var bln=false;
				for (var j=0; j<listArray.length; j++) {
					if(txtOption==listArray[j]){bln=true;break;}
				}
				if(bln==false){oSelect.removeChild(colOptions[i]);}
			}
		}

		if(listArray.length>=1){
			//将listArray中有的名称，但colOptions中没有的名称，加入到oSelect中
			for (var i=0; i<listArray.length; i++) {
				var bln=false;
				for (var j=0; j<colOptions.length; j++) {
					var txtOption=colOptions[j].firstChild.nodeValue;
					if(txtOption==listArray[i]){bln=true;break;}
				}
				if(bln==false){
					var oOption=document.createElement('option');
					var oTxt=document.createTextNode(listArray[i]);
					oOption.appendChild(oTxt);
					oSelect.appendChild(oOption);
				}
			}
		}
	}

function htSelectFocus(c)			//点击相应的客户昵称后，在下拉菜单中显示出来
	{
		//debugger;
		var a=$($('select'),15),bln=false;
		var j=a[0].parentNode.selectedIndex;
		for (var i=0; i<a.length; i++) {
			if(a[i].firstChild.nodeValue==c){a[i].selected=true;bln=true;if(i!=j){a[0].parentNode.fireEvent('onchange');};break;}
		}
		if(bln==false){a[0].selected=true;if(j!=0){a[0].parentNode.fireEvent('onchange');}}
		$('itContent').focus();
	}

function htClear()					//清空谈话内容
	{
		var a=$('ddContent');
		if(a.hasChildNodes()){
			while(a.hasChildNodes()){
				a.removeChild(a.firstChild);
			}
		}
		a=$('ddPrivateContent');
		if(a.hasChildNodes()){
			while(a.hasChildNodes()){
				a.removeChild(a.firstChild);
			}
		}
	}

function htOnLoad()		//打开窗口后需要做的一些事情
	{
		//重新更改窗口大小
		self.resizeTo(812,510);
		//document.title=document.documentElement.scrollHeight+'|'+document.documentElement.clientHeight;
	}

function htReplyModel(oSelect)	//快捷回复
	{
		oSelect=$(oSelect);
		var numIndex=oSelect.selectedIndex;
		if(numIndex==0){return;}
		var oInput=$('itContent');
		oInput.value=oSelect[numIndex].value;
		oInput.focus();
	}

//通用函数
function htGetRemote(oHtp,str,n)
	{
		if(typeof(str)=='object'){
			oHtp.open('get','remote.asp?content='+encodeURIComponent(str[0])+'&target='+encodeURIComponent(str[1])+'&blnPrivate='+encodeURIComponent(str[2])+'&n='+n,true);
		}
		else{
			oHtp.open('get','remote.asp?str='+encodeURIComponent(str)+'&n='+n,true);
		}
		if(n!=4 && n!=5){
			oHtp.onreadystatechange=function () {
				if (oHtp.readyState==4){
					if(oHtp.status==200){
						 htDealRemote(oHtp);
					}
				  }
			}
		}
		oHtp.send(null);
	}

function htDealRemote(a)
	{
		var b=a.responseXML.firstChild;
		switch(b.nodeName){
			case 'guide':		//更新Guide名单
				htListUpdate(b,'ddGuide');
				break;
			case 'client':		//更新client名单
				htListUpdate(b,'ddClient');
				break;
			case 'clientChangeName':
				htClientNameUpdate(b,1);
				break;
			case 'root':		//获得消息
				htGetMessage(b);
				break;
			case 'addedName':	//添加了新的客户
				htClientNameAdded(b);
				break;
			case 'clientInfo':	//返回客户信息
				htClientInfo(b);
				break;
		}
	}

//将字符串中的特殊符号更换为HTML表达式
function htUpdateStr(c)
	{
		var str;
		str=c;
		//将\n更换为空字符串;
		str=str.replace('\n','');
		return str;
	}

function htFlashTitle(runCode,c)		//闪烁Title
	{
		switch (runCode) {
			case 0:			//闪烁c的内容
				//document.title=c;
				//document.focus ? document.focus() : window.focus();
				//var oElement=$('cbSound');
				//var oSound=$('bsSound');
				//if(oElement.checked){oSound.setAttribute('src','/common/images/site/FLOWERE3.MID',0);}
				//if(document.title.toString()!='有新消息'){document.title='有新消息'}else{document.title=c}
				//if(htBlnCurPageFocus==false){setTimeout('htFlashTitle(0,"'+c+'")',500);}
				//self.focus();

				//var src='/common/images/site/flowere3.mid';
				var src='/common/images/site/msg.wav';

				if(blnWindowFocus==false){self.focus();}

				//提示音
				var oIcbBGSound=$('icbBgSound');
				if(oIcbBGSound){
					if(oIcbBGSound.checked){
						//debugger;
						var oSound=$('bsSound');
						if(oSound){
							//document.body.removeChild(oSound);
							oSound.setAttribute('src',src,0);
						}
						else {
							oSound=document.createElement('bgSound');
							oSound=$(oSound);
							oSound.setAttribute('id','bsSound',0);
							oSound.setAttribute('src',src,0);
							oSound.setAttribute('loop','0',0);
							document.body.appendChild(oSound);
						}
					}
				}
			break;
			case 1:			//停止提示音c的内容
				//document.title=c;
				//document.focus ? document.focus() : window.focus();
				//var oSound=$('bsSound');
				//oSound.setAttribute('src',void(0),0);
				//if(document.title.toString()!='有新消息'){document.title='有新消息'}else{document.title=c}
				//if(htBlnCurPageFocus==false){setTimeout('htFlashTitle(0,"'+c+'")',500);}
			break;
			default:

		}
	}

function htStopSound()	//停止背景音乐
	{
		//debugger;
		var oSound=$('bsSound');
		if(oSound){
			oSound.setAttribute('src',void(0),0);
		}
	}

//将字符串生成文本对象后插入到父对象中，如果字符串中有url，则生成url对象后依序插入父对象中
function insertStringUrl(oParent,str)
	{

		//先暂时处理一下，如果不是IE浏览器
		//if(!IE){
			//var oText=document.createTextNode(str);
			//oParent.appendChild(oText);
			//return;
		//}

		var re=/https?\:\/\/[0-9a-z\.\?\#\/_\-&=%\+\:]+/i;
		var c=str;
		var arr;
		var c1;
		var oText;
		var oElement;
		var i=0;
		while (c.length>0) {
			i=i+1;
			if(i>1000){
				alert(i);
				break;
			}
			arr=c.match(re);
			if(arr!=null){
				c1=c.substring(0,arr.index);
				if(c1.length>0){
					oText=document.createTextNode(c1);
					oParent.appendChild(oText);
				}
				oText=document.createTextNode(arr[0]);
				oElement=document.createElement('a');
				oElement.appendChild(oText);
				oElement.setAttribute('href',arr[0],0);
				oElement.setAttribute('target','_blank',0);
				oParent.appendChild(oElement);
				//c=c.substring(arr.lastIndex,c.length);
				c=c.substring(arr.index+arr[0].length,c.length);
			}
			else{
				oText=document.createTextNode(c);
				oParent.appendChild(oText);
				c='';
			}
		}
	}

//初始化时添加新客户
IE ? window.attachEvent('onload',function(){if(self.htOnLoad){htOnLoad();}htGetRemote(g.oHttpGetClient,'',7);}) : window.addEventListener("load",function(){if(self.htOnLoad){htOnLoad();}htGetRemote(g.oHttpGetClient,'',7);},true);
//退出后删除记录
IE ? window.attachEvent('onunload',function(){htGetRemote(g.oHttpUnload,'',4);}) : window.addEventListener("unload",function(){htGetRemote(g.oHttpUnload,'',4);},true);
//
//IE ? window.attachEvent('onfocus',function(){blnWindowFocus=true;}) : window.addEventListener("focus",function(){blnWindowFocus=true},true);
//IE ? window.attachEvent('onblur',function(){blnWindowFocus=false;}) : window.addEventListener("focus",function(){blnWindowFocus=false},true);
document.onfocusin = function() {
	blnWindowFocus=true;
}
document.onfocusout = function() {
	blnWindowFocus=false;
}
//focus后更改htBlnCurPageFocus的内容
//IE ? window.attachEvent('onactive',function(){htBlnCurPageFocus=true;}) : window.addEventListener("active",function(){htBlnCurPageFocus=true;},true);
//blure后更改htBlnCurPageFocus的内容
//IE ? window.attachEvent('ondeactive',function(){htBlnCurPageFocus=false;}) : window.addEventListener("deactive",function(){htBlnCurPageFocus=false;},true);
