activesubmenuhover = function() 
{
	var menuSelector = getElementsByClass("moredropdownmenu", document, "li");

	if ( (null != menuSelector) && (menuSelector.length > 0) )
    {
        //alert(menuSelector + '\n' + menuSelector.length);
        
        for (i = 0; i < menuSelector.length; i++) 
        {
            // Attach New Event
            menuSelector[i].onmouseover = function() {
                this.className = this.className + " activemenu";
            }
            
            var children = menuSelector[i].getElementsByTagName( "a" );
            children[0].onclick = function() {
                this.blur();
                return false;
            }
            
            // Attach New Event
            var menu = menuSelector[i].getElementsByTagName( "ul");
            menu[0].onmouseout = function() 
            {
                this.parentNode.className = this.parentNode.className.substring( 0, this.parentNode.className.indexOf(" activemenu","") );
            }
            
            // Attach New Event
            
            for (x = 0; x < menuSelector[i].childNodes.length; x++) 
            {
                if (menuSelector[i].childNodes[x].tagName == "UL")
                {
                    //This next line keeps the list lined up correctly on the right side.
							//170 should be changed to equal the difference between the a.width and the ul.width.
							//162 should be changed to equal the difference between the a.width and the ul.width + 8 (??? safari).
							//250 should be changed to equal the ul.width.
                    var _leftPosition = getElementLeft( menuSelector[i].childNodes[x] );
                    
                    //alert(_leftPosition);
						  if ( _ff ) {
                    	menuSelector[i].childNodes[x].style.left = (( _leftPosition ) - 100 ) + 'px';
                    } else if ( _safari ) {
                    	menuSelector[i].childNodes[x].style.left = (( _leftPosition ) - 100 ) + 'px';
                    } else {
                    	menuSelector[i].childNodes[x].style.left = (( _leftPosition ) - 180 ) + 'px';

                    }
                
                }
            }
            
        } //for
    } //if
} //function

function getElementLeft(elem) {
        xPos = elem.offsetLeft;
        tempEl = elem.offsetParent;
        while (tempEl != null) {
                xPos += tempEl.offsetLeft;
                tempEl = tempEl.offsetParent;
        }
        xPos -= elem.parentNode.scrollLeft;
        return xPos;
}

// initialization hook up

// DOM2
if ( typeof window.addEventListener != "undefined" )
	window.addEventListener( "load", activesubmenuhover, false );

// IE 
else if ( typeof window.attachEvent != "undefined" ) {
	window.attachEvent( "onload", activesubmenuhover );
}

else {
	if ( window.onload != null ) {
		var oldOnload = window.onload;
		window.onload = function ( e ) {
			oldOnload( e );
			activesubmenuhover();
		};
	}
	else 
		window.onload = activesubmenuhover;
}

