var tamanoAncho=2;
var tamanoAlto=2;
var TamanoFuente=1;
var EstadoCapas="Off";

var ua = navigator.userAgent.toLowerCase();
function detect(text) {
   stringposition = ua.indexOf(text) + 1;
   data = text;
   return stringposition;
}


var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();


/* <![CDATA[ */
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;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

//function openwindowProducto(id){
//	window.open('/popup.php?id='+id,'Imagen'+id,'resizable=yes,menubar=no,toolbar=no,scrollbars=yes,width=468,height=300,top=50,left=50');
//}


/*-----------------------------------------------------------------------------------------*/		
function CheckEmailAddress(value){
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(value)){
		return true;
	}else{
		return false;
	}
}

function VerificarMail(strMail) {
//La siguiente funcion da error si se introduce algo.usuario@dominio.es
	var patMail = /^(.+)@(.+)$/;
	var patUser = /^[a-zñA-Z\d_-]+(\.[a-zñA-Z\d_-]+)*$/;
	var patDomainIP = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
	var patDomain = /^[a-zñA-Z\d_-]+(\.[a-zñA-Z\d_-]+)+$/;
	var matchArray = strMail.match(patMail);
	if(matchArray == null){return false;}
	var user = new String(matchArray[1]);
	var domain = new String(matchArray[2]); 
	if(user.match(patUser) == null){return false;}
	var IPArray = domain.match(patDomainIP);
	if(IPArray != null){ 
		 for (var i=1;i<=4;i++) {
		  if(IPArray[i]>255){return false;}
		 }
		 return true; 
	}
	var domainArray = domain.match(patDomain);
	if(domainArray == null) {return false;}
	if(domainArray[domainArray.length - 1].length < 3 || domainArray[ domainArray.length - 1].length > 5) { return false;}
	return true;
}

function validarEmail(valor) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
    return (true)
  } else {
    alert("La dirección de Email es incorrecta.");
    return (false);
  }
}

function restrictLetraNum(idElementoPasarFoco){//funcion para onKeypress
	//if (event.keyCode == 13) document.getElementById(idElementoPasarFoco).focus();
	//Sólo numerico
	//if (event.keyCode < 48) event.returnValue = false;
	//if (event.keyCode > 57 && event.keyCode < 65) event.returnValue = false;
	//if (event.keyCode > 90 && event.keyCode < 97) event.returnValue = false;
	//if (event.keyCode > 122) event.returnValue = false;
}

function validarEntero(valor){
	if(valor!=0){
		valor = parseInt(valor);
		if (isNaN(valor)) {
			return "";
		}
	}
	return valor;
}

function validarFloat(valor){
	if(valor!=0){
		valor = parseFloat(valor);
		if (isNaN(valor)) {
			return "";
		}
	}
	return valor;
}

function Redondear(x, places){
	return Math.round(x * Math.pow(10, places)) / Math.pow(10, places);
}

function str_replace(haystack, needle, replacement) {
	if(haystack.indexOf(needle) != -1) {
		var temp = haystack.split(needle);
		return temp.join(replacement);
	}
	return haystack;
}

function dateToIngles(strFecha){
	//Esta funcion cambia el formato dd/mm/yyyy por yyyy/mm/dd
	//Es util para comparar fechas como cadenas (para ver cual es mayor o menor)
	var arrayFecha = strFecha.split("/");
	var dia =  arrayFecha[0];
	var mes =  arrayFecha[1];
	var anio =  arrayFecha[2];
	return anio + "/" + mes + "/" + dia;
}
/* ]]> */

function MostrarSubmenu(IdMenu) {
	document.getElementById('SubMenu'+IdMenu).style.display = 'block';
	document.getElementById(IdMenu).style.backgroundColor = '#e8e8e8';
	document.getElementById(IdMenu).style.color ='#002b6c';
}

function OcultarSubmenu(IdMenu) {
	document.getElementById('SubMenu'+IdMenu).style.display = 'none';
	document.getElementById(IdMenu).style.backgroundColor = '#3e0000';
	document.getElementById(IdMenu).style.backgroundColor = '#001D3E';
	document.getElementById(IdMenu).style.color ='#fff';	
}

function AumentarFuente() {
	if (TamanoFuente<1.2) {
		TamanoFuente=TamanoFuente+0.1;
		document.getElementById('ColumnaCentral').style.fontSize=TamanoFuente+"em";
	}
}

