Switch between hover and click events, depending on window width
I have made an HTML5 responsive, 2 levels menu you can see HERE The wide screen version shows submenus upon hovering over the main menu items; the narrow screen (less then 800px) version shows submenus upon clicking the main menu items.
The problem is that, if I resize the window, the switch between hover and click events does not happen properly. Of course, I want the menu to react at click on mobile devices...
What shall I change in my script? Or is there an already made solution that I can use?