/** menus **/

function Menus()
{
}

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

Menus.prototype.mouseOver = function(element, isVet)
{
    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 );

    if( !isVet ) {
	    child.style.left = pos.x + "px";
	    child.style.top = (pos.y + 33) + "px";
	    child.style.display = "block";
	    
	    element.style.background = "url(/layout/mhbg.jpg) repeat";
	} else {
	    child.style.left = (pos.x + 1) + "px";
	    child.style.top = (pos.y + 28) + "px";
	    child.style.display = "block";

		element.style.backgroundColor = "#64acff";
	}
    
    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";
    if( Menus.srcElement != null ) {
		Menus.srcElement.style.background = "";
    }
    
    Menus.hider = null;
    Menus.srcElement = null;
    Menus.activeElement = null;
}
