
  function PopupMenu_showMenu(level, anchorname) {
    var obj_li;
    var offsetX, offsetY;
    var coordinates;
    if (this.use_gebi) {
      this.divs[level] = document.getElementById('div_' + anchorname);
    } else if (this.use_css) {
      this.divs[level] = document.all['div_' + anchorname];
    } else if (this.use_layers) {
      this.divs[level] = document.layers['div_' + anchorname];
    }
    if (level > 0) {
      obj_li = document.getElementById(anchorname);
      obj_li = obj_li.parentNode;
      offsetX = obj_li.offsetWidth;
      offsetY = -1;
    } else {
      if (anchorname.indexOf('left') > 0) {
        offsetX = -2;
        offsetY = -10;
      } else if (anchorname.indexOf('bottom') > 0) {
        offsetX = 0;
        offsetY = 20;
      } else {
        obj_li = document.getElementById(anchorname);
        this.last_a = obj_li;
        obj_li = obj_li.parentNode;
        offsetX = 0;
        offsetY = obj_li.offsetHeight;
				var browserName=navigator.appName;
				if (browserName=="Microsoft Internet Explorer") this.divs[level].style.width = '0px';
//    this.divs[level].style.width = obj_li.offsetWidth + "px";
      }
    }
    coordinates = this.getAnchorPosition(obj_li);
  	coordinates.x += offsetX;
  	coordinates.y += offsetY;
    this.divs[level].style.position = 'absolute';
    this.divs[level].style.left = coordinates.x + "px";
    this.divs[level].style.top = coordinates.y + "px";
    this.divs[level].style.display = '';
		var obj_anch = document.getElementById(anchorname);
		var currWidth = 0;
		for (var i=0;i<obj_anch.childNodes.length;i++) {
			currWidth += obj_anch.childNodes[i].offsetWidth;
		}
		this.divs[level].style.width = this.getWidth(level, currWidth) + 'px';
//		if (this.divs[level].offsetWidth < obj_li.offsetWidth) this.divs[level].style.width = obj_li.offsetWidth + "px";
		picture = document.getElementById('main_picture');
		num = (picture.offsetLeft+picture.offsetWidth)-(this.divs[level].offsetLeft+this.divs[level].offsetWidth);
		if ( num < 0 ) {
			this.divs[level].style.left = obj_anch.lastChild.offsetLeft + obj_anch.lastChild.offsetWidth + coordinates.x - this.divs[level].offsetWidth + 'px';
		}
  }

	function PopupMenu_getWidth(level, start) {
	  var width = start;
    var obj_ul = this.divs[level].getElementsByTagName("UL");
    obj_ul = obj_ul[0];
    for (var i=0;i<obj_ul.childNodes.length;i++) {
			
    	if (obj_ul.childNodes[i].offsetWidth > width) width = obj_ul.childNodes[i].offsetWidth;
    }
    return width;
	}

  function PopupMenu_getSubmenuCount(level) {
    var cnt=0;
    var obj_ul = this.divs[level].getElementsByTagName("UL");
    obj_ul = obj_ul[0];
    for (var i=0;i<obj_ul.childNodes.length;i++) {
      if (obj_ul.childNodes[i].tagName == "LI") cnt++;
    }
    return cnt;
  }

  function PopupMenu_hideMenu(level, e) {
    if (level == 0 && this.last_a != undefined) this.last_a.className = this.last_a.className.replace(/hover/gi,"");
    for (var j=this.divs.length-1;j>=level;j--) {
      if (this.divs[j] != undefined) {
        this.divs[j].style.display = 'none';
      }
    }
  }

  function PopupMenu_mOver(cell, level) {
    this.hideMenu(level);
    cell.className += 'hover';
  }

  function PopupMenu_mOut(cell) {
    cell.className = cell.className.replace(/hover/gi,"");
  }

  function PopupMenu_attachListener() {
    if (document.layers) {
      document.captureEvents(Event.MOUSEUP);
    }
    window.popupMenuOldEventListener = document.onmouseup;
    if (window.popupMenuOldEventListener != null) {
      document.onmouseup = new Function("window.popupMenuOldEventListener(); " + this.name + ".hideMenu(0);");
    } else {
      document.onmouseup = new Function(this.name + ".hideMenu(0);");
	  }
	}

  function PopupMenu(p_instance) {
    this.name = p_instance;
    this.divs = Array();
    this.last_a;
    this.listenerAttached = false;
    this.use_gebi = false;
    this.use_css = false;
    this.use_layers = false;
    if (document.getElementById) { this.use_gebi = true; }
    else if (document.all) { this.use_css = true; }
    else if (document.layers) { this.use_layers = true; }

    this.attachListener = PopupMenu_attachListener;
    this.getSubmenuCount = PopupMenu_getSubmenuCount;
    this.hideMenu = PopupMenu_hideMenu;
    this.mOver = PopupMenu_mOver;
    this.mOut = PopupMenu_mOut;
    this.showMenu = PopupMenu_showMenu;
    this.getAnchorPosition = PopupMenu_getAnchorPosition;
    this.getPageOffsetLeft = PopupMenu_getPageOffsetLeft;
    this.getPageOffsetTop = PopupMenu_getPageOffsetTop;
		this.getWidth = PopupMenu_getWidth;

    if (!this.listenerAttached) {
      this.listenerAttached = true;
      this.attachListener();
    }
  }

  function PopupMenu_getAnchorPosition(anchor) {
    var coordinates=new Object();
    var x=0,y=0;
    coordinates.x=this.getPageOffsetLeft(anchor);
    coordinates.y=this.getPageOffsetTop(anchor);
    return coordinates;
  }

  function PopupMenu_getPageOffsetLeft(el) {
    var ol=el.offsetLeft;
    while ((el=el.offsetParent) != null && el.style.position != 'absolute') {
      ol += el.offsetLeft;
    }
    return ol;
  }

  function PopupMenu_getPageOffsetTop(el) {
    var ot=el.offsetTop;
    while((el=el.offsetParent) != null && el.style.position != 'absolute') {
      ot += el.offsetTop;
    }
    return ot;
  }
