// Copyright (c) ----------------------------------------------------------------------------
// Copyright (c) WebMenu
// Copyright (c)
// Copyright (c) Version: 1.0
// Copyright (c) Release date: 2005.01.30
// Copyright (c)
// Copyright (c) Copyright (c) Amir Firdus (Firdus Software), 2005.
// Copyright (c) All rights reserved.
// Copyright (c)
// Copyright (c) License:
// Copyright (c) This software is free as long as this header is not removed.
// Copyright (c) Firdus Software welcomes improvements, suggestions as well as
// Copyright (c) news about successful application. To contact us, please use either
// Copyright (c) email or message board available at www.firdus.com.
// Copyright (c) ----------------------------------------------------------------------------
// Copyright (c) This has been incorporated into SM - Stylish Monkey to extend existing menus to be cross platform
// Copyright (c) SM is also available for free
// Copyright (c) Enhancements made by Golden Software Engineers Pty Ltd, 2005, All rights reserved
var WM_BOTTOM = "bottom";
var WM_RIGHT = "right";
var MARGIN_BOTTOM = 0;
var MARGIN_RIGHT = -40;
var currentItem = null;
var menuTrail = new Array();
var currentStyleOff = null;
function wmItemOn(item, level, styleOn, styleOff, submenuId, submenuPosition)
{
stopOffTimer();

if (currentItem != null)
{
if (styleOff != currentStyleOff && currentStyleOff != null)
{
currentItem.className = currentStyleOff;
}
else
{
currentItem.className = styleOff;
}
}
currentItem = item;
item.className = styleOn;
currentStyleOff = styleOff;
if (submenuId != null)
{
hide(level);
var menu = document.getElementById(submenuId);
if (submenuPosition == WM_BOTTOM)
{
menu.style.top = findOffsetTop(item) + item.offsetHeight + MARGIN_BOTTOM;
menu.style.left = findOffsetLeft(item);
}
if (submenuPosition == WM_RIGHT)
{
menu.style.top = findOffsetTop(item);
menu.style.left = findOffsetLeft(item) + item.offsetWidth + MARGIN_RIGHT;
}
menu.style.visibility = "visible";
menuTrail[level] = menu;
}
else
{
hide(level);
}
}
function hide(level)
{
for (var i = level; i < menuTrail.length; i++)
{
menuTrail[i].style.visibility = "hidden";
}
}
var timerID = null;
var timerOn = false;
var timecount = 250;
function wmStartOffTimer()
{
if (timerOn == false)
{
timerID = setTimeout("offAll()", timecount);
timerOn = true;
}
}
function stopOffTimer()
{
if (timerOn)
{
clearTimeout(timerID);
timerID = null;
timerOn = false;
}
}
function offAll()
{
hide(0);
if (currentStyleOff != null)
{
currentItem.className = currentStyleOff;
}
}
function findOffsetLeft(obj)
{
var curleft = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (obj.x)
{
curleft += obj.x;
}
return curleft;
}
function findOffsetTop(obj)
{
var curtop = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (obj.y)
{
curtop += obj.y;
}
return curtop;
}
