﻿function Rotate(prefix, toRight) {
    var hiddenCount = $("#" + prefix + "Count").get(0);
    var hiddenCurrent = $("#" + prefix + "Current").get(0);
    var count = parseInt(hiddenCount.value);
    var current = parseInt(hiddenCurrent.value);

    if (toRight) {
        current = current + 6;
        if (current + 6 > count) current = count - 6;
    }
    else {
        current = current - 6;
        if (current < 0) current = 0;
    }

    $("#" + prefix + "Table tr").each(
            function () {
                $("td", this).each(
                function (index) {
                    if (index >= current && index < current + 6)
                        this.style.display = "table-cell";
                    else
                        this.style.display = "none";
                });
            });

    hiddenCurrent.value = current;
}
