
var upfun=function() 
{ 
	if (upxmlHttp.readyState==4 || upxmlHttp.readyState=="complete")
 	{ 
 		document.getElementById("update").innerHTML=upxmlHttp.responseText; 
 	} 
}

var ffun=function() 
{ 
	if (FxmlHttp.readyState==4 || FxmlHttp.readyState=="complete")
 	{ 
 		document.getElementById("frans").innerHTML=FxmlHttp.responseText; 
 	} 
}
var upstatfun=function() 
{ 
	if (upstatxmlHttp.readyState==4 || upstatxmlHttp.readyState=="complete")
 	{ 
 		//document.getElementById("testing").innerHTML=upstatxmlHttp.responseText; 
 	} 
}

var numonfun=function() 
{ 
	if (numonxmlHttp.readyState==4 || numonxmlHttp.readyState=="complete")
 	{ 
 		document.getElementById("onnum").innerHTML=numonxmlHttp.responseText; 
 	} 
}

var numofffun=function() 
{ 
	if (numoffxmlHttp.readyState==4 || numoffxmlHttp.readyState=="complete")
 	{ 
 		document.getElementById("offnum").innerHTML=numoffxmlHttp.responseText; 
 	} 
}

var offfun=function() 
{ 
	if (offxmlHttp.readyState==4 || offxmlHttp.readyState=="complete")
 	{ 
 		document.getElementById("offline").innerHTML=offxmlHttp.responseText; 
 	} 
}

var nickfun=function() 
{ 
	if (nickxmlHttp.readyState==4 || nickxmlHttp.readyState=="complete")
 	{ 
 		document.getElementById("inputf").value=nickxmlHttp.responseText; 
 	} 
}

var outfun=function() 
{ 
	if (outxmlHttp.readyState==4 || outxmlHttp.readyState=="complete")
 	{ 
 		window.location="./login.php";
		//document.getElementById("offline").innerHTML=outxmlHttp.responseText; 
 	} 
}

var nmfun=function() 
{ 
	if (nmxmlHttp.readyState==4 || nmxmlHttp.readyState=="complete")
 	{ 
		var text = nmxmlHttp.responseText;
		if(text!="")
		{
			var urls = text.split(" ");
			var i;
			for(i=1; i<urls.length; i=i+2)
			{
				//alert(urls[i]);
				poptastic(urls[i],urls[i+1]);	
			}
			//document.getElementById("newmsg").innerHTML=urls.length;
		}
	} 
}
var typesound="<embed src='type.wma' width=0 height=0 autostart=true repeat=false loop=false> </embed>";
var nudgesound="<embed src='nudge.wma' width=0 height=0 autostart=true repeat=false loop=false> </embed>";

var msgfun=function()
{ 
	if (MxmlHttp.readyState==4 || MxmlHttp.readyState=="complete")
 	{ 
		msgtext=MxmlHttp.responseText;
		if(msgtext!="")
		document.getElementById("sound").innerHTML=typesound;		
 		var scrollh = document.getElementById("msgoutput").scrollTop;
		document.getElementById("msgoutput").value+=msgtext;
		document.getElementById("msgoutput").scrollTop = scrollh;
	}
}

var nudgefun=function()
{ 
	if (nudxmlHttp.readyState==4 || nudxmlHttp.readyState=="complete")
 	{ 
		nud=nudxmlHttp.responseText;
		if(nud!="")
		{
			document.getElementById("sound").innerHTML=nudgesound;
			window.focus();
			nudge();			
		}		
 		var scrollh = document.getElementById("msgoutput").scrollTop;
		document.getElementById("msgoutput").value+=nud;		
		document.getElementById("msgoutput").scrollTop = scrollh;
	}
}

function msgout()
{ 
	if (SxmlHttp.readyState==4 || SxmlHttp.readyState=="complete")
 	{ 
 		//var scrollh = document.getElementById("msgoutput").scrollTop;
		document.getElementById("msgoutput").value+=SxmlHttp.responseText;
		document.getElementById("msginput").value=""; 
 		document.getElementById("msgoutput").scrollTop = document.getElementById("msgoutput").scrollHeight;
	} 
}
function nudgeout()
{ 
	if (SxmlHttp.readyState==4 || SxmlHttp.readyState=="complete")
 	{ 
		document.getElementById("msgoutput").value+=SxmlHttp.responseText;
 		document.getElementById("msgoutput").scrollTop = document.getElementById("msgoutput").scrollHeight;
	} 
}
function update()
{
	var upurl="update.php";
	upurl+="?sid="+Math.random();
	upxmlHttp=GetXmlHttpObject(upxmlHttp);
	upxmlHttp.onreadystatechange=upfun;
	upxmlHttp.open("GET",upurl,true)
	upxmlHttp.send(null)		
}

