function newsFolders_initialize() {
    var container = document.getElementById('pageMainContentScroller');
    if(!container) return;
    
    var allSubheaders = container.getElementsByTagName('h2');
    var totalSubheaders = allSubheaders.length;
    if(totalSubheaders < 2) return;
    
    var linkBoxInnerHtml = 'View News: &nbsp; ';
    var toggleBoxes = new Array();
    
    for(var i = 0; i < totalSubheaders; ++i) {
        if(i > 0) linkBoxInnerHtml += ' &nbsp;<big>|</big>&nbsp; ';
        linkBoxInnerHtml += '<a id="jsLinkBox_' + i + '" href="javascript:newsFolders_toggle(' + i + ', ' + totalSubheaders + ')">' + allSubheaders[i].innerHTML + '</a>';
        
        var toggleBox = document.createElement('div');
        toggleBox.className = 'ToggleBox';
        toggleBox.style.display = 'none';
        toggleBox.id = 'jsToggleBox_' + i;
        while(allSubheaders[i].nextSibling && (i == totalSubheaders - 1 || allSubheaders[i].nextSibling != allSubheaders[i + 1]))
            toggleBox.appendChild(allSubheaders[i].nextSibling);
        
        toggleBoxes.push(toggleBox);
    }
    
    var linkBox = document.createElement('div');
    linkBox.className = 'LinkBox';
    linkBox.innerHTML = linkBoxInnerHtml;
    container.appendChild(linkBox);
    
    for(var i = 0; i < toggleBoxes.length; ++i)
        container.appendChild(toggleBoxes[i]);
    
    while(allSubheaders.length > 0)
        container.removeChild(allSubheaders[0]);
    
    newsFolders_toggle(0, totalSubheaders);
}

function newsFolders_toggle(activateIndex, totalIndices) {
    for(var i = 0; i < totalIndices; ++i) {
        document.getElementById('jsLinkBox_' + i).style.fontWeight = i == activateIndex ? 'bold' : 'normal';
        document.getElementById('jsLinkBox_' + i).style.textDecoration = i == activateIndex ? 'none' : 'underline';
        document.getElementById('jsToggleBox_' + i).style.display = i == activateIndex ? 'block' : 'none';
    }
}

if(window.addEventListener)  window.addEventListener('load', newsFolders_initialize, false);
else if(window.attachEvent)  window.attachEvent('onload', newsFolders_initialize);
