Question: I'm getting crazy with my javascript menu. The website is [DDay.it](http://www.dday.it) and the menu is a javascript pull down with ajax loading. I'm trying to fight an issue that is quite annoying: if the mouse is on the menu (accidentaly) when the page is loading, the behaviour of the menu is inverted: normal state open, hover state closed.

You can try live on the website using Chrome.

I want to solve it by myself (I'm a rails developer but I'm learning js) , but I cannot figure why the behaviour change on page loading if js are loaded and executed at the end of the page...

Added the code: here is the [gist](https://gist.github.com/robypez/4f4630509480baca40c1)

Answer: 
The faulty code is in line 232:
`$navContainer.addClass('animating').toggleClass('open');`

It belongs to the function `animateMenuToggle` which should receive a status parameter (can be passed by the function `toogleMenu`).

Then, you can use the status parameter to do something like:
`$navContainer.addClass('animating').removeClass('open close').addClass(status);`
The thing is, I guess, you do not get the event of the `mouseenter` on the navigation while loading.

Then on `mouseleave` you get the event and turning all around.

You have dependencies on `.hasClass('animating')` which could flip it.

I greatly suppose to make a switch either on `.hasClass()` or on `status == open/close`.