function area9ScrollPanel(){
	
	// Variabili generali
	this.singleElementWidth;  // variabile larghezza elemento con classe "contSingle"
	this.contaElementi;
	this.decrementValue;
	this.nrSpostamentoElementi=1; // numero di elementi da spostare per ogni click
	this.nrElementiVisualizzati=1; // numero di elementi da visualizzare per ogni pagina
	this.posizioneElementi;	
	this.myInterval;
	this.visBtComandi=true;
	this.indiceElemento=0;
 	this.loopAttivo=true;
	this.spostaElemento;
	this.effettoAnimazioneLoop;
	this.tabAttiva=0;
	this.prefix; // setta il prefisso dell'id dell'elemento con classe "contSingle"
	
	// Setta le opzioni per lo scorrimento
	this.intervalloElemento=5000;
	this.effettoResetta="scorri"; /* opzioni: fade, scorri */
	this.velocitaScroll=1000;
	this.classImgPrev="";
	this.classImgNext="";
	this.classImgPlay="";
	this.classImgPause="";
	
	// Setto le opzioni per le eventuali tab del menu
	this.setStyleTabs=true;
	this.styleTabAttiva="";
	this.styleTabsNonAttive="";
	
	// Eventi onNext, onPrevious, onReset
	this.onNextEvent=null;
	this.onPreviousEvent=null;
	this.onResetEvent=null;

}

area9ScrollPanel.prototype.init=function(){
	
	this.contaElementi=($$('div#contMultiple .contSingle').length);
	
	// Calcolo la larghezza del contenitore di ogni singolo elemento
	var el=$$('div#contMultiple .contSingle');
	this.singleElementWidth=(el[0].offsetWidth);
	
	// Calcolo la larghezza del div che contiene tutti gli elementi
	$('contMultiple').setStyle('width',this.contaElementi*this.singleElementWidth);

	// Se il numero degli elementi e' uguale al numero di elementi visualizzati per pagina, non visualizzo le freccette
	if(this.contaElementi>this.nrElementiVisualizzati){
	
		$('nextBtn').setStyles({opacity:1,visibility: 'visible'});
	
	}

	// Calcolo il valore di spostamento del contenitore
	this.decrementValue=(this.singleElementWidth*this.nrSpostamentoElementi);
	
	var self=this;
	// Attivo le freccette avanti e indietro, play e pausa	
	$('prevBtn').onclick=function(){self.elementoPrecedente()};
	$('nextBtn').onclick=function(){self.elementoSuccessivo()};
	
	
	if ($('pausaBtn')){
		
		$('pausaBtn').onclick=function(){self.pause()};
		$('playBtn').onclick=function(){self.play()};
	
	
		$('playBtn').setStyles({opacity:0,display: 'block'});

	}

	// La freccetta indietro all'inizio di tutto non si deve vedere
	$('prevBtn').setStyles({opacity:0,visibility: 'visible'});

	if(this.contaElementi>1){
		
		if (this.visBtComandi){
			
			//$('contComandi').setStyles({opacity:1,display: 'block'});
			
		}else{
			
			//$('contComandi').setStyles({opacity:0,display: 'none'});
			
		}
		
		if (this.loopAttivo){
			this.play();
		}

	}else{
		
	
		//$('contComandi').setStyles({opacity:0,display: 'none'});
			
		this.loopAttivo=false;
	
	}
	
}

