<!--#include file="../inc/NoDown.asp"-->
//创建对象
function createXMLHttps()
{
    var ret = null;
    try {
        ret = new ActiveXObject('Msxml2.XMLHTTP');
    }
    catch (e) {
        try {
            ret = new ActiveXObject('Microsoft.XMLHTTP');
        }
        catch (ee) {
            ret = null;
        }
    }
    if (!ret && typeof XMLHttpRequest != 'undefined')
        ret = new XMLHttpRequest();
    return ret;
}

//时间函数
function getDataTimes()
{
	var strDate,strTime;
	strDate = new Date();
	strTime = strDate.getTime();
	return strTime;
}

//获取信息
function GameAjax(URL,DIVID,Types) {
if (Types==3) {$(DIVID).innerHTML="<div style='margin-top:50px;margin-bottom:50px;text-align:center'><img src='images/loading.gif'></div>"}
if (Types==2) {URL=URL+"&WL="+XH_WayList+"&M="+XH_OnMap+"&R="+XH_Room+"&L="+XH_Left+"&T="+XH_Top+"&";XH_WayList="";Old_FX=8}
if (Types==4) {URL=URL+"&L="+XH_Left+"&T="+XH_Top+"&"}
URL=URL+"U="+XH_Uid+"&N="+XH_Name+"&Tm="+getDataTimes();
var xmlhttp = createXMLHttps();
xmlhttp.open("GET",URL,true);
xmlhttp.onreadystatechange = function() {
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
	var AjaxHtml=xmlhttp.responseText;
	if (Types==1) {
		if (AjaxHtml=='ERROR') {
		AjaxClear();
		$(DIVID).innerHTML = "<font color=#00FF00>[系统信息]：</font><font color=orange>服务器繁忙或登陆多号引起连接失败,请尝试重新登陆系统！</font>";
		}else{
//当前秒数
		var AllMsgList=AjaxHtml;
		var Talk_List=AllMsgList.split("|")[1];
		var Talk_timer=AllMsgList.split("|")[2];
		var Talk_ListNum=0;
		var MsgHtml="";
//处理聊天
	if (Talk_List!=="") {
		Talk_List.replace(/(\$)/g,function(){Talk_ListNum++});
		Talk_ListNum=Talk_ListNum+1;
		for(i=1;i<Talk_ListNum;i++) {
		var TalkMsg=Talk_List.split("$")[i];
		if (TalkMsg.split("_")[1]=="face") {
		MsgHtml=MsgHtml+"<br><font color=#FFF000>[聊天表情]：</font><font color=#"+TalkMsg.split("_")[2]+">/face:"+TalkMsg.split("_")[3]+"　("+TalkMsg.split("_")[0]+")</font>";
		}else if(TalkMsg.split("_")[1]=="mf") {
		MsgHtml=MsgHtml+"<br><font color=#FFC8A3>[魔法表情]：</font><font color=#"+TalkMsg.split("_")[2]+">/mf:"+TalkMsg.split("_")[3]+"　("+TalkMsg.split("_")[0]+")</font>";
		}else{
		MsgHtml=MsgHtml+"<br><font color=#"+TalkMsg.split("_")[1]+">["+TalkMsg.split("_")[0]+"]：</font><font color=#"+TalkMsg.split("_")[2]+">"+TalkMsg.split("_")[3]+"</font>";
		}
		var TalkDiv="talk_100"+TalkMsg.split("_")[5]
		if ($(TalkDiv)) {
			if (Talk_timer-TalkMsg.split("_")[4]<8) {
			$(TalkDiv).style.display='block';
			if (TalkMsg.split("_")[1]=="face") {
			$(TalkDiv).innerHTML="<img src='images/face/"+TalkMsg.split("_")[3]+".gif' style='width:50px;height:50px;margin-top:50px' class=click>"
			}else if(TalkMsg.split("_")[1]=="mf") {
			$(TalkDiv).innerHTML='<object class=click classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="200" height="200"><param name="movie" value="images/mf/'+TalkMsg.split("_")[3]+'.swf" /><param name="quality" value="high" /><param name="menu" value="false" /><param name="wmode" value="transparent" /><embed src="images/mf/'+TalkMsg.split("_")[3]+'.swf" width="200" height="200" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false" wmode="transparent"></embed></object>'
			}else{
			$(TalkDiv).innerHTML="<img src='images/msgtalk.gif' class=click><span class='newtalk_desc' onclick=GameWin('YouManage','"+TalkMsg.split("_")[0]+"','查看对方信息请先登陆！',350,80,150,200,2)><font color=red>"+TalkMsg.split("_")[0]+"</font>："+TalkMsg.split("_")[3]+"</span>";
			}
			}else{
			$(TalkDiv).style.display='none';
			$(TalkDiv).innerHTML="";
			}
	}
		}
		$(DIVID).innerHTML = MsgHtml;
		$("XH_MsgListBg").scrollTop=200;
	}
		}
	}
	else if (Types==2) {OnlineList=AjaxHtml;LoadOnline()}
	else if (Types==3) {$(DIVID).innerHTML = AjaxHtml}
	else if (Types==4) {}
	else if (Types==5) {
		GameWin(AjaxHtml,AjaxHtml,'Talk.html?'+AjaxHtml,460,427,8,250,5);
		$("XH_LoadJSNow").style.display='none';
		$("XH_LoadJSNow").innerHTML='<span id="XH_LoadJSText">正在缓冲...</span>';
		}
	}

}
xmlhttp.send(null);
}

var MStimer,OLtimer;
//定时加载
function AjaxInfo() {
GameAjax('ShowMess.asp?action=update&','XH_MsgList',1);
MStimer = window.setInterval("GameAjax('ShowMess.asp?action=update&','XH_MsgList',1)",3000);
GameAjax("Online.asp?i=0","XH_OnlineList",2);
OLtimer = window.setInterval("GameAjax('Online.asp?i=0','XH_OnlineList',2)",4000);
}

function AjaxClear() {
clearInterval(OLtimer);clearInterval(MStimer);
}
