var Timer;
function showMenu(LinkAnchor){
	var bName = navigator.appName;
	var bVer = navigator.appVersion;
	if (bName == "Microsoft Internet Explorer"){
		newY=47;
		newX=0;
	}else{
		newY=36;
		newX=5;
	}
	
	
    var mainULList = document.getElementById("menuTop").getElementsByTagName("ul");
        for (k=0;k< mainULList.length;k++) {
            mainULList[k].style.display="none";
        }

    var linkMainParent = LinkAnchor.parentNode.parentNode.parentNode;
	var curleft = curtop = 0;
	if (LinkAnchor.offsetParent) {
		curleft = LinkAnchor.offsetLeft
		curtop = LinkAnchor.offsetTop
		while (LinkAnchor = LinkAnchor.offsetParent) {
			curleft += LinkAnchor.offsetLeft
			curtop += LinkAnchor.offsetTop
		}
	}

    var menuList = linkMainParent.getElementsByTagName("ul");
	for (j=0;j< menuList.length;j++) {
		var count = 0;
        var menu = menuList[j];
	    menu.style.top=curtop+newY;
	    menu.style.left=curleft-newX;
		if (menu.innerHTML != ""){
	    	menu.style.display="block";
		}
		var menuWidth=menu.offsetWidth;
		window.clearTimeout(Timer);

	    menuLinks = menu.getElementsByTagName("a");
	    for (i=0;i< menuLinks.length;i++) {
		    menuLinks[i].onmouseover = function(){stopTimer();};
		    menuLinks[i].onmouseout = function(){closeMenu(menu.id);};
			if(menuLinks[i].style.width==''){
				menuLinks[i].style.width=menuWidth+"px";
			}
	    }
	}
}

//Stops timer
function stopTimer(){
	window.clearTimeout(Timer);
}

function closeMenu(menu){
	i=25;
	startCount(i);
}

function startCount(i){
	if(i>0)
	{
		i-=1;
		Timer=window.setTimeout("startCount("+i+");", 1);
	}else{
		hideIt();
	}
}

function hideIt(){
    var menuList = getElementsByClassName (document, "li", "topMenuItem");
	for (i=0;i< menuList.length;i++) {
        var subMenuList = menuList[i].getElementsByTagName("ul");
        for (j=0;j< subMenuList.length;j++) {
            subMenuList[j].style.display="none";
        }
	}
}

function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.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)
}
