// version 2001110600	change menu name stub code - uses pathname instead of hostname et al
//			  in order to get around various implementations showing or not showing port
//			  port numbers when and when not port=80
//			add delay of menu display - nowshow() called from showmenu
//			mydiv and obj now GLOBAL for nowshow() from showmenu()
//			protect hidemenus() if currmenu is NOT set (i.e. mouseout before it ever gets set

var rootdir	= "d.holmes/";	// top level of URL - used to trim pathname to get menu name stub in whatmenu()
				// NOTE that using pathname instead of hostname etc. gets around the various
				// interpretations of whether port appears in host and/or is ever null etc.
				// NOTE2 that MSIE drops leading / while NS does not
var showdelay	= 70;		// delay to ignore transients (mouseover-mouseout)
var hidedelay	= 1500;		// delay until hide after mouseout
var timeout	= 7000;		// timeout if no activity after initial top link mouseover
var mx		= -1;		// set for each menu
var my		= -1;		// set once by first menu called
var menuholdID			// timer until menu re-hidden
var currmenu	= "x";		// currently displayed menu; "x" means none are visible
var mydiv

var whoami = navigator.userAgent + '';
var obj;

// NS4 = ( document.layers) ? true : false;
// IE4 = ( document.all && !document.getElementById) ? true : false;
// IE5 = ( document.all &&  document.getElementById) ? true : false;
// NS6 = (!document.all &&  document.getElementById) ? true : false;


function hold() {
	clearTimeout(menuholdID);
}

function drop() {
	clearTimeout(menuholdID);
	menuholdID = setTimeout("hidemenus()", hidedelay);
}

function hidemenus() {

	clearTimeout(menuholdID);

	if (currmenu != "x") {
		if (!document.all && document.getElementById) {		// NS6
			myobj = "div" + currmenu;
			obj = document.getElementById(myobj);
			obj.style.visibility = "hidden";
		} else if (whoami.indexOf('MSIE')==-1) {
			obj = eval("document.div"+currmenu);			// current drop menu
			obj.visibility = 'hidden';
		} else {
			obj = eval("document.all.div"+currmenu+".style");	// current drop menu
			obj.visibility = 'hidden';
		}
	currmenu = "x";	// mark currmenu as "all hidden"
	}
}

function showmenu(event,mythis) {

	clearTimeout(menuholdID);

	var a      = mythis.pathname.indexOf(rootdir) + rootdir.length;
	var b      = a + 4;		// right index for substring cut
	mydiv = mythis.pathname.substring(a,b);
					// just the path with or without leading '/'
					//used to id the menu DIVs
					// inde (index.html/home) ;  phot (photos) ; port (portfolio) ; hard (hardware)

	if (mydiv == "") { mydiv = "home"; }

	//alert(mydiv + "\n" + mydivb + "\n"  + (rootdir.length + 2) + "\n" + b);
	//alert(mythis.pathname);
	//alert(event.type);	// "mouseover", "mouseout" etc.

	if(isNaN(mx))
	{
		mx = -1;
		my = -1;
	}

	if (mydiv != currmenu) {
		if (!document.all && document.getElementById) {		// NS6
			mx = event.pageX - 20;
			mx = ((mx < 10) ? 10 : mx);
			if (my == -1) {		// once  "my"  is set we use it for both
				my = ((event.pageY < 20) ? 20 : event.pageY);
			}

			myobj = "div" + mydiv;
			obj = document.getElementById(myobj);
			obj.style.left = mx;
			obj.style.top  = my + 10 ;
			menuholdID = setTimeout("nowshow()", showdelay);

		} else if (whoami.indexOf('MSIE')==-1) {
			mx = event.pageX - 20;
			mx = ((mx < 10) ? 10 : mx);
			if (my == -1) {		// once  "my"  is set we use it for both
				my = ((event.pageY < 20) ? 20 : event.pageY);
			}

			obj = eval("document.div"+mydiv);
			obj.pageX = mx;				// ** edit makeMenus AND css **
			obj.pageY = my + 10 ;
			menuholdID = setTimeout("nowshow()", showdelay);

		} else {
			mx = window.event.clientX - 20;
			mx = ((mx < 10) ? 10 : mx);
			if (my == -1) {		// once  "my"  is set we use it for both
				my = ((window.event.clientY < 20) ? 20 : window.event.clientY);
			}

			obj = eval("document.all.div"+mydiv+".style");
			obj.pixelLeft = mx;
			obj.pixelTop  = my + 10 ;
			menuholdID = setTimeout("nowshow()", showdelay);

		} // NS or IE

	} // mydiv != currmenu
} // showmenu

