

var ARRAY_ARTICLE = new Array();
var CONTENTSDELAY = 4000;


function DataVisible(top10table, contentId) {

    if ((top10table < 1) || (contentId < 1)) return;

    Tab_Close(top10table);

    var id = "main_bg-" + top10table + "-" + contentId;
    var o = document.getElementById(id);
    if (!o) return;
    o.className = "contentheading";

    var id = "bigtext-" + top10table + "-" + contentId;
    var o = document.getElementById(id);
    if (!o) return;
    o.style.display = "block";
}

function breakDataSwitch(top10table) {
    for (var i=0; i<ARRAY_ARTICLE.length; i++) {
        if (ARRAY_ARTICLE[i] == top10table) {
            ARRAY_ARTICLE[i] = 0;
        }
    }
}

function Data_Move() {
    for (var i=0; i<ARRAY_ARTICLE.length; i++) {
        var top10table = ARRAY_ARTICLE[i];
        if (top10table > 0) Content_Scrolling_Starts(top10table);
    }
}

function Tab_Close(top10table) {
    if (top10table < 1) return;
    var id = "rss-data-" + top10table;
    var ul = document.getElementById(id);
    if (!ul) return;
    for (var i=0; i<ul.childNodes.length; i++) {
        var o = ul.childNodes.item(i);
        if (!o) continue;
        o.className = "";
        if (!o.id) continue;
        id = o.id;
        id = id.substr(id.lastIndexOf("-")+1);
        if (!(id > 0)) continue;
        id = "bigtext-" + top10table + "-" + id;
        o = document.getElementById(id);
        if (!o) continue;
        o.style.display = "none";
    }
}

function Content_Scrolling_Starts(top10table) {

    if (top10table < 1) return;

    var prime = 0;
    var id = "rss-data-" + top10table;
    var ul = document.getElementById(id);
    if (!ul) return;
    for (var i=0; i<ul.childNodes.length; i++) {
        var o = ul.childNodes.item(i);
        if (!o || !o.id) continue;
        id = o.id;
        id = id.substr(id.lastIndexOf("-")+1);
        if (!(id > 0)) continue;
        if (o.className == "contentheading") {
            prime = i;
        }
    }

    prime++;
    if (prime >= ul.childNodes.length) prime = 0;

    var id = ul.childNodes.item(prime).id;
    id = id.substr(id.lastIndexOf("-")+1);

    Tab_Close();
    DataVisible(top10table, id);
    
}

function Content_Auto_Scroller(top10table) {
    if (top10table > 0) ARRAY_ARTICLE.push(top10table);
}



if (CONTENTSDELAY > 0) setInterval(Data_Move, CONTENTSDELAY);
