function dipnetScrollPanel(){

	// Variabili generali
	this.decrementValue;
	this.contaElementi;
	this.posizioneElementi;
	this.myInterval;
	this.visBtComandi=true;
	this.indiceElemento=0;
	this.loopAttivo=true;
	this.spostaElemento;
	this.effettoAnimazioneLoop;
	this.tabAttiva=0;

	
	
	// Setta le opzioni per lo scorrimento
	this.intervalloElemento=2000;
	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;

	
	this.contaElementi=($$('div#contMultiple .contSingle').length);
		
	// Calcolo la larghezza del contenitore di ogni singolo elemento
	this.decrementValue=$('contGenerale').offsetWidth;
	
	// Calcolo la larghezza del div che contiene tutti gli elementi, se coincidono non faccio comparire freccette
	$('contMultiple').setStyle('width',this.contaElementi*this.decrementValue);

	if(($('contMultiple').offsetWidth)!=(this.decrementValue)){
	
		$('nextBtn').setStyles({opacity:1,display: 'block'});
	
	}

	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,display: 'block'});


	
}

dipnetScrollPanel.prototype.init=function(){
	
	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
dipnetScrollPanel.prototype.scorriElemento=function(){
	if (this.indiceElemento<(this.contaElementi-1)){ 
		
		this.elementoSuccessivo();
		if (typeof(this.onNextEvent)=="function"){
			this.onNextEvent();
		}
		
	}else{
		
		this.resetta();
		if (typeof(this.onResetEvent)=="function"){
			this.onResetEvent();
		}
		
	}

}

dipnetScrollPanel.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);
	}
	
	if(this.indiceElemento==0){

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

	}
	
}


dipnetScrollPanel.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;
		
	}
}

dipnetScrollPanel.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);
	
}


dipnetScrollPanel.prototype.elementoPrecedente=function(){
	
	if (parseInt(this.indiceElemento)==0){
	
		$('prevBtn').fade('out');
		
		return;
		
	}else{
	
		this.gotoElemento(parseInt(this.indiceElemento)-1);
		
	}
	
	if (typeof(this.onPreviousEvent)=="function"){
		this.onPreviousEvent();
	}

}


dipnetScrollPanel.prototype.elementoSuccessivo=function(){
	

	if(parseInt(this.indiceElemento)==(this.contaElementi-1)){

		return;
		
	}

	this.gotoElemento(parseInt(this.indiceElemento)+1);
	
	if (typeof(this.onNextEvent)=="function"){
		this.onNextEvent();
	}

}

dipnetScrollPanel.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;

	if (indice>this.indiceElemento){
		
		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.decrementValue)+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;

		}else{
			var spostamentoX=((indice)*this.decrementValue)+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){

		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;
			
		}else{
			
			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+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
dipnetScrollPanel.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;
		
	   });
	}

	
}

dipnetScrollPanel.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');
}

dipnetScrollPanel.prototype.play=function(){
	
	var self = this; 
	
	this.myInterval=setInterval(function(){ self.scorriElemento();},this.intervalloElemento);
	this.loopAttivo=true;

	var effectPlay = new Fx.Tween($('playBtn'),{duration: 1000, transition: Fx.Transitions.Expo.easeIn});
	effectPlay.start('left', 150);
	$('playBtn').fade('out');
	
	var effectPausa = new Fx.Tween($('pausaBtn'),{duration: 1000, transition: Fx.Transitions.Expo.easeOut});
	effectPausa.start('left', 201);
	$('pausaBtn').fade('in');
	
}