/**
 * -----------------------------------
 * Slideshow Script
 *
 * (c) 2009 by Alexander Brakowski
 *     :: http://www.arctoz.de
 *     :: genix@arctoz.de
 *     
 * ----------------------------------
 *  Licensed to René Knipschild
 */

(function($){
    $.fn.slideShow = function(settings){
        var config = {animationSpeed: 1000,
                      duration:       5000
                     };
        
        if (settings) $.extend(config, settings);
        
        this.each(function() {
            var el = $(this);
            el.children('div').not('div:first').css({opacity: 0.0});
            el.children('div:first').addClass('active');
            
            setInterval(function() {
                var active = el.children('div.active');
                
                if(active.length == 0) active = el.children('div:last');
                
                var next = active.next().length ? active.next() : el.children('div:first');
                
                active.animate({opacity: 0.0}, config.animationSpeed);
                
                active.addClass('last-active');
                
                next.css({opacity: 0.0})
                    .addClass('active')
                    .animate({opacity: 1.0}, config.animationSpeed, function() {
                        active.removeClass('active last-active');
                    });
                    
            }, config.duration);
        });
        
        return this;
    };
})(jQuery);

$(document).ready(function() {
	$("#slideshow").slideShow({duration: 1500, animationSpeed: 750}); 
});
