/**
 *	Class to display a floating menu.
 *
 *	@author		Unknown
 *	@version	1.0
 *	@copyright	Katana Productions Pty Ltd 2002
 *
 *	@param	x    The x position of the floating menu.
 *	@param	y    The y position of the floating menu.
*/
function FloatingMenu(x, y)
{
  this.x = x;
  this.y = y;
  this.style = 'floatingMenu';
  this.innerHTML = '';
}

FloatingMenu.ID = 'floatingmenu';

/**
 *	Add a floating menu item.
*/
FloatingMenu.prototype.add = function(menuItem)
{
  this.innerHTML += menuItem.getHTML();
}

/**
 *	Add a floating menu separator.
*/
FloatingMenu.prototype.addSeparator = function()
{
  this.innerHTML += '<hr>';
}

/**
 *	Show the floating menu.
*/
FloatingMenu.prototype.show = function(elm)
{
  if (document.all(FloatingMenu.ID))
  {
    this.hide();
  }
  var html = '<div id="' + FloatingMenu.ID + '" style="position:absolute;left:' + this.x + 'px;top:' + this.y + 'px;background-color:menu;border:2px outset;padding:3px;" class="' + this.style + '" noWrap>' + this.innerHTML + '</div>';
  var tagName = elm.tagName.toUpperCase();
  var sWhere = 'afterEnd';
  if (tagName == 'TD')
  {
    sWhere = 'beforeEnd';
  }
  elm.insertAdjacentHTML(sWhere, html);
  document.body.onclick = this.hide;
}

/**
 *	Hide the floating menu.
*/
FloatingMenu.prototype.hide = function()
{
  document.all(FloatingMenu.ID).outerHTML = '';
  document.body.onclick = null;
}