<!--

var aPopup = [];
var popupID;

function ShowPopup(sParent, sPopup, iPos)
{
  AddPopup(sParent, sPopup);

  if (iPos == 1)
  {
    PlaceMainPopup(sParent, sPopup);
  }
  else
  {
    PlaceSubPopup(sParent, sPopup);
  }

  return true;
}

function PlaceMainPopup(sParent, sPopup)
{
  var obj;
  var objParent;
  var objBar;
  var pos;
  var x;
  var y;

  objParent = document.getElementById(sParent);
  objBar = document.getElementById("keyesmenu");
  obj = document.getElementById(sPopup);

  pos = getElementPosition(objParent);
  x = pos[0];
  if ((x + obj.offsetWidth) > self.outerWidth) x = self.outerWidth - obj.offsetWidth - 10;
  pos= getElementPosition(objBar);
  y = pos[1];
  y += objBar.offsetHeight;

  obj.style.left = x;
  obj.style.top = y;
  obj.style.visibility = "visible";
}

function getElementPosition(obj)  
{  
  var x = 0;  
  var y = 0;  
  var adj = scrollAdjustments(obj);  
  
  if (obj.offsetParent)  
  {  
    do {  
      x += obj.offsetLeft;  
      y += obj.offsetTop;  
    } while (obj = obj.offsetParent);  
    return [ (x - adj[0]), (y - adj[1]) ];  
  }  
} 
 
function scrollAdjustments(obj)  
{  
  var x = 0;  
  var y = 0;  
  do {  
    x += obj.scrollLeft;  
    y += obj.scrollTop;  
    if (obj.nodeName == 'BODY') break;  
  } while (obj = obj.parentNode);  
  return [x, y];  
}  

function PlaceSubPopup(sParent, sPopup)
{
//  var obj;

//  obj = document.getElementById(sPopup);
//todo: add code here for menu placement
//  obj.style.visibility = "visible";
}

function AddPopup(sParent, sPopup)
{
  HideUnused(sParent);
  aPopup[aPopup.length] = sPopup;
}

function HideUnused(sPopup)
{
  PopupStopTimeout();
  if (aPopup.length <= 0) return;

  for (var i=(aPopup.length -1); i>=0; i--)
  {
    if (aPopup[i] == sPopup) break;
    HidePopup(aPopup[i]);
  }

  if (aPopup[(i)] == sPopup) i++;
  if (i < 0) i = 0;
  aPopup.length = i;
}

function HidePopup(sPopup)
{
  var obj;
  obj = document.getElementById(sPopup);
  obj.style.visibility = "hidden";
}

function PopupStartTimeout()
{
  popupID = setTimeout("HideUnused('')",2000);
}

function PopupStopTimeout()
{
  if (popupID != null) 
  {
    clearTimeout(popupID);
    popupID = null;
  }
}

-->
