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 resizeIframe(ID,NOMBRE){
document.getElementById(ID).height=null;
//document.getElementById(ID).width=null;

//SE LO QUITE PARA QUE SALIERA EL FAVICON
//window.location='#';//necesario para safari

//alert(m[5]);
try
{
	m=getWindowData(NOMBRE,ID); 
	//alert(m[5]);
	//alert(m[5]);
	if (m[5] <  550)
		document.getElementById(ID).height=550;
	else
		document.getElementById(ID).height=m[5];
	//alert(document.getElementById(ID).height);
}
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 carga_aviso_legal ()
{
	window.open('../aviso_legal.php',"mywindow","status=1,toolbar=1,height=560,width=690")
}

function carga_aviso_legal_mapaw ()
{
	window.open('aviso_legal.php',"mywindow","status=1,toolbar=1,height=560,width=690")
}


function realizar_busqueda(enlace)
{
	clave = document.getElementById('buscar').value;
	//alert(enlace+'&buscar='+clave);
	if (document.getElementById('buscar').value.length<=2)
		{
			alert('Para realizar una búsqueda son necesarios 3 dígitos como mínimo');
			return false;
		}
		else
			location.href = enlace+'&buscar='+clave;
	
}

function carga_noticias(enlace)
{

	location.href = enlace+'&view=noticias';
}

function carga_agenda(enlace)
{
	location.href = enlace+'&view=agenda';
}

function multicarga(documento2,menu,submenu)
{
//parent.location.href="index.php";
parent.contenido_texto.location.href=documento2;
document.getElementById('titulo_menu').value = menu;
document.getElementById('titulo_submenu').value = submenu;
}

function enviar_al_index(enlace)
{
		location.href = enlace;
}

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 efecto_div_seccion(divseccion, divsubseccion,nmenus, ancho_seccion, seccion, cargado)
{
	
	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 + 3)+"px";
	else
		document.getElementById(divsubseccion).style.top = (document.getElementById(divseccion).offsetTop + 13)+"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
		{ 
			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 = '-10px';
	document.getElementById(divsubseccion).style.height = "0px";	
	desplega(divsubseccion, sumatodos);
	//alert("Se salió");	
}	

//Aqui me quede
function efecto_div(capa,nmenus,documento2)
{
//alert(nmenus);
//alert(document.getElementById(capa).id);
parent.contenido_texto.location.href=documento2;
maximo = parseInt(nmenus);
//alert(maximo);
i= 1;
while (i<=maximo)
{
nombre_menu = 'menu_nombre_' + String(i);
enlace_actual ='enlace_menu_' + String(i);
//alert("Menu: " +nombre_menu+ "- Capa: "+document.getElementById(capa).id);
if (document.getElementById(capa).id == nombre_menu)
{
//document.getElementById(enlace_actual).style.background = '#E42337';
document.getElementById(enlace_actual).style.color = '#000000';
//document.getElementById(enlace_actual).style.fontWeight = 'normal';
//alert('igual '+nombre_menu);
//document.getElementById(capa).style.display = 'block';
if (document.getElementById(capa).style.display == 'none')
{
document.getElementById(capa).style.display = 'block';
}
//else
//{
//document.getElementById(capa).style.display = 'none';
//}
}
else
{
//alert('no entra' + nombre_menu);
//alert('no entra '+nombre_menu);
existe_capa = document.getElementById(nombre_menu);
if (existe_capa)
{
document.getElementById(enlace_actual).style.color = '#E42337';
if (document.getElementById(nombre_menu).style.display == 'block')
{
document.getElementById(nombre_menu).style.display = 'none';
}
}
//alert(i);
//else
//{
//document.getElementById(nombre_menu).style.display = 'none';
//}
}
//alert(i);
i = i + 1;
}
//alert("Se salió");
}

function muestra_submenu(submenu, menu)
{
		document.getElementById(submenu).style.display='block';
		document.getElementById(submenu).style.top = document.getElementById(menu).offsetTop + "px";
		document.getElementById(submenu).style.left = document.getElementById(menu).offsetLeft + 150 + "px";
}

function esconde_submenu(submenu)
{
		document.getElementById(submenu).style.display='none';
}
function multicarga_servicio(documento2,menu,submenu, visualizacion, url, target, reemplaza,enlace_actual, nmenus,enlace_menu, imagen, servicio, nsubmenus)
{
	
maximo = nmenus;
i = 1;
while (i<=maximo)
	{			
		enlace ='enlace_servicio_'+i;
		imageni = 'imagen_'+i;
		if (document.getElementById(enlace))
			document.getElementById(enlace).style.color = '#FFFFFF';
		if (document.getElementById(imageni))
			document.getElementById(imageni).src = '../disenyo/flechasobregris.gif';
		//alert(i);
		i = i + 1;
	}
	
document.getElementById(enlace_menu).style.color = '#000000';
//alert(document.getElementById(imagen).src);
document.getElementById(imagen).src = '../disenyo/flechasobregrisg.gif';

maximo2 = nsubmenus;
i = 1;
while (i<=maximo2)
	{			
		senlace ='submenu_enlace_'+i;
		
		if (document.getElementById(senlace))
			document.getElementById(senlace).style.color = '#FFFFFF';		
		//alert(i);
		i = i + 1;
	}

document.getElementById(enlace_actual).style.color = '#000000';
//document.getElementById(li_actual).style.color = '#000000';
if (visualizacion != 3)
{
	parent.contenido_texto.location.href=documento2+"&enlace_menu="+enlace_menu+"&enlace_submenu="+enlace_actual+"&nmenus="+nmenus+"&nsubmenus="+nsubmenus;
	//document.getElementById('titulo_menu').value = menu;
	//document.getElementById('titulo_submenu').value = submenu;
}
else
{
		//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;
			}
		}
			
}
document.getElementById('ruta').innerHTML = "&nbsp;<a href='../index.php' class='donde' onMouseOver=this.style.textDecoration='underline' onMouseOut=this.style.textDecoration='none'>Home</a> / <a href='index.php' class='donde' onMouseOver=this.style.textDecoration='underline' onMouseOut=this.style.textDecoration='none'>" + servicio +"</a> / " + menu + " / " + submenu;
}


