/**************************************************************************************************
Copyright (C) 2000-2001 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 sNode(prmLink,prmText,prmInfo,prmStyle1,prmStyle2,prmIconOut,prmIconOver,prmIconClick,prmOpen,prmTarget)
{
	/*********************************/
	/* Declaration of public members */
	/*********************************/

	this.meChildAry  = new Array();

	this.meIconOut   = new Image();
	this.meIconOver  = new Image();
	this.meIconClick = new Image();
	
	this.meIconOut.src   = prmIconOut;
	this.meIconOver.src  = prmIconOver;
	this.meIconClick.src = prmIconClick;

	this.meParent   = null;
	this.mePrevNode = null;
	this.meNextNode = null;

	this.meLink   = prmLink;
	this.meText   = prmText;
	this.meInfo   = prmInfo;
	this.meTocTxt = "";

	this.meOpen   = prmOpen;
	this.meTarget = prmTarget;
	
	this.meClass  = prmStyle1;
	this.meActive = prmStyle2;
	
	this.meLevel = 0;
	this.meKey   = -1;
	this.meImgId = "id";
	
	this.meSpacer = false;
	this.meHeader = false;
	
	this.meTtip = prmInfo ? prmInfo : prmText;

	/*****************************************/
	/* Declaration of public memberfunctions */
	/*****************************************/

	this.appendChild = sNode_appendChild;
	this.openParent  = sNode_openParent;
	this.setContent  = sNode_setContent;

	this.getBodyString  = sNode_getBodyString;
	this.getHeadString  = sNode_getHeadString;
	this.getLeadString  = sNode_getLeadString;
	this.getSpaceString = sNode_getSpaceString;	

	this.hasTrailSpacer = sNode_hasTrailSpacer;
	this.getTreeString  = sNode_getTreeString;
}

function cNode(prmLink,prmText,prmInfo,prmStyle1,prmStyle2,prmIconOut,prmIconOver,prmIconClick,prmOpen,prmTarget)
{
	var strClass,strActive;
	var strLink,strText,strInfo,strTarget;
	var strIconOut,strIconOver,strIconClick;

	var bOpen = prmOpen ? true : false;

	strIconOut = prmIconOut ? prmIconOut : imgIconOut.src;

	if (prmIconOver) {
		strIconOver = prmIconOut ? prmIconOver : imgIconOver.src;
	} else {
		strIconOver = prmIconOut ? prmIconOut : imgIconOver.src;
	}

	if (prmIconClick) {
		strIconClick = prmIconOut ? prmIconClick : imgIconClick.src;
	} else {
		strIconClick = prmIconOut ? prmIconOut : imgIconClick.src;
	}

	if (prmLink) {
		strLink   = prmLink;
		strTarget = (prmTarget || !isNaN(prmTarget)) ? prmTarget : defIDMAINFRM;
		strText   = prmText ? prmText : prmLink;
		cssClass  = prmStyle1 ? prmStyle1 : defCSSLINK;
		cssActive = prmStyle2 ? prmStyle2 : (prmStyle1 ? prmStyle1 : defCSSACTIVE);
//		strInfo   = prmInfo ? prmInfo : prmLink;
		strInfo   = prmInfo ? prmInfo : prmInfo;
	} else {
		strLink   = null;
		strTarget = null;
		strText   = prmText ? prmText : defNOTEXT;
		cssClass  = prmStyle1 ? prmStyle1 : defCSSTEXT;
		cssActive = prmStyle2 ? prmStyle2 : (prmStyle1 ? prmStyle1 : defCSSTEXT);
		strInfo   = prmInfo ? prmInfo : defNOINFO;
	}

	strText = defSPACER+strText+defSPACER;
	strText = strText.replace(/ /g,"&nbsp;");
	
	/*************************************************/
	/* Call constructor function from base prototype */
	/*************************************************/
	this.meBase = sNode;
	this.meBase(strLink,strText,strInfo,cssClass,cssActive,strIconOut,strIconOver,strIconClick,bOpen,strTarget);
}

/*******************************************************************************/
/* Enable dynamic inheritance for new added properties and methods at run time */
/*******************************************************************************/
cNode.prototype = new sNode;

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

