

function handleOut(elname) {
    // hides all popups, parameter is the div name
    // function called on onmouseout of hyperlink parameter
 
    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 handleOutTab(obj1, elname) {
    // hides all popups, parameter is the div name
    // function called on onmouseout of hyperlink parameter
    obj = document.getElementById(obj1);
        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;
        if (url.indexOf(t1) == -1) {
            obj.className = '';
        }
	

    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) {

    obj = document.getElementById(obj1);
    
    obj.className = obj1 + '_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);
    
    //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 - 130; // starting point of nav item
    finy = newY + 45; // width of top nav item

    if (obj1 = "nav1") 
    {
        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;
  }
