﻿// jQuery to switch the images
var currentImage = 0; // Start with 0
var countImages = 3;

$(document).ready(function() {
    SwitchImages(); // Get started
});

function SwitchImages() {

    if (++currentImage > countImages)
        currentImage = 1;

    for (var i = 1; i <= countImages; i++) {
        var id = '#Pic' + i;
        if (i == currentImage) {
            // 1 sec to come in, then wait 5 secs and switch again
            $(id).animate({ opacity: 1 }, { duration: 1000, complete: function() { setTimeout(SwitchImages, 5000); } });
        }
        else if ($(id).css('opacity') == 1) {
            // 2 secs to go out
            $(id).animate({ opacity: 0 }, { duration: 2000 });
        }
    }
}
