function openMenu(menu) {
	var submenu = menu.getElementsByTagName('ul')[0];
	if (!submenu || menu.className == 'menu opened') return;


	if (!document.openedMenu) document.openedMenu = [];
	var openedMenu = null;
	while (openedMenu = document.openedMenu.pop()) {
		if (openedMenu != menu.parentNode ) {
			var m = openedMenu; 
			var animateClose = function() {
				if (m.parentNode.submenuHeight > 3.5) {
					m.parentNode.style.overflow = 'hidden';
					m.parentNode.submenuHeight = m.parentNode.submenuHeight/1.5;
					m.parentNode.style.height = m.parentNode.submenuHeight + "em";
					window.setTimeout(animateClose, 2);
				} else {
					m.opened = false;
					m.parentNode.className = 'menu closed';
					m.parentNode.style.height = 'auto';
					m.parentNode.style.overflow = 'visible';
					m.style.marginTop = '-1.5em';
					m.style.left = '100%';
					m.className = 'submenu';
				}
			}
			window.setTimeout(animateClose, 0);
		}
	}
	
	menu.className = 'menu opened';
	var animation = {"marginTop" : -1.5, "marginLeft": 100, "menuHeight": 1};
	var submenuHeight = 1.3;
	var submenuEntry = submenu.firstChild;
	do {
		if (submenuEntry.nodeType==1) submenuHeight += 1.3;
	} while (submenuEntry = submenuEntry.nextSibling);
	menu.submenuHeight = submenuHeight;
	
	var x=0;
	var animate = function() {
		animation.marginTop = animation.marginTop / 1.3;
		animation.marginLeft = animation.marginLeft / 1.3; 
		animation.menuHeight += submenuHeight / 15;
		submenu.style.marginTop = animation.marginTop + 'em';
		submenu.style.left = animation.marginLeft + '%';
		menu.style.height = animation.menuHeight+'em';
		if (x<15) {
			window.setTimeout(animate, 15);
			x++;
			
		} else {
			submenu.className = 'submenu aktiv';
			/*submenu.style.marginTop = 'inherit';
			submenu.style.left = 'inherit';*/
			menu.style.height = 'auto';
		}
	}
	window.setTimeout(animate, 0);
	submenu.opened = true;
	document.openedMenu.push(submenu);
}
