﻿function slideSwitch() {
// label the first and last iamges in each rotation with the css classes 'first' and 'last', respectively
    var $active = $('.slideshow IMG.active');

    if ($active.length == 0) {
        $active = $('.slideshow IMG.last');
        if ($active.length == 0) {
            $active.addClass('active');
        }
    }

    var $next = ($active.next().length != 0)
            ? $active.next()
            : $('.slideshow IMG.first');

    $next.addClass('active');
    $active.addClass('last-active');

    $next.css({ opacity: 0.0 })
        .animate({ opacity: 1.0 }, 1000, function () {
            $active.removeClass('last-active');
        });
    $active.removeClass('active');
}

$(function () {
    setInterval("slideSwitch()", 5000);
});
