

PortalHomeShellContent.prototype = {
        
        
    element: undefined,
    
    topMenu: undefined,
    
    
    updateVisibility: function() {
        var mi = this.topMenu.selectedItem;
        if (mi && DOMUtil.hasClass(mi.element, "home_shell_content_trigger")) {
            this.element.style.display = "";
        } else {
            this.element.style.display = "none";
        }
    }, // updateVisibility
    

    loadedContent: function(loader) {
        this.updateVisibility();
    }, // loadedContent
    

    unloadedContent: function(loader) {
        this.updateVisibility();
    } // unloadedContent
    
        
}; // PortalHomeShellContent


function PortalHomeShellContent() {
    this.element = document.getElementById("home_shell_content");
    if (this.element) {
        this.topMenu = document.getElementById("top_nav").shellMenu;
        var loader = document.getElementById("page_content").contentLoader;
        loader.addContentListener(this);
    }
} // PortalHomeShellContent


// initialize portal when the page is loaded
new Script.Action(function() {
    
    var homeContent = new PortalHomeShellContent();

    // find the page content container
    var pageContent = document.getElementById("page_content");
    
    // scroll to the top whenever page content arrives
    var scroll = function(loader) {
        var top = Geometry.getTop(pageContent);
        var vh = Geometry.getViewportHeight();
        var yoff = Geometry.getViewportYOffset();
        if (top < yoff) {
            // top of content is above the top of the viewport
            if (vh !== undefined && top < vh / 2) {
                // close enough to the top to scroll all the way there
                top = 0;
            }
            window.scrollTo(0, top);
        }
    };
    var scroller = new Object();
    scroller.loadedContent = scroll;
    scroller.unloadedContent = scroll;
    pageContent.contentLoader.addContentListener(scroller);
    
}).run();

