function createRequestObject() {
    var ro;
    if (navigator.appName == "Microsoft Internet Explorer") {
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        ro = new XMLHttpRequest();
    }
    return ro;
}

var httpVariables=createRequestObject();
var httpCreaVariables=createRequestObject();
var httpContenido=createRequestObject();
var httpMenu=createRequestObject();
var httpIndicador=createRequestObject();
var httpMenuPpal=createRequestObject();
var httpSuperior=createRequestObject();
var httpLinks=createRequestObject();
var httpBlog=createRequestObject();
var httpVideo=createRequestObject();

function sendRequestVariables(codmenu,idioma) {
    var aleatorio = Math.round(Math.random()*1000);
    httpVariables.open('get', 'ajaxvariables.php?codmenu='+codmenu+'&idioma='+idioma+'&aleatorio='+aleatorio);
    httpVariables.onreadystatechange = handleResponse1;
    httpVariables.send(null);
}
function sendRequestCreaVariables(codmenu,idioma) {
    var aleatorio = Math.round(Math.random()*1000);
    httpCreaVariables.open('get', 'ajaxvariables.php?codmenu='+codmenu+'&idioma='+idioma+'&aleatorio='+aleatorio);
    httpCreaVariables.onreadystatechange = handleResponse6;
    httpCreaVariables.send(null);
}
function sendRequest(codmenu,idioma,nivel,tipocontenido) {
    location.replace("index.php?codmenu="+codmenu+"&idioma="+idioma);
    /*var aleatorio = Math.round(Math.random()*1000);
	palabra=document.getElementById('palabrabusqueda').value;
	historial='codmenu='+codmenu+'&idioma='+idioma;
	if(llamadohistorial==1)
	  tipocambiohistorial=0;
	else
	  tipocambiohistorial=1;	
	llamadohistorial=0;
	unFocus.History.addHistory(historial);
    httpContenido.open('get', 'ajax.php?codmenu='+codmenu+'&idioma='+idioma+'&nivel='+nivel+'&tipocontenido='+tipocontenido+'&aleatorio='+aleatorio+'&palabrabusqueda='+palabra);
    httpContenido.onreadystatechange = handleResponse2;
    httpContenido.send(null);*/
}
function sendRequestContenidoBlog(codmenu,idioma,nivel,tipocontenido,idblog) {
    var aleatorio = Math.round(Math.random()*1000);
	palabra=document.getElementById('palabrabusqueda').value;
	historial='codmenu='+codmenu+'&idioma='+idioma+'&idblog='+idblog;
	if(llamadohistorial==1)
	  tipocambiohistorial=0;
	else
	  tipocambiohistorial=1;	
	llamadohistorial=0;
	unFocus.History.addHistory(historial);
    httpContenido.open('get', 'ajaxblog.php?codmenu='+codmenu+'&idioma='+idioma+'&nivel='+nivel+'&idblog='+idblog+'&tipocontenido='+tipocontenido+'&aleatorio='+aleatorio+'&palabrabusqueda='+palabra);
    httpContenido.onreadystatechange = handleResponse2;
    httpContenido.send(null);
}
function sendRequestMenu(codmenu,idioma,nivel,nivel1,nivel2,nivel3,nombre1,nombre2,nombre3) {
    var aleatorio = Math.round(Math.random()*1000);
    httpMenu.open('get', 'ajaxmenu.php?codmenu='+codmenu+'&idioma='+idioma+'&nivel='+nivel+'&nivel1='+nivel1+'&nivel2='+nivel2+'&nivel3='+nivel3+'&nombre1='+nombre1+'&nombre2='+nombre2+'&nombre3='+nombre3+'&aleatorio='+aleatorio);
    httpMenu.onreadystatechange = handleResponse3;
    httpMenu.send(null);
}
function sendRequestIndicador(codmenu,idioma,nivel,nivel1,nivel2,nivel3,nombre1,nombre2,nombre3) {
    var aleatorio = Math.round(Math.random()*1000);
    httpIndicador.open('get', 'ajaxindicador.php?codmenu='+codmenu+'&idioma='+idioma+'&nivel='+nivel+'&nivel1='+nivel1+'&nivel2='+nivel2+'&nivel3='+nivel3+'&nombre1='+nombre1+'&nombre2='+nombre2+'&nombre3='+nombre3+'&aleatorio='+aleatorio);
    httpIndicador.onreadystatechange = handleResponse4;
    httpIndicador.send(null);
	colocatitle();
}
function sendRequestMenuPpal(codmenu,idioma,nivel,nivel1) {
    var aleatorio = Math.round(Math.random()*1000);
    httpMenuPpal.open('get', 'ajaxmenuppal.php?codmenu='+codmenu+'&idioma='+idioma+'&nivel='+nivel+'&nivel1='+nivel1+'&aleatorio='+aleatorio);
    httpMenuPpal.onreadystatechange = handleResponse5;
    httpMenuPpal.send(null);
}
function sendRequestSuperior(codmenu,idioma) {
    var aleatorio = Math.round(Math.random()*1000);
    httpSuperior.open('get', 'ajaxsuperior.php?codmenu='+codmenu+'&idioma='+idioma+'&aleatorio='+aleatorio);
    httpSuperior.onreadystatechange = handleResponse7;
    httpSuperior.send(null);
}
function sendRequestLinks(codmenu,idioma) {
    var aleatorio = Math.round(Math.random()*1000);
    httpLinks.open('get', 'ajaxlinks.php?codmenu='+codmenu+'&idioma='+idioma+'&aleatorio='+aleatorio);
    httpLinks.onreadystatechange = handleResponse8;
    httpLinks.send(null);
}
function sendRequestBlog(codmenu,idioma,codblog) {
    var aleatorio = Math.round(Math.random()*1000);
    //httpBlog.open('get', 'ajaxblog.php?codmenu='+codmenu+'&idioma='+idioma+'&idblog='+codblog+'&aleatorio='+aleatorio);
	httpVariables.open('get', 'ajaxvariables.php?codmenu='+codmenu+'&idioma='+idioma+'&idblog='+codblog+'&aleatorio='+aleatorio);
    httpVariables.onreadystatechange = handleResponse1;
    httpVariables.send(null);
}
function sendRequestVideo(codvideo,idioma) {
    var aleatorio = Math.round(Math.random()*1000);
    httpVideo.open('get', 'ajaxvideo.php?codvideo='+codvideo+'&aleatorio='+aleatorio+'&idioma='+idioma);
    httpVideo.onreadystatechange = handleResponse10;
    httpVideo.send(null);
}


