jQuery.fn.ListaDestaques = function (options) {
	
	var opts = jQuery.extend({
		timer: 4000,
		animSpeed: "normal",
		autoPlay: true,
		classAt: "dstBtAt",
		classOver: "dstBtOver",
		btNext: null,
		btPrev: null,
		btPlay: null,
		btStop: null,		
		typeEffect: "fade" //fade, slide
	}, options);
	
	this.each(function(){
		
		//Configs iniciais
		var Interval;
		var Father		= jQuery(this);
		var selItem		= 1;
		var nItens 		= jQuery(".dstItem", Father).size();
		
		if(nItens>1){
		
			jQuery('.dstItem', Father).hide();
			//jQuery('.dstItem:first', Father).show();
			
			jQuery(".dstItens", Father).css('position', 'relative');
			jQuery('.dstItem', Father).css('position', 'absolute');
			
			//----------------
			
			//Funcoes		
			function showDst (n){
				if (opts.autoPlay) { stopDst(); }
				
				$item = jQuery(".dstItem", Father);
				$currItem = jQuery(".dstItem:eq("+(n-1)+")", Father);
				
				if(opts.typeEffect=='fade'){	
					$item.fadeOut(opts.animSpeed);
					$currItem.fadeIn(opts.animSpeed);
				} else if(opts.typeEffect=='slide'){
					$item.slideUp(opts.animSpeed);
					$currItem.slideDown(opts.animSpeed);
				}
				
				selItem = n;
				jQuery(".btRpt", Father).removeClass(opts.classAt);
				jQuery(".btRpt:eq("+(n-1)+")", Father).addClass(opts.classAt);
				if (opts.autoPlay) { playDst(opts.timer); }
			}
			
			function nextDst () {
	
				if (selItem > nItens-1) {
					n = 1;
				} else {
					n = selItem + 1;
				}
	
				showDst(n);
	
			}
			
			function prevDst () {
	
				if (selItem == 1) {
					n = nItens;
				} else {
					n = selItem - 1;
				}
				showDst(n);
	
			}
			
			function playDst (t) {
				Interval = setTimeout(nextDst, t);
			}
			
			function stopDst () {
				clearTimeout(Interval);
			}
			//-------
			
			//Crio os Botoes
			var btModel = jQuery(".btRpt:last", Father);
			for (i=0; i<nItens-1; i++) { btModel.clone().insertAfter(btModel); }
			
			var lblBt = 0;
			jQuery(".btRpt", Father).each(function(){
				lblBt++;
				jQuery(this).html(lblBt);
				jQuery(this).click(function(){
					n = parseFloat(jQuery(this).html());
					if (selItem != n) {
						showDst(n);
					}
				});
				
				jQuery(this).hover(function(){
					jQuery(this).addClass(opts.classOver);
				},
				function(){
					jQuery(this).removeClass(opts.classOver);
				});
			});
			//--------------
			
			//Iniciais
			showDst (1);
			if (opts.autoPlay) { playDst(opts.timer); }
			
			//Botoes nav
			if (opts.btNext!=null) { opts.btNext.click(nextDst); }
			if (opts.btPrev!=null) { opts.btPrev.click(prevDst); }
			if (opts.btPlay!=null) { opts.btPlay.click(function(){ playDst(opts.timer); }); }
			if (opts.btStop!=null) { opts.btStop.click(stopDst); }
		
		} else {
			if (opts.btNext!=null) { opts.btNext.css('opacity', .5); }
			if (opts.btPrev!=null) { opts.btPrev.css('opacity', .5); }
		}
		
	});
}
