hover slide problem

hover slide problem

Hello,

I've got an very annoying problem with my navbar. When the visitor moves his cursor over a button, a submenu should appear with a slideDown-Effect and moving the mouse out of the button should have a slideToggle-Effect.
Unfortunately, many times when moving my mouse on the button, it slides down, slides up, slides down etc. 
And stops randomly when being sliden down.

Code:

  1. <script>
  2. $(document).ready(function(){
  3. $("#main1").hover(function() {
  4. $("#sub1").slideDown(400);
  5. }, function() {
  6. $("#sub1").slideUp(400);
  7. });
  8. });
  9. </script>
Has anybody had the same problem? Or has a solution for it?

Hope it's understundable enough - otherwise: don't hesitate to ask.