var SCREEN_MAX_WIDTH = 1000;

function scrollTop() {
    document.body.scrollTop = 0;
}

function hideMenu() {
    setMenuVisibility("hidden");
}    

function showMenu(){
    setMenuVisibility("visible");
}

function setMenuVisibility(visibility) {
    var menu = document.getElementById("menu-container");
    if (menu) {
        menu.style.visibility = visibility;
    }
    var px = document.getElementById("px-container");
    if (px) {
        var menuWidth = getMenuWidth();
        px.style.left = menuWidth + "px";
        // in IE versions below 8.0, generate a dynamic expression for px iframe width;
        // other browsers will calculate the width automatically
        if (px.style.getExpression) {
            var IE8below,idx = navigator.userAgent.indexOf("MSIE")>-1;
            // in IE8 getExpression("width") throws "Not implemented"
            IE8below = (idx>-1) ? Number(navigator.userAgent.substr(idx+5,3)) < 8  : false;
            if (IE8below && px.style.getExpression("width")) {
                px.style.setExpression("width", "document.body.clientWidth - " + menuWidth);
            }    
        }
    }
}
function getMenuWidth() {
    var menu = document.getElementById("menu-container");
    if (menu && menu.style.visibility != "hidden") {
        return menu.offsetWidth;
    } else {
        return 0;
    }
}

function resizePx() {
    var px = document.getElementById("px-container");
    if (px) {
        var menuWidth = getMenuWidth();
        px.style.left = menuWidth + "px";
        // in IE, generate a dynamic expression for px iframe width;
        // other browsers will calculate the width automatically
        if (px.style.getExpression && px.style.getExpression("width")) {
            px.style.setExpression("width", "document.body.clientWidth - " + menuWidth);
        }
    }
}

function currentWidth() {
    var w = document.body.clientWidth;
    return w < SCREEN_MAX_WIDTH ? w : SCREEN_MAX_WIDTH;
}

function currentBlkWidth() {
    return currentWidth() - 50;
}
