﻿var rwd = rwd || {};

rwd.rotation = {
    currentIndex: 0,
    step: function () {
        rwd.rotation.currentIndex = (rwd.rotation.currentIndex + 1) % rwd.rotation.max;

        rwd.rotation.parent.children().hide();
        rwd.rotation.parent.children(':nth-child(' + (rwd.rotation.currentIndex + 1) + ')').show();
    },
    start: function () {
        rwd.rotation.stop();
        rwd.rotation.timer = setInterval(rwd.rotation.step, rwd.rotation.interval);
        rwd.rotation.step();
    },
    stop: function () {
        if (rwd.rotation.timer) {
            clearTimeout(rwd.rotation.timer);
        }
    }
};
