toogle menu

toogle menu

Hi,
i´m using this basic script von the Jquery-site:
$(document).ready(function() {
var toggle = function(direction, display) {
return function() {
var self = this;
var ul = $("ul", this);
if( ul.css("display") == display && !self["block" + direction] ) {
self["block" + direction] = true;
ul["slide" + direction]("slow", function() {
self["block" + direction] = false;
});
}
};
}
$("li.menu").hover(toggle("Down", "none"), toggle("Up", "block"));
$("li.menu ul").hide();
});

So far it works fine. I would like to enhance it. If you click on a link
the submenu should be revealed,
also if you click on a submenu-item it should stay revealed.
How could i achieve this. Thanks for your help.