//Aqui me quede
function efecto_div_servicio(capa,nmenus, documento2, menu, visualizacion,url, target, reemplaza, enlace_menu, imagen, servicio,nsubmenus)
{
maximo = nmenus;
i = 1;
while (i<=maximo)
	{			
		enlace ='enlace_servicio_'+i;
		imageni = 'imagen_'+i;
		if (document.getElementById(enlace))
			document.getElementById(enlace).style.color = '#FFFFFF';
		if (document.getElementById(imageni))
			document.getElementById(imageni).src = '../disenyo/flechasobregris.gif';
		//alert(i);
		i = i + 1;
	}
document.getElementById(enlace_menu).style.color = '#000000';
document.getElementById(imagen).src = '../disenyo/flechasobregrisg.gif';

maximo2 = nsubmenus;
i = 1;
while (i<=maximo2)
	{			
		senlace ='submenu_enlace_'+i;
		
		if (document.getElementById(senlace))
			document.getElementById(senlace).style.color = '#FFFFFF';	
		//alert(i);
		i = i + 1;
	}
if (visualizacion != 3)
{
	parent.contenido_texto.location.href=documento2+"&enlace_menu="+enlace_menu+"&enlace_submenu="+0+"&nmenus="+nmenus+"&nsubmenus="+nsubmenus;
	//document.getElementById('titulo_menu').value = menu;
	//document.getElementById('titulo_submenu').value = '';
}
else
{
		//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
			{	
					parent.contenido_texto.location.href = url;
			}
		}
}

document.getElementById('ruta').innerHTML = "&nbsp;<a href='../index.php' class='donde' onMouseOver=this.style.textDecoration='underline' onMouseOut=this.style.textDecoration='none'>Home</a> / <a href='index.php' class='donde' onMouseOver=this.style.textDecoration='underline' onMouseOut=this.style.textDecoration='none'>" + servicio +"</a> / " + menu;
}

