Hello,
I have a working javascript menu, similar to a tree menu. If I click on a
submenu, the page refreshes and shows content related to the link i clicked.
Now, what i need is for that submenu whose link i clicked to stay open and
all other submenus to close. This should happen only when i click on a link
of a submenu otherwise any submenu opened before can stay open. How do i
do that? I think the function has to be in an onclick event of individual
links of the submenus, right?

(title and submenu is defined in a css file as classes)

.js code:
_____________
// The main script for toggling the selected menu
// Input variables:
// n = the number of the submenu to show/hide
// move = the number of pixels for moving the objects below

function toggle(n,move) {
menu = ('submenu' + n);
if (document.layers) {
submenu = document.layers[menu];
}
else if (document.all) {
submenu = document.all(menu).style;
}
if (submenu.visibility == visible) {
submenu.visibility = hidden;
picclose(n);
for (var i = (n+1); i <= nom; i++) {
if (document.layers) {
document.layers[tits[i]].top -= move;
document.layers[subs[i]].top -= move;
}
else if (document.all) {
document.all(tits[i]).style.pixelTop -= move;
document.all(subs[i]).style.pixelTop -= move;
}
}
}
else {
submenu.visibility = visible;
picopen(n);
for (var i = (n+1); i <= nom; i++) {
if (document.layers) {
document.layers[tits[i]].top += move;
document.layers[subs[i]].top += move;
}
if (document.all) {
document.all(tits[i]).style.pixelTop += move;
document.all(subs[i]).style.pixelTop += move;
}
}
}
}


document.write( '<div class="title" id="title2" style="top: 160px">' );
document.write( '<a href="#" onclick="javascript: toggle(2,60); return false"><img
name="pic2" src="images/closed.gif" border="0" hspace="2">Papalim </a>' );

document.write( '</div>' );

document.write( '<div class="submenu" id="submenu2" style="top: 180px" onclick="javascript:
showMenu(this);">' );
document.write( '<a href="SampleTree.html">Papa 2</a><br>' );
document.write( '<a href="SampleTree.html">Papa 3</a><br>' );
document.write( '</div>' );

Thank you,
sks