//function show_layer(objid){ document.getElementById('sub_cat_' + objid).style.display = "block"; }
//function hide_layer(objid) { document.getElementById('sub_cat_' + objid).style.display = "none"; }

(function ($) {

    $(document).ready(function () {

        var timeouts = {};

        $('#top_cat a').bind('mouseenter', function () {
            var rel = $(this).attr("rel");
            var subMenuID = '#sub_' + $(this).attr('id');

            if ($(subMenuID).length > 0 && $(subMenuID).children().length > 0) {
                if (timeouts[rel]) clearTimeout(timeouts[rel]);
                timeouts[rel] = setTimeout(function () { $(subMenuID).fadeIn("fast") }, 300);
            }
        }).bind('mouseleave', function () {
            var rel = $(this).attr("rel");
            var subMenuID = '#sub_' + $(this).attr('id');

            if ($(subMenuID).length > 0) {
                if (timeouts[rel]) clearTimeout(timeouts[rel]);
                $(subMenuID).hide();
            }
        });

        $('.sub_cat_layer').bind('mouseenter', function () {
            $(this).show();
        }).bind('mouseleave', function () {
            $(this).hide();
        });

    });

})(jQuery);
