function slideSwitch() {
    // Get the active image
    var $active = $('#slideshow img.active');

    // If no active image get the last image
    if ($active.length == 0)
        $active = $('#slideshow img:last');
    
    // Get the next sibling after the active one
    var $next = $active.next('img');

    // If no next image get the first one
    if ($next.length == 0)
        $next = $('#slideshow img:first');
    else
        // If the next image is the logo then get the next one
        if ($next.hasClass('logo'))
            $next = $next.next('img');

    // Animate opacity to 0 for the active image
    $active.animate({ opacity: 0.0 }, 1500,
        function() {
            // Once the animation is finished start animating the next
            // image to full opacity and make it active
            $next.css({ opacity: 0.0 })
                .addClass('active')
                .animate({ opacity: 1.0 }, 1500,
                    function() {
                        // Remove the active class from the now old active image
                        $active.removeClass('active');
                    });
        }
    );
}

$(function() {
    // Set the default opacity for all images so it works in IE
    $('#slideshow img').css({ opacity: 0.0 });
    $('#slideshow img.active').css({ opacity: 1.0 });
    $('#slideshow img.logo').css({ opacity: 0.3 });
    // Run the slideshow
    setInterval("slideSwitch()", 6000);
});
