function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node === null )
		node = document;
	if ( tag === null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}


var menu;
var hover;
var dtnode;
var timer;
var dd;
function hoverOut()
{
	if(window.hover==false)
	{
		ddnodes = menu.getElementsByTagName("DD");
		for(k=0; k<ddnodes.length; k++)
		{
			ddnodes[k].style.visibility = "hidden";
			window.hover=false;
		}
	}
	else{ setTimeout("hoverOut()",750);}
}
function menuVisibility()
{
	if(!document.getElementById) {exit;}
	// Grab menu root
	menu = document.getElementById("menu");
	// Get main menu items (DT)
	var dt = menu.getElementsByTagName("DT");
	for (i=0; i<dt.length; i++)
	{
		dtnode = dt[i];
		dtnode.onmouseover = function()
		{	
			window.hover = false; hoverOut();
			window.hover = true;
			dd = getElementsByClass(this.id,menu,"DD");
			for(j=0; j<dd.length; j++)
			{
				if(dd[j].className==this.id)
				{
					// Horizontal positioning
					dd[j].style.left = this.offsetLeft - Math.abs(this.offsetWidth- dd[j].offsetWidth) + "px";
					// Vertical positioning
					if(j==0)
					{
						posY = this.offsetTop + this.offsetHeight + 6;
					}
					else
					{
						posY = dd[j-1].offsetTop + dd[j-1].offsetHeight ;
					}
					dd[j].style.top = posY + "px";
						
					dd[j].style.visibility = "visible";
					dd[j].onmouseover = function(){ 
						this.style.backgroundColor = "#89A2B3";
						window.hover = true;
						};
					dd[j].onmouseout = function(){
						this.style.backgroundColor = "#4d1979";
						window.hover = false;
						};
				}
			}
			this.onmouseout = function(){hoverOut()};
		};
	}
}


