// JavaScript Document

<!-- Copyright 2002 Bontrager Connection, LLC
// You may use this so long as the copyright notice, above, 
//   and the "more information" statement with URL, below, 
//   are retained.
// Additional instructions and more information can be obtained from
//   the "Making Your Own Layered Sub-Menus" article linked from
//   http://willmaster.com/possibilities/archives/
//
// (Version 1.0, November 25, 2002, original release version.)
// (Version 1.1, December 2, 2002, added Opera 5 and 6 functionality.)
//
//
// I N S T R U C T I O N S
//
// These instructions are succinct. See the URL printed above 
//   for more detailed instructions.
//
// Two sections need to be customized. But first, the following 
//   line must be left as is. Don't change it.

MDMG_menusection = new Array();


// Now that you've left the above line as is, here are the 
//   sections that need to be customized:
//
//
// Customization Section One:
//
// It is assumed that you've already created your layered sub-menus 
//   as detailed in "Making Your Own Layered Sub-Menus." Here, 
//   tell the script whether you want the positions you specified 
//   for your layered sub-menus (1) to be static or (2) to adjust
//   the positions relative to the mouse position at the time the 
//   popup is displayed. Answer "static"; or "adjust"; (all lower 
//   case). If this is left blank, or the answer misspelled, then 
//   "adjust" is assumed.

MDMG_MovabilityOfSubMenuPositions = "static";


// Customization Section Two:
//
// Between the quotation marks, on the lines below, type the ID's 
//   of the layered sub-menus you've created. The number between 
//   the square brackets is the number you've assigned to the 
//   main_section menu items and their layered sub-menus. Add/Delete 
//   lines as needed to accomodate your menu system, adjusting 
//   the numbers between square brackets to be sequential from 
//   one line to the next, starting with the digit 1

MDMG_menusection[1] = "submenu1";
MDMG_menusection[2] = "submenu2";
MDMG_menusection[3] = "submenu3";
MDMG_menusection[4] = "submenu4";


//
// End of customization sections.
///////////////////////////////////////////////////////////////


MDMG_menusection[0] = "unused";
MDMG_menusectionprinted = new Array();
for(i = 0; i < MDMG_menusection.length; i++) { MDMG_menusectionprinted[i] = false; }
bNS4 = bNS6 = bIE = bOPERA = false;
if     (navigator.userAgent.indexOf("Opera") != -1) { bOPERA = true; }
else if(navigator.userAgent.indexOf("Gecko") != -1) { bNS6 = true;   }
else if(document.layers)                            { bNS4 = true;   }
else if(document.all)                               { bIE = true;    }

MDMGx = MDMGxx = MDMGy = MDMGyy = 0;
var MDMG_mousex;
var MDMG_mousey;
STO = null;
if(bNS4 || bNS6 || bOPERA) { document.captureEvents(Event.MOUSEMOVE); }
document.onmousemove = MDMG_getmouseposition;


// Functions used by all browsers

function MDMG_getmouseposition(e){
if(bIE || bOPERA) { 
	MDMG_mousex = event.clientX;
	MDMG_mousey = event.clientY;
	}
else if(bNS6 || bNS4) {
	MDMG_mousex = e.pageX;
	MDMG_mousey = e.pageY;
	}
} // MDMG_getmouseposition()

function MDMG_HideIfOutsideRectangle()
{
	if(MDMG_mouseinrectangle()) { STO = setTimeout('MDMG_HideIfOutsideRectangle()',500); }
	else { clearTimeout(STO); MDMG_hideallmenusections(); }
} // MDMG_HideIfOutsideRectangle()

function MDMG_mouseinrectangle() {
if(MDMG_mousex >= MDMGx && MDMG_mousex <= MDMGxx && MDMG_mousey >= MDMGy && MDMG_mousey <= MDMGyy) { return true; }
else { return false; }
} // MDMG_mouseinrectangle()



// Functions to relay browser type to custom functions

function MDMG_showsection(m_section) {
clearTimeout(STO);
if(bIE) {
	MDMG_bIE_hideallmenusections();
	MDMG_bIE_showit(m_section);
	}
else if(bNS6) {
	MDMG_bNS6_hideallmenusections();
	MDMG_bNS6_showit(m_section);
	}
else if(bOPERA) {
	MDMG_bOPERA_hideallmenusections();
	MDMG_bOPERA_showit(m_section);
	}
else if(bNS4) {
	MDMG_bNS4_hideallmenusections();
	MDMG_bNS4_showit(m_section);
	}
} // MDMG_showsection()

