$(document).ready(function()
{
    setInterval(switchSlideshow, 5000);
});

function switchSlideshow()
{
    var active = $('#rotation img.active');
    var next = active.next();

    if (next.length == 0)
    {
        next = $('#rotation img:first');
    }

    active.addClass('last-active');

    next.css({opacity: 0})
        .addClass('active')
        .animate({opacity: 1}, 1000, function() {
            active.attr('class', '');
        });
}
