var http;
var idControl;

function enviaQuery(id,archivo)
{
http=getXmlHttpObject();
http.open("GET",archivo,true);
idControl=id;
http.onreadystatechange=handleHttpResponse;
http.send(null);
}
function getXmlHttpObject()
{
	var xmlhttp;
	try
	{
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttp=new XMLHttpRequest();
			}
			catch(e)
			{
				xmlhttp=false;
				alert('error');
			}
		}
	}
	return xmlhttp;
}
function handleHttpResponse()
{
	if(http.readyState==1)
	   {
        document.getElementById(idControl).innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cargando...";
        //modificamos el estilo de la div, mostrando una imagen de fondo
         document.getElementById(idControl).style.background = "url('../images/loading.gif') no-repeat"; 
		}
	else
		if(http.readyState==4)
		{
			results=http.responseText;
			document.getElementById(idControl).style.background = "url('') no-repeat"; 
			document.getElementById(idControl).innerHTML=results;
		}
}
