<!-- Original: Mike McGrath  (mike_mcgrath@lineone.net) --> 
<!-- Website : http://website.lineone.net/~mike_mcgrath -->
<!-- Modified: Paul Ireland, improved, parameterised, simplified, supported muliple menus, componentised, applied coding standards -->
<!--

var marrayMenus;
var mMenuCount;
var mbNav;

function initpopup()
{
  marrayMenus = new Array();
  mMenuCount=0;
  mbNav=(document.layers);
}

function addpopup(strDivMenuName,left,top,width,height)
{
  var objMenu;

  objMenu = getdiv(strDivMenuName);

  mMenuCount++;
  marrayMenus = marrayMenus.concat( new Array(objMenu,left,left+width,top,top+height) );

}

function menu(strDivMenuName)
{
  var objMenu;
  var iCount;
  var iElement;

  objMenu = getdiv(strDivMenuName);

  if(objMenu)
  {
    if(mbNav)
    {
      objMenu.visibility="visible";
      for(iCount=0;iCount<mMenuCount;iCount++)
      {
        iElement = iCount * 5;
        if(marrayMenus[iElement].name==objMenu.name)
        {
          objMenu.left = marrayMenus[iElement+1];
          objMenu.top = marrayMenus[iElement+3];
        }
      }
    }
    else
    {
      objMenu.style.visibility="visible";
      for(iCount=0;iCount<mMenuCount;iCount++)
      {
        iElement = iCount * 5;
        if(marrayMenus[iElement]==objMenu)
        {
          objMenu.style.left = marrayMenus[iElement+1];
          objMenu.style.top = marrayMenus[iElement+3];
        }
      }
    }
  }
}

function startpopup()
{
  if(mbNav)
    document.captureEvents(Event.MOUSEMOVE);
  document.onmousemove=track;
}

function track(e) 
{
  var iCount;
  var iElement;
  var x=(mbNav)?e.pageX:event.x; 
  var y=(mbNav)?e.pageY:event.y;
  for(iCount=0;iCount<mMenuCount;iCount++)
  {
    iElement = iCount * 5;
    isvis(marrayMenus[iElement],x,y,marrayMenus[iElement+1],marrayMenus[iElement+2],marrayMenus[iElement+3],marrayMenus[iElement+4]);
  }
}

function isvis(objMenu,x,y,left,right,top,bottom)
{
  if(objMenu)
  {
    if(mbNav)
    {
      if(objMenu.visibility!="hide")
      {
        if(x<left-20||x>right+20||y<top-30||y>bottom+40)
          objMenu.visibility="hide";
      }
    }
    else 
    {
      if(objMenu.style.visibility!="hidden")
      {
        if(x<left-20||x>right+20||y<top-40||y>bottom+40)
          objMenu.style.visibility="hidden";
      }
    }
  }
}

function getdiv(strDivName)
{
  var iCount;

  if(mbNav)
  {
    for(iCount=0;iCount<document.layers.length;iCount++)
    {
      if(document.layers[iCount].name==strDivName||document.layers[iCount].NAME==strDivName)
        return document.layers[iCount];
    }
  }
  else
  {
    for(iCount=0;iCount<document.all.length;iCount++)
    {
      if(document.all[iCount].name==strDivName||document.all[iCount].NAME==strDivName)
        return document.all[iCount];
    }
  }
}

// -->
