$(document).ready(function() {

	$(".numero_slides").show();
	$(".numero_slides a:first").addClass("active");
		
	var imageWidth = $("#slider").width();
	var imageSum = $(".slider_absolute img").size();
	var imageReelWidth = imageWidth * imageSum;
	
	$(".slider_absolute").css({'width' : imageReelWidth});
	
	rotate = function(){	
		var triggerID = $active.attr("rel") - 1;
		var image_reelPosition = triggerID * imageWidth;

		$(".numero_slides a").removeClass('active');
		$active.addClass('active');
		
		$(".slider_absolute").animate({ 
			left: -image_reelPosition
		}, 500 );
		
	}; 
	
	rotateSwitch = function(){		
		play = setInterval(function(){
			$active = $('.numero_slides a.active').next();
			if ( $active.length === 0) {
				$active = $('.numero_slides a:first');
			}
			rotate();
		}, 7000);
	};
	
	rotateSwitch();
	
	$(".slider_absolute a").hover(function() {
		clearInterval(play);
	}, function() {
		rotateSwitch();
	});	
	
	$(".numero_slides a").click(function() {	
		$active = $(this);
		clearInterval(play);
		rotate();
		rotateSwitch();
		return false;
	});	
	
});
