PDA

View Full Version : Cascading Menu script modification



Aksaunders
01-24-2007, 09:01 PM
I am just learning javascript and have a question. I would
like to modify this script to collapse the drop-down menu onMouseout. Is it possible to do this? Please help.

CASCADE MENU SCRIPT
function highlight(obj)
{
var PElement = eval(obj.parentElement.id)
if(PElement.hasChildNodes() == true)
{ var Elements = PElement.children
for(var i=0;i<Elements.length;i++)
{
TE = eval(Elements[i].id)
TE.className = "menuItem"
}
}
obj.className="ItemMouseOver"
window.defaultStatus = obj.title
ShowSubMenu(obj)
}


function Do(obj)
{
var cmd = eval(obj).cmd
window.navigate(cmd)


}


function HideMenu(obj)
{
if(obj.hasChildNodes()==true)
{
var child = obj.children


for(var j =0;j<child.length;j++)
{
if (child[j].className=="barOver")
{var bar = eval(child[j].id)
bar.className="Bar"}


if(child[j].menu != null)
{
var childMenu = eval(child[j].menu)
if(childMenu.hasChildNodes()==true)
HideMenu(childMenu)


childMenu.style.visibility = "hidden"
}
}


}
}
function ShowSubMenu(obj)
{
PMenu = eval(obj.parentElement.id)
HideMenu(PMenu)
if(obj.menu != null)
{
var menu = eval(obj.menu)
menu.style.visibility = "visible"
menu.style.pixelTop = obj.getBoundingClientRect().top +
Bdy.scrollTop
menu.style.pixelLeft = obj.getBoundingClientRect().right +
Bdy.scrollLeft
if(menu.getBoundingClientRect().right > window.screen.availWidth )
menu.style.pixelLeft = obj.getBoundingClientRect().left -
menu.offsetWidth
}
}