Please consider placing different versions of your menu in separate files with a loader.js to load the appropriate file.
For example, MenuDOM.js for DOM compatible browsers, MenuNS4.js etc. This will increase the speed of the program and simplify debugging and testing.
God bless you!
Dieter