
// thanks to http://jonraasch.com/blog/a-simple-jquery-slideshow

(function($) {
	$.fn.shuffle = function(options){
			var opts = $.extend({}, $.fn.shuffle.defaults, options);
			opts.wrapper = this;
			// add extra images
			
			$(opts.images).each(function() {
				opts.wrapper.append("<img src='" + opts.prefix + this + "' />");
			});
			this.cycleTimeout = setInterval(function(){$.fn.shuffle.go(opts)}, opts.timeout);
	};
	
	$.fn.shuffle.go = function(opts) {
	    var $active = $('IMG.active',opts.wrapper);
	    var $next =  $active.next().length ? $active.next() : $('IMG:first',opts.wrapper); // $('#slideshow IMG:first');
    	$active.addClass('last-active');
	    $next.css({opacity: 0.0})
	        .addClass('active')
	        .animate({opacity: 1.0}, 1000, function() {
	            $active.removeClass('active last-active');
	        });
	}
	
	$.fn.shuffle.defaults = {
		auto	: 1,
		easing	: null,
		prefix	: '../images',
		transition	: 800,
		timeout	: 5000  // ms per image
	};

})(jQuery);