function mostrar()
{
	//alert(document.getElementById('destacados_content_oculto').style.zIndex):
	//alert('Hola');	
	document.getElementById('destacados_content_oculto').style.zIndex=998;	
	document.getElementById('destacados_content_oculto').style.display = 'block';	
	document.getElementById('menu_oculto').style.zIndex=997;
	document.getElementById('oculto').style.zIndex=996;
	document.getElementById('oculto').style.display = 'block';
	document.getElementById('mostrar').style.zIndex = 995;		
	collapse1.slidedown();		
	//crece('destacados_content_oculto', 175, 535); 
}

function ocultando_xsegundos()
{
	document.getElementById('destacados_content_oculto').style.zIndex=997;
	document.getElementById('destacados_content_oculto').style.display = 'none';
	document.getElementById('menu_oculto').style.zIndex=998;
	document.getElementById('menu_oculto').style.display = 'block';	
	document.getElementById('oculto').style.zIndex=995;
	document.getElementById('oculto').style.display = 'none';
	document.getElementById('mostrar').style.zIndex = 996;
	document.getElementById('mostrar').style.display = 'block';	
}

function ocultar()
{
	//alert(document.getElementById('destacados_content_oculto').style.zIndex):
	//alert('Hola');	
	//alert(document.getElementById('destacados_content_oculto').style.width);	
	collapse1.slideup();
	setTimeout("ocultando_xsegundos()", 510);
	
	//var collapse1=new animatedcollapse('destacados_content_oculto', 3000, false);
	
	
	//aumentar(-1);
	
}


///Cortina div
function $(x) { return document.getElementById(x); } 

function crece(id, w, h) { 
    var capa = $(id); 
    var creciendo = setInterval( function() { 
        if(capa.style.display==='none') { 
            capa.style.display = 'block'; 
            capa.style.width = "1px"; 
            //capa.style.height = "1px"; 
        } 
        else { 
            var anchoActual = parseInt( capa.style.width ); 
            //var altoActual = parseInt( capa.style.height ); 
            if( anchoActual < w ) 
                capa.style.width = (anchoActual+=2) +"px"; 
            //if( altoActual < h ) 
                //capa.style.height = (altoActual+=2) +"px"; 
            if( anchoActual>=w) 
                clearInterval(creciendo); 
        } 
    }, 1);  
} 

function decrece(capa) { 
    var decreciendo = setInterval( function() { 
        var anchoActual = parseInt( capa.style.width ) - 2; 
        var altoActual = parseInt( capa.style.height ) - 2; 
        if( anchoActual<0 ) anchoActual = 0; 
        if( altoActual<0 ) altoActual = 0; 
        if( anchoActual > 0 ) 
            capa.style.width = (anchoActual) +"px"; 
        if( altoActual > 0 ) 
            capa.style.height = (altoActual) +"px"; 
        if( anchoActual<=0 && altoActual<=0 ) { 
            capa.style.display = 'none'; 
            clearInterval(decreciendo); 
        } 
    }, 1); 
} 


this.findLeftObj = function(obj) {  
var curleft = 0;  
if (obj.offsetParent) {  
   while (obj.offsetParent) {  
    curleft += obj.offsetLeft  
    obj = obj.offsetParent;  
    }  
}  
else {  
 if(obj.x) {  
   curleft += obj.x;  
  }  
}  
return(curleft);  
}  
           
this.findTopObj = function(obj) {  
var curtop = 0;  
if (obj.offsetParent) {  
    while (obj.offsetParent) {  
        curtop += obj.offsetTop  
        obj = obj.offsetParent;  
    }  
}  
else {  
  if (obj.y) {  
    curtop += obj.y;  
   }  
}  
return(curtop);  
}  
   
function posicionImagen(imagen) {  
   
    posXImagen = findLeftObj(imagen);  
    posYImagen = findTopObj(imagen);  
       
    alert('La imagen está en la posición:\nLeft(X) ' + posXImagen +   
    '\nTop(Y) ' + posYImagen)  
   
} // Fin de la función posicionImagen()  
   

