var rst=new Array(2000);
var ix;
var period=2000;
var ajax_time;
function ajax_process(xmlhttp)
	{
	if(xmlhttp.readyState==4)
  			{
  			if (xmlhttp.status==200)
  				{
  				//alert(xmlhttp.responseText);
  				rst=xmlhttp.responseText.split("%");
  				for (ix=0; ix<rst.length;ix++)
  					{
  					try {eval(rst[ix]+"();");} catch(err) {error("eval["+ix+"] :: "+err+" :: '"+xmlhttp.responseText+"'");}
  					}
  				//try {document.getElementById("test").innerHTML+=" :{"+xmlhttp.responseText+"}: ";} catch(err) {}
  				ajax_time=setTimeout("ajax_get('','');",period);
		  		} 		
  			else {error("Ajax request error :: "+xmlhttp.status);}
  			}
	}

function ajax_get(cmd,pm)
	{
	//try {document.getElementById("test").innerHTML+=" |"+cmd+";"+pm+"| ";} catch(err) {}
	xmlhttp=new XMLHttpRequest();
	xmlhttp.onreadystatechange=function() {ajax_process(xmlhttp);}
	xmlhttp.open("GET","system.php?onm="+onlinenm+"&exe="+cmd+pm,true);
	xmlhttp.send(null);
	}


function ajax_post(url,data,cmd)
	{
	xmlhttp=new XMLHttpRequest();
	xmlhttp.onreadystatechange=function() {ajax_process(xmlhttp,cmd);}
	xmlhttp.open("POST",url+"&exe="+cmd,true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", data.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(data);//document.getElementById('newsfeed').innerHTML=xmlhttp.responseText;
	}
function ok() {/*error(xmlhttp.responseText);*/}
function ajax_syn(cmd,pm)
	{
	clearTimeout(ajax_time);
	ajax_get(cmd,pm);
	}
function ajax_post_msg()
	{
	setCookie("name",document.getElementById("name").value,365);
	clearTimeout(ajax_time);
	ajax_post("system.php?onm="+onlinenm,"c="+(document.getElementById("txarea").value),"send");
	document.getElementById("txarea").value="";
	}
	
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

	
var whonm = (getCookie("name")=="") ? "guest"+(Math.floor(Math.random()*89)+10): getCookie("name");
document.getElementById("name").value=whonm;onlinenm=whonm;
setCookie("name",document.getElementById("name").value,365);
ajax_time=setTimeout("ajax_get('','');",0);
setTimeout("checkload();",4000);
