
$(document).ready(function() {

	//
	$(".paging").show();
	$(".paging a:first").addClass("active");
		
	//
	var imageWidth = $(".window").width();
	var imageSum = $(".image_reel img").size();
	var imageReelWidth = imageWidth * imageSum;
	
	//
	$(".image_reel").css({'width' : imageReelWidth});
	
	//
	rotate = function(){
		var triggerID = $active.attr("rel") - 1; 
		var image_reelPosition = triggerID * imageWidth - 1; 
		$(".paging a").removeClass('active'); 
		$active.addClass('active'); 
		
		$(".image_reel").animate({left: -image_reelPosition}, 1 );
		$(".image_reel").animate({opacity: 1}, 200 );//Velocidade do fade
	}; 
	
	//
	rotateSwitch = function(){		
		play = setInterval(function(){
			$active = $('.paging a.active').next();
			if ( $active.length === 0) { 
				$active = $('.paging a:first');
			}
			$(".image_reel").animate({opacity: 0}, 200 );//Velocidade do fade
			rotate(); 
		}, 6000); //Velocidade da pausa
	};
	
	rotateSwitch(); 
	
	//
	$(".image_reel a").hover(function() {
		clearInterval(play); //
	}, function() {
		rotateSwitch(); //
	});	
	
	//
	$(".paging a").click(function() {	
		$active = $(this); 
		
		clearInterval(play); 
		$(".image_reel").animate({opacity: 0}, 200 ); //Velocidade do fade no clique
		rotate(); 
		rotateSwitch(); 
		return false; 
	});	
	
});
