You can actually greatly simplify your Javascript for this. This should achieve your desired effect.
The Javascript here will do the following:
- Add the "mouseover" class when you hover a link
- Remove the "mouseover" class when you no longer hover a link
- When you click a link, it will toggle the "clicked" class and remove it from any other link that may have had the class - this will restore your other tabs to their "normal" state.