// Once the document is loaded, start the slideshow
$(function() {
    var images = $("#event img").get();
    if (images.length < 2) return;

    // Hide all but the first image
    for (var i = 1; i < images.length; i++) {
        $(images[i]).hide();
    }

    // Begin swapping images
    swap(images, 0, 1, 8000);
});

function swap(images, curr, next, duration) {
    $(images[curr]).fadeOut(duration);
    $(images[next]).fadeIn(duration, function() {
        curr = next;
        next = (next + 1) % images.length;

        swap(images, curr, next, duration);
    });
}