function ReducirFuente() {
	if (TamanoFuente>1) {
		TamanoFuente=TamanoFuente-0.1;
		document.getElementById('ColumnaCentral').style.fontSize=TamanoFuente+"em";
	}
}

function charactermax(id,idreturn){
	var longit = document.getElementById(id).value.length;
	if(!longit) {longit = '0';}
	document.getElementById(idreturn).innerHTML = longit;

	if (longit>2500) {
		document.getElementById('Contador').style.color= '#990000';
		document.getElementById('Contador').style.fontWeight= 'bold';
	}else{
		if (longit>2200 && longit<2500) {
			document.getElementById('Contador').style.color= '#ff6000';
		}else{
			document.getElementById('Contador').style.color= '#999999';
		}
		document.getElementById('Contador').style.fontWeight= 'normal';
	}
}


function CorregirFormulario(elemento,Variable) {
	if (document.getElementById(elemento).value==Variable) {
		document.getElementById(elemento).value="";
	}
}


/* FUNCIONES PARA POPUPS POR CAPAS */
function VerCreciente(NombreCapa, ancho, alto) {
	if (EstadoCapas=="Off") {
		document.getElementById(NombreCapa).style.display = "block";
		redibujarCreciente(NombreCapa,ancho, alto);	
		tamanoAncho=20;
		tamanoAlto=11;	
	}
}

function redibujarCreciente(NombreCapa2, ancho, alto) {
	if (tamanoAncho<ancho || tamanoAlto<alto)  {
		if (tamanoAncho<ancho)  {
			tamanoAncho=tamanoAncho+20;
			document.getElementById(NombreCapa2).style.width = tamanoAncho+"px";
			document.getElementById(NombreCapa2).style.marginLeft = ((385-(tamanoAncho/2))+10)+"px";		
		}
		if (tamanoAlto<alto) {
			tamanoAlto=tamanoAlto+10;
			document.getElementById(NombreCapa2).style.height = tamanoAlto+"px";
			document.getElementById(NombreCapa2).style.marginTop = (200-(tamanoAlto/2))+"px";		
		}
		setTimeout("redibujarCreciente('"+NombreCapa2+"',"+ancho+", "+alto+")",5);
	}else{
		document.getElementById('Contenido'+NombreCapa2).style.display='block';
		EstadoCapas="On";
	}
}

function OcultarMenguante(NombreCapa) {
	if (EstadoCapas=="On") {
		document.getElementById('Contenido'+NombreCapa).style.display='none';
		redibujarMenguante(NombreCapa);
	}
}

function redibujarMenguante(NombreCapa2) {
	if (tamanoAncho>21 && tamanoAlto>11)  {
		tamanoAncho=tamanoAncho-20;
		document.getElementById(NombreCapa2).style.width = tamanoAncho+"px";
		document.getElementById(NombreCapa2).style.marginLeft = ((385-(tamanoAncho/2))+10)+"px";		
		tamanoAlto=tamanoAlto-10;
		document.getElementById(NombreCapa2).style.height = tamanoAlto+"px";
		document.getElementById(NombreCapa2).style.marginTop = (200-(tamanoAlto/2))+"px";		
		setTimeout("redibujarMenguante('"+NombreCapa2+"')",5);
	}else {
		tamanoAncho=2;
		tamanoAlto=2;
		document.getElementById(NombreCapa2).style.display = "none";
		EstadoCapas="Off";
	}
}



/* FUNCION CARRUSELL EMPRESAS */

	
function CarrusellProductos (NombreElementoAFundir) {
	//alert("Total: " + NumElementos+"\nContador: "+contador)
	if (contador<NumElementos-1) {
		contador++;
	}else{
		contador=0;
	}
	setTimeout("AlphaOut(100,"+contador+",'"+NombreElementoAFundir+"')",100);
}