//***********************************************************************************************************************
// Controllo se l'indice dell'elemento e' minore del numero totale di elementi oppure resetto la funzione
//***********************************************************************************************************************
area9ScrollPanel.prototype.scorriElemento=function(){
	
	if ((this.indiceElemento+this.nrElementiVisualizzati)<(this.contaElementi)){ 
		
		this.elementoSuccessivo();
		if (typeof(this.onNextEvent)=="function"){
			this.onNextEvent();
		}
		
	}else{
		
		this.resetta();
		if (typeof(this.onResetEvent)=="function"){
			this.onResetEvent();
		}
		
	}

}
//***********************************************************************************************************************
//***********************************************************************************************************************
area9ScrollPanel.prototype.fineEffetto=function(){
	
	var self=this;
	
	if (this.loopAttivo==true){
		this.myInterval=setInterval(function(){self.scorriElemento()},this.intervalloElemento);
		if($('pausaBtn')){
			$('pausaBtn').fade('in');
		}
	}
	
	this.spostaElemento.isTween=false;
	
	// Attivo le freccette avanti e indietro, play e pausa	
	$('prevBtn').onclick=function(){self.elementoPrecedente()};
	$('nextBtn').onclick=function(){self.elementoSuccessivo()};

	if($('menuTabs')){
		$$('.tabs').each(function(tab){
		
			tab.onclick=function(){self.gotoElemento(tab.id.substr(3))};
			
	   });
	}

	if($('pausaBtn')){
		$('pausaBtn').setStyle('opacity',0);
	}
	
//	alert(this.indiceElemento+this.nrElementiVisualizzati);
	
	if(this.indiceElemento==0){

		$('nextBtn').fade('in');
		$('prevBtn').fade('out');
	
	}else if((this.indiceElemento+this.nrElementiVisualizzati)==(this.contaElementi)){
	
		$('nextBtn').fade('out');
		$('prevBtn').fade('in');
	
	}else{
	
		$('nextBtn').fade('in');
		$('prevBtn').fade('in');

	}
	
}
//***********************************************************************************************************************
//***********************************************************************************************************************
area9ScrollPanel.prototype.resetta=function(){
	
	var self=this;
	
	$('prevBtn').fade('out');
	
	if($('pausaBtn')){
		$('playBtn').fade('out');
		$('pausaBtn').fade('out');
	}
	
	this.indiceElemento=0;
	clearInterval(this.myInterval);
		
	switch(this.effettoResetta){
		
		case "fade":
	
			this.effettoAnimazioneLoop = new Fx.Tween($('contMultiple'),{duration: 1000,onStart:function(){self.evtInizioAnimazione();},onComplete:function(){self.ricominciaColFade()}});
			this.effettoAnimazioneLoop.start('opacity',0);


		break;
		
		
		case "scorri":
			this.posizioneElementi=$('contMultiple').offsetLeft;
			this.effettoAnimazioneLoop = new Fx.Tween($('contMultiple'),{duration: 1500,onStart:function(){self.evtInizioAnimazione();},onComplete:function(){self.fineEffetto()}});
			this.effettoAnimazioneLoop.start('left',this.posizioneElementi,0);
			
		break;
		
	}
}
//***********************************************************************************************************************
//***********************************************************************************************************************
area9ScrollPanel.prototype.ricominciaColFade=function(){
		
		var self=this;
		var risettaPosizione = new Fx.Tween('contMultiple', {duration: 1});
		risettaPosizione.start('left',0);
		var fadeIn = new Fx.Tween($('contMultiple'),{duration: 1500,onComplete:function(){self.fineEffetto()}});
		fadeIn.start('opacity',1);
	
}
//***********************************************************************************************************************
//*** Spostamento indietro
//***********************************************************************************************************************
area9ScrollPanel.prototype.elementoPrecedente=function(){
	
	if (parseInt(this.indiceElemento)==0){
	
		$('prevBtn').fade('out');
		
		return;
		
	}else{
		
		this.gotoElemento(parseInt(this.indiceElemento)-this.nrSpostamentoElementi);
	}
	
	if (typeof(this.onPreviousEvent)=="function"){
		this.onPreviousEvent();
	}

}
//***********************************************************************************************************************
//*** Spostamento avanti
//***********************************************************************************************************************
area9ScrollPanel.prototype.elementoSuccessivo=function(){
	
	if(parseInt(this.indiceElemento)==(this.contaElementi-1)){
		return;
	}
	
	this.gotoElemento(parseInt(this.indiceElemento)+this.nrSpostamentoElementi);

	if (typeof(this.onNextEvent)=="function"){
		this.onNextEvent();
	}

}
//***********************************************************************************************************************
//*** FUNZIONE CHE PASSANDO L'ID SPOSTA GLI ELEMENTI
//***********************************************************************************************************************
area9ScrollPanel.prototype.gotoElemento=function(indice){

	//Funzione per spostarsi ad un elemento predefinito
	//Se indice passato e' > dell'indice corrente
	if (indice!=this.indiceElemento){
		this.posizioneElementi=$('contMultiple').offsetLeft;
		clearInterval(this.myInterval);
	}
	
	var self=this;
	
	//*** Se il nuovo indice � > di quello corrente bisogna andare avanti
	if (indice>this.indiceElemento){
	
		var elementiRimanenti=parseInt(this.contaElementi) - (parseInt(indice)+parseInt(this.nrElementiVisualizzati));
		
		// Ci vengono dei buchi alla fine
		if (elementiRimanenti<0){
			
			indice-=Math.abs(elementiRimanenti);
						
		}
						
		if(($('menuTabs')) && (this.setStyleTabs==true)){
			
			this.tabAttiva=indice;
						
			$('tab'+this.tabAttiva).addClass(this.styleTabAttiva);
			$('tab'+this.indiceElemento).removeClass(this.styleTabAttiva);
			$('tab'+this.indiceElemento).addClass(this.styleTabsNonAttive);

		}
		
		this.indiceElemento=indice;
		
		//Se e' in animazione
		if((typeof(this.spostaElemento)!="undefined") && this.spostaElemento.isTween==true){
		
			this.spostaElemento.cancel();
		/*	var spostamentoX=((indice)*this.singleElementWidth)+this.posizioneElementi;
			this.spostaElemento = new Fx.Tween('contMultiple', {duration: this.velocitaScroll,onStart:function(){self.evtInizioAnimazione();},onComplete:function(){self.fineEffetto();}});
			this.spostaElemento.start('left',this.posizioneElementi,this.posizioneElementi-this.spostamentoX);

			$('prevBtn').onclick=null;
*/
		}	
					
		var spostamentoX=((indice)*this.singleElementWidth)+this.posizioneElementi;
		this.spostaElemento = new Fx.Tween('contMultiple', {duration: this.velocitaScroll,onStart:function(){self.evtInizioAnimazione();},onComplete:function(){self.fineEffetto();}});
		this.spostaElemento.start('left',this.posizioneElementi,this.posizioneElementi-spostamentoX);
	
		$('prevBtn').onclick=null;

		
		
		if (typeof(this.onPreviousEvent)=="function"){
			this.onPreviousEvent();
		}
			
	}else if (indice<this.indiceElemento){
		
		// Ci vengono dei buchi alla fine
		if (indice<0){
			
			indice=0;
						
		}
		
		if(($('menuTabs')) && (this.setStyleTabs==true)){
			
			this.tabAttiva=indice;
			
			$('tab'+this.tabAttiva).addClass(this.styleTabAttiva);
			$('tab'+this.indiceElemento).removeClass(this.styleTabAttiva);
			$('tab'+this.indiceElemento).addClass(this.styleTabsNonAttive);

		}
	
		this.indiceElemento=indice;
		
		if(this.spostaElemento.isTween==true){
			
			this.spostaElemento.cancel();		
			/*var spostamentoX=-this.posizioneElementi-(indice*this.decrementValue);
			this.spostaElemento = new Fx.Tween('contMultiple', {duration: this.velocitaScroll,onStart:function(){self.evtInizioAnimazione();},onComplete:function(){self.fineEffetto();}});
			this.spostaElemento.start('left',this.posizioneElementi,this.posizioneElementi+this.spostamentoX);
			
			$('nextBtn').onclick=null;
		*/	
		}
			
		var spostamentoX=((indice)*this.singleElementWidth)+this.posizioneElementi;
		this.spostaElemento = new Fx.Tween('contMultiple', {duration: this.velocitaScroll,onStart:function(){self.evtInizioAnimazione();},onComplete:function(){self.fineEffetto();}});
		this.spostaElemento.start('left',this.posizioneElementi,this.posizioneElementi-spostamentoX);
		$('nextBtn').onclick=null;

		if (typeof(this.onNextEvent)=="function"){
			this.onNextEvent();
		}

	}
	
}

