

var offsetLeft = 178;
var timeout = 300;
var timer = {};
function mouseout(id) {
    if( timer[id] ) clearTimeout( timer[id] );
    timer[id] = setTimeout("hideMenu('"+id+"')", timeout);
};
function hideMenu(id) {
    var menu = $("#" + id + "_menu");
    if( menu.length > 0 ) {
        menu.hide();
    }
    if( menu.is(".mode_home") ) {
        $("#" + id).css('background-image','url(/system/modules/ch.corner.card.frontend/resources/img/bgd_boxentrance_bottom.gif)');
        $("#" + id).children("a").css('color', '#000000');
        $("#" + id).children("a").css('text-decoration', 'none');
    }
    timer[id] = null;
};
$(document).ready(function() {
    $('.menu_launcher').mouseover(function(){
        var id = $(this).attr('id');
        if( timer[id] ) clearTimeout( timer[id] );
        var menu = $("#" + id + "_menu:hidden");
        if( menu.is(".mode_home") ) {
            $(this).css('background-image','url(/system/modules/ch.corner.card.frontend/resources/img/bgd_boxentrance_bottom_hover.gif)');
            $(this).children("a").css('color', '#fff');
            $(this).children("a").css('text-decoration', 'underline');
            var os = $(this).offset()
            menu.css("left", $(this).offset().left + offsetLeft);
            menu.show();
            menu.css("top", $(this).offset().top - menu.height() );
        }
        if( menu.is(".mode_navigation") ) {
            menu.css("left", $(this).offset().left + $(this).width() - 6);
            menu.css("top", $(this).offset().top - 7);
            menu.show();
        }
        return false;
    });
    $('.menu_launcher').mouseout(function(){
        mouseout($(this).attr("id"));
    });
    $('.dynamicmenu').mouseover(function(){
        var id = $(this).attr("id").split("_")[0];
        if( timer[id] ) clearTimeout( timer[id] );
        return false;
    });
    $('.dynamicmenu').mouseout(function(){
        mouseout($(this).attr("id").split("_")[0]);
    });
});