// $Id: sharenetatm.js 30 2010-01-30 05:01:48Z tboronczyk $

function findPosition(obj) {
    var sumTop = 0;
    var sumLeft = 0;

    if (obj.offsetParent) {
        do {
            sumTop += obj.offsetTop;
            sumLeft += obj.offsetLeft;

            obj = obj.offsetParent;
        }
        while (obj);
    }

    return {top:sumTop, left:sumLeft};
}

function displayDropDown(obj, value) {
    obj.style.display = (value) ? "block" : "none";
}

function init() {
    // Each drop down needs to be positioned beneigth its parent
    var pos = findPosition($("products_item"));
    $("products_menu").style.position = "absolute";
    $("products_menu").style.left = pos.left + "px";

    // Both drop down and parent need to have show/hide attached
    $("products_item").onmouseover = function () { displayDropDown($("products_menu"), true); };
    $("products_item").onmouseout =  function () { displayDropDown($("products_menu"), false); };
    $("products_menu").onmouseover = function () { displayDropDown($("products_menu"), true); };
    $("products_menu").onmouseout =  function () { displayDropDown($("products_menu"), false); };

    // the video appearing on the about.php page needs to open in a new window
    if ($("video_a")) {
        $("video_a").onclick = function () {
            window.open("/video/video.html","video_window","height=400,width=560");
            return false;
        };
    }
}
