﻿var rotateInterval = 10000; //ms
var timerID = null;
var tabCount = 0;

function initialize() {
    startRotation(0);
}

function startRotation(activeTab) {
    xpcCarousel.SetActiveTabIndex(activeTab);
    var tabCount = xpcCarousel.GetTabCount();
    if (activeTab >= tabCount - 1)
        activeTab = 0;
    else
        activeTab++;
    timerID = setTimeout('startRotation(' + activeTab + ')', rotateInterval);
}

function pauseRotation() {
    if (timerID != null) {
        clearTimeout(timerID);
        timerID = null;
    }
}

function playRotation() {
    if (timerID == null) {
        timerID = setTimeout('startRotation(' + xpcCarousel.GetActiveTabIndex() + ')', rotateInterval);
    }
}