function AlphaOut(NivelTransparencia,contador,NombreElementoAFundir) {
	imgobj=document.getElementById(NombreElementoAFundir);
	if (NivelTransparencia>0) {
		if (BrowserDetect.browser=="Firefox") {
			imgobj.style.MozOpacity=NivelTransparencia/100;
		} else {
			if (BrowserDetect.browser=="Explorer") {
				imgobj.style.filter = "alpha(opacity=" + NivelTransparencia + ")";
			} else {
				imgobj.style.opacity = NivelTransparencia/100; 
			}
		}
		NivelTransparencia-=10;
		setTimeout("AlphaOut("+NivelTransparencia+","+contador+",'"+NombreElementoAFundir+"')",100);
	}else{
		if (BrowserDetect.browser=="Firefox") {
			imgobj.style.MozOpacity=0;
		} else {
			if (BrowserDetect.browser=="Explorer") {
				imgobj.style.filter = "alpha(opacity=0)";
			} else {
				imgobj.style.opacity = 0; 
			}
		}
		document.getElementById('FotoProductos').src = '/img/'+Fotos[contador];		
		document.getElementById('EnlaceProductos').href = Enlaces[contador];
		document.getElementById('EnlaceProductosFoto').href = Enlaces[contador];
		document.getElementById('EnlaceProductos').innerHTML = Nombres[contador];
		document.getElementById('PrecioProductos').href = Enlaces[contador];			
		document.getElementById('PrecioProductos').innerHTML = Precios[contador];
		if (BrowserDetect.browser=="Firefox") {
			imgobj.style.MozOpacity=0;
		} else {
			if (BrowserDetect.browser=="Explorer") {
				imgobj.style.filter = "alpha(opacity=0)";
			} else {
				imgobj.style.opacity = 0; 
			}
		}		
		setTimeout("AlphaIn(0,'"+NombreElementoAFundir+"')",100);	
	}
}

function AlphaIn(NivelTransparencia,NombreElementoAFundir) {
	imgobj=document.getElementById(NombreElementoAFundir);
	if (NivelTransparencia<=90) {
		if (BrowserDetect.browser=="Firefox") {
			imgobj.style.MozOpacity=NivelTransparencia/100;
		} else {
			if (BrowserDetect.browser=="Explorer") {
				imgobj.style.filter = "alpha(opacity=" + NivelTransparencia + ")";
			} else {
				imgobj.style.opacity = NivelTransparencia/100; 
			}
		}
		NivelTransparencia+=10;
		setTimeout("AlphaIn("+NivelTransparencia+",'"+NombreElementoAFundir+"')",100);
	}else{
		if (BrowserDetect.browser=="Firefox") {
			imgobj.style.MozOpacity=1;
		} else {
			if (BrowserDetect.browser=="Explorer") {
				imgobj.style.filter = "alpha(opacity=100)";
			} else {
				imgobj.style.opacity = 1; 
			}
		}	
		setTimeout("CarrusellProductos('"+NombreElementoAFundir+"')",VelocidadCarrusel);	
	}
}

	function position(event){
	   var x = event.clientX+document.body.scrollLeft;
	   var y = event.clientY+document.body.scrollTop+document.documentElement.scrollTop;
	   document.getElementById('CajaEnMapa').style.top= (y-61)+'px';
	   document.getElementById('CajaEnMapa').style.left= (x+10)+'px';  
	}
	function MostrarInformacion(LineaTexto) {
		document.getElementById('CajaEnMapa').style.display = 'block';
		document.getElementById('TextoCajaEnMapa').innerHTML  = Textos[LineaTexto];
	}
	function OcultarInformacion() {
		document.getElementById('CajaEnMapa').style.display = 'none';
	}	
	
	function MostrarContenidos(IdCaja) {
		if (document.getElementById("Contenidos"+IdCaja).style.display == 'block') {
			document.getElementById("Contenidos"+IdCaja).style.display = 'none';
		} else {
			var mylist = document.getElementById("ListadoDeCajasContenidos")
			var listitems= mylist.getElementsByTagName('div')
			for (i=0; i<listitems.length; i++) {
				listitems[i].style.display="none";
			}		
			document.getElementById("Contenidos"+IdCaja).style.display = 'block';
		}
	}
	
	function MeOculto(IdAOcultar) {
		document.getElementById(IdAOcultar).style.display = 'none';
	}
	
	function MostrarContenidosEXPO(IdCaja) {
		if (document.getElementById("Contenidos"+IdCaja).style.display == 'block') {
			document.getElementById("Contenidos"+IdCaja).style.display = 'none';
		} else {
			var mylist = document.getElementById("ListadoDeCajasContenidos")
			var listitems= mylist.getElementsByTagName('div')
			for (i=0; i<listitems.length; i++) {
				listitems[i].style.display="none";
			}		
			document.getElementById("Contenidos"+IdCaja).style.display = 'block';
		}
	}
	
	function MostrarInformacionEXPO(LineaTexto) {
		document.getElementById('CajaEnMapa').style.display = 'block';
		document.getElementById('TextoCajaEnMapa').innerHTML  = '<strong>' + document.getElementById(LineaTexto).alt + '</strong><br /> Pulsa para ver contenidos';
	}
	
	
	

			
