﻿var PromoTimer = null;
var PromoTimerUpdateInterval = 2000; // in milliseconds
var PromoCount = 0;
var PromoIndex = 0;
var PromoContext = null;
var PromoItemHeight = 210;

$(function() {
    PromoContext = $("#PromoBox");
    PromoCount = $(".Item", PromoContext).length;
    if (PromoTimer) { clearInterval(PromoTimer); }
    PromoTimer = setInterval(PromoTimerUpdate, PromoTimerUpdateInterval);
    PromoTimerUpdate();
});

function PromoTimerUpdate() {
    if (PromoIndex + 1 >= PromoCount) {
        $(".Items", PromoContext).delay(1200).animate({ top: 0 }, 900, function() { });
        PromoIndex = 0;
    }
    else {
        $(".Items", PromoContext).delay(1200).animate({ top: '-=' + PromoItemHeight }, 1800, function() { });
        PromoIndex++;
    }
}
