(function($){

$.fn.slideshow = function(options) {
	
	var defaults = {
		delay: 4000,
		speed: 1000
	};
	
	var options = $.extend(defaults, options);

    return this.each(function() {
	
	    var $slideshow = $(this);
		var count = 0;
		var children = $slideshow.children().size();
		
		if(children > 1)
		{
			$slideshow.children().hide();
			showhide($slideshow.children().eq(count));
		}
		
		function showhide($child)
		{
			$child.fadeIn(defaults.speed).delay(options.delay).fadeOut(defaults.speed,
				function()
				{
					count++; if(count >= children) count = 0;
					showhide($slideshow.children().eq(count));
				}
			);
		}	
		
    });
 };

})(jQuery);
