/** menus **/

function Menus()
{
}

Menus.activeElement = null;
Menus.srcElement = null;
Menus.hider = null;
Menus.popColor = "";
Menus.popColor2 = "";

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 );

 
    child.style.left = pos.x + "px";
    child.style.top = (pos.y + 108) + "px";
    child.style.display = "block";
    Menus.popColor = element.style.backgroundColor;
    Menus.popColor2 = element.style.color;
    element.style.backgroundColor="#00004d";
    element.style.color="#ffffff";
    Menus.activeElement = child;
    Menus.srcElement = element;
  
    if( (pos.x + child.offsetWidth) > (element.offsetParent.offsetWidth) ) {
	var newx = pos.x - ((pos.x + child.offsetWidth) - (element.offsetParent.offsetWidth));
	child.style.left = newx + "px";
    }
}

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";
    if( Menus.srcElement != null ) {
	Menus.srcElement.style.backgroundColor = Menus.popColor;
	Menus.srcElement.style.color = Menus.popColor2;
    }
    Menus.hider = null;
    Menus.srcElement = null;
    Menus.activeElement = null;
}
