Little java script for a menu

Have trouble finding a missing piece of the script for a simple menu. The menu is : menu tree - click to open, click to close category. Categories and sub cat are in unordered list, placed in a <div>. Have the following script for the click-function:… The prob is, once i’ve clicked on the subcategory, the menu folds. Want it simply to keep open until another main category is pressed. I’m really not into java, so every little help is appreciated.
The js i’ve found for now:
clickMenu = function(menu) {
var getEls = document.getElementById(menu).getElementsByTagName(“LI”);
var getAgn = getEls;

for (var i=0; i&lt;getEls.length; i++) {
        getEls*.onclick=function() {
            for (var x=0; x&lt;getAgn.length; x++) {
            getAgn[x].className=getAgn[x].className.replace("unclick", "");
            getAgn[x].className=getAgn[x].className.replace("click", "unclick");
            }
        if ((this.className.indexOf('unclick'))!=-1) {
            this.className=this.className.replace("unclick", "");;
            }
            else {
            this.className+=" click";
            }
        }
        getEls*.onmouseover=function() {
            this.className+=" hover";
        }
        getEls*.onmouseout=function() {
            this.className=this.className.replace("hover", "");
        }
    }
}