Hi,
I understand what you are trying to acheive, but its not the best or easiest way of doing it (using js is 'old' method) CSS makes it alot easier if you take 5 mins to grasp.

Here is something I found to give you an idea. It doesn't actualy demonstrate how to change the state of the menu item when clicked but its easy to show a different state on a page if required:

http://superfluousbanter.org/archives/2004/05/navigation_matr.php

post back if this does not help, I have an example myself I can make available to you and save lots of headaches...