var DrArrayImageDiaporama = new Class({
						initialize: function(divimg,tab0,tab1,height,width) {
						

							
							this.tabimg= createimg(tab0,0,height,width);							
							this.nbimage = this.tabimg.length;							
							this.divimg=divimg;
							
							this.displayImage=0;
							
							this.tabimg[this.displayImage].setOpacity(1);
							
							if(this.nbimage>1)
							this.switchimg.pass([1000],this).periodical(4000);
							
							this.divimg.adopt(this.tabimg);
							
							this.divimg.addEvent('click',function(){
								
								new DrArrayImageViewer (tab1,this.displayImage);
								
							}.bind(this));
							
						},
						debug: function(todebug){
							
							console.log(todebug);
						},
						//fonction qui crée les image a partir d'un tableau d'image avec opacity a 0
						switchimg:function(time)
						{
							//on efface progressivement l'image affiché
							this.tabimg[this.displayImage].effect('opacity', {duration: time, transition: Fx.Transitions.linear}).start(1, 0);
							
							if(this.displayImage+1>=this.nbimage)
								this.displayImage=0;
							else
								this.displayImage++;
							
							//on affiche progressivement l'image a affiché
							this.tabimg[this.displayImage].effect('opacity', {duration: time, transition: Fx.Transitions.linear}).start(0, 1);
						}
						
						
						
					});

function createimg(tabimg,opacity,height,width)
{
	var tabreturn = new Array();							
	tabimg.each(function(el,i){	
		var img=Asset.image(el);
		
		img.setOpacity(opacity);
		
		if(height!=undefined)
		img.setStyle('height',height);
		
		if(width!=undefined)
			img.setStyle('width',width);
		
		
		tabreturn.push(img);								
	});							
	return tabreturn;
}
