var tabTimer;

function tabsTimer(tabIdx) {
    if (tabIdx < 1 || tabIdx > tabC.count || isNaN(tabIdx) || tabC.count <= 1)
        return;

    for (i = 1; i <= tabC.count; i++) {
        if (i == tabIdx) {
            $("#istab" + i).show();
            $("#istabsel" + i).addClass("on");
        }
        else {
            $("#istab" + i).hide();
            $("#istabsel" + i).removeClass("on");
        }
    }
    if (tabC.pause == 0) {
        tabIdx++;
        if (tabIdx > tabC.count)
            tabIdx = 1;
    }
    tabC.current = tabIdx;
    if (tabC.time && tabC.pause == 0 && tabC.count > 1)
        tabTimer = window.setTimeout('tabsTimer(' + tabC.current + ')', tabC.time);

    return true;
}

function isTabsInit(tabCount) {
    tabC.count = tabCount;
    if (tabC.count > 1 && tabC.time)
        tabTimer = window.setTimeout('tabsTimer(1)', tabC.time);
}

function tabSelect(tabIdx) {
    tabC.pause = 1;
    tabsTimer(tabIdx);
    return false;
}

function tabStart() {
    if (tabC.pause == 1) {
        tabC.pause = 0;
        if (tabC.time)
            tabTimer = window.setTimeout('tabsTimer(' + tabC.current + ')', tabC.time);
    }
}

function tabStop() {
    if (tabC.pause == 0) {
        window.clearTimeout(tabTimer);
        tabC.pause = 1;
    }
}
