// Documento JavaScript

function nuevoAjax(){
	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;
} 
// Esta función cargará las páginas de manera síncrona
function cargarSincrono (url, id_contenedor)
{
    var objAjax = nuevoAjax();
	
	if (!objAjax){
		return false;	
	}else{
		objAjax.open ('GET', url, false); // asignamos los métodos open y send
		objAjax.send (null);
		cargarPagina (objAjax, id_contenedor);
	}
}

//  Esta función cargará las páginas de manera asíncrona
function cargarAsincrono (url, id_contenedor)
{
    var objAjax = nuevoAjax();
	if (!objAjax){
		return false;	
	}else{
		objAjax.onreadystatechange = function ()
		{
			// función de respuesta
			cargarPagina (objAjax, id_contenedor);
		}
		objAjax.open ('GET', url, true); // asignamos los métodos open y send
		objAjax.send (null);
	}
}
// todo es correcto y ha llegado el momento de poner la información requerida
// en su sitio en la pagina xhtml
function cargarPagina (objAjax, id_contenedor)
{
    if (objAjax.readyState == 4 && (objAjax.status == 200 || window.location.href.indexOf ("http") == - 1)){
	    document.getElementById (id_contenedor).innerHTML = objAjax.responseText;
		//alert('cargada!!');
	}
	
}


