

/* FUNCIONES VISOR PORTADA */

var velocidadEfecto 	= 10;
var EsperaEfecto 		= 50;
var numeroOpcionActiva	= 1;
var opcionActiva		= 'CarruselOpcion1';
var RollOverVisor		= false;
var Transicion			= false;
var opacidad 			= 100;
var PlayerVisor 		='';

imagen = new Image();

function CarrusellFotos () {
	try{
		TotalEltosCarrusel = parseInt(TotalEltosCarrusel);
	}catch(err){
		TotalEltosCarrusel = 0;
	}
	
	if (parseInt(TotalEltosCarrusel)>1){
		
		for(j=1;j<=TotalEltosCarrusel;j++){
			if (FotosVisor[j].complete) flag[j]=true;
		}
		
		var todasactivas= true;
		for(j=1;j<=TotalEltosCarrusel;j++){
			if(flag[j]=false){
				todasactivas = false;
			}
		}
		if (todasactivas) {
			numeroOpcionActiva++;
			if (numeroOpcionActiva>TotalEltosCarrusel) {
				numeroOpcionActiva=1;
			}
			fadeOut();				
		} else {
			alert ('Kio');
			PlayerVisor = setTimeout ('CarrusellFotos()',tiempoEspera);
		}
	}
}

function activarPestanna(Selecccionado) {

	if (TotalEltosCarrusel>1){
		for(j=1;j<=TotalEltosCarrusel;j++){
			if (FotosVisor[j].complete) flag[j]=true;
		}
	}
	var todasactivas= true;
	for(j=1;j<=TotalEltosCarrusel;j++){
		if(flag[j]=false){
			todasactivas = false;
		}
	}
	if (todasactivas && Selecccionado!=numeroOpcionActiva) {
		if (!Transicion) {
			numeroOpcionActiva=Selecccionado;
			fadeOut();
		}
	}
}

function fadeOut() {
	clearTimeout(PlayerVisor);
	Transicion	= true;
	opacidad=opacidad-velocidadEfecto;
	if (opacidad>=0) {
		document.getElementById('Pantalla').style.opacity = (opacidad/100);
		document.getElementById('Pantalla').style.filter = 'alpha(opacity=' + opacidad + ')';		
		EfectoPlayer=setTimeout ('fadeOut()',EsperaEfecto);
		
	}else{
		document.getElementById(opcionActiva).className='';
		opcionActiva= 'CarruselOpcion'+numeroOpcionActiva;		
		document.getElementById(opcionActiva).className='Activo';		
		document.getElementById('FotoVisor').src			= FotosVisor[numeroOpcionActiva].src;
		imagen = FotosVisor[numeroOpcionActiva];
		fadeIn();
	}
}

function fadeIn() {
	opacidad=opacidad+velocidadEfecto;
	if (opacidad<=100) {
		document.getElementById('Pantalla').style.opacity = (opacidad/100);
		document.getElementById('Pantalla').style.filter = 'alpha(opacity=' + opacidad + ')';
		EfectoPlayer=setTimeout ('fadeIn()',EsperaEfecto);
	}else{
		Transicion	= false;
		PlayerVisor=setTimeout ('CarrusellFotos()',tiempoEspera);		
	}
}
