/**
 *	Class to handle menu actions.
 *
 *	@author		Unknown
 *	@version	1.0
 *	@copyright	Katana Productions Pty Ltd 2002
*/
function MenuAction()
{

}

/**
 *	Causes a menu to be built when an object is right-clicked.
 *
 *  @param  id  Id of the node to show menu for
 *
*/
MenuAction.prototype.doFloatingMenuAction = function(id)
{
  document.oncontextmenu = new Function('return false');

  var xmlObj = document.all(id.toString());
  if (xmlObj)
  {  
    var button = event.button;
    if (button == 2)
    {
      var xmlDoc = xmlObj.XMLDocument;
      var nodes = xmlDoc.selectNodes('menu/menuitem');
      if (nodes.length > 0)
      {
        var menu = new FloatingMenu(event.x + document.body.scrollLeft, event.y + document.body.scrollTop);
        for (var i = 0; i < nodes.length; i++)
        {
          var name = nodes(i).getAttribute('name');
          if (name)
          {
            menu.add(new FloatingMenuItem(name, nodes(i).getAttribute('action')));
          }
          else
          {
            menu.addSeparator();
          }
        }
        menu.show(event.srcElement);
      }
      return false;
    }
  }
}