function Altezze() {
	var a = document.getElementById("corpo").clientHeight
	document.getElementById("blusin").style.height = a
	document.getElementById("bludes").style.height = a
}

var gblPhotoShufflerDivId = "photodiv";
var gblPhotoShufflerImgId = "photoimg";
var gblImg = new Array
var numImmagini = 4;											// n° immagini totali da far girare
for (i=0; i<numImmagini; i++) {
	gblImg[i] = 'images/top' + i + '.jpg';
}
var gblPauseSeconds = 3.00;
var gblFadeSeconds = 1.45;
var gblRotations = 100;

var gblDeckSize = gblImg.length;
var gblOpacity = 100;
var gblOnDeck = Math.ceil(numImmagini * Math.random())-1;
var gblStartImg;
var gblImageRotations = gblDeckSize * (gblRotations+1);

function photoShufflerLaunch() {
	var theimg = document.getElementById(gblPhotoShufflerImgId);
	gblStartImg = theimg.src; // save away to show as final image
	document.getElementById(gblPhotoShufflerDivId).style.backgroundImage='url(' + gblImg[gblOnDeck] + ')';
	photoShufflerFade()
}

function photoShufflerFade() {
	var theimg = document.getElementById(gblPhotoShufflerImgId);
	// determine delta based on number of fade seconds
	// the slower the fade the more increments needed
	var fadeDelta = 100 / (30 * gblFadeSeconds);
	// fade top out to reveal bottom image
	if (gblOpacity < 2*fadeDelta) {
		gblOpacity = 100;
		// stop the rotation if we're done
		if (gblImageRotations < 1) return;
		// prima di sostituire l'immagine verifica che la successiva sia caricata
		// DA FARE !!!
		photoShufflerShuffle();
		// pause before next fade
		setTimeout("photoShufflerFade()",gblPauseSeconds*1000); }
	else {
		gblOpacity -= fadeDelta;
		setOpacity(theimg,gblOpacity);
		setTimeout("photoShufflerFade()",30); // 1/30th of a second
	}
}

function photoShufflerShuffle() {
	var thediv = document.getElementById(gblPhotoShufflerDivId);
	var theimg = document.getElementById(gblPhotoShufflerImgId);
	theimg.src = gblImg[gblOnDeck];		// copy div background-image to img.src
	setOpacity(theimg,100);						// set img opacity to 100
	// shuffle the deck
	gblOnDeck = ++gblOnDeck % gblDeckSize;
	// decrement rotation counter
	if (--gblImageRotations < 1) {
		gblImg[gblOnDeck] = gblStartImg;				// insert start/final image if we're done
	}
	// slide next image underneath
	thediv.style.backgroundImage='url(' + gblImg[gblOnDeck] + ')';
}

function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	obj.style.filter = "alpha(opacity:"+opacity+")";		// IE/Win
	obj.style.KHTMLOpacity = opacity/100;								// Safari<1.2, Konqueror
	obj.style.MozOpacity = opacity/100;									// Older Mozilla and Firefox
	obj.style.opacity = opacity/100;										// Safari 1.2, newer Firefox and Mozilla, CSS3
}

function movepic(img_name,img_src) {
	document[img_name].src=img_src;
}

function show_div(div_id,refimg) {
	if (refimg.src.search("piu")>0) {
		document.getElementById(div_id).style.display='block'
		refimg.src = "img/menoRED.gif"
		Altezze()
	} else {
		document.getElementById(div_id).style.display='none'
		refimg.src = "img/piuREDleggi.gif"
		Altezze()
	}
}

function show_divPP(div_id,refimg) {
	if (refimg.src.search("piu")>0) {
		document.getElementById(div_id).style.display='block'
		refimg.src = "img/menoRED.gif"
		Altezze()
	} else {
		document.getElementById(div_id).style.display='none'
		refimg.src = "img/piuRED.gif"
		Altezze()
	}
}

function show_divEV(div_id,refimg) {
	if (refimg.src.search("piu")>0) {
		document.getElementById(div_id).style.display='block'
		refimg.src = "img/menoRED.gif"
		Altezze()
	} else {
		document.getElementById(div_id).style.display='none'
		refimg.src = "img/piuRED.gif"
		Altezze()
	}
}

function show_divIMG(div_id,imago) {
	if (document.getElementById(imago).src.search("piu")>0) {
		document.getElementById(div_id).style.display='block'
		document.getElementById(imago).src = "img/menoRED.gif"
		Altezze()
	} else {
		document.getElementById(div_id).style.display='none'
		document.getElementById(imago).src = "img/piuREDleggi.gif"
		Altezze()
	}
}




function ScriviM_ETM() {
    a = 65
    b = "ilto"
    document.write("<a class=mail hre" + "f=ma" + b + ":in" + "fo" + String.fromCharCode(a - 1) + "turismomalesia" + String.fromCharCode(a - 19) + "i" + "t>" + "in" + "fo" + String.fromCharCode(a - 1) + "turismomalesia" + String.fromCharCode(a - 19) + "i" + "t<" + "/a>")
}

function ScriviM_TMHQ() {
    a = 65
    b = "ilto"
    document.write("<a class=mail hre" + "f=ma" + b + ":enqui" + "ries" + String.fromCharCode(a - 1) + "tourism.gov" + String.fromCharCode(a - 19) + "m" + "y>" + "enqui" + "ries" + String.fromCharCode(a - 1) + "tourism.gov" + String.fromCharCode(a - 19) + "m" + "y<" + "/a>")
}

function TogliBox() {
	document.getElementById("destinazioni2_box").style.display = 'none'
}

var DestAttuale = -1
function DestMostra(quale) {
	if (DestAttuale>-1)
		eval("document.getElementById('destinazioni_testo" + DestAttuale + "')").style.display = 'none'
	//alert(eval("document.getElementById('destinazioni_testo" + quale + "')"))
	eval("document.getElementById('destinazioni_testo" + quale + "')").style.display = 'block'
	Altezze()
	DestAttuale = quale
}

