/*MOVIMIENTO DIV NOTICIAS */
var delayb4scroll=1500 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?

////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''

function scrollmarquee(){
if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8))
cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px"
else
cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
}
/*
function initializemarquee(){
cross_marquee=document.getElementById("vmarquee")
cross_marquee.style.top=0
marqueeheight=document.getElementById("noticias").offsetHeight
actualheight=cross_marquee.offsetHeight
if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
cross_marquee.style.height=marqueeheight+"px"
cross_marquee.style.overflow="scroll"
return
}
setTimeout('lefttime=setInterval("scrollmarquee()",40)', delayb4scroll)
}

if (window.addEventListener)
window.addEventListener("load", initializemarquee, false)
else if (window.attachEvent)
window.attachEvent("onload", initializemarquee)
else if (document.getElementById)
window.onload=initializemarquee

/*FIN MOVIMIENTO DIV NOTICIAS */

/*MOVIMIENTO DIV AGENDA */
/*
var delayb4scroll2=1500 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed2=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit2=1 //Pause marquee onMousever (0=no. 1=yes)?
*/
////NO NEED TO EDIT BELOW THIS LINE////////////
/*
var copyspeed2=marqueespeed2
var pausespeed2=(pauseit2==0)? copyspeed2: 0
var actualheight2=''
*/
/*
function scrollmarquee2(){
if (parseInt(cross_marquee2.style.top)>(actualheight2*(-1)+8))
cross_marquee2.style.top=parseInt(cross_marquee2.style.top)-copyspeed2+"px"
else
cross_marquee2.style.top=parseInt(marqueeheight2)+8+"px"
}*/
/*
function initializemarquee2(){
cross_marquee2=document.getElementById("vmarquee2");
 cross_marquee2.style.top=0;
marqueeheight2=document.getElementById("agenda").offsetHeight
actualheight2=cross_marquee2.offsetHeight
if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
cross_marquee2.style.height=marqueeheight2+"px"
cross_marquee2.style.overflow="sroll"
return
}
setTimeout('lefttime=setInterval("scrollmarquee2()",40)', delayb4scroll2)
}

if (window.addEventListener)
window.addEventListener("load", initializemarquee2, false)
else if (window.attachEvent)
window.attachEvent("onload", initializemarquee2)
else if (document.getElementById)
window.onload=initializemarquee2
/*FIN MOVIMIENTO DIV AGENDA */


function getWindowData(n,i){
    var ifr=document.getElementById(i).contentWindow.document || document.getElementById(i).contentDocument;
    var widthViewport,heightViewport,xScroll,yScroll,widthTotal,heightTotal;
    if (typeof window.frames[n].innerWidth != 'undefined'){
        widthViewport= window.frames[n].innerWidth;
        heightViewport= window.frames[n].innerHeight;
    }else if(typeof ifr.documentElement != 'undefined' && typeof ifr.documentElement.clientWidth !='undefined' && ifr.documentElement.clientWidth != 0){
        widthViewport=ifr.documentElement.clientWidth;
        heightViewport=ifr.documentElement.clientHeight;
    }else{
        widthViewport= ifr.getElementsByTagName('body')[0].clientWidth;
        heightViewport=ifr.getElementsByTagName('body')[0].clientHeight;
    }
    xScroll=window.frames[n].pageXOffset || (ifr.documentElement.scrollLeft+ifr.body.scrollLeft);
    yScroll=window.frames[n].pageYOffset || (ifr.documentElement.scrollTop+ifr.body.scrollTop);
    widthTotal=Math.max(ifr.documentElement.scrollWidth,ifr.body.scrollWidth,widthViewport);
    heightTotal=Math.max(ifr.documentElement.scrollHeight,ifr.body.scrollHeight,heightViewport);
    return [widthViewport,heightViewport,xScroll,yScroll,widthTotal,heightTotal];
} 
function redimen(){
	auxil=document.getElementById('contenido_texto').height;
	//alert("windowredimen"+window.frames.contenido_texto.document.body.scrollHeight);
	document.getElementById('contenido_texto').height = window.frames.contenido_texto.document.body.scrollHeight;
	//window.frames.contenido_texto2.height=window.frames.contenido_texto2.document.body.scrollHeight;
	}


function resizeIframe(ID,NOMBRE){
document.getElementById(ID).height=null;
try
{
	m=getWindowData(NOMBRE,ID); 
	//alert(m[5]);
	if (m[5] <  515)
		document.getElementById(ID).height=515;
	else
		document.getElementById(ID).height=m[5];
}
catch(mierror)
{
	document.getElementById(ID).height=850;
}
} 

