function toggleMenu(el){
	sel=el.id;	
	if(Browser.id.OP5||Browser.id.NS4) return;
	var l=Btn.gL(el);	
	if(l.isDp){
		
		if(TreeParams.OPEN_MULTIPLE_MENUS||l.m.ct.aM==l.m){
			l.m.cS();l.m.ct.aM=null;
		}
	}else{
		if(l.m.ct){
			//alert(l.m.ct);		
			if(TreeParams.OPEN_MULTIPLE_MENUS||l.m.ct.aM==null ){
				l.m.oS();l.m.ct.aM=l.m;
			}else{
				l.m.ct.aM.cS();			
				l.m.oS();l.m.ct.aM=l.m;
			
			}
		}
	}
}




//Button function

Btn=function(el,cat){	
	this.el=el;
	this.cat=cat;
	//alert(cat);	
	this.name=this.cat+"Menu";
	//alert("name= "+this.name); //-> = "406Menu"
	this.div=document.getElementById(this.name); //-> = Null
	//this.div=document.getElementById('406Menu'); //-> = Object
	//alert(this.div);
	this.m=new Mnu(this.div,this);	
	var ics=el.getElementsByTagName("img");
	this.ic=(ics.length>0)?ics[0]:null;
	this.isIc=false;
	if(el.tagName.toLowerCase()=="img"){
		this.isIc=true;this.ic=el;
	}
	this.isDp=false;
};


//menu auswahl:
var old;
var sel;
function setTrans(id){		
	if(sel!=id)document.getElementById(id).style.backgroundImage='URL(./img/leer.gif)'; 	
}
function setWh(id){	
	document.getElementById(id).style.backgroundImage='URL(./img/white.gif)'; 	
}
Btn.gL=function(el){	
	//window.parent.right.location.href = el.title;	
	if(old&&old!=el.id)setTrans(old);	
	setWh(el.id);		 	
	old=el.id;
	for(var m in Mns)
		
if(Mns[el.id]!=null)
return Mns[el.id].ob;		
		return new Btn(el,el.id);
		
};



//menu geschlossen:

Btn.prototype.sdl=function(){
	if(this.isIc)
return void(this.ic.src=TreeParams.CLOSED_MENU_ICON);
	//removeClass(this.el,"labelHover");
	//removeClass(this.el,"labelDown");
	if(this.ic!=null)
this.ic.src=TreeParams.CLOSED_MENU_ICON;
};




Mnu=function(el,l){
	//alert(l);
	this.ob=l;
	this.id=l.cat;
	this.el=el;
	this.its=getChildNodesWithClass(el,"menuNode");
	if(this.its!=null){
		this.its.unshift(el);	
		this.all=getElementsWithClass(el,"*","menuNode");
		this.all.unshift(el);
		this.cur=0;
		this._r=null;
		this.ct=this.getC();
		this.aM=null;	
		Mns[this.id]=this;	
	}
};

Mns={};





Mnu.prototype={
	oS:function(){if(this.isO) return;	
	if(this.ob.ic!=null)
this.ob.ic.src=TreeParams.OPEN_MENU_ICON;
	if(this.isC){
		this.cE();
		if(this.itc){
			this.ito=this.itc.reverse();
			this.cur=this.itc.length-this.cur;
		}
	}else{
		this.cur=0;
		this.ito=new Array();
		if(this.itc)
this.ito=this.itc.reverse();
		else
this.ito=this.its;
		if(!this.ob.isIc)
this.ob.el.className+=" labelDown";
	}	
	this.isC=false;
	this.isO=true;
	if(this.ito[0]!=this.el)
this.ito.reverse();	
	this.pat=setInterval("Mns["+this.id+"].o()",TreeParams.TIME_DELAY);
	this.ob.isDp=true;
},cS:function(){
	if(this.isC) return;
	if(this.isO){
		this.oE();
	}else{
		this.isO=false;
		this.cur=0;
		this.itc=new Array();
		for(var i=this.all.length-1,n=0;i>0;i--)
			
if(this.all[i].style.display=="block")
this.itc[n++]=this.all[i];
	}
	this.itc[this.itc.length]=this.el;
	this.pat=setInterval("Mns["+this.id+"].c()",TreeParams.TIME_DELAY);
	this.isC=true;
	this.ob.isDp=false;
},o:function(){	
	this.ito[this.cur].style.display="block";
	if(++this.cur==this.ito.length)
this.oE();
},c:function(){
	this.itc[this.cur].style.display="none";
	if(++this.cur>=this.itc.length)
this.cE();
},oE:function(){
	clearInterval(this.pat);
	this.isO=false;
	this.itc=this.ito.reverse();
	this.cur=this.ito.length-this.cur;
	if(!TreeParams.OPEN_MULTIPLE_MENUS&&this.ct.aM!=this)
this.cS();
	this.ct.aM=this;
},cE:function(){
	clearInterval(this.pat);
	this.isC=false;
	if(this.cur>=this.itc.length)this.ob.sdl();
	if(Browser.id.IE6)
setTimeout("repaintFix(document.getElementById('"+this.el.id+"'));",50);
},getC:function(){	
	var p=findAncestorWithClass(this.el,"menu");
	if(p!=null)
return Mns[p.id.replace(/Menu$/,"")];
	if(!this._r){
		var rt=findAncestorWithClass(this.el,"AnimTree");
		if(!rt)
rt=document.body;
		if(!rt.id)
rt.id="AnimTree_"+Math.round(Math.random()*1E5);
		if(Trees[rt.id]!=null)
this._r=Trees[rt.id];
		else
this._r=new Tree(rt);
		return this._r;
	}
}
};

Tree=function(el){
	this.el=el;
	this.aM=null;
	this.id=el.id;
	Trees[this.id]=this;
};
Trees={};

if(document.getElementById&&!Browser.id.OP5&&!window.Tree_inited){
	document.writeln("<style type='text/css'>","\n",".menu,.menuNode{display:none;}\n","","<"+"/style>");
	window.Tree_inited=true;
}