/* Not so much a slideshow as a fadeshow */

(function($) {
    $.fn.fbisSlideShow = function(settings) {
        var config = {
            animationIn: { opacity: 'hide' },
            animationOut: { opacity: 'show' },
            start: 0,
            rotate: true,
            pause: 5000,
            fadeSpeed: 1000
        };

        if (settings) $.extend(config, settings);

        var $items = this;
        //if theres only one no point in doing anything
        if ($items.length > 1) {
            //hide all bar one
            $items.addClass('fbisSlide').hide().css({ position: 'absolute' });
            //show start slide
            var $active = $items.eq(config.start);
            //set active class on initial item
            $active.addClass('active').show();

            setInterval(switchNext, config.pause);

        }
        function switchNext() {
            //get current active
            var $active = $items.parent().find('.fbisSlide.active');
            $active.removeClass('active');
            //get next item
            var $next = $active.next();
            //if there is no next item go to start
            if ($next.length == 0) $next = $items.eq(0);
            $next.addClass('active');

            // $active.animation(config.animationIn);
            // $next.animation(config.animationOut);
            $active.fadeOut(config.fadeSpeed);
            $next.fadeIn(config.fadeSpeed);
        }
        return this;
    };
})(jQuery);