function sNode_appendChild(prmChild)
{
	if (prmChild) {
		prmChild.meLevel    = this.meLevel+1;
		prmChild.meParent   = this;
		prmChild.meNextNode = null;
		
		if (this.meChildAry.length) {
			var lastChild = this.meChildAry[this.meChildAry.length-1];
			if (lastChild) {
				prmChild.mePrevNode  = lastChild;
				lastChild.meNextNode = prmChild;
			} else {
				return(false);
			}
		} else {
			prmChild.mePrevNode = null;
		}

		this.setContent(prmChild);
		this.meChildAry[this.meChildAry.length] = prmChild;
		return(true);
	}

	return(false);
}

function sNode_openParent()
{
	var theParent = this.meParent;

	if (theParent) {
		theParent.meOpen = true;
		theParent.openParent();
	}
}

function sNode_setContent(prmChild)
{
	if (!prmChild || prmChild.meSpacer) return;

	if (this.meTocTxt.length) {
		this.meTocTxt += defTTDELIMITER + prmChild.meText;
	} else {
		this.meTocTxt = prmChild.meText;
	}
}

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

function sNode_getTreeString()
{
	var retStr  = "";
	var theNode = null;

	if (this.meLevel) {
		if (this.meRoot || this.meHeader) {
			retStr = this.getHeadString();
		} else if (this.meSpacer) {
			retStr = this.getSpaceString();
		} else {
			retStr = this.getBodyString();
		}
	}
	
	if (this.meOpen) {
		for (var i=0; i<this.meChildAry.length; i++) {
			theNode = this.meChildAry[i];
			if (theNode) {
				retStr += theNode.getTreeString();
			}
		}
	}

	return(retStr);
}

function sNode_getLeadString(prmStr)
{
	prmStr = prmStr ? prmStr : "";
	
	var theStr = "";
	var theParent = this.meParent;
	
	if (theParent && theParent.meLevel) {
		if (!theParent.meRoot && !theParent.meHeader) {
			if (theParent.meNextNode) {
				theStr  = "<td nowrap='nowrap' width='"+defCELLWIDTH+"' height='"+defCELLHEIGHT+"'>";
				theStr += "<img src='"+imgLine.src+"' border='0' \/>";
				theStr += "<\/td>";
			} else {
				theStr  = "<td nowrap='nowrap' width='"+defCELLWIDTH+"' height='"+defCELLHEIGHT+"'>";
				theStr += "<img src='"+imgBlank.src+"' border='0' \/>";
				theStr += "<\/td>";
			}
		}
		prmStr = theStr + prmStr;
		prmStr = theParent.getLeadString(prmStr);
	}
	
	return(prmStr);
}

function sNode_hasTrailSpacer()
{
	var bTrailer = true;
	var theSibling = this.meNextNode;
	
	if (theSibling) {
		if (theSibling.meSpacer) {
			bTrailer = theSibling.hasTrailSpacer();
		} else {
			bTrailer = false;
		}
	}
	
	return(bTrailer);
}

function sNode_getSpaceString()
{
	var retStr = "";
	
	retStr += "<table border='0' cellpadding='0' cellspacing='0' summary='SpaceTable' width='100%'>";
	retStr += "<tr align='left' valign='middle'>";
	    
	retStr += this.getLeadString();
	
	if (this.meLevel>1) {
		retStr += "<td nowrap='nowrap' width='"+defCELLWIDTH+"' height='"+defCELLHEIGHT+"'>";
		retStr += "<\/td>";
	}
	    

	retStr += "<td nowrap='nowrap' width='100%' height='"+defCELLHEIGHT+"'>";
	retStr += "<hr noshade='noshade' size='1' width='96%' align='center'>";
	retStr += "<\/td>";

	retStr += "<\/tr><\/table>";

	return(retStr);
}

