var activo=0;
var contador=0;
var activoTabla=1;
var contadorTabla=1;

function subMenuVisible(numSubMenuActivar)
{
	if(activo==numSubMenuActivar)
	{
		contador=contador+1;
		subMenuOcultarMismo(numSubMenuActivar);
	}
	else
	{
		contador=0;
		document.getElementById('menuOculto'+numSubMenuActivar).style.visibility='visible';
		document.getElementById('menuOculto'+numSubMenuActivar).style.display='block';
		document.getElementById('opcion'+numSubMenuActivar).className='enlaceMenu2';
		window.document.getElementById('cabezaIglesias').className='cabezaIglesiasPequena';
		window.document.getElementById('piglesias').className='piglesiasPequena';
		if(activo!=0) {
			document.getElementById('menuOculto'+activo).style.visibility='hidden';
			document.getElementById('menuOculto'+activo).style.display='none';
			document.getElementById('opcion'+activo).className='enlaceMenu';
			window.document.getElementById('cabezaIglesias').className='cabezaIglesiasPequena';
			window.document.getElementById('piglesias').className='piglesiasPequena';
		}

		activo=numSubMenuActivar;
	}

}

function subMenuOcultarMismo(numSubMenuActivar)
{
	if(contador%2==0)
	{
		document.getElementById('menuOculto'+numSubMenuActivar).style.visibility='visible';
		document.getElementById('menuOculto'+numSubMenuActivar).style.display='block';
		document.getElementById('opcion'+numSubMenuActivar).className='enlaceMenu2';
		window.document.getElementById('cabezaIglesias').className='cabezaIglesiasPequena';
              	window.document.getElementById('piglesias').className='piglesiasPequena';
	}
	else
	{

		document.getElementById('menuOculto'+activo).style.visibility='hidden';
		document.getElementById('menuOculto'+activo).style.display='none';
		document.getElementById('opcion'+activo).className='enlaceMenu';
              	window.document.getElementById('cabezaIglesias').className='cabezaIglesiasGrande';
              	window.document.getElementById('piglesias').className='piglesiasGrande';
	}

}



/* para Tablas */
function tablaVisible(numSubMenuActivar)
{

	if(activoTabla!=numSubMenuActivar)
	{


		document.getElementById('tabla'+numSubMenuActivar).style.visibility='visible';
		document.getElementById('tabla'+numSubMenuActivar).style.display='block';

		document.getElementById('tabla'+activoTabla).style.visibility='hidden';
		document.getElementById('tabla'+activoTabla).style.display='none';


		activoTabla=numSubMenuActivar;
	}

}

function tablaOcultarMismo(numSubMenuActivar)
{
	if(contadorTabla%2==0)
	{
		document.getElementById('tabla'+numSubMenuActivar).style.visibility='visible';
		document.getElementById('tabla'+numSubMenuActivar).style.display='block';


	}
	else
	{
		document.getElementById('tabla'+activoTabla).style.visibility='hidden';
		document.getElementById('tabla'+activoTabla).style.display='none';

	}

}