function nowshow() {
	clearTimeout(menuholdID);
	if (!document.all && document.getElementById) {			// NS6
		obj.style.visibility = 'visible';
	} else {
		obj.visibility = 'visible';
	}
	if (currmenu != "x") {
		if (!document.all && document.getElementById) {		// NS6
			myobj = "div" + currmenu
			obj = document.getElementById(myobj);
			obj.style.visibility = 'hidden';
		} else if (whoami.indexOf('MSIE')==-1) {
			obj.visibility = 'visible';
			obj = eval("document.div"+currmenu);
			obj.visibility = 'hidden';
		} else {
			obj.visibility = 'visible';
			obj = eval("document.all.div"+currmenu+".style");
			obj.visibility = 'hidden';
		}
	}
	currmenu = mydiv;
	menuholdID = setTimeout("hidemenus()", timeout);  // default timeout on drop menus if there's no movement/change
}

function makeMenus() {		// writes HTML for menu DIVs

document.write	(' <DIV id="divhome"> \
<TABLE CELLPADDING=6 class="menutbl"> \
<TR><TD> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/portfolio/work.html" TARGET="_top">portfolio :: web</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/art2/art2.php" TARGET="_top">portfolio :: code/art</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/photos/index.php" TARGET="_top">photography</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/hardware/hardware.html" TARGET="_top">hardware</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/arts/arts.html" TARGET="_top">other arts</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/tincan/camera.php" TARGET="_top">latest photo</A><BR> \
</TD></TR></TABLE> \
</DIV> \
 \
<DIV id="divphot"> \
<TABLE CELLPADDING=6 class="menutbl"> \
<TR><TD> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/photos/gallery1.html" TARGET="_top">OnLine PHOTO GALLERY</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/photos/coolpix_e990/e990_usb_cable.html" TARGET="_top">Nikon E990 dual USB/Serial cable</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/photos/coolpix_e990/firmware-1.html" TARGET="_top">Nikon E990 Firmware Wishlist</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/photos/sharpening.html" TARGET="_top">Sharpening Level Comparison</A><BR> \
</TD></TR></TABLE> \
</DIV> \
 \
<DIV id="divport"> \
<TABLE CELLPADDING=6 class="menutbl"> \
<TR><TD> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/portfolio/work-parksc.html" TARGET="_top">Parks Canada</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/portfolio/work-cp.html" TARGET="_top">CanadianParks.com</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/portfolio/work-leitch.html" TARGET="_top">Leitch / Callisto</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/portfolio/work-geagri.html" TARGET="_top">Le Groupe G&Eacute;AGRI</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/portfolio/work-freshc.html" TARGET="_top">Fresh Creations Ltd.</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/portfolio/work-itemcards.html" TARGET="_top">project resource site</A><BR> \
</TD></TR></TABLE> \
</DIV> \
 \
<DIV id="divart2"> \
<TABLE CELLPADDING=6 class="menutbl"> \
<TR><TD> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/art2/work-dropmenu.php" TARGET="_top">lightweight menus</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/art2/work-5x7glyphs.php" TARGET="_top">5x7 font</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/art2/work-crop.php" TARGET="_top">croptool</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/photos/work-photo.html" TARGET="_top">photo gallery engine</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/artwork/artwork_1.php" TARGET="_top">artwork - 2D/3D</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/ming/index.php" TARGET="_top">ming play</A><BR> \
</TD></TR></TABLE> \
</DIV> \
 \
<DIV id="divhard"> \
<TABLE CELLPADDING=6 class="menutbl"> \
<TR><TD> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/hardware/levelshift.html" TARGET="_top">Bi-directional level-shift with MOSFETs</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/hardware/ata_interface_1.html" TARGET="_top">ATA (IDE) interfacing</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/photos/coolpix_e990/e990_usb_cable.html" TARGET="_top">Nikon E990 dual USB/Serial cable (photo section)</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/hardware/newton_DIN8.html" TARGET="_top">Newton MP2100 internal DIN 8 hack</A><BR> \
<A class="menulink" onMouseOver="hold();" onMouseOut="drop();" \
	HREF="/d.holmes/hardware/9500_battery/index.html" TARGET="_top">Macintosh 9500 lithium battery</A><BR> \
</TD></TR></TABLE> \
</DIV> ');

}