//Funcion que muestra el div en la posicion del mouse
function showdiv(event,imagen, img_act, imgname, imgdate, imgpie)
{
	//Toma el valor de la imagen pequeña para posicionarla
	posXImagen = findLeftObj(img_act);  
    posYImagen = findTopObj(img_act);  
       
    //alert('La imagen está en la posición:\nLeft(X) ' + posXImagen +   
   //'\nTop(Y) ' + posYImagen)  
	//determina un margen de pixels del div al raton	
	margin=0;

	//La variable IE determina si estamos utilizando IE
	var IE = document.all?true:false;

	var tempX = 0;
	var tempY = 0;

	//document.body.clientHeight = devuelve la altura del body
	if (IE)
	{ 
		tempX = event.x
		tempY = event.y
		tempX = event.clientX + document.body.scrollLeft;
        tempY = event.clientY + document.body.scrollTop;
	}
	else
	{ 
		document.captureEvents(Event.MOUSEMOVE);
		tempX = event.pageX;
		tempY = event.pageY;
	}

	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}

	
	
	
	
	posicion_real_y=parent.document.getElementById('content').offsetTop;
	posicion_real_x=parent.document.getElementById('content').offsetLeft;
	//posicionImagen(parent.document.getElementById('content'));
	/*Sigue al raton*/
	/*parent.document.getElementById('imagen_flotante').style.top = ((tempY+margin)+posicion_real_y)+"px";
	parent.document.getElementById('imagen_flotante').style.left = ((tempX+margin)+posicion_real_x)+"px";
	*/
	//alert(img_act.width);
	//alert(findLeftObj(document.getElementById('marco_contenido_servicio')));
	parent.document.getElementById('imagen_flotante').style.top = posYImagen+posicion_real_y+232+"px";
	parent.document.getElementById('imagen_flotante').style.left = (posicion_real_x+posXImagen+130)+"px";

	abrir_flotante(imagen, img_act, imgname, imgdate, imgpie);
	return true;
}

function abrir_flotante(imagen, img_act, imgname, imgdate, imgpie)
{
	parent.document.getElementById("imagen_flotante").style.visibility = 'visible';
	parent.document.getElementById("imagen_flotante").style.display = 'block';
	parent.document.imagen_div.src = imagen;
	parent.document.getElementById('img_name').value = imgname;
	parent.document.getElementById('img_date').value = imgdate;
	parent.document.getElementById('img_pie').value = imgpie;
}

function cerrar_flotante()
{		
	parent.document.getElementById("imagen_flotante").style.visibility = 'hidden';
	parent.document.getElementById("imagen_flotante").style.display = 'none';
}

function muevediv(event)
{
	//determina un margen de pixels del div al raton
	margin=30;

	//La variable IE determina si estamos utilizando IE
	var IE = document.all?true:false;

	var tempX = 0;
	var tempY = 0;

	if (IE)
	{ 
		tempX = event.x
		tempY = event.y
		tempX = event.clientX + document.body.scrollLeft;
        tempY = event.clientY + document.body.scrollTop;

		/*if(window.pageYOffset)
		{
			tempY=(tempY+window.pageYOffset);
			tempX=(tempX+window.pageXOffset);
		}
		else
		{
			tempY=(tempY+Math.max(document.body.scrollTop,document.documentElement.scrollTop));
			tempX=(tempX+Math.max(document.body.scrollLeft,document.documentElement.scrollLeft));
		}*/
	}
	else{ 
		document.captureEvents(Event.MOUSEMOVE);
		tempX = event.pageX;
		tempY = event.pageY;
	}
	
	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}
	
	//parent.document.getElementById('posicion').innerHTML="PosX = "+tempX+" | PosY = "+tempY;
	
	posicion_real_y=document.getElementById('marco_contenido_servicio').offsetTop+90;
	posicion_real_x=document.getElementById('marco_contenido_servicio').offsetLeft+180;
	
	parent.document.getElementById('imagen_flotante').style.top = ((tempY+margin)+posicion_real_y)+"px";
	parent.document.getElementById('imagen_flotante').style.left = ((tempX+margin)+posicion_real_x)+"px";
	
	/*parent.document.getElementById('imagen_flotante').style.top = ((tempY+margin)-100)+"px";
	if (tempX <= 320)
		parent.document.getElementById('imagen_flotante').style.left = (tempX+margin)+"px";
	else
		parent.document.getElementById('imagen_flotante').style.left = ((tempX+margin)-250)+"px";
	*/
	return true;
}


