// JavaScript Document
<!--
function inizializza(){
  //preload immagini
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length; for(i=0; i<NewImg.length; i++)
    if (NewImg[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=NewImg[i];}}
	
	//impostazione variabili
	ImgNum = 0;
	ImgLength = NewImg.length - 1;
	lock = false;

	//Time delay between Slides in milliseconds
	delay = 5000;
	
  //variabili browsers
  if (document.all) {
    documento="document.all";
    parA="[";
    parB="]";
    nascosto="hidden";
    visibile="visible";
  }
  else if (document.layers){
    documento="document.layers";
    parA="[";
    parB="]";
    nascosto="hide";
    visibile="show";
  }
  else if (document.getElementById) {
    documento="document.getElementById";
    parA="(";
    parB=")";
    nascosto="hidden";
    visibile="visible";
  }
}

function resize() {
	//nascondo l'immagine prima di caricare la nuova
	var img = eval(documento+parA+"'ingrandimento'"+parB+"");
	img.style.display = "none";
	
	//recupero le dimensioni dell'immagine
	var myImage = new Image();
	myImage.src = NewImg[ImgNum];
	w = myImage.width;
	h = myImage.height;

	//imposto le dimensioni dell'immagine
	resizeW = (w * 300)/h
	resizeH = (h * 300)/w
	if (w >= h) {
		intWidth = 300;
		intHeight = resizeH;
	} else {
		intHeight = 300;
		intWidth = resizeW;
	}
	img.width = intWidth;
	img.height = intHeight;
	img.src = myImage.src;
	
	//imposto l'altezza delle frecce
	var prec = eval(documento+parA+"'prec'"+parB+"");
	var next = eval(documento+parA+"'next'"+parB+"");
	arrowHeight = (intHeight/2) - 15;
	prec.style.border = "0";
	prec.style.margin = arrowHeight +"px 10px 0 0;";
	next.style.border = "0";
	next.style.margin = arrowHeight +"px 0 0 10px;";
	img.style.display = "block";
}
function chgImg(direction) {
	if (document.images) {
		ImgNum = ImgNum + direction;
		if (ImgNum > ImgLength) {
			ImgNum = 0;
		}
		if (ImgNum < 0) {
			ImgNum = ImgLength;
		}
		resize();
  }
}
function clear() {
	window.clearInterval(run);
}
function auto() {
	if (lock == true) {
		lock = false;
		clear();
	}
	else if (lock == false) {
		lock = true;
		run = setInterval("chgImg(1)", delay);
  }
}
//-->

