 /***********************************************************************
						 sinato jmuffin 2001 
						 DHTML Context Navigation v1.0
						 by jMouse
						 08/08/2001
***********************************************************************/
/* event Handlers click,move */
document.onclick=Clicks
document.onmousemove=mouseMove
/* set mouse cord */
x=0;
y=0;
isLoaded=false; // michi 20.6.03

var NS  = (document.layers) ? 1:0;			// NS 4
var IE  = (document.all) ? 1:0;				// IE 4
var DOM = (document.getElementById) ? 1:0;	// IE 5 / NS 6

function mouseMove(e)	{
	x = (!NS)? e.pageX : event.x+document.body.scrollLeft;
	y = (!NS)? e.pageY : event.y+document.body.scrollTop;
}
/* event click close layers if not on a layer */
function Clicks()	{
	if(!isOnLayer())clearChilds();
}
/* StylesSheet written from top properties */
document.write('<style>');
	document.write('.jmDHTML {text-align: '+jmAlign+'; background-color : '+jmBackground+';font-family : '+jmFontFamily+';font-size : '+jmFontSize+';font-style : '+jmFontStyle+';font-weight : '+jmFontBold+';color:'+jmFontColor+'}');
	/* For Netscape 4 */
	document.write('a.jmDHTML {text-align: '+jmAlign+'; text-decoration : none;font-family : '+jmFontFamily+';font-size : '+jmFontSize+';font-style : '+jmFontStyle+';font-weight : '+jmFontBold+';color:'+jmFontColor+';}');
	/* For IE/Netscape 6 */
	document.write('.jmDHTMLHover {text-align: '+jmAlign+'; background-color : '+jmBackgroundOver+';font-family : "arial";font-size : '+jmFontSize+';font-style : '+jmFontStyle+';font-weight : '+jmFontBold+';color:'+jmFontColorOver+'}');
document.write('</style>');

/* Class of to scroll layers */
function classGlobal()	{
	this.pos=-1;
	this.name=new Array();
	this.add=add;
	this.remove=remove;
	this.next=next;
	this.getName=getName;
	this.caller="";
}
	/* add a new layer */
	function add(sName)	{
		var tmp=true;
		for(var i=0;i<this.name.length;i++)
			if(this.name[i]==sName)tmp=false;
		if(tmp)this.name[this.name.length]=sName;
	}
	/* remove a layer */
	function remove(sName)	{
		var tmp=new Array();
		for(var i=0;i<this.name.length;i++)
			if(this.name[i]!=sName)tmp[tmp.length]=this.name[i];
		this.name=tmp;
	}
	/* browse to the next layer */
	function next()	{
		if(++this.pos< this.name.length)return true;
		else	{
			this.pos=-1;
			return false
		}
	}
	/* get name of current layer */
	function getName()	{
		return this.name[this.pos]
	}
