var animation_en_cours = false;
var fancybox_interval = false;

function js_toggle_lecture(id)
{
	$('#' + id).slideToggle('slow');
}

function js_fleche_mouse_event(obj, gauche, over)
{
	obj.src = 'images/fleche_' + (gauche ? 'gauche' : 'droite') + (over ? '_over' : '') + '.gif';
}

function js_fleche_go(step)
{
	if(!animation_en_cours)
	{
		animation_en_cours = true;

		$('#etapes-fabrication-slider').animate({marginLeft: '+=' + (step * 570) + 'px'}, 'slow', 'swing', function()
		{
			var margin_left = parseInt($('#etapes-fabrication-slider').css('marginLeft')) * -1;

			if(margin_left == 0)
				$('#etapes-fabrication-fleche-gauche').fadeOut('normal', function(){animation_en_cours = false});
			else if(margin_left == 570)
				$('#etapes-fabrication-fleche-gauche').fadeIn('normal', function(){animation_en_cours = false});
			else if(margin_left == 3420)
				$('#etapes-fabrication-fleche-droite').fadeIn('normal', function(){animation_en_cours = false});
			else if(margin_left == 3990)
				$('#etapes-fabrication-fleche-droite').fadeOut('normal', function(){animation_en_cours = false});
			else
				animation_en_cours = false;
		});
	}
}

function js_demarre_diaporama()
{
	$('a.thumb-gallery:first').trigger('click');

	fancybox_interval = window.setInterval(function()
	{
		$.fancybox.next(false);
	}, 5000);
}

function js_stop_diaporama()
{
	if(fancybox_interval)
		window.clearInterval(fancybox_interval);
}