function crearAjax()
{
    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 carregarPagina(url,capa)
{
    
    // creamos un nuevo objeto ajax
    ajax=crearAjax();
    
    //cargar el archivo html por el método GET
    ajax.open("GET", url,true);
    
    ajax.onreadystatechange=function() 
    {
        if (ajax.readyState==4) // Readystate 4 significa que ya acabó de cargarlo
        {
            document.getElementById(capa).innerHTML = ajax.responseText
        }
    }
    ajax.send(null)
}
