Hi,

Thanks for reading this. I am working on some menu code using javascript and CSS. Rather than using the onclick function for some pages I would like to automatically just display the subMenus. I have looked everywhere and cant find a function to replace this. Eg. If I am on the ABOUT US page I want the submenu to be displayed. However while I am on the ABOUT US page and I click on the SHOWCASE page I would like to the submenu to be displayed over the top.

I hope I am making sense and thanks for your help.

HTML
Code:
<li onclick='showSubMenu("sm_item1")'>  
ABOUT US
<ul class="subMenus" id="sm_item1" > 
<li><a href="landscape.htm" class="menulinkoff">LANDSCAPE</a></li> 
<li><a href="swimming.htm" class="menulinkoff">SWIMMING</a></li>
</ul> 
</li> 
											
											
<li onclick='showSubMenu("sm_item2")'>  
SHOWCASE 
<ul class="subMenus" id="sm_item2"> 
<li><a href="residential.htm">RESIDENTIAL</a></li>
<li><a href="designs">DEESIGN</a></li>
<li><a href="commercial.htm">COMMERCIAL</a></li>
</ul> 
</li>

JAVASCRIPT
Code:
window.onload=function() { 
 subMenusO = getElementsByClassName(document,'ul','subMenus'); 
} 
//----------------------------------------------------------- 
  
function showSubMenu(elemId) { 
 var dispStatus = (document.getElementById(elemId).style.display == 'block')? 'none' : 'block'; 
 //hide any visible submenus 
 for(var i=0; i < subMenusO.length; i=i+1) { 
     subMenusO[i].style.display = 'none'; 
    } 
    //show/hide this menu id 
    document.getElementById(elemId).style.display = dispStatus; 
} 
//-------------------------------------------------------------------------- 

function getElementsByClassName(oElm, strTagName, strClassName){ 
    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName); 
    var arrReturnElements = new Array(); 
    strClassName = strClassName.replace(/\-/g, "\\-"); 
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)"); 
    var oElement; 
    for(var i=0; i<arrElements.length; i++) 
    { 
        oElement = arrElements[i]; 
        if(oRegExp.test(oElement.className)) 
        { 
            arrReturnElements.push(oElement); 
        } 
    } 
    return (arrReturnElements) 
}