  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 (this.onmouseout > 0){
      obj_li = document.getElementById(anchorname);
      obj_li.className = 'hover';
    }

    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 = obj_li.offsetWidth    * -1;
        offsetY = obj_li.offsetHeight;
        this.divs[level].style.width = obj_li.offsetWidth + "px";
      }
    }
    coordinates = this.getAnchorPosition(anchorname);
		
    coordinates.x += offsetX;
    coordinates.y += offsetY;
		
		var pos_x = coordinates.x;
		
		if(level==1){
			pos_x = document.getElementById(anchorname).offsetParent.offsetWidth + 5;
			var y = this.getPageOffsetTop(document.getElementById(anchorname)) - 10;
			this.divs[level].style.left = pos_x + "px";
			this.divs[level].style.top = (y-1) + "px";
		}
		else{
			this.divs[level].style.left = pos_x + "px";
			this.divs[level].style.top = coordinates.y + "px";
		}

		var ret = this.menuWidth(anchorname);
		
		var body_width = document.getElementsByTagName("body")[0].offsetWidth;
		var a_right_side = document.getElementById(anchorname).offsetParent.offsetLeft + (document.getElementById(anchorname).offsetParent.offsetWidth);
		var browserName=navigator.appName; 
		if (browserName=="Microsoft Internet Explorer"){
			var div_width = (document.getElementById('div_' + anchorname).childNodes[0].childNodes[0].childNodes[0].childNodes[0].innerHTML.length*5)+30;
		}
		else{
			var div_width = (document.getElementById('div_' + anchorname).childNodes[1].childNodes[1].childNodes[0].text.length*5)+30;
		}
		var a_width = document.getElementById(anchorname).offsetWidth;
		
		if(ret[2] != false){
			this.divs[level].style.width = ret[1] + 'px';
			var new_pos_x = (pos_x - ((ret[1]-ret[0])/2));
			if(level==0) this.divs[level].style.left = new_pos_x + "px";
			else if(level==1) this.divs[level].style.left = pos_x + "px";
		}
		if(body_width < (a_right_side+div_width)){
			this.divs[level].style.left = (pos_x-div_width-a_width-10) + "px";
		}
		
		this.divs[level].style.position = 'absolute';
    this.divs[level].style.display = '';
  }

  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);
    if (cell.className != null) cell.className = 'hover';
  }
  
  function PopupMenu_mOut(cell) {
    cell.className = cell.className.replace(/hover/gi,"");
  }

  function PopupMenu_attachListener() {
    if (document.layers) {
      document.captureEvents(Event.MOUSEOUT);
    }
    var prev = document.onmouseout;
    var f = new Function( this.name + ".hideMenu(0);" );
    document.onmouseout = function(){ if(prev)prev(); f(); }
  }

  function PopupMenu_attachListenerUp() {
    if (document.layers) {
      document.captureEvents(Event.MOUSEUP);
    }
    var prev = document.onmouseup;
    var f = new Function( this.name + ".hideMenu(0);" );
    document.onmouseup = function(){ if(prev)prev(); f(); }
  }

  function PopupMenu(p_instance, p_onmouseout) {
    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;
    this.onmouseout = p_onmouseout;
    if (document.getElementById) { this.use_gebi = true; }
    else if (document.all) { this.use_css = true; }
    else if (document.layers) { this.use_layers = true; }

    if (this.onmouseout > 0){
      this.attachListener = PopupMenu_attachListener;
    } else {
      this.attachListener = PopupMenu_attachListenerUp;
    }
    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.menuWidth = PopupMenu_menuWidth;

    if (!this.listenerAttached) {
      this.listenerAttached = true;
      this.attachListener();
    }
  }

  function PopupMenu_getAnchorPosition(anchorname) {
    var coordinates=new Object();
    var x=0,y=0;
		if (this.use_gebi) {
      var o=document.getElementById(anchorname);
			var o_parent = o.offsetParent;
			x=this.getPageOffsetLeft(o_parent);
      y=this.getPageOffsetTop(o_parent);
    }
		else if (this.use_css) {
      x=this.getPageOffsetLeft(document.all[anchorname]);
      y=this.getPageOffsetTop(document.all[anchorname]);
    }
		else if (this.use_layers) {
      var found=0;
      for (var i=0; i<document.anchors.length; i++) {
				alert(document.anchors[i].name + ' ' + document.anchors[i].x + ' ' + document.anchors[i].y);
        if (document.anchors[i].name==anchorname) { found=1; break; }
      }
      if (found==0) {
        coordinates.x=0; coordinates.y=0; return coordinates;
      }
      x=document.anchors[i].x;
      y=document.anchors[i].y;
    }
		else {
      coordinates.x=0; coordinates.y=0; return coordinates;
    }
    coordinates.x=x;
    coordinates.y=y;
    return coordinates;
  }

   function PopupMenu_getPageOffsetLeft(el) {
    var ol=el.offsetLeft+el.offsetWidth;
    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;
  }

	function PopupMenu_menuWidth(anchorname) {
		var max_width = 0;
		var innerText = '';
		var innerTextLength = 0;
		var sub_menu = document.getElementById('div_' + anchorname);
		
		var browserName=navigator.appName;
		if (browserName=="Microsoft Internet Explorer"){
			for (i=0;i<sub_menu.childNodes.length;i++){ // végigmegyek az almenü DIV-jén
				if (sub_menu.childNodes[i].nodeName=='UL' ){ // megkeresem benne az UL elemet
					var sub_ul = sub_menu.childNodes[i];
					for (j=0;j<sub_ul.childNodes.length;j++){ // végigmegyek az UL-ben lévő elemeken
						if (sub_ul.childNodes[j].nodeName=='LI' ){ // ha találok benne LI tagot, akkor megnézem a benne lévő '<span class="sub_label">' szélességét
							innerText = sub_ul.childNodes[j].childNodes[0].childNodes[0].innerHTML;
							innerTextLength = innerText.length;
							if((innerTextLength*5)>max_width) max_width = (innerTextLength*5);
						}
					}
				}
			}
		}
		else{
			for (i=0;i<sub_menu.childNodes.length;i++){ // végigmegyek az almenü DIV-jén
				if (sub_menu.childNodes[i].localName=='UL' ){ // megkeresem benne az UL elemet
					var sub_ul = sub_menu.childNodes[i];
					for (j=0;j<sub_ul.childNodes.length;j++){ // végigmegyek az UL-ben lévő elemeken
						if (sub_ul.childNodes[j].localName=='LI' ){ // ha találok benne LI tagot, akkor megnézem a benne lévő '<span class="sub_label">' szélességét
							innerText = sub_ul.childNodes[j].childNodes[0].childNodes[0].innerHTML;
							innerTextLength = innerText.length;
							if((innerTextLength*5)>max_width) max_width = (innerTextLength*5);
						}
					}
				}
			}
		}
		
		var datas=new Array();
		var td_width = 0;
		if(document.getElementById('td_' + anchorname)!=null) td_width = document.getElementById('td_' + anchorname).offsetWidth;
		// 0 - a főmenüpont szélessége és az 1 - az almenü szélessége
		if(td_width < (max_width+30)){
			datas[0]=td_width;
			datas[1]=max_width+30;
			datas[2]=true;
			return (datas);
		}
		else{
			datas[0]=td_width;
			datas[1]=max_width+30;
			datas[2]=false;
			return (datas);
		}
	}