There are a few ways to do this, but I think the following is the best way I know. Feel free to change class and id names, of course.
Also, if someone doesn't have JavaScript, do you want them to be shown by default? Here I assume you don't want them to be shown by default.
<style>
.hidden {display: none}
</style>
<div id="navigation">
<ul id="foomenu" class="hidden">
<li>Foo</li>
</ul>
<ul id="barmenu" class="hidden">
<li>Bar</li>
</ul>
</div>
<script>
if (location.pathname=='/foo') {document.getElementById('foomenu').className='' /*removes the hidden class name*/}
else if (location.pathname=='/bar') {document.getElementById('foomenu').className='' /*removes the hidden class name*/}
</script>
I've bolded the important part — the JavaScript conditions you're looking for.