function getXMLHTTPRequest() {
try {
req = new XMLHttpRequest();
} catch(err1) {
  try {
  req = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (err2) {
    try {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (err3) {
      req = false;
    }
  }
}
return req;
}

function cargaMenu() {
  var url='menu.xhtml';
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = url+"?rand="+myRand;
  http2.open("GET", modurl, true);
  http2.onreadystatechange = useHttpResponseMenu;
  http2.send(null);

}
function useHttpResponseMenu() {
   if (http2.readyState == 4) 
   {
		if(http2.status == 200) {
		   var contenidoActual = http2.responseText;
		   document.getElementById('column').innerHTML = contenidoActual;
		}
   	} else {
  		document.getElementById('column').innerHTML = '<span style="padding:0 1em 0 1em;background-color:#FF2200;color:#FFF; font-weight:bolder; text-decoration:blink;">Espere por favor, cargando...</span>';
  	}
}

function contenido(url,act) {
  if ( url == "" ) { url="error.xhtml";};
  if ( act == 1 ) { document.location.hash=''; return true };
  if ( document.location.hash != "" ) { desdeMenu=1; } 
  urlAnterior=urlActual;
  urlActual=url;
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = url+"?rand="+myRand;
  http.open("GET", modurl, true);
  http.onreadystatechange = useHttpResponse;
  http.send(null);
}

function useHttpResponse() {
   if (http.readyState == 4) 
   {
		if(http.status == 200) {
		   var contenidoActual = http.responseText;
		   document.getElementById('contenido').innerHTML = contenidoActual;
		   document.getElementById('contenido').innerHTML += capaVolver;
		   // Insertamos el enlace de Impresión para el contenido.
   		   var titulo=document.getElementById('contenido').getElementsByTagName('h1')
		   titulo[0].innerHTML =titulo[0].innerHTML   +  '<div class="limprimir"><a href="javascript:Imprimir()" title="Impresion documento actual" accesskey="p"> <img src="img/imp.png" alt="Impresion documento actual"  /></a></div>';
		   //recargamos la página para poder acceder a los anclas.
		   if ( desdeMenu == 1 ) {
				document.location=document.location.hash;
				desdeMenu=0;
			}
		}
   	} else {
  		document.getElementById('contenido').innerHTML = '<span style="padding:0 1em 0 1em;background-color:#FF2200;color:#FFF; font-weight:bolder; text-decoration:blink;">Espere por favor, cargando...</span>';
  	}
}

function enlace (url,texto) {
	this.url = url;
	this.texto = texto;
}

function crearEnlace () {
	var tagA='<li><a href="javascript:contenido(\''+this.url+'\');" title="'+this.texto+'">'+texto+'</a></li>';
	return tagA;
}

var	contenidoMenuULxDefecto='<li><a href="index.html" title="Inicio">Inicio</a> &gt;&gt; </li>';
var contenidoMenuUL='';

function actualizaMenu(nodoEnlace) {
//	alert(nodoEnlace.nodeName + "\n" + nodoEnlace.innerHTML);
	if ( nodoEnlace.nodeName == "A" )
		contenidoMenuUL="<li><a href=\"#\" onClick=\"actualizaMenu(this);"+nodoEnlace.href+"\" title=\""+nodoEnlace.title+"\">"+nodoEnlace.innerHTML+"</a> &gt;&gt; </li>"+contenidoMenuUL;
	if ( ( nodoEnlace.nodeName == "UL" && nodoEnlace.id == "MenuVertical" ) || ( nodoEnlace.id == "listaNavega" ) )
	{
		contenidoMenuUL=contenidoMenuULxDefecto+contenidoMenuUL;
		document.getElementById('menucompas').innerHTML='<ul id="listaNavega">'+contenidoMenuUL+'</ul>';
		contenidoMenuUL='';
		nodoEnlace.href;
		return false;
	} else if (nodoEnlace.nodeName == "UL") {
		actualizaMenu(nodoEnlace.parentNode.firstChild);
	} else {
		actualizaMenu(nodoEnlace.parentNode.parentNode);
	}
}


var http = getXMLHTTPRequest();
var http2 = getXMLHTTPRequest();
var urlAnterior='';
var urlActual='';
var capaVolver='<div class="derecha"><div class="limprimir"><a href="javascript:Imprimir()" title="Impresion documento actual" accesskey="p"> <img src="img/imp.png" alt="Impresion documento actual"  /></a></div><a style="display: inline;" id="volverAtajo" href="javascript:contenido(urlAnterior)" title="Volver (Tecla de acceso V)"><< volver</a> || <a href="#inicio" title="Arriba (Tecla de acceso A)" accesskey="7">arriba</a> || </div>';
var enlaceInicio='<li><a href="index.html" title="Inicio">Inicio</a> &gt;&gt; </li>';
var desdeMenu=0;






