﻿
var topMenu={
    currentItem:null,
    currentSubMenu:null,
    closingTimer:null,
    menuCloseTimeOut:500,
    onItemOver:function(obj)
    {
        this.clearTimer();
        
        if(obj!=this.currentItem)
        {
            this.clearSelection();
            
            this.currentItem=obj;
            this.currentSubMenu=this.currentItem.parentNode.getElementsByTagName("ul")[0]
            
            if(this.currentSubMenu)
            {
                this.currentSubMenu.style.display = "block";

                if (this.currentItem && this.currentItem.className != "current")
                    this.currentItem.className="selected";
            }
        }  
    },
    onItemOut:function()
    {
        this.closingTimer=setTimeout("topMenu.clearSelection()",this.menuCloseTimeOut);
        
    },
    clearSelection:function()
    {
        if (this.currentItem && this.currentItem.className != "current")
            this.currentItem.className="";
            
        if(this.currentSubMenu)
            this.currentSubMenu.style.display="none";
            
        this.currentItem=null;
        this.currentSubMenu=null;
    },
    clearTimer:function()
    {
        clearTimeout(this.closingTimer);
    },
    onMenuOver:function()
    {
        this.clearTimer();
    }
}

