// Objeto de deteccion del navegador
function DetectorNavegador() {
  this.NS4 = document.layers;
  this.IE4 = document.all;
  this.DOM = document.getElementById;
  this.DHTML = this.NS4 || this.IE4 || this.DOM;
}

var soporta = new DetectorNavegador();
var menu = new Array();
var menuActivo = null;

// Objeto Menu
function activarMenu() {
  if (soporta.DHTML && menuActivo != this) {
    if (menuActivo) menuActivo.ocultar();
    menuActivo = this;
    this.mostrar();
  }
}

function desactivarMenu() {
  if (soporta.DHTML && menuActivo != this) {
    if (menuActivo) menuActivo.ocultar();
  }
}

function mostrarMenu() {
  this.domRef.style.visibility = "visible";
  this.domRef.style.display = "block";
}

function ocultarMenu() {
  this.domRef.style.visibility = "hidden";
}

function cambiarPosicionMenu(top, left) {
  this.domRef.style.top = top;
  this.domRef.style.left = left;
}

function Menu(capaID, top, left, width) {
  this.activar = activarMenu;
  this.desactivar = desactivarMenu;
  this.mostrar = mostrarMenu;
  this.ocultar = ocultarMenu;
  this.cambiarPosicion = cambiarPosicionMenu;
  if (soporta.DOM) {
    this.domRef = document.getElementById(capaID);
    this.domRef.style.width = width;
    this.domRef.style.display = "none";
    this.cambiarPosicion(top, left);
  }
}

// Manejo de eventos - Ocultar Menu Activo
function oma(e) {
  if (menuActivo) {
    menuActivo.ocultar();
    menuActivo = null;
  }
}

// Inicializacion
function inicializar() {
  if (soporta.DHTML) {
    if (soporta.NS4)
      document.captureEvents(Event.MOUSEUP);
    document.onmouseup = oma;
  }
// fila, columna, ancho
  menu[0] = new Menu("menu0", 91, 2, 136);
  menu[1] = new Menu("menu1", 91, 2+111, 150);
  menu[2] = new Menu("menu2", 91, 2+111+120, 206);
  menu[3] = new Menu("menu3", 91, 2+111+120+116, 310);
  menu[4] = new Menu("menu4", 91, 2+111+120+116+187, 310);
  menu[5] = new Menu("menu5", 91, 2+111+120+116+187+176, 246);
  menu[6] = new Menu("menu6", 91, 2+111+120+116+187+176+104, 178);
  menu[7] = new Menu("menu7", 91, 2+111+120+116+187+176+104+144, 120);
}

window.onload = inicializar;
