

var TABS = new Array();
var DOWNTIME_CONTENT = 4000;


function start_tab_switch(home_wp_news) {
    if (home_wp_news > 0) TABS.push(home_wp_news);
}

function show_Data(home_wp_news, contentId) {

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

    turn_tabs_0ff(home_wp_news);

    var id = "contentarea1003contain-" + home_wp_news + "-" + contentId;
    var o = document.getElementById(id);
    if (!o) return;
    o.className = "framework";

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

function proc_all_Content() {
    for (var i=0; i<TABS.length; i++) {
        var home_wp_news = TABS[i];
        if (home_wp_news > 0) beginTabScroll(home_wp_news);
    }
}

function beginTabScroll(home_wp_news) {

    if (home_wp_news < 1) return;

    var emblem = 0;
    var id = "htext-" + home_wp_news;
    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 == "framework") {
            emblem = i;
        }
    }

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

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

    turn_tabs_0ff();
    show_Data(home_wp_news, id);
    
}

function turn_tabs_0ff(home_wp_news) {
    if (home_wp_news < 1) return;
    var id = "htext-" + home_wp_news;
    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 = "texts-" + home_wp_news + "-" + id;
        o = document.getElementById(id);
        if (!o) continue;
        o.style.display = "none";
    }
}

function stopContentSwitch(home_wp_news) {
    for (var i=0; i<TABS.length; i++) {
        if (TABS[i] == home_wp_news) {
            TABS[i] = 0;
        }
    }
}



if (DOWNTIME_CONTENT > 0) setInterval(proc_all_Content, DOWNTIME_CONTENT);
