


    
    $('#main_slideshow .slideset').each(function(){

        var slides = $(this).find('.slide');
        var width  = $(this).width(), height = $(this).height();

        slides.css({
            'width'  : width,
            'height' : height
        });

        slides.each(function() {
            $(this).find('img').each(function () {
                var $this = $(this);
                $this.attr('src', '/thumbs/' + width + 'x' + height + '/' + $this.attr('delayedsrc'));
                $this.closest('.slide').not('.active').css('opacity', 0);
            });
        });

        if (slides.length > 1) {

            setInterval(function () {

                var slides = $('#main_slideshow').find('.slide');

                var active = slides.filter('.active');

                if (active.length == 0) active = slides.filter(':first');

                var next = active.next().length ? active.next() : slides.filter(':first');

                active.removeClass('active').animate({opacity: 0.0}, 500, function() {
                    next.show().addClass('active').animate({opacity: 1.0}, 500);
                });

            }, 5000);

        }

    });


