function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function flevDivPositionValue(sDiv, sProperty) { // v2.0, Marja Ribbers-de Vroed, FlevOOware
	this.opera = (window.opera); // Opera 5+
	this.ns4 = (document.layers); // Netscape 4.x
	this.ns6 = (document.getElementById && !document.all && !this.opera); // Netscape 6+
	this.ie = (document.all);  // Internet Explorer 4+
    var sValue = ""; docObj = eval("MM_findObj('" + sDiv + "')"); if (docObj == null) {return 0;}
	if ((sProperty == "left") || (sProperty == "top")) {
		if (!this.ns4) {docObj = docObj.style;} 
		sValue = eval("docObj." + sProperty);
	}
	else {
		if (this.opera) {
			docObj = docObj.style;
			if (sProperty == "height") { sValue = docObj.pixelHeight; } 
			else if (sProperty == "width") { sValue = docObj.pixelWidth; } 
		}
		else if (this.ns4) {sValue = eval("docObj.clip." + sProperty);} 
		else if (this.ns6) {sValue = document.defaultView.getComputedStyle(docObj, "").getPropertyValue(sProperty); } 
	    else if (this.ie) { 
			if (sProperty == "width") { sValue = eval(sDiv + ".offsetWidth"); } 
			else if (sProperty == "height") { sValue = eval(sDiv + ".offsetHeight"); } 
		}
   	}
	sValue = (sValue == "") ? 0 : sValue; 
	if (isNaN(sValue)) { if (sValue.indexOf('px') > 0) { sValue = sValue.substring(0,sValue.indexOf('px')); } } 
	return parseInt(sValue); 
}

