Google and other search engines understand a great deal of JavaScripts these days and the code you displayed search engines will have no trouble understanding it. Most responsive frameworks if not all use a similar method to render the menus, bootstrap, zurb foundation etc on Mobile devices.
If you would like to use a non-js method then you could use a form using options and then rendering the form only on the mobile device using a media query.
Form Example
@media (max-width: 640px) {header form{display:none;}}
@media (min-width: 641px) {header nav{display:none;}}
The benefits of this also would mean that anyone on a mobile device that has disabled JS for one reason or another then the page would still render and be usable, while with the current version you have it will be not-usable for people with no js on touch devices.
NO JS
I've seen many devices these days like tablets and large led screens with touch screen espiecally laptops with Windows 8 so its likely these will become more common so it might be even better to have a no-js rather than just a min-width, like so:
.no-js {header nav{display:none;}
Then of course you just need a JavaScript to remove the no-js from the html when JS is present.
Summary
If maximum compatibly is importance then go with NO-JS. if you believe that user experience and not many people will be disabling JS then go with the CSS/JS solution as thats much easier ;)