function getXMLHTTPRequest() {

try {
req = new XMLHttpRequest(); /* p.e. Firefox */
} catch(e) {
  try {
  req = new ActiveXObject("Msxml2.XMLHTTP");
  /* algunas versiones IE */
  } catch (e) {
    try {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    /* algunas versiones IE */
    } catch (E) {
      req = false;
    }
  }
}
return req;

}
var http = getXMLHTTPRequest();


function carga_servicios(pagina_nueva) {
	
   //Define las variables para que sean globales a todo el entorno

   newpagina=pagina_nueva;

	
   var myurl = '../catala/'+pagina_nueva+'.php';
  
    myRand = parseInt(Math.random()*999999999999999);
    // saltarse la cache
   
   var modurl = myurl+"?rand="+myRand;

   http.open("GET", modurl, true);
   http.onreadystatechange = useHttpResponseServicio;
   http.send(null);
}



function useHttpResponseServicio() {
	
	
   //Selecciona el div donde ira todo el contenido que se obtenga
   var area = document.getElementById("contenido");
   
   if (http.readyState == 4) {
	   if(http.status == 200) {
		   
		//Mete en el div contenido, el contenido de la pagina consultada
	    area.innerHTML = http.responseText;
	   }
	}
  else
  {
	  area.innerHTML = '<img src="imagenes/cargando.gif" style="position:absolute;left:32%;top:40%;" />';
  }
}

function carga_areas_serv(area) {
	
	nueva_area=area;
	
   var myurl = '../catala/'+area+'.php';
  
    myRand = parseInt(Math.random()*999999999999999);
    // saltarse la cache
   
   var modurl = myurl+"?rand="+myRand;

   http.open("GET", modurl, true);
   http.onreadystatechange = useHttpResponseArea;
   http.send(null);
}

function useHttpResponseArea() {
	
	
   //Selecciona el div donde ira todo el contenido que se obtenga
   var area = document.getElementById("contenido");
   
   if (http.readyState == 4) {
	   if(http.status == 200) {
			
		//Mete en el div contenido, el contenido de la pagina consultada
	    area.innerHTML = http.responseText;
		new Accordian('basic-accordian',5,'header_highlight');
	   }
	}
  else
  {
	  area.innerHTML = '<img src="imagenes/cargando.gif" style="position:absolute;left:32%;top:40%;" />';
  }
}

function carga_opciones_redac(opcion) {
	
   var myurl = '../catala/includes/'+opcion+'.php';
  
    myRand = parseInt(Math.random()*999999999999999);
    // saltarse la cache
   
   var modurl = myurl+"?rand="+myRand;

   http.open("GET", modurl, true);
   http.onreadystatechange = useHttpResponseRedac;
   http.send(null);
}

function useHttpResponseRedac() {
	
	
   //Selecciona el div donde ira todo el contenido que se obtenga
   var area = document.getElementById("servcontent");
   
   if (http.readyState == 4) {
	   if(http.status == 200) {

		 while (document.getElementById('servcontent') .hasChildNodes())
      	{
			document.getElementById('servcontent').removeChild(document .getElementById('servcontent').firstChild);
      	}
		 
		//Mete en el div contenido, el contenido de la pagina consultada
	    area.innerHTML = http.responseText;
	   }
	}
  else
  {
	  area.innerHTML = '<img src="imagenes/cargando.gif" style="position:absolute;left:32%;top:80%;" />';
  }
}