function handleResponse1() {
    if(httpVariables.readyState == 4)
    {
      var Valor=new String(httpVariables.responseText);
	  //alert(Valor);
	  escribeCapa('variables',Valor);
	  recarga();
    }
}
function handleResponse2() {
    if(httpContenido.readyState == 4)
    {
      var Valor=new String(httpContenido.responseText);
	  escribeCapa('contenidos',Valor);
    }
}
function handleResponse3() {
    if(httpMenu.readyState == 4)
    {
      var Valor=new String(httpMenu.responseText);
	  escribeCapa('menu',Valor);
	  new Accordian('basic-accordian',5,'header_highlight');
    }	
}
function handleResponse4() {
    if(httpIndicador.readyState == 4)
    {
      var Valor=new String(httpIndicador.responseText);
	  escribeCapa('indicadorseccion',Valor);
    }
}
function handleResponse5() {
    if(httpMenuPpal.readyState == 4)
    {
      var Valor=new String(httpMenuPpal.responseText);
	  escribeCapa('menuprincipal',Valor);
    }
}
function handleResponse6() {
    if(httpCreaVariables.readyState == 4)
    {
      var Valor=new String(httpCreaVariables.responseText);
	  escribeCapa('variables',Valor);
      colocatitle();
    }
}
function handleResponse7() {
    if(httpSuperior.readyState == 4)
    {
      var Valor=new String(httpSuperior.responseText);
	  escribeCapa('superior',Valor);
    }
}
function handleResponse8() {
    if(httpLinks.readyState == 4)
    {
      var Valor=new String(httpLinks.responseText);
	  escribeCapa('links',Valor);
    }
}
function handleResponse9() {
    if(httpBlog.readyState == 4)
    {
      var Valor=new String(httpBlog.responseText);
	  escribeCapa('contenidos',Valor);
    }
}
function handleResponse10() {
    if(httpVideo.readyState == 4)
    {
      var Valor=new String(httpVideo.responseText);
	  escribeCapa('contenidos',Valor);
    }
}




