function expandMenus(menuid, autoCollapse) {

	var mm = document.getElementById(menuid);
	if (!mm)
		return;
	clickproc = function (e) {
		var t = (window.event ? window.event.srcElement : (e ? e.target : null));
		t = getAncestor(t,"li");
		if (t && t.getElementsByTagName("ul") && t.getElementsByTagName("ul").length != 0) {
			if (t.className.match(/\bexpand\b/)) {
				if (!autoCollapse || autoCollapse != 'none') {
					morituri = t.getElementsByTagName("li");
					for (var j=0;j<morituri.length;j++) {
						morituri[j].className = morituri[j].className.replace(/\bexpand\b/,"");
					}
				}
				t.className = t.className.replace(/\bexpand\b/,"");
				if (e && e.stopPropagation)
					e.stopPropagation();
				else if (window.event)
					window.event.cancelBubble = true;
			}
			else {
				if (autoCollapse && autoCollapse == 'all') {
					var morituri = t.parentNode.getElementsByTagName("li");
					for (var j=0;j<morituri.length;j++) {
						morituri[j].className = morituri[j].className.replace(/\bexpand\b/,"");
					}
				}
				t.className+=" expand";
				if (e && e.stopPropagation)
					e.stopPropagation();
				else if (window.event)
					window.event.cancelBubble = true;
			}
		}
	}

	addEvent(mm,"click",clickproc,false);
	
	//identify expandable menus
	var lis = mm.getElementsByTagName("li");
	for (var i=0;i<lis.length;i++) {
		var uls=lis[i].getElementsByTagName("ul");
		if (uls && uls.length != 0)
			lis[i].className += " withsub";
	}
}
