$('.info_hide_gamme').hide();
$(document).ready(
	
	function(){
		$('#info_hide_1').hide();
		carrousel('visuel_article_bloc1', 'bloc_1', 730,1,1000, 4);	
		carrousel('visuel_article_bloc2', 'bloc_2', 730,1,1000, 2);	
		
		$('.info_hide_gamme').hide();
		$('.more_gamme').click(function() {
			$('.info_hide_gamme').show(1000);
			$('.more_gamme').hide();
			  return false;
		});
		
		
		$('.more_1').click(function() {
		  $('#visuel_article_bloc1').animate({
			height: '380px'
		  }, 1, function() {
			$('.info_hide_1').show(1000);
			$('.more_1').hide();
			return false;
		  });
		  return false;
		});
		
		$('.more_2').click(function() {
		  $('#visuel_article_bloc2').animate({
			height: '380px'
		  }, 1, function() {
			$('.info_hide_2').show(1000);
			$('.more_2').hide();
			return false;
		  });
		  return false;
		});
	}
);

function carrousel(id, id_bloc, width, nb, vitesse, nb_cat)
{
	
	$('#'+id).append('<span id="span'+id+'" style="display:none;">1</span>');
	
	var i = 1;
	
	while (i <= nb_cat)
	{
		$('#'+id_bloc+' a.link_cat'+i).click(
			function()
			{
				var current;
				var total;
				var left;
				var diff;
				var now;

				now =  parseInt($(this).attr('class').substr(8));
				current=$('#span'+id).html();
				total=$('#'+id+' .item').length+1-nb;
				left=parseInt($('#'+id+' .items').css('left'));
				diff = (width * ((current - 1) * -1)) + (current - now) * width;
				
				$('#'+id+' .items').animate({left:diff},vitesse);
				
				$('#span'+id).html(now);
				$(this).addClass('current');
				$('#'+id_bloc+' a.link_cat'+current).removeClass('current');
				return false;
			}
		);
		i++;
	}
}