/* ONBLUR DESDE JAVASCRIPT DE TODOS LOS FORMULARIOS. */			

function MarcadoresDeFormularios() {
	var inputes=document.getElementsByTagName('input');
	var textareas=document.getElementsByTagName('textarea');
	var selectes=document.getElementsByTagName('select');
	var valor = '';
	var numElementosInput = inputes.length;
	var numElementosTextareas = textareas.length;
	var numElementosSelect = selectes.length;
	for (contador=0; contador<numElementosInput; contador++) {
		if (inputes[contador].type=='radio' || inputes[contador].type=='checkbox') {
			inputes[contador].style.backgroundImage= "none";
			inputes[contador].style.border="0px"
		}
		if (inputes[contador].className!='Boton' && inputes[contador].type!='radio' && inputes[contador].type!='checkbox') {
			inputes[contador].onfocus= function() { 
				this.style.border= '1px solid #00a7ed';
			}
			inputes[contador].onblur= function() { 
				this.style.border= '1px solid #c0c0c0';
			}
		}
	}
	for (contador=0; contador<numElementosTextareas; contador++) {
		textareas[contador].onfocus= function() { this.style.border= '1px solid #00a7ed';}
		textareas[contador].onblur= function() { this.style.border= '1px solid #c0c0c0';}
	}		
	for (contador=0; contador<numElementosSelect; contador++) {
		selectes[contador].onfocus= function() { this.style.border= '1px solid #00a7ed';}
		selectes[contador].onblur= function() { this.style.border= '1px solid #c0c0c0';}
	}			
}


/* FUNCIONES VISOR PORTADA */

var tiempoEspera 		= 8000;
var velocidadEfecto 	= 10;
var EsperaEfecto 		= 50;
var numeroOpcionActiva	= 1;
var opcionActiva		= 'Opcion1';
var RollOverVisor		= false;
var Transicion			= false;
var opacidad 			= 100;
var PlayerVisor 		='';

imagen = new Image();

function activarPestanna(Selecccionado) {
	if (FotosVisor[1].complete) flag1=true;
	if (FotosVisor[2].complete) flag2=true;
	if (FotosVisor[3].complete) flag3=true;					

	if (flag1 && flag2 && flag3 && Selecccionado!=numeroOpcionActiva) {
		if (!Transicion) {
			numeroOpcionActiva=Selecccionado;
			fadeOut();
		}
	}
}

function CarrusellRutas () {

	if (FotosVisor[1].complete) flag1=true;
	if (FotosVisor[2].complete) flag2=true;
	if (FotosVisor[3].complete) flag3=true;					

	if (flag1 && flag2 && flag3) {
		numeroOpcionActiva++;
		if (numeroOpcionActiva>3) {
			numeroOpcionActiva=1;
		}
		fadeOut();				
	} else {
	 	PlayerVisor = setTimeout ('CarrusellRutas()',tiempoEspera);
	}
}

