if(typeof jQuery != 'undefined') {
	jQuery(function($) {
		$.fn.extend({
			dSlider: function(time) {
				return this.each(function() {
					var counter = 1;
					var ativo = 0;
					var total = $(this).children().length;
					var intervalo;
					if (total > 1) {
						intervalo = window.setInterval(nextBanner, time);
					}
					var lista = new Array();
					var next;
					var atual;
					var proximo;
					var name = String($(this));
					
					$(this).children().each(function() {						
						if (counter <= total) {
							$(this).attr("rel",counter-1);							
							if (counter == 1)
								$(this).css({position: "absolute",display:"inline"});
							else
								$(this).css({position: "absolute",display:"none"});
							lista[counter-1] = $(this);	
							counter++;		
						}
											
					});							
										
					function nextBanner() {	
						next = (ativo + 1) % total;
						
						// inativa o atual
						atual = lista[ativo];					
						proximo = lista[next];	

						atual.fadeOut(1000);
						
						// ativa o próximo
						window.setTimeout(function(){proximo.fadeIn(1000)},500);
						
						ativo = next;
					};
				});
			}
		});
		$.fn.dSlider.defaults = {
			message: "teste"
		};
	});
}
