﻿var windowPos = "";
var init = false
function initMenu() {
    menuLyr = document.getElementById("feature_menubar");
    winPosFix = parseInt(menuLyr.style.top);
    windowPos = winPosFix;
    menuSlide = setInterval("moveMenu()", 30);
    YOffset = 0;
    init = true;
}
function moveMenu() {
    if (init) {
        //YOffset = (window.pageYOffset) ? window.pageYOffset : (document.body.scrollTop + document.documentElement.scrollTop);
        if (self.pageYOffset) // all except Explorer
        {
            YOffset = self.pageYOffset;
        }
        else if (document.documentElement && document.documentElement.scrollTop)
        // Explorer 6 Strict
        {
            YOffset = document.documentElement.scrollTop;
        }
        else if (document.body) // all other Explorers
        {
            YOffset = document.body.scrollTop;
        }
        if (YOffset <= windowPos && windowPos == winPosFix) return;
        if (YOffset > windowPos) {
            deltaY = Math.ceil(Math.abs(YOffset - windowPos) / 8);
        }
        else {
            if (YOffset > winPosFix) {
                deltaY = Math.ceil(Math.abs(YOffset - windowPos) / 8);
            }
            else {
                deltaY = Math.ceil(Math.abs(winPosFix - windowPos) / 8);
            }
        }
        if (YOffset <= windowPos) deltaY = 0 - deltaY;
        menuLyr.style.top = (parseInt(menuLyr.style.top) + deltaY) + "px";
        windowPos += deltaY;
    }
}
var menuSlide = 0;
function stopMenu() {
    clearInterval(menuSlide);
}
function startMenu() {
    clearInterval(menuSlide);
    menuSlide = setInterval("moveMenu()", 30);
}

function getRealLeft(el) {
    if (arguments.length == 0) el = this;
    xPos = el.offsetLeft;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetLeft;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}

function getRealTop(el) {
    if (arguments.length == 0) el = this;
    yPos = el.offsetTop;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        yPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    return yPos;
}

function sideNavPos() {
    var sideNav = document.getElementById("feature_menubar");
    var positionMarker = document.getElementById("feature_menubar_marker");
    sideNav.style.top = getRealTop(positionMarker) + "px";
    sideNav.style.left = getRealLeft(positionMarker) + "px";
}