// Función encargada de desplazar la capa por el documento
		function desplazar_capa(evt,layer)
		{
			// Capturamos el Evento
			var e = (window.event) ? window.event : evt;

			var capa = document.getElementById(layer);


			capa.style.visibility ="visible";



			// Determinamos las coordenadas del raton.
			X = e.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
			Y = e.clientY + document.documentElement.scrollTop + document.body.scrollTop;


			// Movemos la capa a las coordenadas del raton
			capa.style.left = X + 10;
			capa.style.top = Y + 25;

			// Ponemos a nuestra capa una opacidad para que sea algo transparente y se vea el contenido del fondo
			capa.style.filter="alpha(opacity=85)"; // Opacidad para IE
			capa.style.opacity="0.85"; // Ocapacidad para Netscape

			// Hacemos que la capa sea totalmente visible
			capa.style.display = "block";


}
//------------------------------------------------------------------------------
function onFila(idFila,idCelda1)
{
	document.getElementById(idFila).style.fontWeight='bold';
	document.getElementById(idCelda1).style.background = 'url(./img/cuadro.gif) no-repeat 0% 50%';
}
//------------------------------------------------------------------------------
function offFila(idFila,idCelda1)
{
	document.getElementById(idFila).style.fontWeight='normal';
	document.getElementById(idCelda1).style.background = 'url(./img/cuadro.gif) no-repeat 0% 50%';
}
//------------------------------------------------------------------------------
function Busqueda(tipo)
{
  if(tipo > 0)
  {
  	/*document.getElementById('noticia1').style.visibility = 'hidden';
  	document.getElementById('noticia2').style.visibility = 'hidden';
  	document.getElementById('noticia3').style.visibility = 'hidden';
	document.getElementById('noticia4').style.visibility = 'hidden';*/
	document.getElementById('noticias').style.visibility = 'hidden';

    	if(tipo == 1)
        {
          document.getElementById('fra_busqueda').src = 'fondos_unidades.jsp?clase=es.intecna.xml.estructura.DatoDefecto&accion=buscar&cod_dat_defecto=&cod_dato=5&valor=&cod_ente=&cod_tip_ente=&cod_tip_contenido=1';
        }
        else if(tipo == 2)
        {
          document.getElementById('fra_busqueda').src = 'busqueda_carteles.jsp?accion=prebuscar&clase=es.intecna.dinainf.estructura.Contenido&cod_contenido=&internet=true&cod_tip_contenido=2';
        }
        else if(tipo == 3)
        {
          document.getElementById('fra_busqueda').src = 'fondos_fotografias.jsp?cod_estado=';
        }
        else if(tipo==4) //Url Biblioteca
        {
          //AbrirVentanaRedimensionable('http://biblio.uah.es/uhtbin/fpiglesias', 800,600);
          document.getElementById('fra_busqueda').src = 'biblioteca.html';
        }
        else if(tipo == 5)
        {
        document.getElementById('fra_busqueda').src = 'busqueda_eventos.jsp?';
        }
        else if(tipo==6) //Url Biblioteca
        {
          document.getElementById('fra_busqueda').src = 'hemeroteca.jsp?accion=prebuscar&clase=es.intecna.dinainf.estructura.Contenido&cod_tip_contenido=4&internet=true&cod_contenido=';
        }
        else if(tipo == 7)
        {
        	document.getElementById('fra_busqueda').src = 'analisis_debate.jsp?cod_categoria=1&pagina=analisis.htm';
        }
        else if(tipo ==8)
        {
        	document.getElementById('fra_busqueda').src = 'audiovisuales.jsp?cod_categoria=2&pagina=audiovisual.htm';
        }
        else if(tipo == 9)
        {
        	document.getElementById('fra_busqueda').src = 'exposiciones.jsp?cod_categoria=3&pagina=exposiciones.htm';
        }
        else if(tipo == 10)
        {
        	document.getElementById('fra_busqueda').src = 'historia_memoria.jsp?cod_categoria=4&pagina=historiaymemoria.htm';
        }
        else if(tipo == 11)
        {
        	document.getElementById('fra_busqueda').src = 'internacional.jsp?cod_categoria=5&pagina=internacional.htm';
        }
        else if(tipo == 12)
        {
        	document.getElementById('fra_busqueda').src = 'investigacion_estudios.jsp?cod_categoria=6&pagina=investigacion.htm';
        }
        else if(tipo == 13)
        {
        	document.getElementById('fra_busqueda').src = 'publicaciones.jsp?cod_categoria=8&pagina=publicaciones.html';
        }
        else if(tipo==21)
        {
          document.getElementById('fra_busqueda').src = 'fundapru.htm';
        }
        else if(tipo==22)
        {
          document.getElementById('fra_busqueda').src = 'archivo2.html';
        }
        else if(tipo == 23)
        {
          document.getElementById('fra_busqueda').src = 'mapa.html';
        }
        else if(tipo == 24)
        {
          document.getElementById('fra_busqueda').src = 'contacto.html';
        }
        else if(tipo == 25)
        {
          document.getElementById('fra_busqueda').src = 'archivo.html';
        }
        else if(tipo == 26)
        {
          document.getElementById('fra_busqueda').src = 'aviso.html';
        }
        else if(tipo == 27)
        {
          document.getElementById('fra_busqueda').src = 'politica.html';
        }
        else if(tipo == 28)
        {
          document.getElementById('fra_busqueda').src = 'enlaces.html';
        }
        else if(tipo == 29)
        {
          document.getElementById('fra_busqueda').src = 'salaprensa.html';
        }
        else if(tipo == 30)
        {
          document.getElementById('fra_busqueda').src = 'lista_distribucion.jsp';
        }
        else if(tipo == 31)
        {
          document.getElementById('fra_busqueda').src = 'intro_fundacion.html';
        }
  	document.getElementById('busqueda').style.visibility = 'visible';

  }
  else
  {
  	document.getElementById('busqueda').style.visibility = 'hidden';
  	/*document.getElementById('noticia1').style.visibility = 'visible';
  	document.getElementById('noticia2').style.visibility = 'visible';
  	document.getElementById('noticia3').style.visibility = 'visible';*/
  	document.getElementById('noticia4').style.visibility = 'visible';
	document.getElementById('noticia5').style.visibility = 'visible';
  }

}
//------------------------------------------------------------------------------