function fadeOut() {

	clearTimeout(PlayerVisor);

	Transicion	= true;
	opacidad=opacidad-velocidadEfecto;

	if (opacidad>=0) {
		document.getElementById('DatosVisor').style.opacity = (opacidad/100);
		document.getElementById('Pantalla').style.opacity = (opacidad/100);
		document.getElementById('DatosVisor').style.filter = 'alpha(opacity=' + opacidad + ')';
		document.getElementById('Pantalla').style.filter = 'alpha(opacity=' + opacidad + ')';		
		
		/* EFECTO ZOOM OUT */
		/* 
		document.getElementById('FotoVisor').style.width = opacidad+'%';
		document.getElementById('FotoVisor').style.marginTop = ((100-opacidad)/3)+'%';
		document.getElementById('FotoVisor').style.marginLeft = ((100-opacidad)/2)+'%';	
		*/
		
		
		EfectoPlayer=setTimeout ('fadeOut()',EsperaEfecto);
		
	}else{
	
		/* Modifica la pestana activa del menu */
		document.getElementById(opcionActiva).className='';
		opcionActiva= 'Opcion'+numeroOpcionActiva;		
		document.getElementById(opcionActiva).className='Activo';		

		/* Carga de datos en el visor */
		document.getElementById('EnlaceVis1').innerHTML = TitulosVisor[numeroOpcionActiva];
		document.getElementById('FotoVisor').src=FotosVisor[numeroOpcionActiva].src;
		document.getElementById('TextoVisor').innerHTML = TextosVisor[numeroOpcionActiva];
		document.getElementById('FotoVisor').alt = TitulosVisor[numeroOpcionActiva];	
		document.getElementById('EnlaceVis1').href = EnlacesVisor[numeroOpcionActiva];
		document.getElementById('EnlaceVis2').href = EnlacesVisor[numeroOpcionActiva];			

		imagen = FotosVisor[numeroOpcionActiva];
		
		fadeIn();
	}
}

function fadeIn() {
	opacidad=opacidad+velocidadEfecto;
	if (opacidad<=100) {
		document.getElementById('DatosVisor').style.opacity = (opacidad/100);
		document.getElementById('Pantalla').style.opacity = (opacidad/100);
		document.getElementById('DatosVisor').style.filter = 'alpha(opacity=' + opacidad + ')';
		document.getElementById('Pantalla').style.filter = 'alpha(opacity=' + opacidad + ')';
		
		/* EFECTO ZOOM OUT */
		/*
		document.getElementById('FotoVisor').style.width = opacidad+'%';
		document.getElementById('FotoVisor').style.marginTop = ((100-opacidad)/3)+'%';
		document.getElementById('FotoVisor').style.marginLeft = ((100-opacidad)/2)+'%';
		*/
		
		
		EfectoPlayer=setTimeout ('fadeIn()',EsperaEfecto);
		
		
		
	}else{
		Transicion	= false;
		/* EFECTO ZOOM OUT */
		/*
		document.getElementById('FotoVisor').style.marginTop = '0px';
		document.getElementById('FotoVisor').style.marginLeft = '0px';		
		document.getElementById('FotoVisor').style.width = '100%';				
		*/
		PlayerVisor=setTimeout ('CarrusellRutas()',tiempoEspera);		
	}
}
	
	


/*---------------------------------------------------------------------*/

/* FUNCION QUE FLOTA UN TEXTO JUNTO AL PUNTERO DEL RATON. */
/* ---- Abel Tena - 02 marzo 2009 ---- */

	function position(event){
	   var x = event.clientX+document.body.scrollLeft;
	   var y = event.clientY+document.body.scrollTop+document.documentElement.scrollTop;
	   document.getElementById('CajaFlotante').style.top= (y-61)+'px';
	   document.getElementById('CajaFlotante').style.left= (x+13)+'px';  
	}

	function MostrarInformacion(NoticiaCorrelativa,LineaTexto) {
		document.getElementById('CajaFlotante').style.display = 'block';
		document.getElementById('TextoCajaFlotante').innerHTML  = LineaTexto;
		document.getElementById('NoticiaCorrelativa').innerHTML  = NoticiaCorrelativa;
	}

	function OcultarInformacion() {
		document.getElementById('CajaFlotante').style.display = 'none';
		document.getElementById('TextoCajaFlotante').innerHTML  = '';		
		document.getElementById('NoticiaCorrelativa').innerHTML  = '';
	}	
/*---------------------------------------------------------------------*/



/*---------------------------------------------------------------------*/

/* FUNCION QUE MUESTRA UN CUBREPAGINAS. */
/* ---- Abel Tena - 03 marzo 2009 ---- */

function mostrarCubrepaginas(URLIframe){
	var anchoDePantalla = document.body.clientWidth;
	document.getElementById('Cubrepaginas').style.marginTop='0px';	
	document.getElementById('Cubrepaginas').style.display = 'block';
	if (detect('msie')){ 
		document.getElementById('CuerpoPrincipal').scroll = 'no';
		document.getElementById('Cubrepaginas').style.filter= 'alpha(opacity=93)';
	}else{	
		document.getElementById('CuerpoPrincipal').style.overflow = 'hidden';
		document.getElementById('Cubrepaginas').style.opacity = '0.93';
	}	
/*	document.getElementById('IframeComun').src=URLIframe;*/
	parent.top.location = '#cabecera';

    document.getElementById('IframeComun').src = URLIframe; 
	setTimeout ('Ejecutar("'+URLIframe+'")',300)
}

