/** menus **/

function Menus()
{
}

Menus.activeElement = null;
Menus.srcElement = null;
Menus.hider = null;

Menus.prototype.mouseOver = function(element)
{
    if( (element == Menus.activeElement) || (element == Menus.activeSrc) ) {
	if( Menus.hider != null ) {
	    clearTimeout( Menus.hider );
	    Menus.hider = null;
	}
	return;
    }

    if( Menus.activeElement != null ) {
	if( Menus.hider != null )
	    clearTimeout( Menus.hider );
	Menus.hider = null;
	this.finalCleanup();
    }

    var subId = element.getAttribute( "subid" );
    var child = document.getElementById( "sub_" + subId );

    if( !child ) return;

    var pos = getPageCoords( element );
    var dirc = "right";// element.getAttribute( "subdir" );
    var bg = element.getAttribute( "subback" );

    if( dirc == "left" ) {
	child.style.left = (pos.x - 139) + "px";
	child.style.top = pos.y + "px";
    } else if( dirc == "right" ) {
	child.style.left = (pos.x + 139) + "px";
	child.style.top = pos.y + "px";
    }

    child.style.display = "block";
    child.style.backgroundImage = "url(" + bg + ")";
    Menus.activeElement = child;
    Menus.srcElement = element;
}

Menus.prototype.mouseOut = function(element)
{
    if( Menus.hider != null ) return;
    if( Menus.activeElement == null ) return;

    Menus.hider = setTimeout( this.finalCleanup, 800 );
}

Menus.prototype.finalCleanup = function()
{
    if( Menus.activeElement != null ) Menus.activeElement.style.display = "none";
    Menus.hider = null;
    Menus.srcElement = null;
    Menus.activeElement = null;
}

