﻿/* --------------------------------------------------------------------------------- */
function toggleMenu(elementId, makeVisible) {
    var e = document.getElementById(elementId);
    if (e == null) {
        alert('The element [' + elementId + '] was not found on the page.');
        return (false);
    }
    //if desired visibility isn't specified then swap visibility to whatever it isn't...
    if (makeVisible.toString == '') {
        if (e.style.display == 'block') {
            makeVisible == false;
        } else {
            makeVisible = true;
        }
    }
    var mask = document.getElementById('popup-menu-mask');
    switch (elementId) {
        case 'popup-menu-1':
            //calculate the width of the left margin based on the #Page element...
            var p = document.getElementById('Page');
            var marginLeft = getElementPosition(p, 'x');
            mask.style.left = marginLeft + 'px';

            //calculate the position & height of the mask...
            var t = document.getElementById('phTop');
            var marginTop = getElementPosition(t, '') + t.offsetHeight;
            mask.style.height = (Geometry.getViewportHeight() - marginTop) + 'px';
            mask.style.top = marginTop + 'px';
            mask.style.width = p.offsetWidth + 'px'
            toggleVisibility('popup-menu-mask', makeVisible);

            //indent the menu 85px to align under "Services" menu item...
            e.style.left = marginLeft + 85 + 'px';
            e.style.top = marginTop + 'px';
            if (makeVisible) {
                e.style.display = 'block';
            }
        case 'popup-menu-it':
            var me = document.getElementById('box1')
    }
    if (makeVisible) {
        e.style.display = 'block';
    } else {
        e.style.display = 'none';
    }
}
/* --------------------------------------------------------------------------------- */
function getStyle(el, styleProp) {
    var x = document.getElementById(el);
    if (x.currentStyle) {
        var y = x.currentStyle[styleProp];
    } else if (window.getComputedStyle) {
        var y = document.defaultView.getComputedStyle(x, null).getPropertyValue(styleProp);
    }
    return y;
}
/* --------------------------------------------------------------------------------- */
function changeHeight(element, pixelHeight) {
    alertt('element.style.height = ' + pixelHeight + 'px');
    element.style.height = pixelHeight + 'px';
}
/* --------------------------------------------------------------------------------- */
function showElement(elementId) {
    toggleVisibility(elementId, true)
}
/* --------------------------------------------------------------------------------- */
function hideElement(elementId) {
    toggleVisibility(elementId, false)
}
/* --------------------------------------------------------------------------------- */
function toggleVisibility(elementId, makeVisible) {
    var e = document.getElementById(elementId);
    //error if the element isn't there...
    if (e == null) {
        alert('The element [' + elementId + '] was not found on the page.');
        return (false);
    }
    //if desired visibility isn't specified assume visibility should be swapped to whatever it isn't...
    if (makeVisible.toString == '') {
        if (e.style.display == 'block') {
            makeVisible == false;
        } else {
            makeVisible = true;
        }
    }
    if (makeVisible) {
        e.style.display = 'block';
    } else {
        e.style.display = 'none';
    }
    return (true);
}

