
	// **********
	// Fonction loadImages() : Chargement des images...
	// **********
	
	var loadImages = function(str)
	{
		var strSelector = $(str);
		
		// Récupération dans un Array de l'URL de chaque attribut "src" de la balise "img"
		var arrImages = $(strSelector).getElements('img');
		var arrSources = [];
		arrImages.each(function(eleImage) {
			arrSources.push(eleImage.get('src'));
		})
		
		// Affichage
		new Asset.images(arrSources, {
			onProgress: function(counter, i) {
				this.setStyles({
					'position': 'absolute',
					'opacity': 0,
					'left': ($('loading').getCoordinates().width / 2) - (this.width / 2),
					'top': ($('loading').getCoordinates().height / 2) - (this.height / 2)
				});
				
				//loadedImages[counter] = this;
				var percent = ((counter + 1) * $('loading').getStyle('width').toInt()) / arrImages.length;
				$$('.bar').setStyle('width', percent).set('html', 'Chargement de '+ (counter + 1) +' / '+ arrImages.length);
			},
			onComplete: function() {
				$('loading').setStyle('display', 'none');
				/*
					// *****
					// BUGGY
					// *****
					var objChain = new Chain;
					arrImages.each(function(eleImage, i) {
					//for(var i = 0; i < arrImages.length; i++) {
						objChain
						.chain(function() {
							eleImage.set('tween', {duration: 700}).tween('opacity', 0, 1);
							this.callChain.delay(500, this); // L'image reste visible durant 5 secondes
						})
						.chain(function() {
							eleImage.set('tween', {duration: 700}).tween('opacity', 1, 0);
							this.callChain.delay(700, this); // Le "fade out" dure 700 millisecondes
						});
					//}
					});
					
					objChain.callChain();
				*/
				
				// Usage of FadeGallery()
				var myGallery = new FadeGallery( $$('#'+ str +' img') );
			}
		});
	}
	
	// **********
	// Fonction FadeGallery() : ...Affichage des images en fondu progressif
	// **********
	
	var FadeGallery = new Class({
	    Implements: [Options, Events],
	    options: {
	        auto: true,
	        duration: 5000
	    },
	   
	    containers: [],
	    current: -1,
	    autotimer: $empty,
	   
	    initialize: function(containers, options) {
	        this.setOptions(options);
	        this.containers = $$(containers);
	        this.show(0);
	    },
	   
	    show: function(id) {
	        if( id != this.current) {
				// Hide old one
				if( this.current > -1 ) {
				    this.containers[this.current].set('tween', {duration: 150}).tween('opacity', 1, 0);
				}
				
	            // Show new one
	           	this.containers[id].set('tween', {duration: 1250}).tween('opacity', 0, 1);
	           	
	            this.current = id;
	            if( this.options.auto ) { 
	            	this.auto();
	            }
	        }
	    },
	   
	    auto: function() {
	        $clear(this.autotimer);
	        this.autotimer = this.next.delay(this.options.duration, this);
	    },
	   
	    next: function(step) {
	        var step = step || 1;
	        var next = 0;
	       
	        if ( this.current + step < this.containers.length ) next = this.current + step;
	        if ( this.current + step < 0 )  next = this.containers.length-1;
	       
	        this.show(next);
	    }
	   
	});