var ua = navigator.userAgent.toLowerCase();
function detect(text) {
   stringposition = ua.indexOf(text) + 1;
   data = text;
   return stringposition;
}

/* VALIDAR JS */
function VerificarMail(strMail) {
//La siguiente funcion da error si se introduce algo.usuario@dominio.es
	var patMail = /^(.+)@(.+)$/;
	var patUser = /^[a-zA-Z\d_-]+(\.[a-zA-Z\d_-]+)*$/;
	var patDomainIP = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
	var patDomain = /^[a-zA-Z\d_-]+(\.[a-zA-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;
}

/* FUNCION QUE REDUCE ESPACIOS EN LOCALIZACION DE BANNERS VACIOS */
/* CON http://ads.grupozeta.es/RealMedia/ads/Creatives/default/empty.gif DENTRO */

function OcultaEspacioBannersVacios () {

	var ua = navigator.userAgent.toLowerCase();

	function detect(text) {

	   stringposition = ua.indexOf(text) + 1;

	   data = text;

	   return stringposition;

	}

	var Capas = document.getElementsByTagName("div");

	for (var i=0; i<Capas.length; i++) {

		if (detect('msie')){

			if (Capas[i].getAttribute("className")=="Publicidadx01" || Capas[i].getAttribute("className")=="PublicidadTop3" || Capas[i].getAttribute("className")=="PublicidadTop1" || Capas[i].getAttribute("className")=="PublicidadTopRight" || Capas[i].getAttribute("className")=="PublicidadBottom1" || Capas[i].getAttribute("className")=="PublicidadPosition1" || Capas[i].getAttribute("className")=="PublicidadBottom2" || Capas[i].getAttribute("className")=="PublicidadMiddle3" || Capas[i].getAttribute("className")=="PublicidadTopLeft" || Capas[i].getAttribute("className")=="PublicidadLeft3" || Capas[i].getAttribute("className")=="PublicidadMiddle1" || Capas[i].getAttribute("className")=="PublicidadFrame2" || Capas[i].getAttribute("className")=="PublicidadMiddle2") {

				var BannerImg = Capas[i].getElementsByTagName("img");

				if (BannerImg!=null) {

					for (var n=0; n<BannerImg.length; n++) {

						ContieneEspacioVacio=BannerImg[n].getAttribute("src");

						if(ContieneEspacioVacio =='http://ads.grupozeta.es/RealMedia/ads/Creatives/default/empty.gif'){

							Capas[i].style.display = "none";

						}

					}

				}

			}	 

			if (Capas[i].getAttribute("className")=="PublicidadTop1") {

				var BannerImg = Capas[i].getElementsByTagName("img");

				if (BannerImg!=null) {

					for (var n=0; n<BannerImg.length; n++) {

						ContieneEspacioVacio=BannerImg[n].getAttribute("src");

						if(ContieneEspacioVacio =='http://ads.grupozeta.es/RealMedia/ads/Creatives/default/empty.gif'){

							document.getElementById('publicidadCabecera').style.display = "none";

						}

					}

				}

			}

			if (Capas[i].getAttribute("className")=="PublicidadTop1") {

				if (Capas[i].innerHTML.indexOf('<!--  -->')!=-1){

					Capas[i].style.display = "none";

					document.getElementById('publicidadCabecera').style.display = "none";

				}

			}			

		}else{

			if (Capas[i].getAttribute("class")=="Publicidadx01" || Capas[i].getAttribute("class")=="PublicidadTop3" || Capas[i].getAttribute("class")=="PublicidadTop1" || Capas[i].getAttribute("class")=="PublicidadTopRight" || Capas[i].getAttribute("class")=="PublicidadBottom1" || Capas[i].getAttribute("class")=="PublicidadPosition1" || Capas[i].getAttribute("class")=="PublicidadBottom2" || Capas[i].getAttribute("class")=="PublicidadMiddle3" || Capas[i].getAttribute("class")=="PublicidadTopLeft" || Capas[i].getAttribute("class")=="PublicidadLeft3" || Capas[i].getAttribute("class")=="PublicidadMiddle1" || Capas[i].getAttribute("class")=="PublicidadFrame2" || Capas[i].getAttribute("class")=="PublicidadMiddle2") {

				var BannerImg = Capas[i].getElementsByTagName("img");

				if (BannerImg!=null) {

					for (var n=0; n<BannerImg.length; n++) {

						ContieneEspacioVacio=BannerImg[n].getAttribute("src");

						if(ContieneEspacioVacio =='http://ads.grupozeta.es/RealMedia/ads/Creatives/default/empty.gif'){

							Capas[i].style.display = "none";

						}

					}

				}

			}

			if (Capas[i].getAttribute("class")=="PublicidadTop1") {

				if (Capas[i].innerHTML.indexOf('<!--  -->')!=-1){

					Capas[i].style.display = "none";

					document.getElementById('publicidadCabecera').style.display = "none";

				}

			}

		}

	}

}



/* ---- FUNCIONES COMPORTAMIENTO DE ESTILOS DE BUSCADOR DE CABECERA ---- */
/* ---- Abel Tena - 26 feb 2009 ---- */

function ActivarBuscador() {
	document.getElementById('q').style.border = "2px solid #00a7ed";
	document.getElementById('q').style.padding= "2px";	
	if (document.getElementById('q').value == "Texto a buscar...") {
		document.getElementById('q').value = "";
	}
	document.getElementById('q').style.color = "#000";
	document.getElementById('q').style.color = "#000";
}

function DesactivarBuscador() {
	document.getElementById('q').style.border = "1px solid #939394";
	document.getElementById('q').style.padding= "3px";
	
	if (document.getElementById('q').value == "") {
		document.getElementById('q').style.color = "#888";
		document.getElementById('q').value = "Texto a buscar...";
	}
}

function CompruebaBusqueda() {
	if (document.getElementById('q').value == "Texto a buscar...") {
		document.getElementById('q').value = "Mediterráneo";
	}	
}


//==========================================================================
// Función de apertura de ventanas flotantes.
//==========================================================================
function openw2(foto,ancho,alto,scrol){
	var centroy=((screen.availHeight - alto)/2);
	var centrox=((screen.availWidth - ancho)/2);
	window.open(foto,"IWIN","toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars="+scrol+",resizable=yes,copyhistory=no,width="+ancho+",height="+alto+",left="+centrox+",top="+centroy)
}

function openw(foto,ancho,alto,scrol)
{
	var centroy=((screen.availHeight - alto)/2);
	var centrox=((screen.availWidth - ancho)/2);
	window.open(foto,"IWIN","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scrol+",resizable=no,copyhistory=no,width="+ancho+",height="+alto+",left="+centrox+",top="+centroy)
}

/*---------------------------------------------------------------------*/


/*---------------------------------------------------------------------*/

/* ---- FUNCIONES MUESTRA Y OCULTA EL MENU DE SECCIONES ---- */
/* ---- Abel Tena - 26 feb 2009 ---- */

function mostrarSubMenuMasSecciones() {
		document.getElementById('SubMenuMasSecciones').style.display = 'block';
		document.getElementById('OpcMasSecciones').style.color = '#002daf';
		document.getElementById('OpcMasSecciones').style.backgroundColor="#ffffff";
		document.getElementById('OpcMasSecciones').style.backgroundImage = 'url(/img/fondo_OpcEdicion3.gif)';
}

function ocultarSubMenuMasSecciones() {
		document.getElementById('SubMenuMasSecciones').style.display="none";
		document.getElementById('OpcMasSecciones').style.color = '#ffffff';
		document.getElementById('OpcMasSecciones').style.backgroundColor = '#2e65dc';
		document.getElementById('OpcMasSecciones').style.backgroundImage = 'url(/img/fondo_OpcEdicion2.gif)';
}

/*---------------------------------------------------------------------*/

/* ---- FUNCIONES MUESTRA Y OCULTA EL MENU DE EDICIONES ---- */
/* ---- Abel Tena - 26 feb 2009 ---- */

function mostrarSubmenuEdicion() {
		document.getElementById('SubMenuEdicion').style.display = 'block';
		//document.getElementById('OpcEdicion').style.color = '#004ab9';
		//document.getElementById('OpcEdicion').style.backgroundColor = '#f6f6f6';
		//document.getElementById('OpcEdicion').style.backgroundImage = 'url(/img/fondo_OpcEdicion.gif)';
		document.getElementById('OpcEdicion').style.borderBottom = '1px solid #ffc335';
}

function ocultarSubmenuEdicion() {
		document.getElementById('SubMenuEdicion').style.display="none";
		//document.getElementById('OpcEdicion').style.color = '#290f00';
		//document.getElementById('OpcEdicion').style.backgroundColor="#ffc335";
		//document.getElementById('OpcEdicion').style.backgroundImage = 'url(/img/fondo_OpcEdicion.gif)';
		document.getElementById('OpcEdicion').style.borderBottom = '1px solid #002daf';
}

/*---------------------------------------------------------------------*/

/* ---- FUNCIONES GALERIA EN COLUMNA DERECHA ---- */
/* ---- Abel Tena - 27 feb 2009 ---- */
	  
function CargarFotoEnCajaGaleria(i) {
	document.getElementById('FotoPrincipal_Cajagaleria').src	= Imagen_src[i];
	document.getElementById('Titulo_CajaGaleria').innerHTML		= '<a id="Link_FotoPrincipal_Cajagaleria2" href="' + Imagen_url[i] + '">' + Imagen_title[i] + '</a>';
	document.getElementById('Descripcion_CajaGaleria').innerHTML= Imagen_descrip[i];
	document.getElementById('Link_FotoPrincipal_Cajagaleria').href= Imagen_url[i];

}	  
	  
	  
	  
/*---------------------------------------------------------------------*/

/* MUESTRA LA CAJA DE COMPARTIR CON AGREGADORES */
/* ---- Abel Tena - 02 marzo 2009 ---- */

	function MostrarCompartir(URLNoticia) {
		if (document.getElementById('CajaComparte').style.display!="block") {
			document.getElementById('Comparte').className="ShareActivo";
			document.getElementById('CajaComparte').style.display="block";
			if (document.getElementById('IframeCajaComparte').src=="") {
				document.getElementById('IframeCajaComparte').src="comparte.asp"+"?IdNoticia="+URLNoticia;
			}
		}else{
			document.getElementById('Comparte').className="ShareInactivo";
			document.getElementById('CajaComparte').style.display="none";
		}	
	}
	
/*---------------------------------------------------------------------*/

/* AUNMENTAR Y REDUCIR TEXTO DE LAS NOTICIAS */
/* ---- Abel Tena - 02 marzo 2009 ---- */



function ampliarTexto(bloque){
	if (document.getElementById(bloque).style.fontSize== '1.2em') {
		document.getElementById(bloque).style.fontSize= '1.4em';
	}else{
		if (document.getElementById(bloque).style.fontSize!= '1.4em') {
			document.getElementById(bloque).style.fontSize= '1.2em';
		}
	}
}

function reducirTexto(bloque){
	document.getElementById(bloque).style.fontSize= '1em';
}

/*---------------------------------------------------------------------*/

/* FUNCION QUE MUESTRA Y OCULTA LA CAJA DE AVISO DE COMENTARIOS */
/* ---- Abel Tena - 02 marzo 2009 ---- */

function MostrarCajaAviso(id,numElementos)
{
	for (i=0; i<numElementos; i++)
	{
		if ("CajaAviso"+i != id)
		{
			document.getElementById("CajaAviso"+i).style.display="none";
		}
	}
	
	if (document.getElementById(id).style.display=="block")
	{
		document.getElementById(id).style.display="none";
	}
	else
	{
		document.getElementById(id).style.display="block";	
	}
}


/*---------------------------------------------------------------------*/

/* 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.display = 'block';
	if (detect('msie')){ 
		document.getElementById('CuerpoPrincipal').scroll = 'no';
		document.getElementById('Cubrepaginas').style.filter= 'alpha(opacity=75)';
	}else{	
		document.getElementById('CuerpoPrincipal').style.overflow = 'hidden';
		document.getElementById('Cubrepaginas').style.opacity = '0.75';
	}	
/*	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='/vacio.asp';
	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 CARRUSELL FOTOS DE PORTADA  */

var FotoActiva=0;
var NivelAlpha = 100;

function CarrusellFotos() {
	if (NumElementos>0) {
		setTimeout("CambiarFoto()",5000);
	}
}

function CambiarFoto() {
	if (FotoActiva<NumElementos) {
		FotoActiva=FotoActiva+1;
	}else{
		FotoActiva=0;
	}
	setTimeout("FundidoOut()",1);
}


function FundidoOut() {
	NivelAlpha=NivelAlpha-10;
	if (NivelAlpha > 0) {
		if (detect('msie')){
			document.getElementById('Datos_CajaGaleria').style.filter = "alpha(opacity=" + NivelAlpha + ")";
		}else{
			document.getElementById('Datos_CajaGaleria').style.opacity  = NivelAlpha/100; 
		}
		setTimeout("FundidoOut()",5);
	}else{
		document.getElementById('FotoPrincipal_Cajagaleria').src=SRCImagenGrande[FotoActiva];
		document.getElementById('Datos_CajaGaleria').style.opacity  = '0';
		document.getElementById('Link_FotoPrincipal_Cajagaleria').href= LinksGalerias[FotoActiva];
		document.getElementById('Link_FotoPrincipal_Cajagaleria2').href= LinksGalerias[FotoActiva];
		document.getElementById('Link_FotoPrincipal_Cajagaleria2').innerHTML=Titular[FotoActiva];
		document.getElementById('Descripcion_CajaGaleria').innerHTML=Textos[FotoActiva];
		setTimeout("FundidoIn()",5);		
	}
}

function FundidoIn() {
	NivelAlpha=NivelAlpha+10;
	if (NivelAlpha <= 100) {
		if (detect('msie')){
			document.getElementById('Datos_CajaGaleria').style.filter = "alpha(opacity=" + NivelAlpha + ")";
		}else{
			document.getElementById('Datos_CajaGaleria').style.opacity  = NivelAlpha/100; 
		}		
		setTimeout("FundidoIn()",1);
	}else{
		for (cuenta=0; cuenta<NumElementos+1; cuenta++) {
			document.getElementById('Opcion_CajaGaleria'+cuenta).style.borderColor='#7b7b7b';
		}
		document.getElementById('Opcion_CajaGaleria'+FotoActiva).style.borderColor='#00a7ed';		
		
		setTimeout("CambiarFoto()",5000);
	}
}

//==========================================================================
function setRowsPerPageVideo( t_intRowsPerPage )
{
	document.getElementById('InputHiddenRowsPerPageVideo').value = t_intRowsPerPage;
	document.getElementById('InputHiddenCurrentPageVideo').value = 0;
	
	document.getElementById('FormSearchParametersVideo').submit();
}
//==========================================================================
function setPageVideo( t_intPage )
{
	document.getElementById('InputHiddenCurrentPageVideo').value = t_intPage;
	
	document.getElementById('FormSearchParametersVideo').submit();
}

//==========================================================================
function setSearchCriteriaQuickSearch_Lower()
{					
	document.getElementById('InputHiddenSearchType').value		 = '1';
	document.getElementById('InputHiddenOrderCriteria').value	 = '0';
	document.getElementById('InputHiddenCurrentPage').value		 = '0';
	document.getElementById('InputHiddenRowsPerPage').value		 = '0';
	document.getElementById('InputHiddenSearchText').value		 = document.getElementById('InputTextQuickSearchText_Lower').value;
	document.getElementById('InputHiddenSearchDateRange').value	 = document.getElementById('SelectQuickSearchDateRange_Lower').options[document.getElementById('SelectQuickSearchDateRange_Lower').selectedIndex].value;
	document.getElementById('InputHiddenSearchBeginDay').value	 = '0';
	document.getElementById('InputHiddenSearchBeginMonth').value = '0';
	document.getElementById('InputHiddenSearchBeginYear').value	 = '0';
	document.getElementById('InputHiddenSearchEndDay').value	 = '0';
	document.getElementById('InputHiddenSearchEndMonth').value	 = '0';
	document.getElementById('InputHiddenSearchEndYear').value	 = '0';
	
	document.getElementById('FormSearchParameters').submit();
}

//==========================================================================
function setRowsPerPage( t_intRowsPerPage )
{
	document.getElementById('InputHiddenRowsPerPage').value = t_intRowsPerPage;
	document.getElementById('InputHiddenCurrentPage').value = 0;
	
	document.getElementById('FormSearchParameters').submit();
}
//==========================================================================
function setOrder( t_intOrderCriteria )
{
	document.getElementById('InputHiddenOrderCriteria').value = t_intOrderCriteria;
	document.getElementById('InputHiddenCurrentPage').value	  = 0;
	
	document.getElementById('FormSearchParameters').submit();
}
//==========================================================================
function setPage( t_intPage )
{
	document.getElementById('InputHiddenCurrentPage').value = t_intPage;
	document.getElementById('FormSearchParameters').submit();
}
//==========================================================================
// JAVASCRIPT DE OJD PARA ESPECIALES EN PDF.
//==========================================================================
function sR(target) {
            pixel = new Image(); 
            pixel.src = "http://permedit.ojdinteractiva.com/cgi-bin/ivw/CP/descarga_documentos";
            var wnd = window.open(target,"_blank");
}	

//==========================================================================


/* Nifty Corners Cube - rounded corners with CSS and Javascript
Copyright 2006 Alessandro Fulciniti (a.fulciniti@html.it)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

var niftyOk=(document.getElementById && document.createElement && Array.prototype.push);
var niftyCss=false;

String.prototype.find=function(what){
return(this.indexOf(what)>=0 ? true : false);
}

var oldonload=window.onload;
if(typeof(NiftyLoad)!='function') NiftyLoad=function(){};if(typeof(oldonload)=='function')
    window.onload=function(){oldonload();AddCss();NiftyLoad()};
else window.onload=function(){AddCss();NiftyLoad()};

function AddCss(){
niftyCss=true;
var l=CreateEl("link");
l.setAttribute("type","text/css");
l.setAttribute("rel","stylesheet");
l.setAttribute("href","niftyCorners.css");
l.setAttribute("media","screen");
document.getElementsByTagName("head")[0].appendChild(l);
}

function Nifty(selector,options){
if(niftyOk==false) return;
if(niftyCss==false) AddCss();
var i,v=selector.split(","),h=0;
if(options==null) options="";
if(options.find("fixed-height"))
    h=getElementsBySelector(v[0])[0].offsetHeight;
for(i=0;i<v.length;i++)
    Rounded(v[i],options);
if(options.find("height")) SameHeight(selector,h);
}

function Rounded(selector,options){
var i,top="",bottom="",v=new Array();
if(options!=""){
    options=options.replace("left","tl bl");
    options=options.replace("right","tr br");
    options=options.replace("top","tr tl");
    options=options.replace("bottom","br bl");
    options=options.replace("transparent","alias");
    if(options.find("tl")){
        top="both";
        if(!options.find("tr")) top="left";
        }
    else if(options.find("tr")) top="right";
    if(options.find("bl")){
        bottom="both";
        if(!options.find("br")) bottom="left";
        }
    else if(options.find("br")) bottom="right";
    }
if(top=="" && bottom=="" && !options.find("none")){top="both";bottom="both";}
v=getElementsBySelector(selector);
for(i=0;i<v.length;i++){
    FixIE(v[i]);
    if(top!="") AddTop(v[i],top,options);
    if(bottom!="") AddBottom(v[i],bottom,options);
    }
}

function AddTop(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
d.style.marginLeft="-"+getPadding(el,"Left")+"px";
d.style.marginRight="-"+getPadding(el,"Right")+"px";
if(options.find("alias") || (color=getBk(el))=="transparent"){
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
    }
else{
    bk=getParentBk(el); border=Mix(color,bk);
    }
d.style.background=bk;
d.className="niftycorners";
p=getPadding(el,"Top");
if(options.find("small")){
    d.style.marginBottom=(p-2)+"px";
    btype+="s"; lim=2;
    }
else if(options.find("big")){
    d.style.marginBottom=(p-10)+"px";
    btype+="b"; lim=8;
    }
else d.style.marginBottom=(p-5)+"px";
for(i=1;i<=lim;i++)
    d.appendChild(CreateStrip(i,side,color,border,btype));
el.style.paddingTop="0";
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
d.style.marginLeft="-"+getPadding(el,"Left")+"px";
d.style.marginRight="-"+getPadding(el,"Right")+"px";
if(options.find("alias") || (color=getBk(el))=="transparent"){
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
    }
else{
    bk=getParentBk(el); border=Mix(color,bk);
    }
d.style.background=bk;
d.className="niftycorners";
p=getPadding(el,"Bottom");
if(options.find("small")){
    d.style.marginTop=(p-2)+"px";
    btype+="s"; lim=2;
    }
else if(options.find("big")){
    d.style.marginTop=(p-10)+"px";
    btype+="b"; lim=8;
    }
else d.style.marginTop=(p-5)+"px";
for(i=lim;i>0;i--)
    d.appendChild(CreateStrip(i,side,color,border,btype));
el.style.paddingBottom=0;
el.appendChild(d);
}

function CreateStrip(index,side,color,border,btype){
var x=CreateEl("b");
x.className=btype+index;
x.style.backgroundColor=color;
x.style.borderColor=border;
if(side=="left"){
    x.style.borderRightWidth="0";
    x.style.marginRight="0";
    }
else if(side=="right"){
    x.style.borderLeftWidth="0";
    x.style.marginLeft="0";
    }
return(x);
}

function CreateEl(x){
return(document.createElement(x));
}

function FixIE(el){
if(el.currentStyle!=null && el.currentStyle.hasLayout!=null && el.currentStyle.hasLayout==false)
    el.style.display="inline-block";
}

function SameHeight(selector,maxh){
var i,v=selector.split(","),t,j,els=[],gap;
for(i=0;i<v.length;i++){
    t=getElementsBySelector(v[i]);
    els=els.concat(t);
    }
for(i=0;i<els.length;i++){
    if(els[i].offsetHeight>maxh) maxh=els[i].offsetHeight;
    els[i].style.height="auto";
    }
for(i=0;i<els.length;i++){
    gap=maxh-els[i].offsetHeight;
    if(gap>0){
        t=CreateEl("b");t.className="niftyfill";t.style.height=gap+"px";
        nc=els[i].lastChild;
        if(nc.className=="niftycorners")
            els[i].insertBefore(t,nc);
        else els[i].appendChild(t);
        }
    }
}

function getElementsBySelector(selector){
var i,j,selid="",selclass="",tag=selector,tag2="",v2,k,f,a,s=[],objlist=[],c;
if(selector.find("#")){ //id selector like "tag#id"
    if(selector.find(" ")){  //descendant selector like "tag#id tag"
        s=selector.split(" ");
        var fs=s[0].split("#");
        if(fs.length==1) return(objlist);
        f=document.getElementById(fs[1]);
        if(f){
            v=f.getElementsByTagName(s[1]);
            for(i=0;i<v.length;i++) objlist.push(v[i]);
            }
        return(objlist);
        }
    else{
        s=selector.split("#");
        tag=s[0];
        selid=s[1];
        if(selid!=""){
            f=document.getElementById(selid);
            if(f) objlist.push(f);
            return(objlist);
            }
        }
    }
if(selector.find(".")){      //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    if(selclass.find(" ")){   //descendant selector like tag1.classname tag2
        s=selclass.split(" ");
        selclass=s[0];
        tag2=s[1];
        }
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass==""){
    for(i=0;i<v.length;i++) objlist.push(v[i]);
    return(objlist);
    }
for(i=0;i<v.length;i++){
    c=v[i].className.split(" ");
    for(j=0;j<c.length;j++){
        if(c[j]==selclass){
            if(tag2=="") objlist.push(v[i]);
            else{
                v2=v[i].getElementsByTagName(tag2);
                for(k=0;k<v2.length;k++) objlist.push(v2[k]);
                }
            }
        }
    }
return(objlist);
}

function getParentBk(x){
var el=x.parentNode,c;
while(el.tagName.toUpperCase()!="HTML" && (c=getBk(el))=="transparent")
    el=el.parentNode;
if(c=="transparent") c="#FFFFFF";
return(c);
}

function getBk(x){
var c=getStyleProp(x,"backgroundColor");
if(c==null || c=="transparent" || c.find("rgba(0, 0, 0, 0)"))
    return("transparent");
if(c.find("rgb")) c=rgb2hex(c);
return(c);
}

function getPadding(x,side){
var p=getStyleProp(x,"padding"+side);
if(p==null || !p.find("px")) return(0);
return(parseInt(p));
}

function getStyleProp(x,prop){
if(x.currentStyle)
    return(x.currentStyle[prop]);
if(document.defaultView.getComputedStyle)
    return(document.defaultView.getComputedStyle(x,'')[prop]);
return(null);
}

function rgb2hex(value){
var hex="",v,h,i;
var regexp=/([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/;
var h=regexp.exec(value);
for(i=1;i<4;i++){
    v=parseInt(h[i]).toString(16);
    if(v.length==1) hex+="0"+v;
    else hex+=v;
    }
return("#"+hex);
}

function Mix(c1,c2){
var i,step1,step2,x,y,r=new Array(3);
if(c1.length==4)step1=1;
else step1=2;
if(c2.length==4) step2=1;
else step2=2;
for(i=0;i<3;i++){
    x=parseInt(c1.substr(1+step1*i,step1),16);
    if(step1==1) x=16*x+x;
    y=parseInt(c2.substr(1+step2*i,step2),16);
    if(step2==1) y=16*y+y;
    r[i]=Math.floor((x*50+y*50)/100);
    r[i]=r[i].toString(16);
    if(r[i].length==1) r[i]="0"+r[i];
    }
return("#"+r[0]+r[1]+r[2]);
}

/*---------------------------------------------------------------------*/

/* 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=93)";
	}else{	
		document.getElementById('Cubrepaginas').style.opacity = '0.93';
		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()",700);
}


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";
}

/* FUNCION QUE ELIMINA 'Texto' EN EL FORM BUSCADOR */
function CorregirFormulario(elemento,Variable) {
	if (document.getElementById(elemento).value==Variable) {
		document.getElementById(elemento).value="";
	}
}