function isIE55() { return (navigator.userAgent.indexOf("MSIE 5.5") > -1);}
function getMainMenuBarMenuLeftPos(menuBarObj, menuBarItemObj, menuObj, x) { var barBorderLeftWidth = parseInt(getPropertyValue(menuBarObj, "border-left-width")); var menuBorderLeftWidth = parseInt(getPropertyValue(menuObj, "border-left-width")); if ((x + menuObj.offsetWidth) <= getClientWidth()) { if (isOpera()) { return (x - menuBorderLeftWidth);}
else { return (x + barBorderLeftWidth - menuBorderLeftWidth);}
}
else { if (isOpera()) { return (x - menuObj.offsetWidth + menuBarItemObj.offsetWidth + menuBorderLeftWidth);}
else { return (x - menuObj.offsetWidth + menuBarItemObj.offsetWidth + barBorderLeftWidth + menuBorderLeftWidth);}
}
}
function getMainMenuBarMenuTopPos(menuBarObj, menuObj, y) { if ((y + menuObj.offsetHeight) <= getClientHeight()) { return y;}
else { return (y - menuObj.offsetHeight - menuBarObj.offsetHeight);}
}
function popUpMenuBarMenu(menuBarObj, menuBarItemObj, menuObj) { if (menuObj.style.position == "fixed") { var x = menuBarObj.offsetLeft + menuBarItemObj.offsetLeft; var y = menuBarObj.offsetTop + menuBarObj.offsetHeight; var left = getMainMenuBarMenuLeftPos(menuBarObj, menuBarItemObj, menuObj, x); var right = getMainMenuBarMenuTopPos(menuBarObj, menuObj, y); menuObj.style.position = "absolute"; menuObj.style.left = left + "px"; menuObj.style.top = right + "px"; menuObj.style.position = "fixed";}
else { var x = menuBarObj.offsetLeft + menuBarItemObj.offsetLeft - getScrollLeft(); var y = menuBarObj.offsetTop + menuBarObj.offsetHeight - getScrollTop(); menuObj.style.left = (getMainMenuBarMenuLeftPos(menuBarObj, menuBarItemObj, menuObj, x) + getScrollLeft()) + "px"; menuObj.style.top = (getMainMenuBarMenuTopPos(menuBarObj, menuObj, y) + getScrollTop()) + "px";}
if ((isIE()) && (menuObj.mode == "fixed")) { menuObj.initialLeft = parseInt(menuObj.style.left) - getScrollLeft(); menuObj.initialTop = parseInt(menuObj.style.top) - getScrollTop();}
menuObj.style.visibility = "visible";}
function menuBarItemOver(e) { if (this.parent.menuBarObj.activated) { if (!this.clicked) { var menuBarObj = this.parent.menuBarObj; var i; for (i = 0; i < menuBarObj.childNodes.length; i++) { if ((menuBarObj.childNodes[i].enabled) && (menuBarObj.childNodes[i].clicked)) { menuBarObj.childNodes[i].className = menuBarObj.childNodes[i].itemClassName; menuBarObj.childNodes[i].clicked = false; if (menuBarObj.childNodes[i].menu) { hideMenus(menuBarObj.childNodes[i].menu.menuObj);}
break;}
}
if (this.enabled) { if (this.menu) { this.onclick(e);}
else { if (this.actionOnClick) { this.className = this.itemClassNameClick; this.clicked = true;}
}
}
}
}
else { var menuBarObj = this.parent.menuBarObj; var i; for (i = 0; i < menuBarObj.childNodes.length; i++) { if (menuBarObj.childNodes[i].enabled) { menuBarObj.childNodes[i].className = menuBarObj.childNodes[i].itemClassName;}
}
if ((this.enabled) && ((this.menu) || (this.actionOnClick))) { this.className = this.itemClassNameOver;}
}
}
function menuBarItemClick(e) { if (this.enabled) { if (this.menu) { if (this.clicked) { this.className = this.itemClassNameOver; hideMenus(this.menu.menuObj); this.clicked = false; this.parent.menuBarObj.activated = false;}
else { this.className = this.itemClassNameClick; popUpMenuBarMenu(this.parent.menuBarObj, this, this.menu.menuObj); this.clicked = true; this.parent.menuBarObj.activated = true;}
}
else { if (this.actionOnClick) { var action = this.actionOnClick; if (action.indexOf("link:") == 0) { location.href = action.substr(5);}
else { if (action.indexOf("code:") == 0) { eval(action.substr(5));}
else { location.href = action;}
}
this.className = this.itemClassName; this.clicked = false; this.parent.menuBarObj.activated = false;}
}
}
if (!e) { var e = window.event; e.cancelBubble = true;}
if (e.stopPropagation) { e.stopPropagation();}
}
function menuBarItemOut() { if (!this.parent.menuBarObj.activated) { this.className = this.itemClassName;}
}
function menuBarDown(e) { draggingObj = this.parent.menuBarObj; var menuBarObj = this.parent.menuBarObj; menuBarObj.differenceLeft = getX(e) - menuBarObj.offsetLeft; menuBarObj.differenceTop = getY(e) - menuBarObj.offsetTop; document.onmousemove = mouseMoveHandler;}
function menuBarUp() { draggingObj = null; var menuBarObj = this.parent.menuBarObj; menuBarObj.differenceLeft = 0; menuBarObj.differenceTop = 0; menuBarObj.initialLeft = menuBarObj.offsetLeft - getScrollLeft(); menuBarObj.initialTop = menuBarObj.offsetTop - getScrollTop(); document.onmousemove = null;}
function addMenuBarItem(menuBarItemObj) { var itemElm = createElm("div"); itemElm.id = menuBarItemObj.id; itemElm.menu = menuBarItemObj.menu; itemElm.enabled = menuBarItemObj.enabled; itemElm.clicked = false; itemElm.actionOnClick = menuBarItemObj.actionOnClick; itemElm.itemClassName = menuBarItemObj.className; itemElm.itemClassNameOver = menuBarItemObj.classNameOver; itemElm.itemClassNameClick = menuBarItemObj.classNameClick; itemElm.className = itemElm.itemClassName; if (isIE5()) { itemElm.style.width = "0px";}
if (isIE55()) { itemElm.style.width = "auto";}
this.menuBarObj.appendChild(itemElm); var textNode = document.createTextNode(menuBarItemObj.displayText); itemElm.appendChild(textNode); itemElm.parent = this; itemElm.setClassName = function(className) { this.itemClassName = className; this.className = this.itemClassName;}; itemElm.setClassNameOver = function(classNameOver) { this.itemClassNameOver = classNameOver;}; itemElm.setClassNameClick = function(classNameClick) { this.itemClassNameClick = classNameClick;}; itemElm.setDisplayText = function(text) { this.firstChild.nodeValue = text;}; itemElm.setMenu = function(menu) { this.menu = menu;}; itemElm.onmouseover = menuBarItemOver; itemElm.onclick = menuBarItemClick; itemElm.onmouseout = menuBarItemOut; if (menuBarItemObj.itemName.length > 0) { this.items[menuBarItemObj.itemName] = itemElm;}
else { this.items[this.items.length] = itemElm;}
}
function menuBarItem() { this.displayText = arguments[0]; this.id = "MenuBarItem" + (++menuBarItemCount); this.itemName = ""; this.menu = null; this.enabled = true; this.actionOnClick = ""; this.className = menuBarItemClassName; this.classNameOver = menuBarItemClassNameOver; this.classNameClick = menuBarItemClassNameClick; var length = arguments.length; if ((length > 1) && (typeof(arguments[1]) == "object")) { this.menu = arguments[1];}
if ((length > 2) && (arguments[2].length > 0)) { this.itemName = arguments[2];}
if ((length > 3) && (typeof(arguments[3]) == "boolean")) { this.enabled = arguments[3];}
if ((length > 4) && (arguments[4].length > 0)) { this.actionOnClick = arguments[4];}
if ((length > 5) && (arguments[5].length > 0)) { this.className = arguments[5];}
if ((length > 6) && (arguments[6].length > 0)) { this.classNameOver = arguments[6];}
if ((length > 7) && (arguments[7].length > 0)) { this.classNameClick = arguments[7];}
}
function jsDOMenuBar() { this.items = new Array(); var dragElm = createElm("div"); dragElm.className = menuBarDragClassName; var textNode = document.createTextNode(""); dragElm.appendChild(textNode); var menuBarElm = createElm("div"); menuBarElm.appendChild(dragElm); menuBarElm.id = "DOMenuBar" + (++menuBarCount); menuBarElm.mode = "absolute"; menuBarElm.draggable = false; menuBarElm.className = menuBarClassName; menuBarElm.activated = false; menuBarElm.initialLeft = 0; menuBarElm.initialTop = 0; menuBarElm.differenceLeft = 0; menuBarElm.differenceTop = 0; var length = arguments.length; if ((length > 0) && (arguments[0].length > 0)) { switch (arguments[0]) { case "absolute":
menuBarElm.style.position = "absolute"; break; case "fixed":
if (isIE()) { menuBarElm.style.position = "absolute";}
else { menuBarElm.style.position = "fixed";}
menuBarElm.mode = "fixed"; break;}
}
if ((length > 1) && (typeof(arguments[1]) == "boolean")) { menuBarElm.draggable = arguments[1]; if (menuBarElm.draggable) { dragElm.style.visibility = "visible";}
else { dragElm.style.visibility = "hidden";}
}
if ((length > 2) && (arguments[2].length > 0)) { menuBarElm.className = arguments[2];}
if ((length > 3) && (typeof(arguments[3]) == "number") && (arguments[3] > 0)) { menuBarElm.style.width = arguments[3] + "px";}
if ((length > 4) && (typeof(arguments[4]) == "number") && (arguments[4] > 0)) { menuBarElm.style.height = arguments[4] + "px";}
with (menuBarElm.style) { left = "0px"; top = "0px";}
document.body.appendChild(menuBarElm); if (!getPropertyValue(menuBarElm, "border-left-width")) { menuBarElm.style.borderWidth = menuBarBorderWidth + "px";}
this.menuBarObj = menuBarElm; this.dragObj = dragElm; dragElm.parent = this; this.addMenuBarItem = addMenuBarItem; this.menuBarObj.onclick = function(e) { if (!e) { var e = window.event; e.cancelBubble = true;}
if (e.stopPropagation) { e.stopPropagation();}
}; dragElm.onmousedown = menuBarDown; dragElm.onmouseup = menuBarUp; this.setMode = function(mode) { switch (mode) { case "absolute":
this.menuBarObj.style.position = "absolute"; this.menuBarObj.mode = "absolute"; var left = parseInt(this.menuBarObj.style.left); var top = parseInt(this.menuBarObj.style.top); this.menuBarObj.initialLeft = left; this.menuBarObj.initialTop = top; break; case "fixed":
if (isIE()) { this.menuBarObj.style.position = "absolute"; var left = parseInt(this.menuBarObj.style.left); var top = parseInt(this.menuBarObj.style.top); this.menuBarObj.initialLeft = left; this.menuBarObj.initialTop = top;}
else { this.menuBarObj.style.position = "fixed";}
this.menuBarObj.mode = "fixed"; break;}
}; this.setDraggable = function(draggable) { if (typeof(draggable) == "boolean") { this.menuBarObj.draggable = draggable; if (this.menuBarObj.draggable) { this.dragObj.style.visibility = "visible";}
else { this.dragObj.style.visibility = "hidden";}
}
}; this.setClassName = function(className) { this.menuBarObj.className = className;}; this.setDragClassName = function(className) { this.dragObj.className = className;}; this.show = function() { this.menuBarObj.style.visibility = "visible";}; this.hide = function() { this.menuBarObj.style.visibility = "hidden";}; this.setX = function(x) { this.menuBarObj.initialLeft = x; this.menuBarObj.style.left = x + "px";}; this.setY = function(y) { this.menuBarObj.initialTop = y; this.menuBarObj.style.top = y + "px";}; this.moveTo = function(x, y) { this.menuBarObj.initialLeft = x; this.menuBarObj.initialTop = y; this.menuBarObj.style.left = x + "px"; this.menuBarObj.style.top = y + "px";}; this.moveBy = function(x, y) { var left = parseInt(this.menuBarObj.style.left); var top = parseInt(this.menuBarObj.style.top); this.menuBarObj.initialLeft = left + x; this.menuBarObj.initialTop = top + y; this.menuBarObj.style.left = (left + x) + "px"; this.menuBarObj.style.top = (top + y) + "px";}; this.setBorderWidth = function(width) { this.menuBarObj.style.borderWidth = width + "px";};}
function hideMenuBarMenus() { var i, j; for (i = 1; i <= menuBarCount; i++) { var menuBarObj = getElmId("DOMenuBar" + i); for (j = 0; j < menuBarObj.childNodes.length; j++) { if ((menuBarObj.childNodes[j].enabled) && (menuBarObj.childNodes[j].clicked)) { menuBarObj.childNodes[j].className = menuBarObj.childNodes[j].itemClassName; menuBarObj.childNodes[j].clicked = false; hideMenus(menuBarObj.childNodes[j].menu.menuObj); break;}
}
menuBarObj.activated = false;}
}
function mouseMoveHandler(e) { if (draggingObj) { draggingObj.style.left = (getX(e) - draggingObj.differenceLeft) + "px"; draggingObj.style.top = (getY(e) - draggingObj.differenceTop) + "px";}
}
function menuBarScrollHandler() { var i; for (i = 1; i <= menuBarCount; i++) { var menuBarObj = getElmId("DOMenuBar" + i); if ((isIE()) && (menuBarObj.mode == "fixed")) { with (menuBarObj.style) { left = (menuBarObj.initialLeft + getScrollLeft()) + "px"; top = (menuBarObj.initialTop + getScrollTop()) + "px";}
}
}
}
if (typeof(menuBarClassName) == "undefined") { var menuBarClassName = "jsdomenubardiv";}
if (typeof(menuBarItemClassName) == "undefined") { var menuBarItemClassName = "jsdomenubaritem";}
if (typeof(menuBarItemClassNameOver) == "undefined") { var menuBarItemClassNameOver = "jsdomenubaritemover";}
if (typeof(menuBarItemClassNameClick) == "undefined") { var menuBarItemClassNameClick = "jsdomenubaritemclick";}
if (typeof(menuBarDragClassName) == "undefined") { var menuBarDragClassName = "jsdomenubardragdiv";}
if (typeof(menuBarBorderWidth) == "undefined") { var menuBarBorderWidth = 2;}
var menuBarCount = 0; var menuBarItemCount = 0; var draggingObj = null; 