/* instanz layer */
global= new classGlobal();
/* on mouse over (not NS4) */
function mouseOver(oTd)	{
	oTd.className="jmDHTMLHover";
	oTd.style.cursor="hand"
}
/* on mouse out (not NS4) */
function mouseOut(oTd)	{
	oTd.className="jmDHTML";
}
/* on click link in layer */
function goesTo(areaID,aID)	{
	for(var i=0;i<aAreaID.length;i++)
		if(aAreaID[i]==areaID)var code=aAreaCode[i]
	window.location=code+"index.cfm?treeID="+aID;
}
/* give back written string of items to insert into layer */
function getChilds(parent,top,left,lev)	{
	var content="";
	var count=countChilds(parent);
	var iCount=0;
	for(var i=0;i<aID.length;i++)
		if(aParent[i]==parent && aState[i]==1)	{
			links ='eval(getSize(\'level'+lev+'\',\'Left\')+getSize(\'level'+lev+'\',\'Width\')-jmEngageHorizontal)';
			height='eval( ( getSize(\'level'+lev+'\',\'Height\')/'+count+')*'+(iCount++)+'+ jmEngageVertical)';
			if(NS)	{
				content+='<tr>'
				+'<td class="jmDHTML" '
				+'width="'+jmMinWidth+'" '
				+' nowrap >'
				+'<a '
				+'onmouseover="setLayer('+aID[i]+','+top+'+'+height+', '+links+' ,'+eval(lev+1)+')" '
				+'href="javascript:goesTo('+aArea[i]+','+aID[i]+')" class="jmDHTML">'
				+aTitle[i]
				+'</a></td>'
				+'</tr>';
			}
			else	{
				content+='<tr>'
				+'<td class="jmDHTML" '
				+'width="'+jmMinWidth+'" '
				+'onmouseover="setLayer('+aID[i]+','+top+'+'+height+', '+links+' ,'+eval(lev+1)+');mouseOver(this)" '
				+'onmouseout="mouseOut(this)" '
				+'onclick="goesTo('+aArea[i]+','+aID[i]+')" nowrap>'
				+aTitle[i]
				+'</td>'
				+'</tr>';
			}
		}
	// has Childs
	if(content!="")	{
		content='<table style="filter:SHADOW(color=gray, strength=4)" border="0" width="'+jmMinWidth+'" cellspacing="0" cellpadding="0"><tr><td bgcolor="'+jmBorderColor+'"><table border="0" width="'+jmMinWidth+'" cellpadding="'+jmPadding+'" cellspacing="'+jmSpacing+'">'+content+'</table></td></tr></table>';
	}
	return content;
}
/* give back child count(int) */
function countChilds(parent)	{
	count=0;
	for(var i=0;i<aID.length;i++)
		if(aParent[i]==parent)count++;
	return count;
}
/* give back boolean childs for this item exist */
function hasChilds(parent)	{
	bol=false;
	for(var i=0;i<aID.length;i++)
		if(aParent[i]==parent)bol=true;
	return bol;
}
/* clear all childs form level */
function clearChilds(level)	{
	var lev = level || 0;
	if(lev==0)	{
		out(global.caller)
		global.caller="";
	}
	while(sLayer("level"+(++lev))) {
		setVisibility("level"+lev,false);
		global.remove("level"+lev);
	}
}
/* boolean for is numeric or not */
function isNumeric(str) {
    numeric="01234567890 ";
	if(str.length==0)return false;
	for(var i=0;i<str.length;i++)
		if(numeric.indexOf(str.charAt(i))==-1)	return false;	
	return true;
 }
/* when you not have the treeid only the area code this function give bachk the start id */
function getParentFromArea(code)	{
	var returnValue=0;
	for(var i=0;i<aAreaCode.length;i++)
		if(aAreaCode[i]==code)var areaID=aAreaID[i]
	for(var i=0;i<aID.length;i++)
		if(aParent[i]==0 && aArea[i]==areaID)returnValue=aID[i];
return returnValue;
}
/* sets a layer */
function setLayer(parent,top,left,level)	{
	if(!isLoaded) return;  //michi 20.06.03
	if(!isNumeric(parent))parent=getParentFromArea(parent);
	datum=new Date();
	var lev = level || 1;
	var sName="level"+lev
	clearChilds(lev);
	if(!sLayer(sName))createLayer(sName);
	if(hasChilds(parent))	{
		setStyle(sName,"top",top);
		setStyle(sName,"left",left);
		setInnerHTML(sName,getChilds(parent,top,left,lev));
		setVisibility(sName,true);
		global.add(sName);
	}
	else {
		setVisibility(sName,false);
		global.remove(sName);
	}
}
function setLayerAndOver(parent,top,left,caller){
	if(global.caller!="")out(global.caller);
	global.caller=caller;
	over(caller);
	if(parent != -1) setLayer(parent,top,left,1);
}

/* check is on layer or not */
function isOnLayer()	{
	var canClose=false;
	while(global.next())	{
		tmpName=global.getName();
		iLeft = getSize(tmpName,"Left");
		//iLeft=sLayer(tmpName).offsetLeft;
		iRight=iLeft+getSize(tmpName,"Width");
		//iRight=iLeft+sLayer(tmpName).offsetWidth;
		iTop=getSize(tmpName,"Top");
		//iTop=sLayer(tmpName).offsetTop;
		iBottom=iTop+getSize(tmpName,"Height");
		//iBottom=iTop+sLayer(tmpName).offsetHeight;
		if(x>iLeft && x<iRight && y>iTop && y<iBottom )	{
			canClose=true;
		}		
	}
	return canClose;
}
/* loop to close layers when not on it  */
datum=new Date();
function closeAll()	{
	setTimeout("closeAll()",10000);
	//window.status=datum.getTime()+"-"+new Date().getTime();
	if(isOnLayer()) datum=new Date();
	else if( (1500+datum.getTime())  < new Date().getTime())clearChilds();
}
closeAll();