function MDMG_hideallmenusections() {
clearTimeout(STO);
if(bIE) { MDMG_bIE_hideallmenusections(); }
else if(bNS6) { MDMG_bNS6_hideallmenusections(); }
else if(bOPERA) { MDMG_bOPERA_hideallmenusections(); }
else if(bNS4) { MDMG_bNS4_hideallmenusections(); }
} // MDMG_hideallmenusections()




// IE functions

function MDMG_bIE_hidesection(m_section) {
if(MDMG_mouseinrectangle()) { return; }
eval(MDMG_menusection[m_section] + '.style.visibility="hidden"');
MDMG_menusectionprinted[m_section] = false;
} // MDMG_bIE_hidesection()

function MDMG_bIE_hideallmenusections() {
for(i = 1; i < MDMG_menusection.length; i++) { 
	eval(MDMG_menusection[i] + '.style.visibility="hidden"');
	MDMG_menusectionprinted[i] = false;
	}
} // MDMG_bIE_hideallmenusections()

function MDMG_bIE_showit(m_section) {
	if(MDMG_menusectionprinted[m_section] == true) { return; }
	clearTimeout(STO);
	MDMG_bIE_hideallmenusections();
	MDMG_menusectionprinted[m_section] = true;
	var x = MDMG_mousex - 1;
	if(x < 0) { x = 0; }
	var y = MDMG_mousey - 1;
	if(y < 0) { y = 0; }
	if(MDMG_MovabilityOfSubMenuPositions != "static") {
		eval(MDMG_menusection[m_section] + '.style.left="' + x + '"');
		eval(MDMG_menusection[m_section] + '.style.top="' + y + '"');
		}
	eval(MDMG_menusection[m_section] + '.style.visibility="visible"');
	MDMGx = eval(MDMG_menusection[m_section] + '.style.pixelLeft');
	MDMGxx = eval(MDMG_menusection[m_section] + '.scrollWidth') + MDMGx;
	MDMGy = eval(MDMG_menusection[m_section] + '.style.pixelTop');
	MDMGyy = eval(MDMG_menusection[m_section] + '.scrollHeight') + MDMGy;
	STO = setTimeout('MDMG_HideIfOutsideRectangle()',2000);
} // MDMG_bIE_showit()



// Netscape 6 functions

function MDMG_bNS6_hidesection(m_section) {
if(MDMG_mouseinrectangle()) { return; }
document.getElementById(MDMG_menusection[m_section]).style.visibility="hidden";
MDMG_menusectionprinted[m_section] = false;
} // MDMG_bNS6_hidesection()

function MDMG_bNS6_hideallmenusections() {
for(i = 1; i < MDMG_menusection.length; i++) { 
	document.getElementById(MDMG_menusection[i]).style.visibility="hidden";
	MDMG_menusectionprinted[i] = false;
	}
} // MDMG_bNS6_hideallmenusections()

function MDMG_bNS6_showit(m_section) {
	if(MDMG_menusectionprinted[m_section] == true) { return; }
	clearTimeout(STO);
	MDMG_bNS6_hideallmenusections();
	MDMG_menusectionprinted[m_section] = true;
	var x = MDMG_mousex - 1;
	if(x < 0) { x = 0; }
	var y = MDMG_mousey - 1;
	if(y < 0) { y = 0; }
	if(MDMG_MovabilityOfSubMenuPositions != "static") {
		document.getElementById(MDMG_menusection[m_section]).style.left = x + 'px';
		document.getElementById(MDMG_menusection[m_section]).style.top = y + 'px';
		}
	document.getElementById(MDMG_menusection[m_section]).style.visibility="visible";
	var padding = 0;
	if(parseInt(document.getElementById(MDMG_menusection[m_section]).style.padding) > 0) { padding = parseInt(document.getElementById(MDMG_menusection[m_section]).style.padding) * 2; }
	MDMGx = parseInt(document.getElementById(MDMG_menusection[m_section]).style.left);
	MDMGxx = parseInt(document.getElementById(MDMG_menusection[m_section]).style.width) + MDMGx + padding;
	MDMGy = parseInt(document.getElementById(MDMG_menusection[m_section]).style.top);
	MDMGyy = parseInt(document.getElementById(MDMG_menusection[m_section]).style.height) + MDMGy + padding;
	STO = setTimeout('MDMG_HideIfOutsideRectangle()',2000);
} // MDMG_bNS6_showit()



