//istruzioni per la larghezza minima (colpa di IE6 che non regge min-width!!!)
if (window.width <= 720) document.getElementById('corpo').style.width = "665px";

//istruzioini preload
function preload() {
	var immagini = new Array;
	argomenti = preload.arguments;
	for (t=0; t<argomenti.length; t++) {
		immagini[t] = new Image();
		immagini[t].src = argomenti[t];
	}
}


// script javascript per slide show con dissolvenza
indice_slide = 1;
indice_img = 0;
numero_foto_slide = 11;
nome_foto = 'foto_copertina';
foto='copertina';
var ievs = (/MSIE (\d+\.\d+);/.test(navigator.userAgent));

//istruzioini preload specifico per lo slide
function preload_slide(numero_foto_preload) {
	var immagini = new Array;
	for (t=0; t<numero_foto_preload; t++) {
		immagini[t] = new Image();
		immagini[t].src = livelloxsli+'images/'+foto+'/'+foto+'-'+t+'.jpg';
		if	(t==(numero_foto_preload-1))	slide_diss();
	}
}
	
function slide_diss()	{
	indice_img2= (indice_img+1) % 2;
	id=nome_foto+indice_img;
	id2=nome_foto+indice_img2;
	opacity = 0;
	diss();
}
function diss()	{
	opacity=opacity+0.02;
	if (!ievs)	{
		document.getElementById(id).style.opacity = (0.98-opacity);
		document.getElementById(id2).style.opacity = opacity;
	}	/*else	{
		document.getElementById(id).filters.alpha.opacity = (0.98-opacity)*100;
		document.getElementById(id2).filters.alpha.opacity = opacity*100;
	}*/
	if (opacity>=1)	{
		indice_slide=++indice_slide % numero_foto_slide;
		document.getElementById(id).src = livelloxsli+'images/'+foto+'/'+foto+'-'+indice_slide+'.jpg';
		indice_img=indice_img2;
// 		left=(535 - parseInt(document.getElementById(id).offsetWidth)) /2;
// 		document.getElementById(id).style.left = left+'px';
		setTimeout('slide_diss()', 3000);
		return;
	}
	setTimeout('diss()', 40);
}


// l'oggetto fotolat gestisce la visione delle foto della barra laterale e quelle degli spunti
function fotolat(ntot, nomepag, dir, livel) {
	this.ntot=ntot;
	this.nome=nomepag;
	this.livello=livel;
	this.dir=dir;
	this.foto=-1;
	this.lis=document.getElementsByTagName('li');
	if (this.dir==this.nome) {
		for (i=0; i<this.ntot; i++) {
			this.lis[i].firstChild.href='javascript:;';
			this.lis[i].style.cursor='pointer';
		}
	}
	this.mostra = function (nfoto) {
		if ((this.foto>=0)&&(this.ntot!=0)) this.alat.style.color='#007941';
		this.foto=nfoto;
		this.alat=this.lis[this.foto].firstChild;
// 		this.alat.href='';
		if (this.ntot!=0) this.alat.style.color='#C5AE39';
		document.getElementById('divimglat').style.display = 'block';
		document.getElementById('immaginelat').src = this.livello+'images/fotolat/'+this.dir+'/foto-'+this.foto+'.jpg';
	}
	this.mostra_g = function () {
		document.getElementById('foto').src = this.livello+'images/fotolat/originali/'+this.dir+'/foto-'+this.foto+'.jpg';
		document.getElementById('divfoto').style.display = 'block';
		document.getElementById('linkfoto').href = this.livello+'images/fotolat/originali/'+this.dir+'/foto-'+this.foto+'.jpg';
	}
	this.chiudi = function () {
		document.getElementById('divfoto').style.display = 'none';
	}
	this.avanza = function () {
			this.foto= (this.foto+1)%this.ntot;
		if (this.dir.indexOf('/')<0) {
			this.alat.style.color='#007941';
			this.alat=this.lis[this.foto].firstChild;
			if (this.ntot!=0) this.alat.style.color='#C5AE39';
		}
		document.getElementById('immaginelat').src = this.livello+'images/fotolat/'+this.dir+'/foto-'+this.foto+'.jpg';
		document.getElementById('foto').src = this.livello+'images/fotolat/originali/'+this.dir+'/foto-'+this.foto+'.jpg';
		document.getElementById('linkfoto').href = this.livello+'images/fotolat/originali/'+this.dir+'/foto-'+this.foto+'.jpg';
	}
	this.indietro = function () {
			if (this.foto==0) this.foto=this.ntot-1;
			else this.foto= (this.foto-1);
		if (this.dir.indexOf('/')<0) {
			this.alat.style.color='#007941';
			this.alat=this.lis[this.foto].firstChild;
			if (this.ntot!=0) this.alat.style.color='#C5AE39';
		}
		document.getElementById('immaginelat').src = this.livello+'images/fotolat/'+this.dir+'/foto-'+this.foto+'.jpg';
		document.getElementById('foto').src = this.livello+'images/fotolat/originali/'+this.dir+'/foto-'+this.foto+'.jpg';
		document.getElementById('linkfoto').href = this.livello+'images/fotolat/originali/'+this.dir+'/foto-'+this.foto+'.jpg';
	}
	this.mostra_g_int = function (nfoto) {
		this.foto=nfoto;
		this.mostra_g();
	}
}


function mod(number) {
	if (number<0) number*=-1;
	return number;
}
