var Menu = new Object();

Menu.timer = null;
Menu.currentId = null;

Menu.showMenu = function(id) {
    if(this.currentId != null && this.currentId != id) {
        this.hideMenu(this.currentId);
    }
    $("#"+id+" ul.sub").slideDown("fast");
    this.currentId = id;
    this.holdMenu();
}

Menu.hideMenu = function(id) {
    $("#"+id+" ul.sub").slideUp("fast");
}

Menu.leaveMenu = function() {
    this.timer = window.setTimeout("Menu.hideMenu('"+this.currentId+"')",500);
}

Menu.holdMenu =  function() {
    if(this.timer != null) {
        window.clearTimeout(this.timer);
    }
    this.timer = null;
}    

Menu.initMainItem = function(id) {

    $("#"+id+" > a").mouseover(function(){
        Menu.showMenu(id);
    }).mouseout(function(){
        Menu.leaveMenu();
    });
    
    this.initSubItems(id);
}

Menu.initSubItems = function(id) {

    $("#"+id+" .sub > li > a").mouseover(function(){
        Menu.holdMenu();
    }).mouseout(function(){
        Menu.leaveMenu();
    });
}