var xhr = false;
var outMsg = "Unable to display";
var urlFile = "whosOnline.php";
var theDivID = "putItHere";

function submitWhosOnline(file, divID) 
{
	urlFile = file;	
	theDivID = divID;
	if (window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest();
	}
	else
	{
		if (window.ActiveXObject)
		{
			try
			{
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) { xhr = false; alert("There is no support for XMLHttpRequest with this browser."); }
		}
	}
	
	if (xhr)
	{
		xhr.onreadystatechange = showContents;
		xhr.open("GET", urlFile, true);
		xhr.send(null);
	}
	else
	{
		alert("Sorry, but I couldn\'t create an XMLHttpRequest");
	}
}

function showContents()
{
	if (xhr.readyState == 4)
	{
		if (xhr.status == 200)
		{
			outMsg = xhr.responseText;
			//setTimeout("submitWhosOnline('"+urlFile+"', '"+theDivID+"')", 30000);
			var thisURL = "whosOnline.php" + "?NoCache=" + new Date().getTime();
			setTimeout("submitWhosOnline('"+thisURL+"', 'putItHere')", 30000);
		}
		else
		{
			outMsg = "There was a problem with the request " + xhr.status;
			alert("Sorry, but I couldn\'t create an XMLHttpRequest");
		}
	}
	
	if (window.document.getElementById(theDivID) != null)
	{
		window.document.getElementById(theDivID).innerHTML = outMsg;
	}
	else
	{
		alert("Sorry, but I couldn\'t create an XMLHttpRequest");
	}
}
