/*
 *   menu object
 */

function menuObject() {
  this.submenus = new Array();
  this.popuped = null;
  this._init = mo_init;
  this.popup = mo_popup;
}

function mo_init() {
  var top = document.getElementById('box1').offsetHeight;
  var allA = document.getElementsByTagName('a');
  //var allMenus = new Array('menu-view', 'menu-go', 'menu-bookmarks', 'menu-tasks', 'menu-help');
  var allMenus = new Array('menu-go', 'menu-help');
  for (var i=0; i<allMenus.length; i++) {
    var tmp = eval("document.getElementById('"+allMenus[i]+"');");
    tmp.style.top = top + "px";
    tmp.style.left = allA[i].offsetLeft - 1 + "px";
    this.submenus[allMenus[i]] = tmp;
  }
}

function mo_popup(whichOne) {
  var tmp = null;
  tmp = this.submenus[whichOne];
  if (this.popuped == null) {		// no popup opened
    tmp.style.display = 'block';
    this.popuped = tmp;
  } else {
    this.popuped.style.display = 'none';
    if (this.popuped == tmp) {		// opened popup clicked
      this.popuped = null;
    } else {				// another popup clicked
      tmp.style.display = 'block';
      this.popuped = tmp;
    }
  }
}

var menu = new menuObject();

