 
 var a_testa = new Array();	
 var maxImg = 0;
 var curImg;
 var next = 0;
 var num = "";
 var animazione;
 
 function setSlideShow(){
	a_testa = document.getElementById('divTesta').getElementsByTagName('IMG');
	curImg = a_testa[0];
	maxImg = a_testa.length;
	animazione = setInterval(slideShow,5000);
 }

 function slideShow(){
	num = curImg.id.split('_')[1];
	next = 0;
	if(num==(maxImg-1)){
		//torno alla prima immagine
		next = 0;
	}else{
		//vado alla prossima immagine
		next = parseInt(num,10) + 1;
	}
	document.getElementById('imgTesta_'+ next).style.display='block';
	//fermo il primo timer 
	clearInterval(animazione);
	//qui in mezzo ci devo mettere la dissolvenza
	fading(curImg.id);
 }

 function fading(id){
	//lancio il timer per la dissolvenza
	 var img = document.getElementById(id);
	 var opacity = 1;
	 var opacityIE = 100;
	 img.dissolvenza = window.setInterval(
 		function() { 
 			img.style.opacity = opacity - (1/10);
 			img.style.filter = 'alpha(opacity=' + opacityIE - 10 + ')';
 		  	opacity = opacity - (1/10);
 	  		if (opacity<=0){ 
 	  			window.clearInterval(img.dissolvenza);
 	  			endSlideShow();
 	  		}
 		} 
 	,60)
 }

 function endSlideShow(){
	document.getElementById('imgTesta_'+ next).style.zIndex=20;		
	document.getElementById('imgTesta_'+ num).style.zIndex=18;
	document.getElementById('imgTesta_'+ num).style.display='none';
	document.getElementById('imgTesta_'+ num).style.opacity = 1;
 	document.getElementById('imgTesta_'+ num).style.filter = 'alpha(opacity=100)';
	changeDesc();
	curImg = document.getElementById('imgTesta_'+ next);
	//faccio ripartire il timer principale
	animazione = setInterval(slideShow,5000);
 }
 
 function changeDesc(){
	document.getElementById('divImgT_'+ num).style.backgroundImage='';
	document.getElementById('divImgT_'+ next).style.backgroundImage="url('images/back_open_h.jpg')";
	document.getElementById('divText_'+ num).style.display='none';
	document.getElementById('divText_'+ next).style.display='block';
 }
 
 
 
 
