
// Falls IE, dann testen, ob "body" geladen.
// Falls ja, dann Menues aktivieren
if ( navigator.userAgent.indexOf("MSIE") != -1 && document.getElementById ) {
	var BodyTimeout = null;
	var MenuTimeout = null;
	var OpenMenu    = null;
	bodyTest();
}



function bodyTest() {
	if ( document.body ) {
		if ( BodyTimeout != null ) { 
			window.clearTimeout( BodyTimeout ); 
		}
		ie_menu_init();
	} else {
		BodyTimeout = window.setTimeout( bodyTest, 1000 );
	}
}


function ie_menu_init() {
	if ( navigator.userAgent.indexOf("MSIE") != -1 && document.getElementById ) {
		var emover = false;
		var emout = false;
		var dls = document.getElementsByTagName("dl");
		for ( var i = 0; i < dls.length; i++ ) {
			if ( dls[i].getAttribute("id") && dls[i].parentNode.getAttribute("id") == "nav" ) {
				emover = dls[i].onmouseover = function () {
					menuRollOver( this.id );
				};
				emout  = dls[i].onmouseout  = function () {
					menuRollOut( this.id );
				};
			}
		}
	}
}



function menuRollOver( MenuId ) {
	if ( MenuTimeout != null ) {
		window.clearTimeout( MenuTimeout );
	}
	if ( OpenMenu != null ) {
		hideMenu( OpenMenu );
	}
	showMenu( MenuId );
}

function menuRollOut( MenuId ) {
	if ( MenuTimeout != null ) {
		MenuTimeout = null;
	}
	MenuTimeout = window.setTimeout( 'hideMenu("' + MenuId + '")', 1000);
}


function showMenu( MenuId ) {
	var dds = document.getElementById( MenuId ).childNodes;
	var bgid    = "bg-" + MenuId;
	var bgidact = bgid + "-act";
	var bg      = document.getElementById( bgid );
	var bgact   = document.getElementById( bgidact );
	bg.style.display    = "none";
	bgact.style.display = "block";
	
	for ( var i = 0; i < dds.length; i++ ) {
		if ( dds[i].nodeName == "DT" ) {
			dds[i].style.backgroundColor = "rgb(77,77,77)";
		}
		if ( dds[i].nodeName == "DD" ) {
			dds[i].style.display = "block";
		}
	}
	OpenMenu = MenuId;
}

function hideMenu( MenuId ) {
	var dds = document.getElementById( MenuId ).childNodes;
	var bgid    = "bg-" + MenuId;
	var bgidact = bgid + "-act";
	var bg      = document.getElementById( bgid );
	var bgact   = document.getElementById( bgidact );
	bg.style.display    = "block";
	bgact.style.display = "none";

	for ( var i = 0; i < dds.length; i++ ) {
		if ( dds[i].nodeName == "DT" ) {
			dds[i].style.backgroundColor = "transparent";
		}
		if ( dds[i].nodeName == "DD" ) {
			dds[i].style.display = "none";
		}
	}
	if ( OpenMenu == MenuId ) {
		OpenMenu = null;
	}
}

