window.onload = function()
{
  new xMenu1A('m1', 'submenu1', 10, 500, 'mouseover');
  new xMenu1A('m2', 'submenu2', 10, 500, 'mouseover');
  new xMenu1A('m3', 'submenu3', 10, 500, 'mouseover');
  new xMenu1A('m4', 'submenu4', 10, 500, 'mouseover');
}

/* xMenu1A Object Prototype

  Parameters:
    triggerId   - id string of trigger element.
    menuId      - id string of menu.
    mouseMargin - integer margin around menu;
                  when mouse is outside this margin the menu is hid.
    slideTime   - integer time for menu slide (in milliseconds).
    openEvent   - string name of event on which to open menu ('click', 'mouseover', etc).
*/

function xMenu1A(triggerId, menuId, mouseMargin, slideTime, openEvent)
{
  var isOpen = false;
  var trg = xGetElementById(triggerId);
  var mnu = xGetElementById(menuId);
  if (trg && mnu) {
    xHide(mnu);
    xAddEventListener(trg, openEvent, onOpen, false);
  }
  function onOpen()
  {
    if (!isOpen) {
      xMoveTo(mnu, xPageX(trg), xPageY(trg));
      xShow(mnu);
      xSlideTo(mnu, xPageX(trg), xPageY(trg) + xHeight(trg), slideTime);
      xAddEventListener(document, 'mousemove', onMousemove, false);
      isOpen = true;
    }
  }
  function onMousemove(ev)
  {
    var e = new xEvent(ev);
    if (!xHasPoint(mnu, e.pageX, e.pageY, -mouseMargin) &&
        !xHasPoint(trg, e.pageX, e.pageY, -mouseMargin))
    {
      xRemoveEventListener(document, 'mousemove', onMousemove, false);
      xSlideTo(mnu, xPageX(trg), xPageY(trg), slideTime);
      setTimeout("xHide('" + menuId + "')", slideTime);
      isOpen = false;
    }
  }
} // end xMenu1A
if (document.images) {
 var botones=new Array();
  botones[0]= new Image();
  botones[0].src = "/fcg/img/museo/logoredondo.png";
  botones[1] = new Image();
  botones[1].src = "/fcg/img/museo/logoredondo.png";
  botones[2] = new Image();
  botones[2].src = "/fcg/img/museo/logoredondo.png";
  botones[3] = new Image();
  botones[3].src = "/fcg/img/museo/logoredondo.png";
  botones[4] = new Image();
  botones[4].src = "/fcg/img/museo/logoredondo.png";
}

// Carga de imagen cuando el ratón pasa por encima
function entra(boton,opcion) {
  var imagen;
  if (document.images) {
      document.images[boton].src = botones[opcion].src;
  }
}
