
$.extend({
    cssmenu: function(menuid) {
        var $mainmenu = $("#" + menuid);
        var $headers = $mainmenu.find("table").parent();

        var that = this; // keep a reference to the instance

        $headers.each(function(i) {
            var $curobj = $(this);
            var $menuItems = $(this).find('table');

            $curobj.bind('mouseenter', function(e) {
                var $target = $(this).children("table");
                if ($target.find("tr").length > 1)
                    $target.css({ left: 15, top: $target.parent().attr('offsetHeight') + "px" }).fadeIn('fast');
            }).bind('mouseleave', function(e) {
                $(this).children("table").fadeOut('slow');
            });


            $curobj.find('td').hover(
                    function() {
                        $(this).css('background-color', '#ccc');
                        $(this).find('a').css('color', 'white');
                    },
                    function() {
                        $(this).css('background-color', 'white');
                        $(this).find('a').css('color', 'black');
                    });
        }); //end $headers.each()

    }
});
