// revolve - object rotation plugin by chris greninger
// jquery.revolve.js
// last modified 10/31/11
// ©2011 Chris Greninger - www.creativecag.com

(function($){
    $.fn.extend({ 
         
        // pass the options variable to the function
        revolve: function(options) {
 
            // set the default values
            var defaults = {
                duration : 4000,
                fadeDuration : 1500,
				slide : 'img'
            },
            options =  $.extend(defaults, options);
 
            return this.each(function() {
                var o = options;
				var $container = $(this);			
				
				// show the first slide immediately.
				$container.find(o.slide + ':first').css('display','block').addClass('active');

				// loop thru slides every X seconds
			 	setInterval(function() {
				
					// set variables for current and next slides
					var $current = $container.find('.active');
					var $next = $current.next(o.slide);

					// if there is not a next slide, set the next variable back to the first slide
					if (! $current.next(o.slide).length > 0) {
						$next = $container.find(o.slide+':first');
					}

					// fade in the next slide on top of current slide
					$next.fadeIn(o.fadeDuration).addClass('active');

					// fade out current slide
					$current.fadeOut(o.fadeDuration).removeClass('active');
				
				}, o.duration);
				
            });
        }
    });
     
})(jQuery);
