[accordion] - first click opens, second click follows the link

[accordion] - first click opens, second click follows the link


hello everybody!
I am hoping that accordion plugin for jQuery ( http://plugins.jquery.com/project/accordion
) is discussed here.
Here's my code for UL menu of Joomla menu, which is contained in a
div#sidemenu in my case:
<script type="text/javascript" charset="utf-8">
function accordion_create(c) {
    for (i=1;i<=c;i++) {
        $j('ul.menu'+i).children('li').addClass('menuitem'+i);
        $j('li.menuitem'+i).children('ul').addClass('menu'+(i+1));
        $j('ul.menu'+i).siblings('a').addClass('head'+i);
        $j('.menu'+(i-1)).accordion({
            active: 'a.on',
            header: 'a.head'+i,
            autoheight: false,
            alwaysOpen: false,
            disabled: true,
            event: 'click'
        });
    }
}
$j(document).ready(function() {
        $j('div#sidemenu ul.menu').addClass('menu0');
        $j('ul.menu0').children('li').addClass('menuitem0');
        $j('li.menuitem0').children('ul').addClass('menu1');
        accordion_create(15);
    //    $j('div#menu-ms ul').droppy();
})
</script>
When the event:'click' is set, only the leafs are being followed by
clicking, but no hubs of menu.
Which means, that if a LI element has UL element nested, then clicking
on the LI > A > SPAN expands it and collapses.
I need the first click to expand it (when there's a UL to expand
nested), and the second to follow the LI > A link (instead of
collapsing the UL).
What do I do for the functionality, which works this way?
Changing to event:'mousedown' makes it to follow all the clicks
immidiately, so no animation is seen (since the browser loads the
clicked link).
Where should I seek for the solution?
I guess I should switch some classes, like clicking on A.collapsed
makes it A.expanded and expands, then clicking on A.expanded follows
the HREF link.
Still trying to examine the internals of the scripts, but no success
yet.
Help me, guys, please?