I have a java script colapsible menu. I am looking to figure out how to keep the section of the menu open when a user clicks on a link.

Here is the javascript:

var _id = 'sub-nav';
var _innerEl = 'ul';
var _className = 'active';
var _hide = true;

var _menu;
var _nodes;
function initMenu() {
_menu = document.getElementById(_id);
if (_menu){
_nodes = _menu.getElementsByTagName('a');
for (var i=0; i<_nodes.length; i++) {
if (_nodes[i].parentNode.getElementsByTagName(_innerEl)[0]) {
_nodes[i].onclick = function () {
if(this.parentNode.className.indexOf(_className) !=-1) {
this.parentNode.className = this.parentNode.className.replace(_className, "");
} else {
if (_hide) hideLevels(this);
this.parentNode.className += ' '+_className;
}
return false;
}
}
}
}
}
function hideLevels(_this){
var _lis = _menu.getElementsByTagName('li');
for (var i=0; i<_lis.length; i++) {
var _f = false;
var _a = _lis[i].getElementsByTagName('a');
for (var j=0; j<_a.length; j++) {
if (_a[j] == _this) _f = true;
}
if (!_f) _lis[i].className = _lis[i].className.replace(_className, "");
}
}

if (window.addEventListener){
window.addEventListener("load", initMenu, false);
}
else if (window.attachEvent){
window.attachEvent("onload", initMenu);
}

This just uses <UL> and <LI>'s on the page to work.

Thanks in advance.