I cant seem to get it to work. I need to create a menu, that allows for a submenu to show and hide when clicked. It also needs to switch the images onmouseover, as well as change the static image when clicked, the problem comes in when you change the static image and mouse is still over or mouses out, it switches back. Here is what I have so far:
[CODE]<script language=”JavaScript” type=”text/JavaScript”>
function switchImage(id)
{
if (lastSwitched){
lastSwitched.className=lastSwitched.className.replace(‘b’,”);
}
var men = document.getElementById(id);
var menclass = men.className;
men.className=menclass+’b’
lastSwitched = men;
}
function hoverMain(id)
{
var hovering = document.getElementById(id);
var hoverclass = hovering.className;
if (!hoverclass.match(/b$/))
{
hovering.className = hoverclass+’c’
}
}
funtion hoverOut(id)
(
var hovering = document.getElementByID(id);
var hoverclass = hovering.className;
if (!hoverclass.match(/b$/))
{
hovering.className = hoverclass.replace(/c/,”);
}
}
var last_expanded = ”;
function showHide(id)
{
var obj = document.getElementById(id);
var status = obj.className;
if (status == ‘hide’) {
if (last_expanded != ”) {
var last_obj = document.getElementById(last_expanded);
last_obj.className = ‘hide’;
}
obj.className = ‘show’;
last_expanded = id;
} else {
obj.className = ‘hide’;
}
}
</script>
<div><a id=”mainmenu2″ class=”rmenu2″ onclick=”showHide(‘rmymenu1’); switchImage(‘mainmenu2’)” onmouseover=”hoverMain(‘mainmenu2’)” onmouseout=”hoverOut(‘mainmenu2’)” border=”0″ target=”blockrandom” href=”index2.php?option=com_content&view=article&id=45″></a></div>
Thanks up front!