function sNode_getHeadString()
{
	var retStr = "";
	var imgStr = "";
	var txtStr = "";
	
	retStr  = "<table border='0' width='100%' cellpadding='0' cellspacing='0' summary='HeadTable'>";
	retStr += "<tr align='left' valign='middle'>";
	
	retStr += this.getLeadString();
	
	if (this.meChildAry.length) {
		if (this.meOpen) {
		 	imgStr  = "<a href='javascript:parent.onSetStatus("+this.meKey+")' onMouseover='parent.onChangeText(\""+this.meInfo+"\");return(true);' onMouseout='parent.onChangeText();return(true);'>";
 			imgStr += "<img src='"+this.meIconClick.src+"' border='0' title='"+this.meInfo+"' alt='"+this.meInfo+"' \/>";
		 	imgStr += "<\/a>";
		 } else {
	 		imgStr  = "<a href='javascript:parent.onSetStatus("+this.meKey+")' onMouseover='parent.onChangeText(\""+this.meInfo+"\");return(true);' onMouseout='parent.onChangeText();return(true);'>";
	 		imgStr += "<img src='"+this.meIconOut.src+"' border='0' title='"+this.meInfo+"' alt='"+this.meInfo+"' \/>";
		 	imgStr += "<\/a>";
	 	}
	 } else {
	 	if (defISACTIVE && oNodeMgr.isActiveNode(this.meKey)) {
		 	imgStr  = "<a href='javascript:parent.onLoadHref("+this.meKey+")' onMouseover='parent.onChangeText(\""+this.meInfo+"\");return(true);' onMouseout='parent.onChangeText();return(true);'>";
 			imgStr += "<img src='"+this.meIconClick.src+"' border='0' title='"+this.meInfo+"' alt='"+this.meInfo+"' \/>";
		 	imgStr += "<\/a>";
	 	} else {
	 		imgStr  = "<a href='javascript:parent.onLoadHref("+this.meKey+")' onMouseover='parent.onChangeText(\""+this.meInfo+"\");return(true);' onMouseout='parent.onChangeText();return(true);'>";
	 		imgStr += "<img src='"+this.meIconOut.src+"' border='0' title='"+this.meInfo+"' alt='"+this.meInfo+"' \/>";
		 	imgStr += "<\/a>";
	 	}
	 }
	
	if (this.meLink) {
		if (defISACTIVE && oNodeMgr.isActiveNode(this.meKey)) {
			if (this.meChildAry.length) {
				txtStr = "<a href='"+this.meLink+"' target='"+this.meTarget+"' onClick='parent.onSetStatus("+this.meKey+");return(false);' onMouseover='parent.onChangeText(\""+this.meInfo+"\");return(true);' onMouseout='parent.onChangeText();return(true);' class='"+this.meActive+"' title='"+this.meTtip+"' alt='"+this.meText+"'>"+this.meText+"<\/a>";
			} else {
				txtStr = "<a href='"+this.meLink+"' target='"+this.meTarget+"' onClick='parent.onLoadHref("+this.meKey+");return(false);' onMouseover='parent.onChangeText(\""+this.meInfo+"\");return(true);' onMouseout='parent.onChangeText();return(true);' class='"+this.meActive+"' title='"+this.meTtip+"' alt='"+this.meText+"'>"+this.meText+"<\/a>";
			}
		} else {
			if (this.meChildAry.length) {
				txtStr = "<a href='"+this.meLink+"' target='"+this.meTarget+"' onClick='parent.onSetStatus("+this.meKey+");return(false);' onMouseover='parent.onChangeText(\""+this.meInfo+"\");return(true);' onMouseout='parent.onChangeText();return(true);' class='"+this.meClass+"' title='"+this.meTtip+"' alt='"+this.meText+"'>"+this.meText+"<\/a>";
			} else {
				txtStr = "<a href='"+this.meLink+"' target='"+this.meTarget+"' onClick='parent.onLoadHref("+this.meKey+");return(false);' onMouseover='parent.onChangeText(\""+this.meInfo+"\");return(true);' onMouseout='parent.onChangeText();return(true);' class='"+this.meClass+"' title='"+this.meTtip+"' alt='"+this.meText+"'>"+this.meText+"<\/a>";
			}
		}
	} else {
		txtStr += "<span class='"+this.meClass+"'>"+this.meText+"<\/span>";
	}
	
	retStr += "<td nowrap='nowrap' width='"+defCELLWIDTH+"' height='"+defCELLHEIGHT+"'>"+imgStr+"<\/td>";
	retStr += "<td nowrap='nowrap' align='left' onMouseover='parent.onChangeColor(this,true);parent.onChangeText(\""+this.meInfo+"\");return(true);' onMouseout='parent.onChangeColor(this,false);parent.onChangeText();return(true);' title='"+this.meText+"' alt='"+this.meText+"'>"+txtStr+"<\/td>";
	
	retStr += "<\/tr><\/table>";

	return(retStr);
}

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

