// Menu 1.0.5 // by Scott Yenor, October 2002 // Copyright (c) iolo technologies, LLC var ns4 = ((navigator.appName == "Netscape") && document.layers)?1:0; var ns6 = ((navigator.appName == "Netscape") && document.getElementById)?1:0; var ie4 = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4) && (navigator.userAgent.indexOf('Opera') == -1))?1:0; var op6 = (navigator.userAgent.indexOf('Opera') != -1)?1:0; // opera is compatible with the Netscape 6 version of this menu if (op6 == 1) ns6 = 1; var intLastTimeout; var objCurrentMenu; window.MouseMoveX = 0; window.MouseMoveY = 0; function Menu() { if (!window.Menus) window.Menus = new Array(); this.ID = window.Menus.length; this.Type = "Menu"; this.Width = 200; this.Color = 'EFEFEF'; // this gets modified each time an entry is added - modify the add item function to // increment this value by the estimated height of each menu item this.Height = 0; // variables to hold the painted area of the menu this.topX = 0; this.topY = 0; this.botX = 0; this.botY = 0; this.ItemOnColor = 'FFFFFF'; this.ItemOnBgColor = 'CC0000'; this.ItemOffColor = '000000'; this.ItemOffBgColor = 'EFEFEF'; // containers for properties this.Items = new Array(); this.Links = new Array(); this.OnColors = new Array(); this.OffColors = new Array(); this.OnBgColors = new Array(); this.OffBgColors = new Array(); // procedures for Menu object this.AddItem = fAddItem; this.ShowMenu = fShowMenu; this.HideMenu = fHideMenu; this.ShowMenuEx = fShowMenuEx; this.WriteMenus = fWriteMenus; // handles usage of menu this.Written = 0; this.Activated = 0; window.Menus[window.Menus.length] = this; } function fAddItem(sText, sLink, sOnColor, sOffColor, sOnBgColor, sOffBgColor) { if (sText) this.Items[this.Items.length] = sText; else this.Items[this.Items.length] = ''; if (sLink) this.Links[this.Links.length] = sLink; else this.Links[this.Links.length] = ''; if (sOnColor) this.OnColors[this.OnColors.length] = sOnColor; else this.OnColors[this.OnColors.length] = ''; if (sOffColor) this.OffColors[this.OffColors.length] = sOffColor; else this.OffColors[this.OffColors.length] = ''; if (sOnBgColor) this.OnBgColors[this.OnBgColors.length] = sOnBgColor; else this.OnBgColors[this.OnBgColors.length] = ''; if (sOffBgColor) this.OffBgColors[this.OffBgColors.length] = sOffBgColor; else this.OffBgColors[this.OffBgColors.length] = ''; // adjust the height of the menu container by estimated size of each menu item this.Height += 22; } function fWriteMenus() { for (x = 0; x < window.Menus.length; x++) { obj = window.Menus[x]; if (obj.Written == 1) continue; else obj.Written = 1; if (ie4 == 1) { strParBeg = ""; strParEnd = ""; } else if (ns4 == 1) { strParBeg = ""; strParBeg += ""; strParBeg += ""; strParEnd += "
"; strParBeg += ""; strParEnd = "
"; strParEnd += "
"; strParEnd += "
"; } else if (ns6 == 1) { strParBeg = "
"; strParBeg += "
"; strParBeg += "
"; strParEnd = "
"; strParEnd += "
"; strParEnd += "
"; } else return; strParBeg = strParBeg.replace('{ID}', x); strParBeg = strParBeg.replace('{ID}', x); strParBeg = strParBeg.replace('{WIDTH}', obj.Width); strParBeg = strParBeg.replace('{BGCOLOR}', obj.Color); strParBeg = strParBeg.replace('{BGCOLOR}', obj.Color); strParBeg = strParBeg.replace('{BORDERCOLOR}', obj.Color); document.writeln(strParBeg); for (y = 0; y < obj.Items.length; y++) { if (ie4 == 1) { strItemBeg = ""; strItemEnd = ""; } else if (ns4 == 1) { strItemBeg = ""; strItemEnd = ""; if (obj.Links != '') { strItemBeg += ""; strItemEnd += ""; } strItemBeg += ""; strItemEnd += ""; strItemEnd += ""; } else if (ns6 == 1) { strItemBeg = "
"; strItemEnd = "
"; } //determine color settings if (obj.OffColors[y] == '') strColor = obj.ItemOffColor; else strColor = obj.OffColors[y]; if (obj.OffBgColors[y] == '') strBgColor = obj.ItemOffBgColor; else strBgColor = obj.OffBgColors[y]; for (z = 0; z < 4; z++) { strItemBeg = strItemBeg.replace('{ID}', x); strItemBeg = strItemBeg.replace('{SID}', y); } strItemBeg = strItemBeg.replace('{COLOR}', strColor); strItemBeg = strItemBeg.replace('{WIDTH}', obj.Width - 5); strItemBeg = strItemBeg.replace('{BGCOLOR}', strBgColor); if (obj.Items[y] != '') { document.writeln(strItemBeg); document.writeln(obj.Items[y]); document.writeln(strItemEnd); } else { if (ns4 == 1) { document.writeln(''); fMenuSeparator(obj.Width); document.writeln(''); } else document.writeln('
'); fMenuSeparator(obj.Width); document.writeln('
'); } } document.writeln(strParEnd); } } function fMenuSeparator(Width) { document.writeln('
'); } function fMenuItemClick(id, sid) { objMenu = window.Menus[id]; if (objMenu.Links[sid] != '') document.location = objMenu.Links[sid]; } function fMenuItemMouseStyle(id, sid, state) { objMenu = window.Menus[id]; if (ie4 == 1) objItem = document.all('syMenu' + id + 'SubMenu' + sid); else if (ns6 == 1) objItem = document.getElementById('syMenu' + id + 'SubMenu' + sid); else return; if (state == 1) // menu is on { if (objMenu.OnColors[sid] == '') strColor = objMenu.ItemOnColor; else strColor = objMenu.OnColors[sid]; if (objMenu.OnBgColors[sid] == '') strBgColor = objMenu.ItemOnBgColor; else strBgColor = objMenu.OnBgColors[sid]; } else // menu is off { if (objMenu.OffColors[sid] == '') strColor = objMenu.ItemOffColor; else strColor = objMenu.OffColors[sid]; if (objMenu.OffBgColors[sid] == '') strBgColor = objMenu.ItemOffBgColor; else strBgColor = objMenu.OffBgColors[sid]; } if (ie4 == 1) { objItem.style.color = strColor; objItem.style.background = strBgColor; } else if (ns6 == 1) { objItem.style.color = strColor; objItem.style.background = '#' + strBgColor; } } function fShowMenu(xPos, yPos) { if (objCurrentMenu) objCurrentMenu.HideMenu(); if (ie4 == 1) objMenu = document.all('syMenu' + this.ID); else if (ns4 == 1) objMenu = document.layers['syMenu' + this.ID]; else if (ns6 == 1) objMenu = document.getElementById('syMenu' + this.ID); else return; objCurrentMenu = window.Menus[this.ID]; objCurrentMenu.topX = xPos; objCurrentMenu.topY = yPos; objCurrentMenu.botX = xPos + this.Width; objCurrentMenu.botY = yPos + this.Height; if (ie4 == 1) { objMenu.style.pixelTop = yPos; objMenu.style.pixelLeft = xPos; objMenu.style.visibility = 'visible'; } else if (ns4 == 1) { objMenu.top = yPos; objMenu.left = xPos; objMenu.visibility = 'visible'; } else if (ns6 == 1) { objMenu.style.top = yPos; objMenu.style.left = xPos; objMenu.style.visibility = 'visible'; } fClearTimeout(); intLastTimeout = setTimeout('fHideMenuIfNotActivated()', 6000); } function fShowMenuEx(Align, Offset) { if (Align == 'Right') { xPos = window.MouseMoveX - this.Width + Offset; yPos = window.MouseMoveY; } else { xPos = window.MouseMoveX; yPos = window.MouseMoveY; } this.ShowMenu(xPos, yPos); } function fHideMenu() { window.Menus[this.ID].Activated = 0; if (ie4 == 1) { objMenu = document.all('syMenu' + this.ID); objMenu.style.visibility = 'hidden'; objMenu.style.pixelTop = 0; objMenu.style.pixelLeft = 0; } else if (ns4 == 1) { objMenu = document.layers['syMenu' + this.ID]; objMenu.visibility = 'hide'; objMenu.top = 0; objMenu.left = 0; } else if (ns6 == 1) { objMenu = document.getElementById('syMenu' + this.ID); objMenu.style.visibility = 'hidden'; objMenu.style.top = 0; objMenu.style.left = 0; } objCurrentMenu = null; } function fHideCurrentMenu() { if (objCurrentMenu) objCurrentMenu.HideMenu(); } function fMarkMenuActivated(id) { fClearTimeout(); window.Menus[id].Activated = 1; } function fHideMenuIfNotActivated() { if (objCurrentMenu) if (!objCurrentMenu.Activated) objCurrentMenu.HideMenu(); } function fShortDelayOnMouseOut() { fClearTimeout(); intLastTimeout = setTimeout('fHideMenuIfNotActivated()', 100); } function fClearTimeout() { if (intLastTimeout != null) { clearTimeout(intLastTimeout); intLastTimeout = null; } } function eClick(e) { if (e) evt = e; if (window.event) evt = event; if (objCurrentMenu) fHideCurrentMenu(); } function eMouseMove(e) { if (e) evt = e; if (window.event) evt = event; if (ie4 == 1 || ns6 == 1) { window.MouseMoveX = evt.clientX; window.MouseMoveY = evt.clientY; // get vertical scroll offset if (ie4 == 1) yScroll = document.body.scrollTop; else if (ns6 == 1) yScroll = window.pageYOffset; window.MouseMoveY = window.MouseMoveY + yScroll; } else if (ns4 == 1) { window.MouseMoveX = evt.pageX; window.MouseMoveY = evt.pageY; } if (objCurrentMenu && objCurrentMenu.Activated) { mouseX = window.MouseMoveX; mouseY = window.MouseMoveY; if(mouseX < (objCurrentMenu.topX) || mouseX > (objCurrentMenu.botX) || mouseY < (objCurrentMenu.topY) || mouseY > (objCurrentMenu.botY)) objCurrentMenu.HideMenu(); } } if (ie4 == 1 || ns6 == 1) document.onclick = eClick; if (ie4 == 1 || ns6 == 1) document.onmousemove=eMouseMove; if (document.captureEvents) { if (Event.CLICK) { document.captureEvents(Event.CLICK); document.onclick = eClick; } if (Event.MOUSEMOVE) { document.captureEvents(Event.MOUSEMOVE); document.onmousemove = eMouseMove; } }