
/* Carrusell Destacados */



var CajaVisorOn = new Array();
var CajaVisorOff = new Array();

var EstadoVisor = true;
var tamanno=32;
var tamannoNegativo=532;
var ElementoPulsado = 0;
var animacionAutomatica;
var SobreCaja = true;
var ElementoAnterior = 0;
var alphaElementoAnterior = 100;
var alphaElemento = 0;


function CargaVisor() {
	for (u=0; u<numero_elementos+1; u++) {
		CajaVisorOn[u] = new Image();
		CajaVisorOn[u].src	= URLServidor+'/img/visor/CajaVisor'+u+'.jpg';
		CajaVisorOff[u] = new Image();
		CajaVisorOff[u].src	= URLServidor+'/img/visor/CajaVisor'+u+'_off.jpg';
	}
}

/* Precarga de la imagenes del visor */	
function makeDoubleDelegate(Valor) {
	if (Valor=="Estado1") {
		estado1=true;
	}
	if (Valor=="Estado2") {
		estado2=true;
	}				
	for (u=0; u<=numero_elementos; u++) {
		if (document.getElementById('CajaVisor'+u).className=="Activo") {
			document.getElementById('ImagenCajaVisor'+u).src	= CajaVisorOn[u].src;					
		}else{
			document.getElementById('ImagenCajaVisor'+u).src	= CajaVisorOff[u].src;				
		}
	}
	if (estado2 && estado2) {
		var animacionAlPulsar = setTimeout('ActivarDestacado(1)',5000);	
	}
}

function ActivarDestacado(IdElemento) {
	if (EstadoVisor) {
		clearTimeout (animacionAutomatica);
		if (document.getElementById('CajaVisor'+IdElemento).className=="Activo") {
			parent.top.location = document.getElementById('CajaVisor'+IdElemento).href;
		}else{
			ElementoAnterior = ElementoPulsado;
			ElementoPulsado = IdElemento;
			for (i=0; i<numero_elementos; i++) {
				document.getElementById('ImagenCajaVisor'+i).src	= CajaVisorOff[i].src;
			}	
			
			document.getElementById('CajaVisor'+ElementoAnterior).className			= '';
			
			document.getElementById('ImagenCajaVisor'+ElementoAnterior).src			= CajaVisorOn[ElementoAnterior].src;		
			document.getElementById('CajaVisor'+IdElemento).className				= 'Activo';
			document.getElementById('ImagenCajaVisor'+IdElemento).src				= CajaVisorOn[IdElemento].src;
			document.getElementById('ImagenCajaVisor'+IdElemento).style.opacity		= '0';
			setTimeout ('CrecerImagen('+IdElemento+')',0);
		}
	}
}

function CrecerImagen(IdElemento) {
	EstadoVisor = false;
	if (tamanno<532) {

		tamannoNegativo=tamannoNegativo-20;
		if (alphaElementoAnterior>0) {
			alphaElementoAnterior=alphaElementoAnterior-3;
		}
		document.getElementById('ImagenCajaVisor'+ElementoAnterior).style.width		= tamannoNegativo+'px';
		document.getElementById('CajaVisor'+ElementoAnterior).style.width			= tamannoNegativo+'px';
		document.getElementById('ImagenCajaVisor'+ElementoAnterior).style.opacity	= (alphaElementoAnterior/100);

		tamanno=tamanno+20;
		if (alphaElemento<100) {
			alphaElemento=alphaElemento+3;
		}		
		document.getElementById('ImagenCajaVisor'+IdElemento).style.width			= tamanno+'px';
		document.getElementById('CajaVisor'+IdElemento).style.width					= tamanno+'px';
		document.getElementById('CajaVisor'+IdElemento).style.width					= tamanno+'px';
		document.getElementById('ImagenCajaVisor'+IdElemento).style.opacity			= (alphaElemento/100);
		
		setTimeout ('CrecerImagen('+IdElemento+')',1);
		
	}else{
	
		tamanno=32;
		tamannoNegativo=532;
		alphaElementoAnterior = 100;
		alphaElemento = 0;
		
		document.getElementById('ImagenCajaVisor'+ElementoAnterior).style.width='32px';
		document.getElementById('CajaVisor'+ElementoAnterior).style.width='32px';	
		document.getElementById('ImagenCajaVisor'+ElementoAnterior).style.opacity	= "";
		
		document.getElementById('ImagenCajaVisor'+ElementoAnterior).src = CajaVisorOff[ElementoAnterior].src;
		document.getElementById('CajaVisor'+ElementoAnterior).className = '';
		
		document.getElementById('ImagenCajaVisor'+IdElemento).style.width='532px';
		document.getElementById('CajaVisor'+IdElemento).style.width='532px';
		document.getElementById('ImagenCajaVisor'+IdElemento).style.opacity	= "1";
		
		IdElemento++;
		if (IdElemento>numero_elementos) {
			IdElemento=0;
		}
		
		EstadoVisor = true;
		animacionAutomatica = setTimeout ('ActivarDestacado('+IdElemento+')',5000);
		
	}
}

	