//***********************************************************************************************************************
// Se il riavvolgimento del loop o lo spostamento avanti/indietro e' in animazione, disattivo le freccette e le tabs
//***********************************************************************************************************************
area9ScrollPanel.prototype.evtInizioAnimazione=function(){
	
	if(this.spostaElemento){
		
		this.spostaElemento.isTween=true;
	
	}else if(this.effettoAnimazioneLoop){
		
		this.effettoAnimazioneLoop.isTween=true;
	
	}
	
	$('prevBtn').onclick=null;
	$('nextBtn').onclick=null;
	
	if($('menuTabs')){
		$$('.tabs').each(function(tab){
		
			tab.onclick=null;
		
	   });
	}

}
//***********************************************************************************************************************
//***********************************************************************************************************************
area9ScrollPanel.prototype.pause=function(){
	
	clearInterval(this.myInterval);
	this.loopAttivo=false;
	
	var effectPausa = new Fx.Tween($('pausaBtn'),{duration: 1000, transition: Fx.Transitions.Expo.easeIn});
	effectPausa.start('left', 150);
	$('pausaBtn').fade('out');

	var effectPlay = new Fx.Tween($('playBtn'),{duration: 1000, transition: Fx.Transitions.Expo.easeOut});
	effectPlay.start('left', 201);
	$('playBtn').fade('in');
	
}
//***********************************************************************************************************************
//***********************************************************************************************************************
area9ScrollPanel.prototype.play=function(){
	
	
	var self = this; 
	
	this.myInterval=setInterval(function(){ self.scorriElemento();},this.intervalloElemento);
	this.loopAttivo=true;
	
	
}
