var ajax=null;

function objetoAjax()
{
	var xmlhttp = false;
	try
	{
		xmlhttp= new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e) 
	{
		try
		{
		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (E)
		{
			xmlhttp = false;
  		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined')
	{
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function MostrarConsulta(datos,id,type)
{
	if (ajax==null)
	{
		divResultado = document.getElementById(id);

		if(type == null)
		{
			divResultado.innerHTML = "<table align='center' height='80%' width='100%'><tr><td align='center' valign='middle'><img src='lightwindow/img/loading.gif'></td></tr></table>";
		}
		else
		{
			divResultado.innerHTML = "Actualizando...";
		}

		ajax = objetoAjax();
		ajax.open("GET", datos);
		ajax.onreadystatechange=function()
		{
			if (ajax.readyState==4)
			{
				divResultado.innerHTML = rescatar_script(ajax.responseText);
				ajax = null
			}
		}
	ajax.send(null)
	}
	else
	{
		setTimeout("MostrarConsulta('"+datos+"','"+id+"',"+type+")",100);
	}
}

function updateBasket(datos,id)
{
	if (ajax==null)
	{
		divResultado = document.getElementById(id);
		divResultado.innerHTML = "<img src='lightwindow/img/loading.gif' width='20'>";

		ajax = objetoAjax();
		ajax.open("GET", datos);
		ajax.onreadystatechange=function()
		{
			if (ajax.readyState==4)
			{
				divResultado.innerHTML = ajax.responseText;
				ajax = null
			}
		}
	ajax.send(null)
	}
	else
	{
		setTimeout("updateBasket('"+datos+"','"+id+"')",100);
	}
}

function rescatar_script(texto)
{
	var p1=texto.split("<scrip",2);
	if (p1[1]) {
		var p2=p1[1].split(">",2);
		var p3=p2[1].split("</script",2)
		if (p3[0] && p3[0]!='')
			eval(p3[0]); 
			texto=p1[0]+p3[1]; 
			texto=rescatar_script(texto); 
	}
	return texto;	
}
