window.onload = registerMenuShows;

function registerMenuShows()
{
	var menuitems = getElementsByClassName(document, 'div', 'outercontainer');
    for(var i=0; i<menuitems.length; i++)
	{
		menuitems[i].onmouseover = overMenu;
		menuitems[i].onmouseout = outMenu;
	}
}

function overMenu()
{
	if (this.childNodes[1] != null)
	{
		var children = this.childNodes[1].childNodes;
		for(var i=0; i<children.length; i++)
		{
			// if child's classname includes 'outercontainer'
			var oRegExp = new RegExp("(^|\\s)outercontainer(\\s|$)");
			if(oRegExp.test(children[i].className))
			{
				clearTimeout(children[i].hide_timer);
				children[i].show_timer = setTimeout("showItem('" + children[i].id + "');", 200);
			}
		}
	}
}

function showItem(itemid)
{
	getElement(itemid).style.display = 'block';
}
function hideItem(itemid)
{
	getElement(itemid).style.display = 'none';
}

function outMenu()
{
	if (this.childNodes[1] != null)
	{
		var children = this.childNodes[1].childNodes;
		for(var i=0; i<children.length; i++)
		{
			// if child's classname includes 'hide'
			var oRegExp = new RegExp("(^|\\s)hide(\\s|$)");
			if(oRegExp.test(children[i].className))
			{
				clearTimeout(children[i].show_timer);
				children[i].hide_timer = setTimeout("hideItem('" + children[i].id + "');", 200);
			}
		}
	}
}

function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}

function getElement(itemid) {
	var theElement;
	if (document.all) {
		eval("theElement = document.all."+itemid+";");
	}
	else {
		if (navigator.userAgent.indexOf("Gecko")!=-1) {// is NS6 ?
			theElement = document.getElementById(itemid);
		}
		else {
			eval("theElement = document.layers['"+itemid+"'];");
		}
	}
	return theElement;
}