
function createRequestObject()
{
	this.dv = false;
	this.XMLHttp = false;

	if (window.XMLHttpRequest)
	{
		this.XMLHttp = new XMLHttpRequest();
	}
	else
		if (window.ActiveXObject)
		{
			this.XMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}

	return this;
}

function sndReq(url, dv, resp)
{

	document.getElementById(dv).innerHTML='<div style="text-align: center; margin-top: 50px;"><img src="imagenes/loading.gif" alt="Cargando..."></div>';

	http.XMLHttp.open('get', url);
	http.XMLHttp.onreadystatechange = resp;
	http.div = dv;
	http.XMLHttp.send(null);
}

function handleResponse()
{
	if(http.XMLHttp.readyState == 4)
	{
		var response = http.XMLHttp.responseText;
        
		document.getElementById(http.div).innerHTML = response;
	}
}


function goURL(url, fr)
{
	if(!http || !http.XMLHttp)
	{
		window.location=url;
		return;
	}
		
	if(fr==0)
	{
		window.open(url);
		return;
	}
	
	if(fr & 1)
		sndReq(url + '&frame=iz&ajax=true', 'contenido-izquierda', handleResponse);
		
	if(fr & 2)
		sndReq(url + '&frame=de&ajax=true', 'contenido-derecha', handleResponse);
}

function goURLid(url, id)
{
	if(!http || !http.XMLHttp)
	{
		window.location=url;
		return;
	}
		
	if(id==null)
	{
		window.open(url);
		return;
	}
	
	sndReq(url + '&ajax=true', id, handleResponse);
}

var http = new createRequestObject();