function updatestat(status)
{
	status++;
	var upstaturl="updatestatus.php";
	upstaturl+="?status="+status+"&sid="+Math.random();
	upstatxmlHttp=GetXmlHttpObject(upstatxmlHttp)
	upstatxmlHttp.onreadystatechange=upstatfun;
	upstatxmlHttp.open("GET",upstaturl,true)
	upstatxmlHttp.send(null)	
}

function offline()
{
	var offurl="offline.php";
	offurl+="?sid="+Math.random();
	offxmlHttp=GetXmlHttpObject(offxmlHttp);
	offxmlHttp.onreadystatechange=offfun;
	offxmlHttp.open("GET",offurl,true)
	offxmlHttp.send(null)		
}
function numoffline()
{
	var numoffurl="numoffline.php";
	numoffurl+="?sid="+Math.random();
	numoffxmlHttp=GetXmlHttpObject(numoffxmlHttp);
	numoffxmlHttp.onreadystatechange=numofffun;
	numoffxmlHttp.open("GET",numoffurl,true)
	numoffxmlHttp.send(null)		
}

function online()
{
	var furl="online.php";
	furl+="?sid="+Math.random();
	FxmlHttp=GetXmlHttpObject(FxmlHttp);
	FxmlHttp.onreadystatechange=ffun;
	FxmlHttp.open("GET",furl,true)
	FxmlHttp.send(null)		
}

function numonline()
{
	var numonurl="numonline.php";
	numonurl+="?sid="+Math.random();
	numonxmlHttp=GetXmlHttpObject(numonxmlHttp);
	numonxmlHttp.onreadystatechange=numonfun;
	numonxmlHttp.open("GET",numonurl,true)
	numonxmlHttp.send(null)		
}

function logout()
{
	var outurl="logout.php";
	outurl+="?sid="+Math.random();
	outxmlHttp=GetXmlHttpObject(outxmlHttp);
	outxmlHttp.onreadystatechange=outfun;
	outxmlHttp.open("GET",outurl,true)
	outxmlHttp.send(null)		
}

function newnick(nick)
{
	var nickurl="newnick.php";
	nickurl+="?nick="+nick+"&sid="+Math.random();
	nickxmlHttp=GetXmlHttpObject(nickxmlHttp)
	nickxmlHttp.onreadystatechange=nickfun;
	nickxmlHttp.open("GET",nickurl,true)
	nickxmlHttp.send(null)		
}

function newmsg()
{
	var nmurl="checkqueue.php";
	nmurl+="?sid="+Math.random();
	nmxmlHttp=GetXmlHttpObject(nmxmlHttp)
	nmxmlHttp.onreadystatechange=nmfun;
	nmxmlHttp.open("GET",nmurl,true)
	nmxmlHttp.send(null)		
}

function getmsg(franid)
{
	var murl="getmsg.php";
	murl+="?fran="+franid+"&sid="+Math.random();	
	MxmlHttp=GetXmlHttpObject(MxmlHttp)
	MxmlHttp.onreadystatechange=msgfun;
	MxmlHttp.open("GET",murl,true)
	MxmlHttp.send(null)
}

function getnudge(franid)
{
	var nudurl="getnudge.php";
	nudurl+="?fran="+franid+"&sid="+Math.random();	
	nudxmlHttp=GetXmlHttpObject(nudxmlHttp)
	nudxmlHttp.onreadystatechange=nudgefun;
	nudxmlHttp.open("GET",nudurl,true)
	nudxmlHttp.send(null)	
}

function sendmsg(msg, franid, type)
{
	var surl="sendmsg.php";
	surl+="?fran="+franid+"&msg="+msg+"&msgtype="+type+"&sid="+Math.random();	
	SxmlHttp=GetXmlHttpObject(SxmlHttp)
	if(type=="nudge")
	SxmlHttp.onreadystatechange=nudgeout;	
	else
	SxmlHttp.onreadystatechange=msgout;	
	SxmlHttp.open("GET",surl,true)
	SxmlHttp.send(null)		
}

function ajaxeasy(url,fun)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	xmlHttp.onreadystatechange=fun;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function ajaxeasy2(url,fun)
{
	xmlHttp2=GetXmlHttpObject();
	if (xmlHttp2==null)
  	{
  		alert ("Browser does not support HTTP Request");
  		return;
  	}
	xmlHttp2.onreadystatechange=fun;
	xmlHttp2.open("GET",url,true);
	xmlHttp2.send(null);
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

function GetXmlHttpObject2()
{
var xmlHttp2=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp2=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp2;
}
