MenuNode=function(name,parentName,menu,onclick){
	this.name=name;
	this.menu=menu;
	this.parentName=parentName;
	this.parent=this.menu.menuNodes[parentName];
	this.htmlNode=document.getElementById(name);
	this.childs=new Array();

	this.append=function(menuNode){
		this.childs[this.childs.length]=menuNode;
	}

	/* add properties and methods to generic html-nodes */
	if(!this.htmlNode.classNames){
		this.htmlNode.classNames=this.htmlNode.className.split(' ');
	}
	this.htmlNode.menuNode=this;
	this.htmlNode.addClassName=function(className){
		this.classNames[this.classNames.length]=className;
		this.className=this.classNames.join(' ');
	}
	this.htmlNode.deleteClassName=function(className){
		var cns=new Array();
		for(var i=0;i<this.classNames.length;i++){
			if(this.classNames[i]!=className){
				cns[cns.length]=this.classNames[i];
			}
		}
		this.classNames=cns;
		this.className=this.classNames.join(' ');
	}
	this.htmlNode.onmouseover=function(){
		this.menuNode.menu.clearClose();
		this.menuNode.mark();
		this.menuNode.showChilds();
		this.menuNode.menu.hideNodesByTagName('IFRAME');
	}
	this.htmlNode.onmouseout=function(){
		this.menuNode.menu.initClose();
		this.menuNode.demark();
		this.menuNode.clear();
	}

	this.show=function(){
		this.htmlNode.deleteClassName('hide');
		this.htmlNode.parentNode.style.display='block';
		this.htmlNode.addClassName('show');
		this.parent.show();
		this.shown=true;
	}
	this.showChilds=function(){
		for(var i=0;i<this.childs.length;i++){
			var child=this.childs[i];
			if(!child.shown){
				child.show();
			}
		}
		if(!this.shown){
			this.parent.showChilds();
		}
		this.hideSistersChilds();
	}
	this.hide=function(){
		this.htmlNode.addClassName('hide');
		this.htmlNode.parentNode.style.display='none';
		this.htmlNode.deleteClassName('show');
		this.shown=false;
	}
	this.hideChilds=function(except){
		for(var i=0;i<this.childs.length;i++){
			var child=this.childs[i];
			if(child.shown && child!=except){
				child.hide();
				child.hideChilds();
			}
		}
	}
	this.hideSistersChilds=function(){
		for(var i=0;i<this.parent.childs.length;i++){
			menuNode=this.parent.childs[i];
			if(menuNode!=this){
				menuNode.hideChilds();
			}
		}
	}
	this.mark=function(){
		if(!this.marked){
			this.htmlNode.addClassName('mark');
			this.marked=true;
		}
		this.parent.mark();
	}
	this.demark=function(){
		if(this.marked){
			this.htmlNode.deleteClassName('mark');
			this.marked=false;
		}
	}
	this.warn=function(){
		for(var i=0;i<this.childs.length;i++){
			child=this.childs[i];
			child.htmlNode.addClassName('warn');
		}
		this.warned=true;
	}
	this.clear=function(){
		for(var i=0;i<this.childs.length;i++){
			child=this.childs[i];
			child.htmlNode.deleteClassName('warn');
		}
		this.warned=false;
	}
	this.htmlNode.onclick=function(e){
		if(!e){e=window.event;}
		this.menuNode.warn();
		e.cancelBubble=true;
	}
}
menus=new Array()
Menu=function(name){
	this.name=name;
	menus[name]=this;
	this.childs=new Array();
	this.delay=1000;
	this.menuNodes=new Array();
	this.showChilds=function(){};
	this.hideSisterChilds=function(){};
	this.show=function(){};
	this.mark=function(){}
	this.menuNodes[name]=this;
	this.nodesByTagName=new Array();
	this.append=function(menuNode){
		this.childs[this.childs.length]=menuNode;
		menuNode.show();
	}
	/* public method add */
	this.add=function(name,parentName,onClick){
		var temp=new MenuNode(name,parentName,this,onClick);
		this.menuNodes[name]=temp;
		temp.hide();
		this.menuNodes[parentName].append(temp);
	}
	this.initClose=function(){
		window.clearTimeout(this.timeout);
		this.timeout=window.setTimeout('menus["'+this.name+'"].close()',this.delay);
	}
	this.clearClose=function(){
		window.clearTimeout(this.timeout);
	}
	this.close=function(){
		temp='';
		for(menuNodeName in this.menuNodes){
			menuNode=this.menuNodes[menuNodeName];
			if(menuNode.shown && menuNode.parent!=this){
				menuNode.hide();
			}
			if(menuNode.marked){
				menuNode.demark();
			}
		}
		this.showNodesByTagName('IFRAME');
	}
	this.setCurrentItem=function(name){
		menuNode=this.menuNodes[name];
		if(menuNode){
			while(menuNode!=this){
				menuNode.htmlNode.addClassName('current');
				menuNode=menuNode.parent;
			}
		}
	}
	this.hideNodesByTagName=function(tagname){
		if(!this.nodesByTagName[tagname]){
			this.nodesByTagName[tagname]=document.getElementsByTagName(tagname);
		}
		nodes=this.nodesByTagName[tagname];
		for(var i=0;i<nodes.length;i++){
			nodes[i].style.display='none';
		}
	}
	this.showNodesByTagName=function(tagname){
		if(!this.nodesByTagName[tagname]){
			this.nodesByTagName[tagname]=document.getElementsByTagName(tagname);
		}
		nodes=this.nodesByTagName[tagname];
		for(var i=0;i<nodes.length;i++){
			nodes[i].style.display='block';
		}
	}
}