// DHTML Navigation Popup Layer!

ns4 = (document.layers) 							? true : false;
ie	= (document.all)								? true : false;
ns6 = (!document.all && document.getElementById)	? true : false;
//ie4 = (document.all && !document.getElementById)	? true : false;
//ie5 = (document.all && document.getElementById)	? true : false;
//msie40 = (navigator.appVersion.indexOf("MSIE 4.0")>=0)? true:false;

var layerloaded 		= false;
var layercontentloaded	= false;
var HIDE				= null;
var HideFlag			= true;
var aktHighlightNr		= -1;


// anzeigen des Layers
function showMenu(aktLayerNrInhalt, aktLayerNr, changeColors)
{
	clearTimeout(HIDE);

	// change backgroundcolors...
	if (aktHighlightNr!=-1)	changeLeftnaviColors(aktHighlightNr,false);
	if (changeColors) {
		aktHighlightNr=aktLayerNr;
		changeLeftnaviColors(aktHighlightNr,true);
	}

	if (layerloaded && layercontentloaded) {
        if (ns4 && top.cont.document.layers['NavigationLayer'])	{		
			top.cont.document.layers['NavigationLayer'].visibility = "hide";
			top.cont.document.layers['NavigationLayer'].document.open();
			top.cont.document.layers['NavigationLayer'].document.writeln('<LAYER onMouseOver="parent.HideFlag=false; parent.overlayer();" onMouseOut="parent.HideFlag=true; parent.timehideMenu(2000);">');
	    	top.cont.document.layers['NavigationLayer'].document.writeln(aktLayerNrInhalt);
			top.cont.document.layers['NavigationLayer'].document.writeln('</LAYER>');
	    	top.cont.document.layers['NavigationLayer'].document.close();
			LayerPos(aktLayerNr);
	        top.cont.document.layers['NavigationLayer'].zIndex = "10000";
			top.cont.document.layers['NavigationLayer'].visibility = "show";
		}
		else if ((ie && top.cont.document.all['NavigationLayer']) || (ns6 && top.cont.document.getElementById("NavigationLayer")) ) {
			if (ie) {
		layer = top.cont.document.all['NavigationLayer'];
                        }
			else if (ns6) 	layer = top.cont.document.getElementById("NavigationLayer");
			layer.style.visibility = "hidden";
		    layer.innerHTML = aktLayerNrInhalt;
			LayerPos(aktLayerNr);
	        layer.style.zIndex = "10000";		
			layer.style.visibility = "visible";
		}
	} // if (layerloaded && layercontentloaded)
}

// verstecken des Layers nach delay-Millisekunden
function timehideMenu(delay)
{
  // Override delay value passed by template
  var delay = 1200;
  if ((ns4 || ie || ns6))
  {
  if (HideFlag)
  HIDE = setTimeout("hideMenu();",delay);
  }
}

// verstecken des Layers
function hideMenu()
{
	clearTimeout(HIDE);
    if (ns4 && top.cont.document.layers['NavigationLayer'])
		top.cont.document.layers['NavigationLayer'].visibility = "hide";
    else if (ie && top.cont.document.all['NavigationLayer']) {
	 	top.cont.document.all['NavigationLayer'].style.visibility = "hidden";
	}
	else if (ns6 && top.cont.document.getElementById("NavigationLayer")) {
		top.cont.document.getElementById("NavigationLayer").style.visibility = "hidden";
	}
	if (aktHighlightNr!=-1) changeLeftnaviColors(aktHighlightNr,false);
}

// beim Ueberfahren des Layers
function overlayer()
{
    clearTimeout(HIDE);
	if (ns4) top.cont.document.layers['NavigationLayer'].visibility = "show";
    else if (ie)  top.cont.document.all['NavigationLayer'].style.visibility = "visible";
	else if (ns6) top.cont.document.getElementById("NavigationLayer").style.visibility = "visible";;
}

