(function($){
	$.fn.simpleSlide = function(options){
		
		var defaults = {
			delay: 5000,
			speed: 1500,
			overwriteCSS: false
		};
		var options = $.extend(defaults, options);
		var object = $(this);
		
		if(!options.overwriteCSS){
			if(object.css("position") != "relative" && object.children().css("position") != "absolute"){
				if(window.console && window.console.firebug){
					console.warn("The default simpleSlide CSS hasn't been applied");
				}
		
				object.css({
					"position" : "relative",
					"height" : object.children(':first').css('height'),
					"overflow" : "hidden"
				})
				object.children().css({
					"position" : "absolute",
					"top" : 0,
					"left" : 0,
					"zIndex" : 8
				})
				object.children('.active').css("zIndex", 10);
				object.children('.last').css("zIndex", 9);
			}
		}
		
		if(object.children().length > 1){
			setInterval( function(){
				var active = object.children('.active');
				if ( active.length == 0 ) active = object.children(':last');
				
				var next = active.next().length > 0 ? active.next() : object.children(':first');
			
				active.addClass('last');
			
				next.css({opacity: 0.0})
					.addClass('active')
					.animate({opacity: 1.0}, options.speed, function() {
						active.removeClass('active last');
					});
					
				object.children('.active').css("zIndex", 10);
				object.children('.last').css("zIndex", 9);
			}, options.delay );
		}
	
		return this;
	}
})(jQuery);

