/**************************************************************************************************
Copyright (C) 2000 Caspar-David Senfft aliasing CDS-Virtuallender.
This javascript is made by and copyrighted to CDS-Virtuallender at 

http://www.scriptlender.de/

Wherever the source code state that the script or demo is free to use, 
the source is free to use as long the copyright notice is kept in the source. 

As mentioned; the only thing I require if you use any of my scripts or demos on your own pages is 
that you keep the copyright notice in there. 

Very simple; All may be used freely as long as this message is intact!
**************************************************************************************************/

function onSetStatus(prmIdx)
{
	var theNode = oNodeMgr.getParent(prmIdx);

	if (theNode) {
		var bOpen = theNode.meOpen;
	
		if (!theNode.meRoot) {
			if (defISMULTIPLE) {
				theNode.meOpen = !bOpen;
			} else {
				oNodeMgr.closeParents();
				theNode.meOpen = !bOpen;
				theNode.openParent();
			}
		}
		
		if (theNode.meLink && (theNode.meTarget==defIDMAINFRM)) {
			oNodeMgr.meActiveNode = theNode;
			parent.frames[defIDMAINFRM].location.href = theNode.meLink;
		}
		
		oNodeMgr.showTreeMenu(true);
	}
}

/*************************************************************************************************/

function onChangeImage(prmKey,prmOver)
{
	var theNode = oNodeMgr.getNode(prmKey);

	if (theNode) {
		var objStr = "parent."+defIDMENUFRM+".document.images."+theNode.meImgId+";";
		var objImg = eval(objStr);

		// Sometimes my Netscape v4.7x ends with an unhandled fucking exception caused by this hover effect!
		// You can remove the following statement if newer versions are more save.
		if (window.document.layers) return;

		if (prmOver) {
			if (objImg) objImg.src = theNode.meIconOver.src;
			
		} else {
			if (oNodeMgr.isActiveNode(prmKey)) {
				if (objImg) objImg.src = theNode.meIconClick.src;
			} else {
				if (objImg) objImg.src = theNode.meIconOut.src;
			}
		}
	}
}

function onChangeColor(prmThis,prmOver)
{
	if (prmThis && defISHIGHLIGHT) {
		if (window.document.layers) {
			prmThis.bgColor = prmOver ? defHLCOLOR : defBGCOLOR;
		} else {
			prmThis.style.backgroundColor = prmOver ? defHLCOLOR : defBGCOLOR;
		}
	}
}

function onChangeText(prmTxt)
{
	parent.status = prmTxt ? prmTxt : defSBDEFAULT;
}

/*************************************************************************************************/

function writeMenuString(prmString)
{
	prmString = prmString ? prmString : "&nbsp;";

	var strHTML  = "";
	strHTML += "<div style='padding:1px;width:96%;color:#8B0000;font-family:Verdana;font-size:9px;border-width:2px;border-color:#fff;border-style: groove ridge ridge groove;*border:2px groove grey;'><b>Please be aware: <br>We are currently working on translating our website and not all pages may appear in English. <br>We apologize for any inconvenience.</b></div><br>";
    strHTML += "<table border='0' width='99.9%' style='margin:0px; padding=0px' align='left' cellpadding='0' cellspacing='0' bgcolor='"+defBGCOLOR+"' summary='PositionTable'>";
/*if (window.document.all && (navigator.appName=="Microsoft Internet Explorer") && (navigator.appVersion.substring(0,1) < "7"))
{
	    strHTML += "<table border='0' width='99.9%' style='margin:0px; padding=0px' align='left' cellpadding='0' cellspacing='0' bgcolor='#F0F0F0' summary='PositionTable'>";

}
else
{
	    strHTML += "<table border='0' background='"+imgOpac.src+"' width='99.9%' style='margin:0px; padding=0px' align='left' cellpadding='0' cellspacing='0' bgcolor='"+defBGCOLOR+"' summary='PositionTable'>";
}
*/	    strHTML += "<tr align='left'>";
	    strHTML += "<td valign='middle'><img src='"+imgTrans.src+"' width='"+defMARGINLEFT+"' height='"+defMARGINTOP+"' border='0' \/><\/td>";
	    strHTML += "<td valign='middle'><img src='"+imgTrans.src+"' width='1' height='"+defMARGINTOP+"' border='0' \/><\/td>";
	    strHTML += "<\/tr>";
	    strHTML += "<tr align='left'>";
	    strHTML += "<td valign='middle'><img src='"+imgTrans.src+"' width='"+defMARGINLEFT+"' height='1' border='0' \/><\/td>";
	    strHTML += "<td valign='middle'>"+prmString+"<\/td>";
	    strHTML += "<\/tr>";
	    strHTML += "<\/table>";

	defMENUSTRING = strHTML;

	parent.frames[defIDMENUFRM].location.replace(defMENUPAGE);
}