// JavaScript Document

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

timerID = null;
var active = 0;
var active2 = 0;
var active3 = 0;

function ChangePage(num){
    	if(document.getElementById){
    		obj[active].style.visibility = "hidden";
    		active = num;
    		obj[active].style.top = 0;
    		obj[active].style.visibility = "visible";
    	}
}
    function ChangePage2(dum){
    	if(document.getElementById){
    		obj2[active2].style.visibility = "hidden";
    		active2 = dum;
    		obj2[active2].style.top = 0;
    		obj2[active2].style.visibility = "visible";
    	}
}

    function ChangePage3(sum){
    	if(document.getElementById){
    		obj3[active3].style.visibility = "hidden";
    		active3 = sum;
    		obj3[active3].style.top = 0;
    		obj3[active3].style.visibility = "visible";
    	}
}

function ScrollUp(speed){
    	if(document.getElementById){
    		if(parseInt(obj[active].style.left) < 0){
    			obj[active].style.left = parseInt(obj[active].style.left) + speed + "px";
		}
    		timerID = setTimeout("ScrollUp("+speed+")",30);
    	}
}

function ScrollDown(speed){
    	if(document.getElementById){

    		if(parseInt(obj[active].style.left) > document.getElementById('cont').offsetWidth - obj[active].offsetWidth){
    			obj[active].style.left = parseInt(obj[active].style.left) - speed + "px";
		}

    		timerID = setTimeout("ScrollDown("+speed+")",30);
    	}
}

function ScrollDown2(speed){
    	if(document.getElementById){
    		if(parseInt(obj[active].style.top) > document.getElementById('cont2').offsetHeight - obj[active].offsetHeight){
    			obj[active].style.top = parseInt(obj[active].style.top) - speed + "px";
		}
    		timerID = setTimeout("ScrollDown2("+speed+")",30);
    	}
}

function ScrollDown3(speed){
    	if(document.getElementById){
    		if(parseInt(obj[active].style.top) > document.getElementById('cont3').offsetHeight - obj[active].offsetHeight){
    			obj[active].style.top = parseInt(obj[active].style.top) - speed + "px";
		}
    		timerID = setTimeout("ScrollDown3("+speed+")",30);
    	}
}

function ScrollDown4(speed){
    	if(document.getElementById){
    		if(parseInt(obj[active].style.top) > document.getElementById('cont4').offsetHeight - obj[active].offsetHeight){
    			obj[active].style.top = parseInt(obj[active].style.top) - speed + "px";
		}
    		timerID = setTimeout("ScrollDown4("+speed+")",30);
    	}
}

function ScrollStop(){
    	if(document.getElementById){
    		clearTimeout(timerID);
    	}
}



function ScrollPageInit(numero) {
    	if(document.getElementById){

		    active = numero;

    		obj = document.getElementById("cont").getElementsByTagName("div");
    		obj['page'+(numero+1)].style.visibility = "visible";
    		obj['page'+(numero+1)].style.top = 0;
			obj['page'+(numero+1)].style.left = 0;
    	}
}

function ScrollPageInit2(numero) {
    	if(document.getElementById){

			active = numero;

			obj = document.getElementById("cont2").getElementsByTagName("div");
    		obj['page'+(numero+1)].style.visibility = "visible";
    		obj['page'+(numero+1)].style.top = 0;
    	}
}

function ScrollPageInit3(numero) {
    	if(document.getElementById){

			active = numero;

			obj = document.getElementById("cont3").getElementsByTagName("div");
    		obj['page'+(numero+1)].style.visibility = "visible";
    		obj['page'+(numero+1)].style.top = 0;
    	}
}

function ScrollPageInit4(numero) {
    	if(document.getElementById){

			active = numero;

			obj = document.getElementById("cont4").getElementsByTagName("div");
    		obj['page'+(numero+1)].style.visibility = "visible";
    		obj['page'+(numero+1)].style.top = 0;
    	}
}

var eActivo="sub1";

function cambiar(id)
{
	if(eActivo!=null)
	{
		document.getElementById(eActivo).style.display="none";
		document.getElementById(id).style.display="block";

	}
	else
		document.getElementById(id).style.display="block";

	eActivo=id;
}
function AbrirEnVentana(url)
{
	window.location.href = url;
}
