﻿$(function () {

    $('#RotateContainer').css({ position: 'relative' });

    var allImgs = $('#RotateContainer img');

    allImgs.css({
        position: 'absolute',
        top: 0,
        left: 0
    }).hide();

    var currIdx = 0;
    allImgs.first().show();

    function next() {
        var nextIdx = currIdx + 1;
        if (nextIdx >= allImgs.length) nextIdx = 0;
        allImgs.eq(currIdx).fadeOut();
        allImgs.eq(nextIdx).fadeIn();
        currIdx = nextIdx;
    }

    function doAuto() {
        next();
        setTimeout(doAuto, 3000);
    }
    setTimeout(doAuto, 3000);

});
