/*
	Galerie de photos
*/
var Galerie = function (id){
	this.photoPrecedente = 0;
	this.photoCourante = 0;
	this.photos = null;
	this.vignettes = null;
	this.timeout = null;
	this.id = id;
	this.slider = $$("#" + id + ">div>ul")[0];
	this.photos = $$("#" + id + ">div>ul>li");
	this.largeurPhoto = this.photos[0].getStyle("width").replace("px","");
	// Créer des liens sur les photos
	for (var i=0;i<this.photos.length;i++){
		this.photos[i].i = i;
		this.photos[i].galerie = this;
		this.photos[i].onclick = function(){
			this.galerie.slide();
		};
	}
	// Slider jusqu'à la photo courante
	this.slide = function(){
		clearTimeout(this.timeout);
		new Effect.MoveBy(this.slider,0,(this.photoPrecedente-this.photoCourante)*this.largeurPhoto,{queue:{position:"end",scope:this.id}});
		this.photoPrecedente = this.photoCourante;
		this.photoCourante = (this.photoCourante+1)%this.photos.length;
		var thisObject = this;
		var timeoutFunction = function(){thisObject.slide();};
		this.timeout = setTimeout(timeoutFunction,5000);
	}
	this.slide();
}
