var __HomePageArticleTabBox;
var __HomePageArticleTabLinks = new Array();

function isSmall(){
    if (location.toString().toLowerCase().indexOf("small")>-1) return true;
    return screen.width < 1024;    
}

function __HomePageArticleinitTabBox(){
    __HomePageArticleTabBox = document.getElementById("HomePageArticleTabBox");
    if(!__HomePageArticleTabBox){
        setTimeout('__HomePageArticleinitTabBox()',10);
        return;
    }
    
    var d = __HomePageArticleTabBox.getElementsByTagName("table");
    for(var i=0;i<d.length;i++){
        if(d[i].className=="HomePageArticleTabLinks"){
            __HomePageArticleTabLinks[__HomePageArticleTabLinks.length] = d[i];
        }
    }
    __HomePageArticleTabBox.Tabs = new Array();
    var c = __HomePageArticleTabBox.getElementsByTagName("td");
    
    for(var i=0;i<c.length;i++){
        if(c[i].className=="HomePageArticleActiveTab"||c[i].className=="HomePageArticleInactiveTab"){
            __HomePageArticleinitTab(c[i]);              
        }
        
        if(c[i].className=="HomePageArticleActiveTab"){
            hparticleoldTab = c[i];
        }
    }
    
    if(isSmall()){
        __HomePageArticleTabBox.Tabs[4].parentNode.removeChild(__HomePageArticleTabBox.Tabs[4]);
    }
}

function __HomePageArticleinitTab(tab){
    var i = __HomePageArticleTabBox.Tabs.length;
    __HomePageArticleTabBox.Tabs[i] = tab;
    tab.index = i;
    tab.__HomePageArticlescheduleChange = __HomePageArticlescheduleChange;
    tab.onmouseover = function(){
        this.__HomePageArticlescheduleChange(true);
    }
    tab.onmouseout = __HomePageArticlecancelChange;
    
    tab.Content = __HomePageArticleTabLinks[i];
    if(i>0){
        tab.Content.style.display = "none";
    }
    
    var c = tab.Content.getElementsByTagName("td");
    if(c.length>2){
        c[1].style.width = "230px";
        c[2].style.width = "230px";
        if(isSmall()){
            var mla = c[2].getElementsByTagName("div");
            var ml = mla[mla.length-1];
            var mla = c[1].getElementsByTagName("div");
            var ll = mla[mla.length-1];
            ml.parentNode.removeChild(ml);
            ll.parentNode.appendChild(ml);
            ll.parentNode.removeChild(ll);
            c[2].parentNode.removeChild(c[2]);
        }
    }
}

var hparticletmrChange = null;
var hparticlenewTab = null;
var hparticleoldTab = null;
var hparticletmrChangeDelay = 300;
function __HomePageArticlescheduleChange(manually){
    if(manually) __HomePageArticlecancelRotate();
    
    __HomePageArticlecancelChange();
    hparticletmrChange = setTimeout('__HomePageArticlechangeTab()',hparticletmrChangeDelay);
    hparticlenewTab = this;
}

function __HomePageArticlecancelChange(){
    if(hparticletmrChange) clearTimeout(hparticletmrChange);
}

function __HomePageArticlechangeTab(){
    if(hparticlenewTab&&hparticleoldTab){
        if(hparticlenewTab.index!=hparticleoldTab.index){
            hparticlenewTab.className="HomePageArticleActiveTab";
            hparticleoldTab.Content.style.display = "none";
            hparticleoldTab.className="HomePageArticleInactiveTab";
            hparticlenewTab.Content.style.display = "block";
            hparticleoldTab = hparticlenewTab;
        }else{
        }
    }
}

var hparticletmrRotate = null;
var hparticletmrRotateDelay = hparticletmrChangeDelay+3000;
function __HomePageArticlerotate(){
    var hparticleindex0 = hparticleoldTab.index;
    var hparticleindex1 = hparticleindex0+1;
    if( (hparticleindex1==__HomePageArticleTabBox.Tabs.length) || (hparticleindex1==__HomePageArticleTabBox.Tabs.length-1 && isSmall())){ articleindex1=0; }
    
    __HomePageArticleTabBox.Tabs[hparticleindex1].onmouseover();  

    if(hparticleindex1>0) hparticletmrRotate=setTimeout('__HomePageArticlerotate()',hparticletmrRotateDelay);
}

function __HomePageArticlecancelRotate(){
    if(hparticletmrRotate) clearTimeout(hparticletmrRotate);
}

$(function(){ setTimeout('__HomePageArticlerotate()',hparticletmrRotateDelay); });