﻿function handleOut(elname) {
    // hides all popups, parameter is the div name
    // function called on onmouseout of hyperlink parameter
    jQuery(".T1Nav ul li .active").toggleClass("active");
    d = document.getElementById(elname);
    d.style.left = "-2650px";
    if (!curActive || curActive == "") {
        return;
    }
    jQuery("#" + curActive).toggleClass("active");

}
function setLyr(obj1, lyr) {
    obj = document.getElementById(obj1);
    jQuery(".T1Nav ul li .active").toggleClass("active");
    jQuery("#" + obj1).toggleClass("active");
    maxwidth = 1000; // right side of screen you dont want the menus to go beyond
   
    var newX = findPosX(obj);
    var newY = findPosY(obj);
    var x = document.getElementById(lyr);
    var finy = 0;
    var finx = 0;
    finx = newX - 0; // starting point of nav item	  141
    finy = newY + 50; // width of top nav item
    owidth = x.clientWidth; //width of menu object html
    tt = finx + owidth;
    x.style.zindex = "500";
    if (tt <= maxwidth) {
        x.style.top = finy + 'px';
        x.style.left = finx + 'px';
        
    }
    else {
        //use the right instead of the left
        finx = finx + obj.clientWidth - x.clientWidth + 3;
        //finx = finx - (tt - maxwidth);
        x.style.top = finy + 'px';
        x.style.left = finx + 'px';
    }
    // = 0;
    //set final position
    

}
function findPosX(obj) { //recursively searches through dom to get x postion
    var curleft = 0;
    if (obj.offsetParent)
        while (1) {
        curleft += obj.offsetLeft;
        if (!obj.offsetParent)
            break;
        
        obj = obj.offsetParent;
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj) {//recursively searches through dom to get y postion
    var curtop = 0;
    if (obj.offsetParent)
        while (1) {
        curtop += obj.offsetTop;
        if (!obj.offsetParent)
            break;
        obj = obj.offsetParent;
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}
