// JavaScript Document
function capa(nomObjecte,nom,idImatge){
	this.nomObjecte=nomObjecte;
	this.nom=nom;
	this.alpha=100;
	this.idImatge=idImatge;
	this.transparentaCapa=transparentaCapa;
	this.veureCapa=veureCapa;
	this.intercanviImatge=intercanviImatge;
}

function intercanviImatge(temps,imatge){
	this.transparentaCapa(temps,imatge);
}

function transparentaCapa(temps,imatge){		
	if(this.alpha>0){				
		//alert('trasnaprentacapa');
		//alert(eval("document.getElementById('"+this.nom+"').style.filter"));
		this.alpha=this.alpha-increment;
		valorIE=this.alpha;
		valorM=this.alpha/100;
		eval("document.getElementById('"+this.nom+"').style.filter='Alpha(Opacity="+valorIE+")';");
		eval("document.getElementById('"+this.nom+"').style.opacity='"+valorM+"';");
		eval("document.getElementById('"+this.nom+"').style.mozOpacity='"+valorM+"';");
		t3=setTimeout("cridaTransparentaCapa('"+this.nomObjecte+"',"+temps+",'"+imatge+"')",temps);
	}else{
		eval("document.getElementById('"+this.idImatge+"').src='"+imatge+"';");
		this.veureCapa(temps);
	}
}

function cridaTransparentaCapa(qui,temps,imatge){
	//alert('hola');
	eval(qui+".transparentaCapa("+temps+",'"+imatge+"');");
}

function veureCapa(temps){	
	if(this.alpha<100){
		//alert('veurecapa '+this.nom);
		//alert(eval("document.getElementById('"+this.nom+"').style.filter"));
		this.alpha=this.alpha+increment;
		valorIE=this.alpha;
		valorM=this.alpha/100;		
		eval("document.getElementById('"+this.nom+"').style.filter='Alpha(Opacity="+valorIE+")';");
		eval("document.getElementById('"+this.nom+"').style.opacity='"+valorM+"';");
		eval("document.getElementById('"+this.nom+"').style.mozOpacity='"+valorM+"';");
		t2=setTimeout("cridaVeureCapa('"+this.nomObjecte+"',"+temps+")",temps);
	}
}

function cridaVeureCapa(qui,temps){
	eval(qui+".veureCapa("+temps+");");
}

function canviImatge() {
	if(imatge<numeroImatges-1) imatge=imatge+1;
	else imatge=0;
	objecteCapa.intercanviImatge(90,'../imatges/'+imatges[imatge]);
	
	for(i=0;i<numeroImatges;i=i+1){
		if(i!=imatge) eval('document.getElementById(\'boto'+i+'\').src=\'../imatges/boton_bucle_B.png\';');	
		else eval('document.getElementById(\'boto'+i+'\').src=\'../imatges/boton_bucle_A.png\';');	
	}
	t1=setTimeout("canviImatge()",5000);
}

objecteCapa= new capa('objecteCapa','contingutImatges','imatge1');
var imatges= new Array();
var imatge=0;
var numeroImatges=4;
var t0;
var t1;
var t2;
var t3;
var increment=10;

if(lang=='es'){
imatges[0]='bucle_01_es.jpg';
imatges[1]='bucle_02_es.jpg';
imatges[2]='bucle_03_es.jpg';
imatges[3]='bucle_04_es.jpg';

}else{
imatges[0]='bucle_01.jpg';
imatges[1]='bucle_02.jpg';
imatges[2]='bucle_03.jpg';
imatges[3]='bucle_04.jpg';

	
}
function posaImatge(quina){
	increment=100;
	eval("document.getElementById('imatge1').src='../imatges/"+imatges[quina]+"';");	
	clearTimeout(t0);
	clearTimeout(t1);
	clearTimeout(t2);
	clearTimeout(t3);				
	
	eval("document.getElementById('"+objecteCapa.nom+"').style.filter='Alpha(Opacity=100)'");	
	eval("document.getElementById('"+objecteCapa.nom+"').style.opacity='1';")
	eval("document.getElementById('"+objecteCapa.nom+"').style.mozOpacity='1';")
	
	imatge=quina*1;	
	for(i=0;i<numeroImatges;i=i+1){
		if(i!=quina) eval('document.getElementById(\'boto'+i+'\').src=\'../imatges/boton_bucle_B.png\';');	
		else eval('document.getElementById(\'boto'+i+'\').src=\'../imatges/boton_bucle_A.png\';');	
	}	
	increment=10;
	inici();
}

function inici(){
	document.getElementById("imatge1").src='../imatges/'+imatges[imatge];
	if(numeroImatges>1) t0=setTimeout("canviImatge()",4000);
}



function actualitzaImatgeCamara(){
	window.frameCamara.location.reload();
	setTimeout("actualitzaImatgeCamara()",1000);	
}



function mostraContingutEnDades(){
	if(document.getElementById('contingutEnDades').style.visibility=='hidden'){
		document.getElementById('contingutEnDades').style.visibility='visible';
		document.getElementById('contingutEnDades').style.height='660px';
	}else{
		document.getElementById('contingutEnDades').style.visibility='hidden';
		document.getElementById('contingutEnDades').style.height='0px';
	}	
}





















