	var statusImage = Array();
	var ss
	statusImage[0] = 'images/txt_28.gif';
	statusImage[1] = 'images/txt_35.png';
	statusImage[2] = 'images/txt_33.png';
	statusImage[3] = 'images/txt_34.png';
	statusImage[4] = 'images/txt_5.png';
	statusImage[5] = 'images/txt_6.png';

	var statusText = Array();
	statusText[0] = '在线';
	statusText[1] = '离开';
	statusText[2] = '忙碌';
	statusText[3] = '勿扰';
	statusText[4] = '隐身';
	statusText[5] = '离线';

	function getOs() {
		var OsObject = "";
		if (navigator.userAgent.indexOf("Firefox") > 0) {
			return "Firefox";
		}
		if (navigator.userAgent.indexOf("MSIE") > 0) {
			return "MSIE";
		}
		return OsObject;
	}
	function FirefoxXMLHttpRequest(){
		var xmlhttp = false;
		xmlhttp = new XMLHttpRequest();
		return xmlhttp;
	}
	function IEXMLHttpRequest(){
		var xmlhttp = false;
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e1) {
				try {
					xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.4.0");
				} catch (e2) {
					xmlhttp = false;
				}
			}
		}
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
			xmlhttp = new XMLHttpRequest();
		}
		return xmlhttp;
	}
	function GetXMLHttpRequest(){
		if (getOs() == "Firefox") {
			return FirefoxXMLHttpRequest();
		}else{
			return IEXMLHttpRequest();
		}
	}

	//function OnlineAjax(url){
	function OnlineAjax(stat){
		xmlhttp=GetXMLHttpRequest();
		xmlhttp.onreadystatechange=function(){
			if (4==xmlhttp.readyState){
				if (200==xmlhttp.status){
					//alert(xmlhttp.responseText);
					var v = xmlhttp.responseText.replace(/(^\s*)|(\s*$)/g,"");
					if (v.substring(0, yt_msghead.length) != yt_msghead)
					{
						if (mEtelNo == 'XXX')
						{
							alert(v);
						}
						return false;
					}
					eval( xmlhttp.responseText.replace(/(^\s*)|(\s*$)/g,"").substring(yt_msghead.length) );
					//document.getElementById('carorder').innerHTML="待发货定单:"+order1;
					//document.getElementById('payorder').innerHTML="待付款订单:"+order2;
					//document.getElementById('remainfee').innerHTML="可用资金余额"+fee+"元";
					xmlhttp="";
					if (getOs() == "MSIE") {
						CollectGarbage();
					}
				}
			}
		}
		//xmlhttp.open("GET",url,true);
		//xmlhttp.send(null);
		var url = 'tongxun/online.php';
		var arg = 'st='+stat+'&d='+Math.random();
		xmlhttp.open("POST",url,true);
		xmlhttp.setRequestHeader('User-Agent','XMLHTTP/1.0');
		xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=utf8");
		//httpmethod.setRequestHeader("Connection", "close");
		xmlhttp.send(arg);
	}
	function online(){
		//alert(document.getElementById('hao'+n).innerHTML);
		//var url = 'tongxun/online.php?st='+stat+'&d='+Math.random();
		if (mID == ''){
			return;
		}
		//alert(url);
		mediaGatewayLogin(mEtelNo, mPasswd, mPermitPublish);
		//OnlineAjax(url);
		OnlineAjax(stat);
	}
	function setStatus(v){
		//alert(document.getElementById('hao'+n).innerHTML);
		stat = v;
		online();
		document.getElementById('statusimg').src=statusImage[v];
		document.getElementById('statustext').innerHTML=statusText[v];
	}
	var stat='0';
	//setInterval('online()', 20000);

	var msgMemID="";
	var msgGroupID=0;
	function chatDirect(){
		if (msgMemID == "") {
			clearflash();
			new_nodis();
			return;
		}
		// 先停止闪烁
		var tmpid=msgMemID;
		clearflash();
		new_nodis();
		if (tmpid == 1001){
			mainFrame.window.groupchat(msgGroupID);
		}else if(tmpid <= 1000){
			window.open('tongxun/validate.php', 'SystemMessageWindow', 'width=466, height=310, scrollbars=no, location=no, menubar=no, status=no');
		}else{
			mainFrame.window.chat(1, tmpid);
		}
	}

	// 文字闪烁
	var speed=1000;
	var flashMsg="";
	var emptyMsg="";
	var timeoutId = 0;
	var col=0;
	var ajaxId = 0;
	var ajaxTimeOut = 0;
	function flashText()  
	{	// 显示文字
		//document.getElementById('newmsg').innerHTML=flashMsg;
		if (col == 0) {
			//document.getElementById('newmsg').style.color="#F00" ;
			document.getElementById('newmsg').innerHTML=flashMsg;
			document.title="乙太天下通 -- " + flashMsg;
			col = 1;
		}else{
			//document.getElementById('newmsg').style.color="#333" ;
			document.getElementById('newmsg').innerHTML="&nbsp;&nbsp;";
			document.title="乙太天下通";
			col = 0;
		}
		//document.getElementById('newmsg').style.display="" ;
		//timeoutId = setTimeout("flashText",speed);
	}  
	//function flashEmpty()
	//{
		// 显示空信息
		//document.getElementById('newmsg').innerHTML=emptyMsg;
	//	document.getElementById('newmsg').style.color="#333" ;
		//document.getElementById('newmsg').style.display="none" ;
	//	timeoutId = setTimeout("flashText()",speed);
	//}  
	function clearflash() {
		if (timeoutId != 0) {
			//alert(timeoutId);
			msgMemID="";
			document.title="乙太天下通";
			document.getElementById('newmsg').innerHTML="消息";
			document.getElementById('inex_nw').style.display = 'none';
			clearInterval(timeoutId);
			timeoutId = 0;
		}
	}

	//function GetNewMsgAjax(url){
	function GetNewMsgAjax(){
		xmlhttp=GetXMLHttpRequest();
		xmlhttp.onreadystatechange=function(){
			if (4==xmlhttp.readyState){
				if (200==xmlhttp.status){
					ajaxId = 0;
					ajaxTimeOut = 0;
					//var v=xmlhttp.responseText.replace(/(^\s*)|(\s*$)/g,"");
					try
					{
						eval(xmlhttp.responseText);					
					}
					catch (e)
					{
						return false;
					}
					//if (v == "no") {
					if (v == -1) {
						clearflash();
					}else{
						//if (v == '0' || v == '1' || v == '2' || v == '3' || v == '4') {
						if (v < 1000) {
							//document.getElementById('newmsg').innerHTML='系统消息';
							flashMsg="系统消息";
						}else if(v == 1001){
							flashMsg="群消息";
						}else{
							//document.getElementById('newmsg').innerHTML='好友消息';
							flashMsg="好友消息";							
						}
						if (timeoutId == 0) {
							//alert('new msg');
							msgMemID=v;
							timeoutId = setInterval('flashText()', 1000);
							document.getElementById('inex_nw').style.display = '';
							MM_controlSound('play','document.CS1212424165127','sounds/msg.wav');
						}
						//flashText();
					}
					v="";
					xmlhttp="";
					if (getOs() == "MSIE") {
						CollectGarbage();
					}
				}
			}
		}
		ajaxId = 1;
		ajaxTimeOut = 0;
		//document.getElementById('status2').innerHTML = 'C:' + ajaxId + "," + ajaxTimeOut + ',' + CurentTime();
		//xmlhttp.open("GET",url,true);
		//xmlhttp.send(null);
		var url = 'tongxun/getnewmsg.php';
		var arg = 'd='+Math.random();
		xmlhttp.open("POST",url,true);
		xmlhttp.setRequestHeader('User-Agent','XMLHTTP/1.0');
		xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=utf8");
		//httpmethod.setRequestHeader("Connection", "close");
		xmlhttp.send(arg);
	}
	function getnewmsg(){
		//alert(window.status);
		//document.getElementById('status1').innerHTML = 'g:' + ajaxId + "," + ajaxTimeOut + ',' + CurentTime();
		if (ajaxId == 1 && ajaxTimeOut < 20) {
			ajaxTimeOut++;
			return;
		}
		//alert(document.getElementById('hao'+n).innerHTML);
		if (status == '3') {
			// 如果是免打扰状态，不需要去检查消息
			clearflash();
			return;
		}

		//var url = 'tongxun/getnewmsg.php?d='+Math.random();
		if (mID == ''){
			return;
		}
		//alert(url);
		GetNewMsgAjax();
		//GetNewMsgAjax(url);
		//url = "";
		//CollectGarbage();
	}
	//setInterval('getnewmsg()', 2000);

	// 发出声音
	function MM_controlSound(x, _sndObj, sndFile) { //v3.0
	  var i, method = "", sndObj = eval(_sndObj);
	  if (sndObj != null) 
	  {
		if (navigator.appName == 'Netscape') method = "play";
		else 
		{
		  if (window.MM_WMP == null) 
		  {
			window.MM_WMP = false;
			for(i in sndObj)
			{ 
			  if (i == "ActiveMovie") 
			  {
				window.MM_WMP = true; break;
			  }
			} 
		  }
		  if (window.MM_WMP) method = "play";
		  else if (sndObj.FileName) method = "run";
		} 
	  }
	  //alert(method);
	  if (method) eval(_sndObj+"."+method+"()");
	  //else window.location = sndFile;
	}
	function changeMusic(musicFile) { //v3.0
		//alert(musicFile);
		document.VIDEO1.src=musicFile;
		document.VIDEO1.controls.playStatus=true;
		//alert(document.VIDEO1.controls.playStatus);
	}
	function CurentTime(){ 
		var now = new Date(); 
		var hh = now.getHours(); 
		var mm = now.getMinutes(); 
		var ss = now.getTime() % 60000; 
		ss = (ss - (ss % 1000)) / 1000; 
		var clock = hh+':'; 
		if (mm < 10) clock += '0'; 
		clock += mm+':'; 
		if (ss < 10) clock += '0'; 
		clock += ss; 
		return(clock); 
	}

	var yt_msghead = "[YITAICHAT]";