function resizeIframe2(ID,NOMBRE){
try
{
	//("cont2scroll"+ window.frames.contenido_texto2.document.body.scrollHeight );
	//alert("cont2heightactual"+ document.getElementById(ID).height);
	document.getElementById(ID).height=null;
	//alert("cont2heighttrasnull"+ document.getElementById(ID).height);
	document.getElementById(ID).height= window.frames.contenido_texto2.document.body.offsetHeight+70; 
	//alert("traslasumacont2height"+document.getElementById(ID).height);
	//parent.document.getElementById('contenido_texto').height=parseInt(window.frames.contenido_texto2.document.body.scrollHeight) + parseInt(document.getElementById(ID).height);
	parent.document.getElementById('contenido_texto').height=document.getElementById(ID).height;
	//alert("finalll");	
}
catch(mierror)
{
	document.getElementById(ID).height=850;
}
//document.getElementById(ID).width=m[4]+22;
} 
function addEvent(obj, evType, fn, useCapture){
 
 if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    
  } else if (obj.attachEvent){
    obj.attachEvent("on"+evType, fn);
   
  } else {
   obj['on'+evType]=fn;
  }
} 

function noNumbers(e)
{
var keynum;
var keychar;
var numcheck;

if(window.event) // IE
{
keynum = e.keyCode;
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which;
}
keychar = String.fromCharCode(keynum);
numcheck = /\d/;
return !numcheck.test(keychar);
}

function realizar_busqueda(clave)
{
		//alert('Hola');
		//alert(document.busqueda.buscar.value.length);
		if (document.busqueda.buscar.value.length<=2)
		{
			alert('Para realizar una búsqueda son necesarios 3 dígitos como mínimo');
			return false;
		}
		else
			return true;
		 //document.getElementById('ruta').innerHTML = "&nbsp;<a href='index.php' class='donde' onMouseOver=this.style.textDecoration='underline' onMouseOut=this.style.textDecoration='none'>Home</a> / Búsqueda: " + clave;
}

function multicarga(documento2,menu,submenu, visualizacion, url, target, reemplaza, enlace_actual, nsubmenus, nmenus, flecha,tmenus) 
{
	
	//document.getElementById(laseccion).style.top='0px';
	//document.getElementById(lasubseccion).style.display='none';
	//alert(flecha);
	//document.getElementById(flecha).style.visibility='visible';
	document.getElementById('flecha_actual').value = flecha;
	laseccion ='seccion' + nmenus;
	lasubseccion ='subseccion' + nmenus;
	ocultar(laseccion,lasubseccion,flecha,tmenus);
	
if (visualizacion != 1)// no es web externa
{
	parent.contenido_texto.location.href=documento2 + "&seccion=" + menu + "&subseccion=" + submenu + "&flecha=" + flecha;
	//cadena = parent.contenido_texto.document.getElementById('ruta').innerHTML ;
	//if (cadena.indexOf('Agenda')==-1) {
		//parent.contenido_texto.document.getElementById('ruta').innerHTML = "&nbsp;<a href='index.php' class='donde' onMouseOver=this.style.textDecoration='underline' onMouseOut=this.style.textDecoration='none'>Home</a> / "+ menu + " / " + submenu ;
	//}
}
else//ES WEB EXTERNNAAAAA
{	
		//alert(target);
		if (target == '_blank')
		{
			url = url.replace('{DOMINIO_RAIZ}',reemplaza)
			window.open(url);
			}
		else
		{
			if (target == '_parent')
			{
				//alert (url );
				url = url.replace('{DOMINIO_RAIZ}',reemplaza)
				window.location.href= url;
				}
			else
			{	
					url = url.replace('{DOMINIO_RAIZ}',reemplaza)
					parent.contenido_texto.location.href = url;
										
			}
		}
		
}
		
}

function carga_noticias ()
{
	parent.contenido_texto.location.href='muestra_noticias.php';
	
}

function carga_aviso_legal ()
{
	window.open('aviso_legal.php',"mywindow","status=1,toolbar=1,height=560,width=690")
}

function carga_agenda ()
{
	parent.contenido_texto.location.href='muestra_agenda.php';
	//cadena = document.getElementById('ruta').innerHTML ;
	//if (cadena.indexOf('Agenda')==-1) {
		//document.getElementById('ruta').innerHTML = "&nbsp;<a href='index.php' class='donde' onMouseOver=this.style.textDecoration='underline' onMouseOut=this.style.textDecoration='none'>Home</a> / Agenda";
	//}
}

