var sources_id	= '#diapo_sources';
var display_id 	= '#cadre1';
var slide_speed = 6000;
var fade_speed 	= 1000;

/* -------------------------------------------------------------------------------------------- */

var images 	= new Array();
var loading = 0;
var index 	= 0;

$(document).ready(function(){
	$(sources_id).hide();
	$(sources_id + ' img').each(function(){
		images.push($(this).attr('src'));
	});
	
	$(sources_id + ' img').load(function(){
		loading++;
		if (loading == images.length)
		{
			slideshow();
		}
	});
});

/* -------------------------------------------------------------------------------------------- */

function slideshow ()
{
	var image = '<img src="' + images[index] + '" />';
	$(display_id).fadeOut(fade_speed, function(){
		$(display_id).html(image);
	});
	$(display_id).fadeIn(fade_speed);
	
	index++;
	if (index == images.length)
	{
		index = 0;
	}
	
	setTimeout('slideshow()', slide_speed + (2 * fade_speed));
}
