I located a javascript (by sandeep over the internet and tried to modify to suite my need but unfortunately i need help. Right now the script does not collapse when there is no sub-menu link. For example.. main-menu without submenu main-menulink1 -submenu-link1 -submenu-link2 main-menulink2 -submenu-link1 -submenu-link2 All collapsed when open..then user click on main-menulink1 it opens the submenu and if the user click on main-menulink2 the main-menulink1 will collapse. But, when the user click on main-menu without submenu the main-menulink2 will not collapse. I WANT ANY main-menulink THAT OPEN TO BE COLLAPSED WHEN THE USER CLICK ON main-menu without submenu. I TRIED THIS BUT NOT WORKING<div onClick="openClose('MN',mainNum,'a3')" class="main"> <a href="main-manu without_sublink.html">main-manu without sublink</a></div> <div onClick="openClose('MN',mainNum,'a1')" class="main"> <span class="mainLink">main-menulink1 <span id="tick_a1">+</span></span></div> <div id="a1" class="sublinks1"> <a href="sublink1.html" class="link">sublink1.html</a><br /> <a href="sublink2.html" class="link">sublink2.html</a><br /> <div onClick="openClose('MN',mainNum,'a2')" class="main"> <span class="mainLink">main-menulink2 <span id="tick_a2">+</span></span></div> <div id="a2" class="sublinks1"> <a href="sublink1.html" class="link">sublink1.html</a><br /> <a href="sublink2.html" class="link">sublink2.html</a><br /> if (document.getElementById) { document.writeln('<style type="text/css">') document.writeln('.main {text-decoration:none; color:black; cursor:hand; cursorointer}') document.writeln('span:hover.mainLink {text-decoration:underline; color:red}') document.writeln('.sublinks1 {display:none; padding-left:14px}') document.writeln('.link2 {text-decoration:none; color:blue}') document.writeln('a:hover.link2 {text-decoration:underline; color:red}') document.writeln('</style>') } // Below you should add a1, a2 etc. for each main link you wish to include // so if you want 3 main links you should add a1, a2, a3 in the format shown // enclosed in double quotes var mainNum = new Array("a1","a2","a3","a4","a5"); // Below you should add b1, b2 etc. for each sub link you wish to include // under one main link, here the first main link. so if you want 4 sub links you // should add b1, b2, b3, b4 in the format shown enclosed in double quotes var subNum1 = new Array("b1","b2","b3","b4","b5","b6","b7","b8","b9"); // Below, this is for sub links under the second main link. there are 3 sub links // in the given example var subNum2 = new Array("c1","c2","c3","c4","c5","c6"); function openClose(theName, menuArray, theID) { for(var i=0; i < menuArray.length; i++) { if (menuArray == theID) { if (document.getElementById(theID).style.display == "block") { document.getElementById(theID).style.display = "none"; document.getElementById("tick_"+menuArray).innerHTML = "+"; eraseCookie(theName); } else { document.getElementById(theID).style.display = "block"; document.getElementById("tick_"+menuArray).innerHTML = "-"; newCookie(theName,menuArray,exp); } } else { document.getElementById(menuArray).style.display = "none"; document.getElementById("tick_"+menuArray).innerHTML = "+"; } } } function memStatus() { var num = readCookie("MN"); if (num) { document.getElementById(num).style.display = "block"; document.getElementById("tick_"+num).innerHTML = "-"; } var num1 = readCookie("SB"); if (num1) { document.getElementById(num1).style.display = "block"; document.getElementById("tick_"+num1).innerHTML = "-"; } } // Multiple onload function created by: Simon Willison // http://simonwillison.net/2004/May/26/addLoadEvent/ function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } addLoadEvent(function() { memStatus(); });