function flevPersistentLayer() { // v3.0, Marja Ribbers-de Vroed, FlevOOware
//	adaptive sliding technique inspired by Christian Lamine
	if (flevPersistentLayer.arguments.length < 7) {return;}
	// gather arguments
	var sDivID = arguments[0]; if (sDivID == "") {return;}
	var	docObj = eval("MM_findObj('" + sDivID + "')"); if (docObj == null) {return;}
	var sXLeft = arguments[1], sXCenter = arguments[2], sXRight = arguments[3];
	var sYTop = arguments[4], sYCenter = arguments[5], sYBottom = arguments[6];
	var iSpeed = (arguments.length > 7) ? parseInt(arguments[7]) : 0;
	var iPx = (arguments.length > 8) ? parseInt(arguments[8]) : 0;
	var iTimeout = 10, sSuffix = "";
	// determine current document window size and scroll position
	var iWinWidth, iWinHeight, iScrollX, iScrollY;
	if (window.innerWidth) { // NS4, NS6 and Opera
		iWinWidth = window.innerWidth;
		iWinHeight = window.innerHeight;
		iScrollX = window.pageXOffset;
		iScrollY = window.pageYOffset;
		}
	else if (document.documentElement && document.documentElement.clientWidth) { // IE6 in standards compliant mode
		iWinWidth = document.documentElement.clientWidth; 
		iWinHeight = document.documentElement.clientHeight; 
		iScrollX = document.documentElement.scrollLeft;
		iScrollY = document.documentElement.scrollTop;
		}
	else if (document.body) { // IE4+
		iWinWidth = document.body.clientWidth; 
		iWinHeight = document.body.clientHeight; 
		iScrollX = document.body.scrollLeft;
		iScrollY = document.body.scrollTop;
		}
	else {return;}
	// determine current layer position
	if (!document.layers) {docObj = docObj.style;} // not NS4.x 
	var iCurX = iNewX = parseInt(docObj.left), iCurY = iNewY = parseInt(docObj.top);
	// calculate new X coordinate
	if (sXLeft != "") {iNewX = iScrollX + parseInt(sXLeft);}
	else if (sXCenter != "") {iNewX = Math.round(iScrollX + (iWinWidth/2) - (flevDivPositionValue(sDivID, 'width')/2));}
	else if (sXRight != "") {iNewX = iScrollX + iWinWidth - (flevDivPositionValue(sDivID, 'width') + parseInt(sXRight));}
	// calculate new Y coordinate
	if (sYTop != "") {iNewY = iScrollY + parseInt(sYTop);}
	else if (sYCenter != "") {iNewY = Math.round(iScrollY + (iWinHeight/2) - (flevDivPositionValue(sDivID, 'height')/2));}
	else if (sYBottom != "") {iNewY = iScrollY + (iWinHeight - flevDivPositionValue(sDivID, 'height') - parseInt(sYBottom));}
	// force persistency?
	if ((iCurX != iNewX) || (iCurY != iNewY)) {  // layer position needs to be adjusted
		if (iSpeed > 0) { // animated move
			if (iPx > 0) { // constant speed
				iTimeout = iSpeed;
				var iPxX = iPx, iPxY = iPx, iMoveX = Math.abs(iCurX - iNewX), iMoveY = Math.abs(iCurY - iNewY);
				// take care of diagonal movement
				if (iMoveX < iMoveY) {iPxY = (iMoveX != 0) ? ((iMoveY/iMoveX)*iPx) : iPx;}
				else {iPxX = (iMoveY != 0) ? ((iMoveX/iMoveY)*iPx) : iPx;}
				if (iPxX >= iMoveX) {iPxX = Math.min(Math.ceil(iPxX), iPx);}
				if (iPxY >= iMoveY) {iPxY = Math.min(Math.ceil(iPxY), iPx);}
				// calculate temporary X/Y coordinates
				if ((iCurX < iNewX) && (iCurX + iPxX < iNewX)) {iNewX = iCurX + iPxX;}
				if ((iCurX > iNewX) && (iCurX - iPxX > iNewX)) {iNewX = iCurX - iPxX;}
				if ((iCurY < iNewY) && (iCurY + iPxY < iNewY)) {iNewY = iCurY + iPxY;}
				if ((iCurY > iNewY) && (iCurY - iPxY > iNewY)) {iNewY = iCurY - iPxY;}
			}
			else { // gradually decreasing speed
				var iMoveX = ((iNewX - iCurX) / iSpeed); 
				iMoveX = (iMoveX > 0) ? Math.ceil(iMoveX) : Math.floor(iMoveX);
				iNewX = iCurX + iMoveX; 
				var iMoveY = ((iNewY - iCurY) / iSpeed); 
				iMoveY = (iMoveY > 0) ? Math.ceil(iMoveY) : Math.floor(iMoveY);
				iNewY = iCurY + iMoveY;
			}
		}
		// now actually move layer
		if ((parseInt(navigator.appVersion)>4 || navigator.userAgent.indexOf("MSIE")>-1) && (!window.opera)) {sSuffix="px";}
		if (iMoveX != 0) {eval("docObj.left = '" + iNewX + sSuffix + "'");}
		if (iMoveY != 0) {eval("docObj.top = '" + iNewY + sSuffix + "'");}
	}
	var sFunction = "flevPersistentLayer('" + sDivID + "','" + sXLeft + "','" + sXCenter + "','" + sXRight + "','" + sYTop + "','" + sYCenter + "','" + sYBottom + "'," + iSpeed + "," + iPx + ")";
	var tmpTimeout = setTimeout(sFunction,10);
}


function flevInitPersistentLayer() { // v3.0, Marja Ribbers-de Vroed, FlevOOware
	if (arguments.length < 8) {return;}
	// gather arguments
	var sDivID = arguments[0]; if (sDivID == "") {return;}
	var	docObj = eval("MM_findObj('" + sDivID + "')"); if (docObj == null) {return;}
	var iCSS = parseInt(arguments[1]);
	var sXLeft = arguments[2], sXCenter = arguments[3], sXRight = arguments[4];
	var sYTop = arguments[5], sYCenter = arguments[6], sYBottom = arguments[7];
	var iSpeed = (arguments.length > 8) ? parseInt(arguments[8]) : 0;
	var iPx = (arguments.length > 9) ? parseInt(arguments[9]) : 0;
	// Position according to CSS style?
	if (iCSS != 0) { // maintain top/left position specified by CSS style
		if (!document.layers) {docObj = docObj.style;} // not NS4.x 
		sXLeft = parseInt(docObj.left), sYTop = parseInt(docObj.top);
	}
	var sFunction = "flevPersistentLayer('" + sDivID + "','" + sXLeft + "','" + sXCenter + "','" + sXRight + "','" + sYTop + "','" + sYCenter + "','" + sYBottom + "'," + iSpeed + "," + iPx + ")";
	eval(sFunction);
}

