var menuTimer = null;

function getRootMenuId(rootMenu)
{
        return $(rootMenu).attr('id').match('[0-9]+$');
}
function clearMenuTimer()
{
        if(null != menuTimer)
                clearTimeout(menuTimer);
}
function hideMenuTimer(childMenu, time)
{
        clearMenuTimer();
        menuTimer = setTimeout(function() {
                $(childMenu).css('display', 'none');
        }, time);
}
function showChildMenu(childMenu)
{
        clearMenuTimer();
        $('#childs-menu-items div').css('display','none');
        $(childMenu).css('display', 'block');
}
function hideChildMenu(childMenu)
{
        hideMenuTimer(childMenu, 50);
}
$(document).ready(function() {

        $("table.menu a").mouseover(function() {
                showChildMenu($('.menu' + getRootMenuId(this)));
        })
        .mouseout(function() {
                hideChildMenu($('.menu' + getRootMenuId(this)));
        });
        $("#childs-menu-items div").mouseover(function() {
                showChildMenu(this);
        })
        .mouseout(function() {
                hideChildMenu(this);
        });
});