// setzt Layer an korrekte Position!
function LayerPos(aktLayerNr)
{
    if(ns4) {
		var layer	= top.cont.document.layers['NavigationLayer'];
		var pos 	= top.leftnavi.document.anchors['LayerPosition'+aktLayerNr];
		var ns4PosY = pos.y+7 + top.cont.pageYOffset; 	// top.cont.pageYOffset=vertikaler Scrollwert des Content-Frames
			ns4PosY	= ns4PosY - top.leftnavi.pageYOffset; // top.leftnavi.pageYOffset=vertikaler Scrollwert des Navi-Frames
		// Falls Fenster zu klein wird Layer am unteren Rand positioniert, Scrolling beachten!
		if ((ns4PosY+layer.clip.bottom-top.cont.pageYOffset)>top.cont.innerHeight)
			ns4PosY	= top.cont.innerHeight-layer.clip.bottom+top.cont.pageYOffset;
		layer.top	= ns4PosY;
		layer.left	= 0;
	}
    else if(ie) {
		// Anzahl der offsetParents haengt v.a. von Tabellenschachtelung ab!!!!!
		var layer		= top.cont.document.all['NavigationLayer'];
		var actualTag	= top.leftnavi.document.all['LayerPosition'+aktLayerNr];
		var iePosY 		= 4+top.cont.document.body.scrollTop; 			// top.cont.document.body.scrollTop=vertikaler Scrollwert des Content-Frames
			iePosY		= iePosY-top.leftnavi.document.body.scrollTop;	// top.leftnavi.document.body.scrollTop=vertikaler Scrollwert des Navi-Frames
		while (actualTag) { // Position der Tags/ParentTags rekursiv durchgehen!
			// alert(actualTag.tagName+": "+actualTag.offsetTop);
			iePosY 		+= actualTag.offsetTop;
			actualTag	=  actualTag.offsetParent;
	 	}
		// Falls Fenster zu klein wird Layer am unteren Rand positioniert, Scrolling beachten!
		if ((iePosY+layer.offsetHeight-top.cont.document.body.scrollTop)>top.cont.document.all['windowsize'].offsetHeight) {
			iePosY = top.cont.document.all.windowsize.offsetHeight-layer.offsetHeight+top.cont.document.body.scrollTop;
		}
		//	 top.cont.document.all['NavigationLayer'].style.width=300;	 
	 	layer.style.top = iePosY;
	 	layer.style.left = 0;
	}
	else if (ns6) {
		// Anzahl der offsetParents haengt v.a. von Tabellens4chachtelung ab!!!!!
		var layer =		 top.cont.document.getElementById("NavigationLayer");
		var actualTag	= top.leftnavi.document.getElementsByName("LayerPosition"+aktLayerNr)[0];
		var ns6PosY 	= 7+top.cont.pageYOffset; 			// top.cont.document.body.scrollTop=vertikaler Scrollwert des Content-Frames
			ns6PosY		= ns6PosY-top.leftnavi.pageYOffset; // top.leftnavi.pageYOffset=vertikaler Scrollwert des Navi-Frames
		while (actualTag) { // Position der Tags/ParentTags rekursiv durchgehen!
			ns6PosY 	+= actualTag.offsetTop;
			actualTag	=  actualTag.offsetParent;
	 	}
		// Falls Fenster zu klein wird Layer am unteren Rand positioniert, Scrolling beachten!
		if ((ns6PosY+layer.offsetHeight-top.cont.pageYOffset)>top.cont.innerHeight)
			ns6PosY	= top.cont.innerHeight-layer.offsetHeight+top.cont.pageYOffset;
	 	layer.style.top = ns6PosY;
	 	layer.style.left = 0;
	}
} 
  
  
function changeLeftnaviColors (elementNr, mouseover)
{
	var bgcolor   = mouseover?'#FFFFFF':'#91a0c1';
	var textcolor = mouseover?'#55658C':'#FFFFFF';
	
	if (ie) {
		top.leftnavi.document.all['td'+elementNr].style.backgroundColor = bgcolor;
		top.leftnavi.document.all['td2nd'+elementNr].style.backgroundColor = bgcolor;
		top.leftnavi.document.all['LayerPosition'+elementNr].style.color = textcolor;
	} 
	else if (ns6) {
		top.leftnavi.document.getElementById("td"+elementNr).style.backgroundColor = bgcolor;
		top.leftnavi.document.getElementById("td2nd"+elementNr).style.backgroundColor = bgcolor;
		top.leftnavi.document.getElementsByName("LayerPosition"+elementNr)[0].style.color = textcolor;
	}
}

function changeLayernaviColors (elementNr, mouseover)
{
	var bgcolor			= mouseover?'#91a0c1':'#FFFFFF';
	var textcolor		= mouseover?'#FFFFFF':'#55658C';
	var textdecoration	= mouseover?'none':'underline';

	if (ie) {
		top.cont.document.all['layertd'+elementNr].style.backgroundColor = bgcolor;
		top.cont.document.all['layerlink'+elementNr].style.color = textcolor;
		top.cont.document.all['layerlink'+elementNr].style.textDecoration = textdecoration;
	}
	else if (ns6) {
		top.cont.document.getElementById("layertd"+elementNr).style.backgroundColor = bgcolor;
		top.cont.document.getElementById("layerlink"+elementNr).style.color = textcolor;
		top.cont.document.getElementById("layerlink"+elementNr).style.textDecoration = textdecoration;
	}
}
