ready = false;
justHiding = false;

function showSubmenu(el) {
  if (document.getElementById) {
    if (justHiding) {
      clearTimeout(justHiding);
      justHiding = false;
      document.getElementById("submenucontainer").style.display = "none";
      document.getElementById("submenucontainer").style.height = "auto";
    }
    subM = el.parentNode.getElementsByTagName("ul")[0].innerHTML;
    posX = 0;
    posY = 0;
    height = el.parentNode.parentNode.offsetHeight;
    while(el) {
      posX += el.offsetLeft;
      posY += el.offsetTop;
      el = el.offsetParent;
    }
    if (ready) {
      document.getElementById("submenucontainer").style.left = (posX+1+4)+"px";
      document.getElementById("submenucontainer").style.top = (posY+height)+"px";
      document.getElementById("submenucontainer").innerHTML = subM;
      document.getElementById("submenucontainer").style.display = "block";
    
      // ueberwachungsbereich einrichten
      // wenn die maus den bereich verlaesst, wird das menue zugeklappt
      ueberwachungLeft = document.getElementById("submenucontainer").offsetLeft -10;
      ueberwachungTop = posY -10;
      ueberwachungRight = ueberwachungLeft + document.getElementById("submenucontainer").offsetWidth +20;
      ueberwachungBottom = document.getElementById("submenucontainer").offsetTop + document.getElementById("submenucontainer").offsetHeight +10;
    }
  }
}
function hideSubmenu() {
  document.getElementById("submenucontainer").style.overflow = "hidden";
  document.getElementById("submenucontainer").style.height = (document.getElementById("submenucontainer").offsetHeight - 8) + "px";
  if (document.getElementById("submenucontainer").offsetHeight >= 8) {
    justHiding = setTimeout("hideSubmenu()",20);
  }
  else {
    justHiding = false;
    document.getElementById("submenucontainer").style.display = "none";
    document.getElementById("submenucontainer").style.height = "auto";
  }
}
function mausMovePos(ereignis) {
  if (ready && !justHiding && document.getElementById("submenucontainer").style.display == "block") {
    posx = document.all ? window.event.clientX + document.documentElement.scrollLeft : ereignis.pageX;
    posy = document.all ? window.event.clientY + document.documentElement.scrollTop : ereignis.pageY;
    if (posx < ueberwachungLeft || posx > ueberwachungRight || posy < ueberwachungTop || posy > ueberwachungBottom) {
      hideSubmenu();
    }
  }
}

document.onmousemove = mausMovePos;


/*
	[MHS]
	Fix for bug in Mozilla < 20040206 & Opera
*/
function fixOldGecko () {
	var sOut = '';
	var rx = RegExp;
	var sPattern = /(\w+)\/([\d\.\w]+)\s*(\[\w+\])*\s*\((.+)\)\s*(\w*)[\/\s]*([\w\.]*)\s*(\w*)[\/\s]*([\w\.]*)/i;
	var sAgent = navigator.userAgent;
	var oContent = document.getElementById("content");

	sPattern.exec (sAgent);

	sOut += sAgent;
	sOut += '\n------\n';
	sOut += '1: '+rx.$1+'\n2: '+rx.$2+'\n3: '+rx.$3+'\n4: '+rx.$4+'\n5: '+rx.$5+'\n6: '+rx.$6+'\n7: '+rx.$7+'\n8: '+rx.$8+'\n9: '+rx.$9;
	sOut += '\n------\n';
	sOut += 'old gecko: ';

	sConclusion = 'no';

	//# If != mozilla than it's definitely not Mozilla / IE / Opera
	if (rx.$1.toLowerCase() == 'mozilla') {
		//# Gecko < 20040206
		if (rx.$2 == 5 && rx.$5.toLowerCase() == 'gecko' && rx.$6 < 20040206) {
			oContent.style.marginLeft = '174px';
			sConclusion = 'yes';
		//# Opera
		} else if (rx.$2 == 4 && rx.$5.toLowerCase() == 'opera' /* && rx.$7 < 7.3 */) {
			oContent.style.marginLeft = '174px';
			sConclusion = 'yes';
		}
	}

	//# Wuerde ich drin lassen, sonst weiß man nie an welcher Position ($1-9) welcher Wert steht (Regex sind ja nicht sonderlich gut lesbar)
	//alert (sOut + sConclusion);
}