function getMenuPosition()
{
	if (typeof(window.pageXOffset)=="number") {
		defSCROLLX = parent.frames[defIDMENUFRM].pageXOffset;
		defSCROLLY = parent.frames[defIDMENUFRM].pageYOffset;
		
	} else if (window.document.all) {
		defSCROLLX = parent.frames[defIDMENUFRM].document.body.scrollLeft;
		defSCROLLY = parent.frames[defIDMENUFRM].document.body.scrollTop;
		
	} else {
		defSCROLLX = 0;
		defSCROLLY = 0;
	}
}

/*************************************************************************************************/

function onLoadHref(prmKey)
{
	var theNode = oNodeMgr.getNode(prmKey);

	if (!theNode) return;

	var theTarget = theNode.meTarget;

	if ((theTarget == defIDMAINFRM) || (theTarget == defIDNAVIFRM)) {
		oNodeMgr.meActiveNode = theNode;
		
		parent.frames[theTarget].location.href = theNode.meLink;
		if (defISACTIVE) {
			oNodeMgr.showTreeMenu(true);
		}
		
	} else if ((theTarget == "_top") || (theTarget == "_parent")) {
		top.location.href = theNode.meLink;
		
	} else if ((theTarget == "_self") || (theTarget == defIDMENUFRM)) {
		parent.frames[defIDMENUFRM].location.href = theNode.meLink;
	
	} else if (theTarget == "_blank") {
		if (defHWININST && !defHWININST.closed) {
			defHWININST.close();
			defHWININST = null;
		}
		defHWININST = window.open(theNode.meLink,theTarget,defWINSTYLE);
	}
}

/*************************************************************************************************/

////////////////////////////////////////////////////////////////////////////
// You have the choice of using the href- or replace()- statement.
// If you want to do this, do it twice in initInstance() and onLoadHref().
// parent.frames[...].location.replace(...);
// parent.frames[...].location.href = .....;

function initInstance()
{
	if (oNodeMgr) {
		var aryPages = window.location.search.substr(1).split("&");
		
		if (aryPages && aryPages[0].length) {
		      var theNode = oNodeMgr.searchForLnk(aryPages[0]);
		      if (theNode) {
                                theNode.meOpen = true;
				theNode.openParent();
				oNodeMgr.meActiveNode = theNode;
				parent.frames[theNode.meTarget].location.href = theNode.meLink + location.hash;
			} else {
				// Use aryPages[0] instead of defNOHELPPAGE if you want to load the unknown page in the Main-Frame.
				parent.frames[defIDMAINFRM].location.href = aryPages[0] + location.hash;
			}
			
		} else {
			var theNode = oNodeMgr.searchForLnk(defMAINPAGE);
			if (theNode) {
				theNode.openParent();
				oNodeMgr.meActiveNode = theNode;
			}
		}
		
		oNodeMgr.showTreeMenu(true);
		
	} else return(false);
	
	return(true);
}

function alertError(prmMsg, prmUrl, prmLine)
{
	window.defaultStatus = "JAVASCRIPT-ERROR";
	window.alert("JAVASCRIPT-ERROR:\n" + "\nMessage:\t" + prmMsg + "\nUrl:\t" + prmUrl + "\nLine:\t" + prmLine);

	return(true);
}

/*************************************************************************************************/

window.onerror = alertError;
window.onload  = initInstance;

/*************************************************************************************************/
