function Menu() {
this.nTimeout = 300;
this.oTimeout = null;
this.cMenuID = 'menu';
}
var oMenu = new Menu();
Menu.prototype.getRoot = function() { 
if (window.document.getElementById) return (window.document.getElementById(this.cMenuID));
}
Menu.prototype.addNodeClass = function (oNode, cAddClassName) {
var cClass = oNode.className;
oNode.className = cClass + (cClass == '' ? '' : ' ') + cAddClassName;
}
Menu.prototype.close = function() {
var oRoot = this.getRoot();
var aItems = oRoot.getItems();
for (var i=0; i<aItems.length; i++) aItems[i].close();
}
Menu.prototype.init = function() {
oRoot = this.getRoot();
oRoot.getItemContainer = function() {
return (this);
}
oRoot.getItems = function() {
var aItems = new Array();
var oContainer = this.getItemContainer();
if (oContainer) for (var i=0; i < oContainer.childNodes.length; i++) {
var oChildNode = oContainer.childNodes[i];
if (oChildNode.nodeName == 'LI') aItems[aItems.length] = oChildNode;
}
return (aItems);
}
oRoot.init = function () {
var aItems = this.getItems();
if (aItems.length > 0) oMenu.addNodeClass (aItems[aItems.length-1], 'last');
if (this != oMenu.getRoot()) {
if (aItems.length > 0) {
if (this.className.match ('current'))
this.className = this.className.replace ('current', 'currentHasChildren');
else
oMenu.addNodeClass (this, 'hasChildren');
}
this.onmouseover = function() {
window.clearTimeout (oMenu.oTimeout);
if (!this.className.match (/\s?over/)) {
for (var j=0; j<this.parentNode.childNodes.length; j++) {
var oSibling = this.parentNode.childNodes[j];
if (oSibling.nodeName=='LI') oSibling.close();
}
oMenu.addNodeClass (this, 'over');
}
}
this.close = function() {
this.className = this.className.replace(/\s?over/, '');
var aItems = this.getItems();
for (var i=0; i<aItems.length; i++) aItems[i].close();
}
if (this.parentNode == oMenu.getRoot()) {
this.onmouseout=function() {
oMenu.oTimeout = window.setTimeout ('oMenu.close()', oMenu.nTimeout);
}
}
}
for (var i=0; i<aItems.length; i++) {
oItem = aItems[i];
oItem.getItemContainer = function() {
for (var j=0; j < this.childNodes.length; j++) {
oChildNode = this.childNodes[j];
if (oChildNode.nodeName == 'UL' || oChildNode.nodeName == 'OL') return (oChildNode);
}
}
oItem.getItems = this.getItems;
oItem.init = this.init;
oItem.init();
}
}
oRoot.init();
this.close();
}
window.onload = function() {
var cUseragent = navigator.userAgent;
oMenu.cMenuID = 'main';
if (window.document.getElementById && !(cUseragent.indexOf('Mac') > 0 && cUseragent.indexOf('MSIE') > 0)) oMenu.init();
}

