var xmlHttp;
var fncResponse;
var tmout;

function ajax(url, resp)
{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
  	fncResponse = resp;
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function ajaxPost(url, parameters, resp)
{ 
	//var poststr = "act=aqr&tid="+encodeURI(txtID)+"&tnm="+encodeURI(txtName)+"&tqs="+encodeURI(txtQuestion);
	//ajaxPost("/tools/do.ajax",poststr, sendQuestionResponse);
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
  	fncResponse = resp;
	xmlHttp.onreadystatechange = stateChanged;

 	xmlHttp.open("POST", url, true);
 	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 	xmlHttp.setRequestHeader("Content-length", parameters.length);
 	xmlHttp.setRequestHeader("Connection", "close");
 	xmlHttp.send(parameters);
}

function simpleajax(url)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	xmlHttp.open('GET',url,0);
	xmlHttp.send(null);
	return (xmlHttp.responseText);
}

function stateChanged() 
{ 
	
	if (xmlHttp.readyState==4)
	{ 
		if (xmlHttp)
		{
			try 
			{
				if (xmlHttp.status == 200)
					fncResponse(xmlHttp.responseText);
				else
					fncResponse("");
					
				//alert(xmlHttp.responseText);
			}
			catch (e){}
		}
	}
}

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;
}