jQuery.fn.extend({
	carousel: function(o){
		o = $.extend({ // definicoes default
			carouselPos: 0
		});
		carouselRun = function(){
			if (o.carouselPos < $("#carousel .thumb").length-1){
				o.carouselPos++;
			} else {
				o.carouselPos = 0;
			}
			carouselChangePos();
		}
		
		carouselChangePos = function(){
			$("#carousel .thumb:not(eq("+o.carouselPos+")) img").fadeTo("fast", 0.20);
			$("#carousel .thumb:eq("+o.carouselPos+") img").fadeTo("fast", 1);
		
			$("#carousel .active").animate({"top": o.carouselPos*46}, "slow");
			$("#carousel .images").animate({"top": "-"+o.carouselPos*235}, "slow");
		}
		
		carouselTimer = function(){
			carouselTimeout = setInterval("carouselRun("+o.carouselPos+")", 5000);
		}
		
		$.each($("#carousel .thumb"), function(i){
			$(this).mouseover(
				function(){
					o.carouselPos = i;
					carouselChangePos();
				}
			)
		})
		
		$("#carousel").hover(
			function(){
				clearTimeout(carouselTimeout)
			},
			function(){
				carouselTimer(o.carouselPos);
			}
		)
	
		carouselChangePos();
		carouselTimer();
	}
});


$(document).ready(function() {
	$("manchete").carousel();
});