// Opera 5 and Opera 6 functions
function MDMG_bOPERA_hidesection(m_section) {
if(MDMG_mouseinrectangle()) { return; }
document.getElementById(MDMG_menusection[m_section]).style.visibility="hidden";
MDMG_menusectionprinted[m_section] = false;
} // MDMG_bOPERA_hidesection()

function MDMG_bOPERA_hideallmenusections() {
for(i = 1; i < MDMG_menusection.length; i++) { 
	document.getElementById(MDMG_menusection[i]).style.visibility="hidden";
	MDMG_menusectionprinted[i] = false;
	}
} // MDMG_bOPERA_hideallmenusections()

function MDMG_bOPERA_showit(m_section) {
	if(MDMG_menusectionprinted[m_section] == true) { return; }
	clearTimeout(STO);
	MDMG_bOPERA_hideallmenusections();
	MDMG_menusectionprinted[m_section] = true;
	var x = MDMG_mousex - 1;
	if(x < 0) { x = 0; }
	var y = MDMG_mousey - 1;
	if(y < 0) { y = 0; }
	if(MDMG_MovabilityOfSubMenuPositions != "static") {
		document.getElementById(MDMG_menusection[m_section]).style.left = x + 'px';
		document.getElementById(MDMG_menusection[m_section]).style.top = y + 'px';
		}
	document.getElementById(MDMG_menusection[m_section]).style.visibility="visible";
	var padding = 0;
	if(parseInt(document.getElementById(MDMG_menusection[m_section]).style.padding) > 0) { padding = parseInt(document.getElementById(MDMG_menusection[m_section]).style.padding) * 2; }
	MDMGx = parseInt(document.getElementById(MDMG_menusection[m_section]).style.left);
	MDMGxx = parseInt(document.getElementById(MDMG_menusection[m_section]).style.width) + MDMGx + padding;
	MDMGy = parseInt(document.getElementById(MDMG_menusection[m_section]).style.top);
	MDMGyy = parseInt(document.getElementById(MDMG_menusection[m_section]).style.height) + MDMGy + padding;
	STO = setTimeout('MDMG_HideIfOutsideRectangle()',2000);
} // MDMG_bOPERA_showit()



// Netscape 4 functions

function MDMG_bNS4_hidesection(m_section) {
if(MDMG_mouseinrectangle()) { return; }
eval('document.' + MDMG_menusection[m_section] + '.visibility="hide"');
MDMG_menusectionprinted[m_section] = false;
} // MDMG_bNS4_hidesection()

function MDMG_bNS4_hideallmenusections() {
for(i = 1; i < MDMG_menusection.length; i++) { 
	eval('document.' + MDMG_menusection[i] + '.visibility="hide"');
	MDMG_menusectionprinted[i] = false;
	}
} // MDMG_bNS4_hideallmenusections()

function MDMG_bNS4_showit(m_section) {
	if(MDMG_menusectionprinted[m_section] == true) { return; }
	clearTimeout(STO);
	MDMG_bNS4_hideallmenusections();
	MDMG_menusectionprinted[m_section] = true;
	var x = MDMG_mousex - 1;
	if(x < 0) { x = 0; }
	var y = MDMG_mousey - 1;
	if(y < 0) { y = 0; }
	if(MDMG_MovabilityOfSubMenuPositions != "static") {
		eval('document.' + MDMG_menusection[m_section] + '.left="' + x + '"');
		eval('document.' + MDMG_menusection[m_section] + '.top="' + y + '"');
		}
	eval('document.' + MDMG_menusection[m_section] + '.visibility="show"');
	MDMGx = eval('parseInt(document.' + MDMG_menusection[m_section] + '.left)');
	MDMGxx = eval('parseInt(document.' + MDMG_menusection[m_section] + '.clip.width)') + MDMGx;
	MDMGy = eval('parseInt(document.' + MDMG_menusection[m_section] + '.top)');
	MDMGyy = eval('parseInt(document.' + MDMG_menusection[m_section] + '.clip.height)') + MDMGy;
	STO = setTimeout('MDMG_HideIfOutsideRectangle()',2000);
} // MDMG_bNS4_showit()

//-->