function desplega(divsubseccion, total)
{
	suma = 0;
	//alert(suma);
	while (suma <= total)	
	{
		//alert('entra');
		suma = suma + 5;	
		document.getElementById(divsubseccion).style.height = suma + "px";
		if (divsubseccion > 0)
  			setInterval("desplega(divsubseccion,total)", 1000);
		
		//alert(suma);
		
	}
}

function ocultar(seccion, subseccion, flecha,nmenus)
{
		document.getElementById(seccion).style.top='0px';
		document.getElementById(subseccion).style.display='none';
		//alert(flecha);
		maximo = parseInt(nmenus);
	//alert(maximo);
	i= 1;
	while (i <= maximo)
	{
		flecha_miro = 'flecha_'+i;;
		//alert(flecha);		
			if (document.getElementById(flecha_miro))
			{
				if (document.getElementById('flecha_actual').value == flecha_miro)
				{				
					//alert('hola')
					if (document.getElementById(flecha_miro))
						document.getElementById(flecha_miro).style.visibility = 'visible'; 
				}
				else
					document.getElementById(flecha_miro).style.visibility = 'hidden';
			}
			else
					document.getElementById(flecha_miro).style.visibility = 'hidden';
		
		i = i + 1;
	}
		
		
}


function efecto_div(divseccion, divsubseccion,nmenus, ancho_seccion, seccion, cargado)
{
	//alert(flecha);
	posicion_real_y=document.getElementById(divseccion).offsetTop+130;
	posicion_real_x=document.getElementById(divseccion).offsetLeft+180;
	
	//alert(document.getElementById(divseccion).offsetTop+130);
	if (cargado == true)
		document.getElementById(divsubseccion).style.top = (document.getElementById(divseccion).offsetTop + 100)+"px";
	else
		document.getElementById(divsubseccion).style.top = (document.getElementById(divseccion).offsetTop + 98)+"px";
	if (seccion == '1')
		document.getElementById(divsubseccion).style.left = document.getElementById(divseccion).offsetLeft +"px";
	else
	{
		if (seccion == nmenus)
			document.getElementById(divsubseccion).style.left = document.getElementById(divseccion).offsetLeft  - ( 200 - ancho_seccion) +"px";
		else
			document.getElementById(divsubseccion).style.left = (document.getElementById(divseccion).offsetLeft + (ancho_seccion / 2)) - 100 +"px";
			//document.getElementById(divsubseccion).style.left = (document.getElementById(divseccion).offsetLeft - (ancho_seccion / 2))+"px";
	}

 
	maximo = parseInt(nmenus);
	//alert(maximo);
	i= 1;
	while (i <= maximo)
	{
		nombre_seccion = 'seccion' + String(i);
		nombre_menu = 'subseccion' + String(i);
		flecha = 'flecha_' + String(i);
		if (document.getElementById(divsubseccion).id == nombre_menu)
		{			
			if (document.getElementById(divsubseccion).style.display == 'none')
			{ 
				document.getElementById(divsubseccion).style.display = 'block'; 
				document.getElementById(flecha).style.visibility = 'visible'; 
			}
		}
		else
		{ 			
			/*laseccion ='seccion' + i;
			lasubseccion ='subseccion' + i;
			ocultar(laseccion,lasubseccion,flecha,nmenus);*/
				if (document.getElementById(nombre_seccion))
					document.getElementById(nombre_seccion).style.top =0+"px";
				//if (document.getElementById(flecha))
					//document.getElementById(flecha).style.visibility = 'hidden';
				existe_capa = document.getElementById(nombre_menu);
				if (existe_capa)
				{
					if (document.getElementById(nombre_menu).style.display == 'block')
					{ 
						document.getElementById(nombre_menu).style.display = 'none'; 
						
					}
				}
			
		}
		i = i + 1;
	}
	
	
	titulo = 'titulo' + seccion;
	imagebsub = 'imagen' + seccion;
	items =  'item' + seccion;
	//alert('titulo' + seccion);
	//alert( document.getElementById(titulo).offsetHeight);
	sumatodos = document.getElementById(titulo).offsetHeight + document.getElementById(imagebsub).offsetHeight + document.getElementById(items).offsetHeight;
	//alert(sumatodos);	
	document.getElementById(divseccion).style.top = '0px';//SI pongo -10 subira el div hacia arriba como antes
	document.getElementById(divsubseccion).style.height = "0px";	
	//document.getElementById(divseccion).style.backgroundColor = '#58585A';
	desplega(divsubseccion, sumatodos);
	//alert("Se salió");	
}	

function valida_busqueda(F) { 
	if ( (F.mes.value == 0) && (F.clave.value == 0) )
	{
		alert("Debe definir los parámetros de búsqueda.");
		return false;
	}	
	return true;           
}


