// JavaScript Document

document.addEvent('domready', function()
{
	init_slide();
});

var timer;
var div_show;
var show_on		=	true;
var tab_img		=	new Array();
var rang_actif	=	0;
var img_active	=	null;
var sizes		=	new Array(982, 210);

function show_auto()
{
	if(show_on)
	{
		if(rang_actif == tab_img.length - 1)
			rang_actif	=	0;
		else
			rang_actif++;

		show_div(rang_actif);
	}
}

function show_div(rang)
{
	// On passe la img active en dessous
	img_active.fx.start('opacity', '0');
	img_active.setStyle("z-index", 1);
	
	// On utilise la nouvelle img comme img active et on la met par dessus 
	img_active	=	tab_img[rang];
	img_active.setStyle("z-index", 50);
	img_active.fx.start('opacity', '1');
}

function init_slide()
{
	var i		=	0;
	$$(".img_slide").each(function(el)
	{
		el.fx	=	new Fx.Tween(el, {"link" : "cancel", "duration" : "long"});
		tab_img.push(el);
		el.addEvents(
		{
			mouseenter: function()
			{
				show_on	=	false;
			},
			mouseleave: function()
			{
				show_on	=	true;
			}
		});
		
		if(i != 0)
		{
			el.set('opacity', 0);
		}
		else
		{
			img_active	=	el;	
		}
		
		i++;
	});

	timer	=	show_auto.periodical(4500, null);
}

