function ajaxinit()
{
var xmlHTTP=null;
try{xmlHTTP=new XMLHttpRequest();}
catch (e){try{xmlHTTP=new ActiveXObject("Msxml2.XMLHTTP");}
catch (e){xmlHTTP=new ActiveXObject("Microsoft.XMLHTTP");}}
return xmlHTTP;
}

function stateChanged()
{
if(xmlHTTP.readyState==4)
{

if(typ==0){
document.getElementById('chatbody').innerHTML+=xmlHTTP.responseText.substr(0,xmlHTTP.responseText.indexOf("|"));
lastchatupdate=xmlHTTP.responseText.substr(xmlHTTP.responseText.indexOf("|")+1);
if(xmlHTTP.responseText.substr(0,xmlHTTP.responseText.indexOf("|")).length>0){top.frames.chat.scrollTo(0,99999);}
}

if(typ==1){

}

if(typ==2){
document.getElementById('infoxpbar').innerHTML=xmlHTTP.responseText.substr(0,xmlHTTP.responseText.indexOf('|'));//strstr(xmlHTTP.responseText,'|',true);
document.getElementById('infohpbar').innerHTML=xmlHTTP.responseText.substr(xmlHTTP.responseText.indexOf('|')+1);
}

if(typ==3 || (typ==4 && xmlHTTP.responseText!='-1')){
var resp=xmlHTTP.responseText;
parent.frames['character'].document.getElementById('infolocation').innerHTML=resp.substr(0,resp.indexOf('|'));
resp=resp.substr(resp.indexOf('|')+1);
document.getElementById('worldcolumnone').innerHTML=resp.substr(0,resp.indexOf('|'));
resp=resp.substr(resp.indexOf('|')+1);
document.getElementById('worldcolumntwo').innerHTML=resp;
}

}
}

function ajax(type,arg1,arg2)
{
typ=type;
xmlHTTP=ajaxinit();
if(typ==0){var url="chat_update.php?t="+arg1;}
if(typ==1){var url="chat_insert.php?m="+arg1+"&r="+arg2;}
if(typ==2){var url="info_bars.php";}
if(typ==3){var url="world_update.php";}
if(typ==4){var url="move.php?x="+arg1+"&y="+arg2;}
xmlHTTP.onreadystatechange=stateChanged;
xmlHTTP.open("GET",url,true);
xmlHTTP.send(null);
}
