/*******************************************************************************
*	jQuery slideshow plugin
*	Author: Phillip j Parr - http://wizpip.com
*******************************************************************************/

(function($){
		  
	$.fn.extend({
				
		slideshow: function(options) {
			
			var defaults = {
				fadeSpeed: 1000,
				duration: 5000
			}
			
			var options = $.extend(defaults, options);			
		
			return this.each(function() {
				
				var o = options;
				$(this).find('li').fadeOut(0);
				$(this).find('li:first').addClass('current').fadeIn(o.fadeSpeed);
				var self = this;
				setTimeout(function() { showNext(self) }, o.duration);
				
				function showNext(obj) {
					var next = $(obj).find('.current').next();
					if(!next.length) {
						next = $(obj).find('li:first');
					}
					$(obj).find('.current').removeClass('current').fadeOut(o.fadeSpeed);
					next.addClass('current').fadeIn(o.fadeSpeed);
					setTimeout(function() { showNext(obj) }, o.duration);
				}
				
			});
		}
	});
})(jQuery);