
var trasparenzaBIG=92;
function apriBIG(cosa) {
	
	document.getElementById('bigFoto').style.display='block';
	posizionaIfame(cosa);
	
	
	if(document.getElementById('divopacomappa')) document.getElementById('divopacomappa').style.opacity=trasparenzaBIG/100;
	if(document.getElementById('divopacomappa')) document.getElementById('divopacomappa').filters.alpha.opacity=trasparenzaBIG;
	
	return false;
}

function posizionaIfame(cosa){

	
	//dimensiona l'iframe
	margineSopraSotto=2;
	if (window.innerWidth) altezzaTotale=window.innerHeight; //firefox
	else if(document.documentElement.clientHeight) altezzaTotale=document.documentElement.clientHeight; //explorer merda
	else if(document.body.clientHeight) altezzaTotale=document.body.clientHeight;
	altezzaDisponibile=altezzaTotale-margineSopraSotto*2;
	altezzaDisponibile=9999;
	document.getElementById("iframeref").height=altezzaDisponibile; 
	
	document.getElementById('iframeref').style.display="block";
	if(cosa=="" || cosa=="undefined"  || cosa==null) document.getElementById('iframeref').src="slidefoto.php?dimensioneH="+altezzaDisponibile+"&cosa=mostre&indiceFoto="+indiceFoto;
	else {
		document.getElementById('iframeref').src=cosa+"&dimensioneH="+altezzaDisponibile;
	}
	document.getElementById('iframeref').style.left=((document.body.clientWidth-1000)/2)+"px";
	document.getElementById("iframeref").style.top=(document.body.scrollTop+margineSopraSotto)+"px";
	
	if(document.getElementById("cazzoDiFlash")) document.getElementById("cazzoDiFlash").style.display="none";

	
	
	
	
	return false;
}


var elencoFotoRef= new Array();
var elencoInfo= new Array(); //per le descrizioni di presenti_images.php
var indiceFoto=-1;



function scorriFotoSet(quale) {
	indiceFoto=quale-1;
	scorriFoto(1);
	autoPlayFoto=false;
	
}
function scorriFoto(come) {

		
		
	if(come>0) indiceFoto+=1; if(indiceFoto>(elencoFotoRef.length-1)) indiceFoto=0;
	if(come<0) indiceFoto-=1; if(indiceFoto<0) indiceFoto=elencoFotoRef.length-1;

	document.getElementById('mettiFoto').src=elencoFotoRef[indiceFoto];
	if(elencoInfo[indiceFoto] && document.getElementById("informazioni")) document.getElementById('informazioni').innerHTML=elencoInfo[indiceFoto];
	document.getElementById('pallini').innerHTML="";
	
	document.getElementById('pallini').style.display="none"; //direttiva emanule 28 sett 2010
	for(i=0;i<elencoFotoRef.length;i++) {
		off=" <a href='#' onclick=\"autoPlayFoto=false; scorriFotoSet('"+i+"'); return false;\" >[]</a> ";
		onn=" [*] ";
		ooo=off; if(i==indiceFoto) ooo=onn;
		document.getElementById('pallini').innerHTML=document.getElementById('pallini').innerHTML+ooo;
	}
	

	if(autoPlayFoto) setTimeout("scorriFoto(1)",3000);
	
	
	//applica gli stili di trasparenza
	for(i=0;i<30;i++){
		rifImm="immagine"+i;
		if(document.getElementById(rifImm)) document.getElementById(rifImm).className="opacitaImmagini";
	}
	
	rifImm="immagine"+indiceFoto;
	if(document.getElementById(rifImm)) document.getElementById(rifImm).className="opacitaImmaginiEvidenziato";
	////////////////////////////////////
	
	document.getElementById('contatoreFoto').innerHTML=(indiceFoto+1)+" / "+elencoFotoRef.length;
	if(elencoFotoRef.length==1) document.getElementById('contatoreFoto').innerHTML="";
	
	if(document.getElementById('scorriPre')) {
			if(indiceFoto==0) document.getElementById('scorriPre').style.display="none";
			else document.getElementById('scorriPre').style.display="block";
	}
	if(document.getElementById('scorriNex')) {
		if(indiceFoto>=(elencoFotoRef.length-1)) document.getElementById('scorriNex').style.display="none";
		else document.getElementById('scorriNex').style.display="block";
	}
	
}

var autoPlayFoto=false;
function playFoto(){
	autoPlayFoto=!autoPlayFoto;
	scorriFoto(1);
}
