Hi,
first - what you have there has absolutely _nothing_ to do with java. it's javascript, which is a script language invented by netscape. java on the other hand is a programming language created by sun microsystems. java code needs to be compiled to be run, javascript code doesn't. so don't mix them up, please :)
then - I think you need to change the template (monobook.php) and add a line like the following inside the <head>-tags:
<script language="text/javascript" href="showHide.js"></script>
and now you need to add your links as HTML, not wikitext (because you need additional attributes, which aren't possible with wikitext). just take them from the html you already have (tags <li>, <span>, etc).
HTH chris
PS: you don't need the first three lines of showHide.js - they do absolutely nothing in this case (those starting with "var" declare new variables - but they are never used).