/*
external js file for dynamical positioning of the functional navigation
$Source: /usr/cvs/eMB/Clickstream_DCVD/js/popup_nav5.js,v $
$Revision: 1.1 $
Check-In $Date: 2002/10/08 10:14:32 $
 */
var eventCounter = 0; // just for testing purposes
var orgYpos = -100; // holds original y-position of funcnavi
var maxStopperYPosition = -1;
var repositionTimer = null;
var funcNaviNewYPosition;
var funcNavLayer = null;
var DEBUG = false;
function repositionFuncNav() {
	// 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);
	}
}

function setFuncNaviNewYPosition() {
	  var scrOfY = 0, myHeight = 0;

	  if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible (DOM compliant)
	    myHeight = document.body.clientHeight;
	  }

	  if( typeof( window.pageYOffset ) == 'number' ) {
	    //Netscape compliant (Non-IE)
	    scrOfY = window.pageYOffset;
	  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
	    //DOM compliant
	    scrOfY = document.body.scrollTop;
	  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
	    //IE6 standards compliant mode
	    scrOfY = document.documentElement.scrollTop;
	  }

		funcNaviNewYPosition = myHeight - funcNavLayer.getHeight() + scrOfY - eval(top_distance);

}
var funcNaviShowTimer = null;
function handleScroll(nullEv, fNNYP) {
	
		funcNavLayer = new eMBLayer("nav5");

		if (funcNavLayer != null) {
			setFuncNaviNewYPosition();
			var go = (funcNaviNewYPosition != fNNYP);
			if (MS || go) {
				clearTimeout(funcNaviShowTimer);
				if (MAC && MS) { // avoid rendering-errors on Mac IE5
					setTimeout("funcNavLayer.show()", 1);
					setTimeout("repositionFuncNav()", 1);
				} else {
					funcNavLayer.show();
					repositionFuncNav();
				}
				funcNaviShowTimer = setTimeout("funcNavLayer.show()",
						((MS || NS) && !MAC) ? 150 : 350);
			}
			if (!MS || (MAC && !DOM))
				repositionTimer = window.setTimeout("handleScroll(" + null
						+ "," + funcNaviNewYPosition + ")", (NS) ? 60 : 150);
			if (DEBUG) {
				window.status = " " + window.status;
				if (window.status.length > 150)
					window.status = funcNavLayer.isObject();
			}
		}
	}

// initializing the repositioning of the funcnav layer
if (MS)
	window.offScreenBuffering = true; // to be tested -> couldn't find
										// detailed explanation
	// window.setTimeout("handleScroll(1, 2)", 350);
if (MS) {
	window.onscroll = handleScroll; // does not work with NS4.x,NS6 and OP
	window.onresize = handleScroll;
}

//additional method for footer handling
function recalculateFooterPosition() {
	funcNavLayer = new eMBLayer("nav5");
	setFuncNaviNewYPosition();
	repositionFuncNav();
	var nav5 = document.getElementById("nav5");
	if (nav5) {
		nav5.style.visibility = "visible";
	}
}
//resets the footer to the correct position
setInterval("recalculateFooterPosition()", 200);

// Opera resize-Topnavigaton Fix Check (not used by any other browser)
// Opera resize-Topnavigation Fix START
var origW = window.innerWidth; // just for Opera resize check
var origH = window.innerHeight; // just for Opera resize check
var ResizeTimerForOP; // TimerObject just for Opera resize check
function checkResizeForOpera() {
	clearTimeout(ResizeTimerForOP);
	if (!OP)
		return true;
	if (!(window.innerWidth == origW && window.innerHeight == origH)) {
		origW = window.innerWidth;
		origH = window.innerHeight;
		// setTimeout("setMenuLayerPositions();
		// showMenu(activeSubNavName,activeTab);", 200);
		location.reload();
	}
	ResizeTimerForOP = window.setTimeout("checkResizeForOpera()", 350);
	return true;
}
// Opera resize-Topnavigation Fix Check END	