function sNode_getBodyString()
{
	var retStr = "";
	var imgStr = "";
	var fldStr = "";
	var txtStr = "";

	retStr  = "<table border='0' width='100%' cellpadding='0' cellspacing='0' summary='NodeTable'>";
	retStr += "<tr align='left' valign='middle'>";

	retStr += this.getLeadString();
	
	if (this.meChildAry.length) {
		if (this.meOpen) {
			if (this.meNextNode) {
				imgStr  = "<a href='javascript:parent.onSetStatus("+this.meKey+")' onMouseover='parent.onChangeText(\""+defSBOPENNODE+"\");return(true);' onMouseout='parent.onChangeText();return(true);'>";
				imgStr += "<img src='"+imgMinusMiddle.src+"' border='0' title='"+defTTSHUTNODE+"' alt='"+defTTSHUTNODE+"' \/>";
				imgStr += "<\/a>";
			} else {
				imgStr  = "<a href='javascript:parent.onSetStatus("+this.meKey+")' onMouseover='parent.onChangeText(\""+defSBOPENNODE+"\");return(true);' onMouseout='parent.onChangeText();return(true);'>";
				imgStr += "<img src='"+imgMinusBottom.src+"' border='0' title='"+defTTSHUTNODE+"' alt='"+defTTSHUTNODE+"' \/>";
				imgStr += "<\/a>";
			}
			fldStr  = "<a href='javascript:parent.onSetStatus("+this.meKey+")' onMouseover='parent.onChangeText(\""+this.meInfo+"\");return(true);' onMouseout='parent.onChangeText();return(true);'>";
			fldStr += "<img src='"+imgFolderOpen.src+"' border='0' title='"+this.meTocTxt+"' alt='"+this.meTocTxt+"' \/>";
			fldStr += "<\/a>";
		} else {
			if (this.meNextNode) {
				imgStr  = "<a href='javascript:parent.onSetStatus("+this.meKey+")' onMouseover='parent.onChangeText(\""+defSBSHUTNODE+"\");return(true);' onMouseout='parent.onChangeText();return(true);'>";
				imgStr += "<img src='"+imgPlusMiddle.src+"' border='0' title='"+defTTOPENNODE+"' alt='"+defTTOPENNODE+"' \/>";
				imgStr += "<\/a>";
			} else {
				imgStr  = "<a href='javascript:parent.onSetStatus("+this.meKey+")' onMouseover='parent.onChangeText(\""+defSBSHUTNODE+"\");return(true);' onMouseout='parent.onChangeText();return(true);'>";
				imgStr += "<img src='"+imgPlusBottom.src+"' border='0' title='"+defTTOPENNODE+"' alt='"+defTTOPENNODE+"' \/>";
				imgStr += "<\/a>";
			}
			fldStr  = "<a href='javascript:parent.onSetStatus("+this.meKey+")' onMouseover='parent.onChangeText(\""+this.meInfo+"\");return(true);' onMouseout='parent.onChangeText();return(true);'>";
			fldStr += "<img src='"+imgFolderClose.src+"' border='0' title='"+this.meTocTxt+"' alt='"+this.meTocTxt+"' \/>";
			fldStr += "<\/a>";
		}

	} else {
		if (this.meNextNode) {
			imgStr = "<img src='"+imgJoinMiddle.src+"' border='0' \/>";
		} else {
			imgStr = "<img src='"+imgJoinBottom.src+"' border='0' \/>";
		}

		if (defISACTIVE && oNodeMgr.isActiveNode(this.meKey)) {
			fldStr  = "<a href='"+this.meLink+"' target='"+this.meTarget+"' onClick='parent.onLoadHref("+this.meKey+");return(false);' onMouseover='parent.onChangeImage("+this.meKey+",true);parent.onChangeText(\""+this.meInfo+"\");return(true);' onMouseout='parent.onChangeImage("+this.meKey+",false);parent.onChangeText();return(true);'>";
			fldStr += "<img src='"+this.meIconClick.src+"' id='"+this.meImgId+"' name='"+this.meImgId+"' border='0' title='"+this.meInfo+"' alt='"+this.meInfo+"' \/>";
			fldStr += "<\/a>";
		} else {
			fldStr  = "<a href='"+this.meLink+"' target='"+this.meTarget+"' onClick='parent.onLoadHref("+this.meKey+");return(false);' onMouseover='parent.onChangeImage("+this.meKey+",true);parent.onChangeText(\""+this.meInfo+"\");return(true);' onMouseout='parent.onChangeImage("+this.meKey+",false);parent.onChangeText();return(true);'>";
			fldStr += "<img src='"+this.meIconOut.src+"' id='"+this.meImgId+"' name='"+this.meImgId+"' border='0' title='"+this.meInfo+"' alt='"+this.meInfo+"' \/>";
			fldStr += "<\/a>";
		}
	}

	if (this.meLink) {
		if (defISACTIVE && oNodeMgr.isActiveNode(this.meKey)) {
			if (this.meChildAry.length) {
				txtStr = "<a href='"+this.meLink+"' target='"+this.meTarget+"' onClick='parent.onSetStatus("+this.meKey+");return(false);' onMouseover='parent.onChangeText(\""+this.meInfo+"\");return(true);' onMouseout='parent.onChangeText();return(true);' class='"+this.meActive+"' title='"+this.meTtip+"' alt='"+this.meText+"'>"+this.meText+"<\/a>";
			} else {
				txtStr = "<a href='"+this.meLink+"' target='"+this.meTarget+"' onClick='parent.onLoadHref("+this.meKey+");return(false);' onMouseover='parent.onChangeImage("+this.meKey+",true);parent.onChangeText(\""+this.meInfo+"\");return(true);' onMouseout='parent.onChangeImage("+this.meKey+",false);parent.onChangeText();return(true);' class='"+this.meActive+"' title='"+this.meTtip+"' alt='"+this.meText+"'>"+this.meText+"<\/a>";
			}
		} else {
			if (this.meChildAry.length) {
				txtStr = "<a href='"+this.meLink+"' target='"+this.meTarget+"' onClick='parent.onSetStatus("+this.meKey+");return(false);' onMouseover='parent.onChangeText(\""+this.meInfo+"\");return(true);' onMouseout='parent.onChangeText();return(true);' class='"+this.meClass+"' title='"+this.meTtip+"' alt='"+this.meText+"'>"+this.meText+"<\/a>";
			} else {
				txtStr = "<a href='"+this.meLink+"' target='"+this.meTarget+"' onClick='parent.onLoadHref("+this.meKey+");return(false);' onMouseover='parent.onChangeImage("+this.meKey+",true);parent.onChangeText(\""+this.meInfo+"\");return(true);' onMouseout='parent.onChangeImage("+this.meKey+",false);parent.onChangeText();return(true);' class='"+this.meClass+"' title='"+this.meTtip+"' alt='"+this.meText+"'>"+this.meText+"<\/a>";
			}
		}
	} else {
		txtStr += "<span class='"+this.meClass+"'>"+this.meText+"<\/span>";
	}
	
	retStr += "<td nowrap='nowrap' width='"+defCELLWIDTH+"' height='"+defCELLHEIGHT+"'>"+imgStr+"<\/td>";
	retStr += "<td nowrap='nowrap' width='"+defCELLWIDTH+"' height='"+defCELLHEIGHT+"'>"+fldStr+"<\/td>";
	retStr += "<td nowrap='nowrap' align='left' onMouseover='parent.onChangeColor(this,true);parent.onChangeText(\""+this.meInfo+"\");return(true);' onMouseout='parent.onChangeColor(this,false);parent.onChangeText();return(true);' title='"+this.meText+"' alt='"+this.meText+"'>"+txtStr+"<\/td>";

	retStr += "<\/tr><\/table>";

	return(retStr);
}

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