var xmlHttp = null;

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

function fetchData(targetId, query)
{
	if(xmlHttp == null) xmlHttp = getXmlHttp();
	if(xmlHttp == null) return;
	
	var targetObj = document.getElementById(targetId);
	if (targetObj == null) return;
	
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{
			targetObj.innerHTML = xmlHttp.responseText;
		}
	};
	xmlHttp.open("GET", "getData.php?q=" + query, true);
	xmlHttp.send(null);
}	

