//carga el contenido de pageurl y lo pone en divId
function load(pageurl, divId, loader, callback)
{
	var page_request = false;
	var bustcacheparameter="";
	if (window.XMLHttpRequest) // if Mozilla, IE7, Safari etc
		page_request = new XMLHttpRequest();
	else if (window.ActiveXObject){ // if IE6 or below
		try {
		page_request = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e){
			try{
			page_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){}
		}
	}
	else
		return false;
	
	var ajaxfriendlyurl=pageurl.replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/") ;
	page_request.onreadystatechange=function(){loadpage(page_request, pageurl, divId, loader, callback);}

	page_request.open('GET', ajaxfriendlyurl+bustcacheparameter, true);
	page_request.send(null);
}

function loadpage_show()
{
	var loading = document.getElementById('loading');
	if (!loading)
	{
		loading = document.createElement('div');
		loading.id = 'loading';
		loading.innerHTML = '<font style="font-family:verdana; font-size:12px; color:white;">Procesando</' + 'font>';
		loading.style.position = 'absolute';
		loading.style.top = '4px';
		loading.style.right = '4px';
		loading.style.backgroundColor = 'red';
		loading.style.width = '75px';
		loading.style.padding = '2px';
		document.getElementsByTagName('body').item(0).appendChild(loading);
	}
	loading.style.display = 'block';
}

function loadpage(page_request, pageurl, divId, loader, callback)
{
	var item = $(divId);
	if (loader) item.innerHTML='<div valign="middle" align="center" class="loading"><br/><img src="images/loader2.gif"/></div>';
	loadpage_show();
	
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
	{
		$('loading').style.display = 'none';
		item.innerHTML=page_request.responseText;				
		if (callback != null)				
				eval(callback);			
	}	
}