function Ejecutar(URLIframe) {
	document.getElementById('IframeHerramientas').style.display = 'block';
}

function ocultarCubrepaginas(){
	document.getElementById('IframeComun').src='/noticias/vacio.php';
	document.getElementById('Cubrepaginas').style.display = 'none';
	document.getElementById('IframeHerramientas').style.display = 'none';
	if (detect('msie')){ 
		document.getElementById('CuerpoPrincipal').scroll = 'yes';	
	}else{	
		document.getElementById('CuerpoPrincipal').style.overflow = 'auto';
	}
}

function monstrarCapa(Elemento) {

	if (document.getElementById(Elemento).style.display != 'block') {
		document.getElementById(Elemento).style.display = 'block';
	}else{
		document.getElementById(Elemento).style.display = 'none';
	}
}





/*---------------------------------------------------------------------*/

/* FUNCION QUE MUESTRA UN CUBREPAGINAS. */
/* ---- Abel Tena - 26 marzo 2009 ---- */

function mostrarFoto(NombreFoto,TextoFoto){
	if (detect('msie')){ 	
		var ScrollDePantalla =  window.document.documentElement.scrollTop;
		var TotalPantalla =  window.document.documentElement.scrollBottom;
	}else{
		var ScrollDePantalla =  window.pageYOffset;	
	}	
	document.getElementById('FotoPopUp').src=NombreFoto;
	document.getElementById('FotoPopUp').alt=TextoFoto;
	if (TextoFoto!="") {
		document.getElementById('TextoFotoPopUp').style.display = 'block';
	}
	document.getElementById('TextoFotoPopUp').innerHTML=TextoFoto;
	document.getElementById('Cubrepaginas').style.marginTop=(ScrollDePantalla)+"px";	
	document.getElementById('Cubrepaginas').style.display = 'block';
	
	if (detect('msie')){ 
		document.getElementById('CuerpoPrincipal').scroll = 'no';
		document.getElementById('Cubrepaginas').style.filter= "alpha(opacity=85)";
	}else{	
		document.getElementById('Cubrepaginas').style.opacity = '0.85';
		document.getElementById('CuerpoPrincipal').style.overflow = 'hidden';
	}	
	
	document.getElementById('PopUpFoto').style.display = 'block';	
	centradoEnPagina();
}

function ocultarCubrepaginasFoto(){
	document.getElementById('FotoPopUp').src="/img/Loader.gif";
	document.getElementById('FotoPopUp').alt="";
	document.getElementById('Cubrepaginas').style.display = 'none';
	document.getElementById('PopUpFoto').style.display = 'none';
	document.getElementById('TextoFotoPopUp').style.display = 'none';
	document.getElementById('EnlaceFoto').style.marginTop= "0px";
	
	if (detect('msie')){ 
		document.getElementById('CuerpoPrincipal').scroll = 'yes';	
	}else{	
		document.getElementById('CuerpoPrincipal').style.overflow = 'auto';
	}
	
}

function centradoEnPagina() {
	setTimeout("CalcularCentradodeFoto()",1400);
}

function CalcularCentradodeFoto() {
	var altoImagen = document.getElementById('FotoPopUp').clientHeight;
	if (detect('msie')){ 	
		var altoDePantalla = document.body.clientHeight;
		var altoDePantalla = document.documentElement.clientHeight;
		var ScrollDePantalla =  window.document.documentElement.scrollTop;
	}else{
		var altoDePantalla =  window.innerHeight;	
		var ScrollDePantalla =  window.pageYOffset;	
	}

	if (altoDePantalla-altoImagen>0) {
		var margenImagen = ((altoDePantalla-altoImagen)/2);
	}else{
		var margenImagen = 0;
	}
	var espaciadoSuperior=parseInt(ScrollDePantalla)+parseInt(margenImagen)-20;
	document.getElementById('PopUpFoto').style.marginTop= ""+espaciadoSuperior+"px";
}

