(function($){

	$.fn.simpleFader = function(options) {
		var defaults = {
			speed		: 4000 ,
			activeClass : 'show' 
		};
	
		var o = $.extend(defaults, options);

		var fadeTime = (o.speed < 2000) ? Math.floor( o.speed / 2) : 1000;
		
		this.each(function() {
			var elem = $(this);
			
			elem.css({ position : 'relative' });
			
			elem.find('ul li').css({
				opacity: 0,
				position : 'absolute',
				top : '0px',
				left : '0px'
			});
			
			elem.find('ul li:first').css({ opacity : 1 }).addClass(o.activeClass);			
			
			setInterval( function() {

				var current = ( elem.find('ul li.show') ? elem.find('ul li.show') : elem.find('ul li:first') );
				
				var next = ( (current.next().length) ? ( (current.next().hasClass(o.activeClass)) ? elem.find('ul li:first') : current.next() ) : elem.find('ul li:first') );	

				//Set the fade in effect for the next image, the show class has higher z-index
				next.css({opacity: 0})
					.addClass(o.activeClass)
					.animate({opacity: 1}, fadeTime);
			
				//Hide the current image
				current.animate({opacity: 0}, fadeTime)
					   .removeClass(o.activeClass);
			
			}, o.speed); // setInterval(
		}); // this.each(
		
		return this;
	}

})(jQuery);
