var xmlHttp;

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 getData(query)
{
	var reqURL = "index.php";
	reqURL += "?q=" + query + "&sid=" + Math.random();
	xmlHttp = getXmlHttpObject();
	if (xmlHttp == null)
	{
		alert("Your browser does not support HTTP Requests, which are required to use this page.");
		return;
	}
	if (query == "users")
		xmlHttp.onreadystatechange = catchUsers;
	else if (query == "applications")
		xmlHttp.onreadystatechange = catchApplications;
	else
		return;
	xmlHttp.open("GET", reqURL, true);
	xmlHttp.send(null)
}

function catchApplications()
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
	{
		document.getElementById("thePane").innerHTML = xmlHttp.responseText;
	}
}

function catchUsers()
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
	{
		alert(xmlHttp.responseText);
	}
}
