// -----------------------------------------------------------------------------------
// Description: hybridMenu functions written by Johan Janssens http://www.jinx.be
// version 1.4.1 - 22/05/2005
// Copyright 2004 - 2005 Johan Janssens, All rights reserved. 
// This script may not be used or distributed without license
// ----------------------------------------------------------------------------------- 

Browser=new Object();
Browser.agt=navigator.userAgent.toLowerCase();
Browser.is_ie=((Browser.agt.indexOf("msie")!=-1)&&(Browser.agt.indexOf("opera")==-1));
hybridMenuBar.Registry=[];
hybridMenuBar.hideDelay=350;
function hybridMenuBar(id){
	this.dom=document.getElementById?1:0;
	if(this.dom&&id){
		this.gRef="hybridMenuBar_"+id;
		eval(this.gRef+"=this");
		this.id=id;
		this.menus=[];
		var kill=document.getElementById('hoverJS');
		kill.disabled=true;
		hybridMenuBar.Registry[id]=this;
		this.createBar()
	}
}

hybridMenuBar.prototype.createBar=function(){
	var root=document.getElementById(this.id);
	if(!root) {
		window.setTimeout(this.gRef+".createBar()",100);
	} else {
		for(i=0;i<root.childNodes.length;i++){
			if(root.childNodes[i].nodeName=="LI") this.addMenu(root.childNodes[i],i)
		}
	}
};


hybridMenuBar.prototype.addMenu=function(node,id){
	if(node.getElementsByTagName('UL').length){
		this.menus[id]=new hybridMenu(node,id,this.id)
	}
};

hybridMenuBar.prototype.getMenus=function() {
	return this.menus
};

function hybridMenu(node,id,parent){
	this.dom=document.getElementById?1:0;
	if(this.dom&&node){
		this.node=false;
		this.id=id;
		this.parent=parent;
		this.hideTimer=false;
		this.over=false;
		this.open=false;
		this.initHybridMenu(node)
	}
}

hybridMenu.prototype.initHybridMenu=function(node){
	node.onmouseover=new Function("show('"+this.id+"','"+this.parent+"')");
	node.onmouseout=new Function("hide('"+this.id+"','"+this.parent+"', "+false+")");
	for(j=0;j<node.childNodes.length;j++){
		if(node.childNodes[j].nodeName=="UL"){
			this.node=node.childNodes[j];
			this.node.onmouseover=new Function("show('"+this.id+"','"+this.parent+"')");
			this.node.onmouseout=new Function("hide('"+this.id+"','"+this.parent+"', "+false+")")
		}
	}
	var width=this.node.offsetWidth;
	for(j=0;j<this.node.childNodes.length;j++){
	var node=this.node.childNodes[j];
	if(node.nodeName=="LI")width=(width>=node.offsetWidth)?width:node.offsetWidth}
	for(j=0;j<this.node.childNodes.length;j++){
		var node=this.node.childNodes[j];
		if(node.nodeName=="LI"){
			if(!Browser.is_ie){	
				this.node.style.width=width+"px" 
			} else {
				node.firstChild.style.width=width+"px"
			}
		}
	}
};

hybridMenu.prototype.show=function(){
	this.open=true;
	this.setVisibility(true)
};

hybridMenu.prototype.hide=function(){
	if(this.hideTimer)window.clearTimeout(this.hideTimer);
	this.open=false;
	this.hideTimer=0;
	this.setVisibility(false)
};

hybridMenu.prototype.setVisibility=function(bShow){
	this.node.style.visibility=bShow?"visible":"hidden"
};

show=function(id,parent){
	var menus=(hybridMenuBar.Registry[parent]).getMenus();
	var menu=menus[id];
	menu.over=true;
	for(itemid in menus){
		var item=menus[itemid];
		if((item.open!=false)&&(item!=menu))item.hide()
	}
	if(menu.hideTimer){
		menu.hideTimer=window.clearTimeout(menu.hideTimer)
	}
	if(!menu.open)menu.show()
};

hide=function(id,parent,delayed){
	var menus=(hybridMenuBar.Registry[parent]).getMenus();
	var menu=menus[id];
	menu.over=false;
	if(!delayed){
		if(menu.hideTimer)window.clearTimeout(menu.hideTimer);
		menu.hideTimer=window.setTimeout("hide('"+id+"','"+parent+"', '"+true+"')",hybridMenuBar.hideDelay)
	}
	if(delayed)menu.hide()
};
