

function handleOut(elname) {
    // hides all popups, parameter is the div name
    // function called on onmouseout of hyperlink parameter
    //alert('handleOut');
    d = document.getElementById(elname);
    if (d != null) {
        d.style.left = "-2650px";

        var ddls = document.getElementsByTagName('select');
        for (var i = 0; i < ddls.length; i++) {
            ddls[i].style.visibility = "";
        }
    }
}


function handleOutTab(obj1, elname) {
    // hides all popups, parameter is the div name
    // function called on onmouseout of hyperlink parameter
    obj = document.getElementById(obj1);
    if (obj != null) {
    //alert('handleOutTab');
        var o = new String(obj);
        o = o.replace("//", "");
        o = o.replace(o.substr(0, o.indexOf("/") + 1), "");
        var t1 = o.substr(0, o.indexOf("/"));
        var url = location.href;
        obj.className = obj.className.replace(" Carrot", "");
        if (url.indexOf(t1) != -1) {
            obj.className = obj.className + " Active";
            obj.className = obj.className.replace(" Active Active", " Active");
        }

        d = document.getElementById(elname);
        d.style.left = "-2650px";

        var ddls = document.getElementsByTagName('select');
        for (var i = 0; i < ddls.length; i++) {
            ddls[i].style.visibility = "";
        }
    }
}
function SetLyrTab(obj1, lyr) {
    
    //alert('SetLyrTab');
    obj = document.getElementById(obj1);
    if (obj != null) {
        //alert(obj1);
        obj.className = obj.className.replace("nav", "Link") + ' Carrot';
        obj.className = obj.className.replace(" Active", "");
        SetLyr(obj1, lyr);
    }
//    var ddls = document.getElementsByTagName('select');
//    for (var i = 0; i < ddls.length; i++) {
//        //ddls[i].style.visibility = "hidden";
//    }

}
var curitem;

function SetLyr(obj1, lyr) {

    maxwidth = document.body.clientWidth; // right side of screen you dont want the menus to go beyond
    obj = document.getElementById(obj1);
    curitem = document.getElementById(obj1);
    if (obj != null && curitem != null) {
        //curitem.className = obj1 + "_active";
        var newX = findPosX(obj);
        var newY = findPosY(obj);
        var x = document.getElementById(lyr);
        var finy = 0;
        var finx = 0;
        finx = newX - 129; // starting point of nav item
        finy = newY + 80; // width of top nav item

           
        if (obj1 = "nav01") {
            finx += 129;
        }

        owidth = x.clientWidth; //width of menu object html
        tt = finx + owidth;

        if (tt <= maxwidth) {
            newX = finx + 0;
        }
        else {
            finx = newX - (tt - maxwidth);
        }
        //set final position
        x.style.top = finy + 'px';
        x.style.left = finx + 'px';
    }
}


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;
  }
