/*
external js file for dynamical positioning of the functional navigation
$Source: /usr/cvs/eMB/Clickstream_DCVD/js/nav5.js,v $
$Revision: 1.1 $
Check-In $Date: 2002/10/08 10:14:32 $
*/
var orgYpos=-1; // holds original y-position of funcnavi
var maxStopperYPosition=-1;
var repositionTimer=null;
var funcNaviNewYPosition;
var funcNavLayer = null;
function repositionFuncNav() {
	var thisYposStopper=0;
	var i=1;
	if (maxStopperYPosition<0){
		while(thisYposStopper>-1) {
			var currentLayer = new eMBLayer("stopper"+i);
			thisYposStopper = currentLayer.getAbsoluteY();
			if(thisYposStopper>maxStopperYPosition) maxStopperYPosition=thisYposStopper;
			i++;
		}
		maxStopperYPosition+=3;
	}
	//window.status=maxStopperYPosition ;
	
	if (funcNaviNewYPosition < maxStopperYPosition) funcNaviNewYPosition = maxStopperYPosition; 
	// just reposition if scrollposition has changed
	if (orgYpos != funcNaviNewYPosition) {
		orgYpos = funcNaviNewYPosition;
		clearTimeout(repositionTimer);
		if (!NS) repositionTimer = setTimeout("funcNavLayer.setY("+funcNaviNewYPosition+")", 30);
		else funcNavLayer.setY( funcNaviNewYPosition );
	}
	return true;
}
function setFuncNaviNewYPosition(){
	if(MS || OP) {
		//IE needs an offset of 4 #tbd: test on other platforms
		if (IE6) // document.body.scrollTop no longer supported in IE6 (now scrollTop is part of html-object)
			var documentBody = document.getElementsByTagName("html")[0];
		else
			var documentBody = document.body;
		funcNaviNewYPosition = documentBody.clientHeight - funcNavLayer.getHeight() + documentBody.scrollTop;
		// recognize horizontal scrolling not needed for IE
	}
	else if (NS || DOM)
	{		
		funcNaviNewYPosition= window.innerHeight - funcNavLayer.getHeight() + window.pageYOffset;
		// recognize horizontal scrolling
		if ( !MAC && NS && window.innerWidth < 770 ) funcNaviNewYPosition=funcNaviNewYPosition-14;
		else if ( !OP && !NS && window.innerWidth < 784 ) funcNaviNewYPosition=funcNaviNewYPosition-15;
	}
}
var funcNaviShowTimer = null;
function handleScroll(nullEv, fNNYP) {
	if (funcNavLayer==null) funcNavLayer = new eMBLayer( "nav5" );
	setFuncNaviNewYPosition();
	var go = (funcNaviNewYPosition!=fNNYP);
	if ((MS && !MAC) || go){ 
		clearTimeout(funcNaviShowTimer);	
		funcNavLayer.hide();
		repositionFuncNav();
		if (!MAC) funcNaviShowTimer=setTimeout("funcNavLayer.show()", (MS||NS)?150:350);
		else funcNaviShowTimer=setTimeout("funcNavLayer.show()", 500);
	}
	if (!MS || (MAC && !DOM))
		repositionTimer = window.setTimeout("handleScroll("+null+","+funcNaviNewYPosition+")",(NS)?60:150);
	else if (MAC && MS)
		repositionTimer = window.setTimeout("handleScroll("+null+","+funcNaviNewYPosition+")",350);
}
// initializing the repositioning of the funcnav layer
if (MS) window.offScreenBuffering=true; // to be tested -> couldn't find detailed explanation
if (MS && !MAC){
	window.onscroll=handleScroll; // does not work with NS4.x,NS6 and OP
	window.onresize=handleScroll;
}

