//  all code copyright by Phil Barnard; phil@perite.com//----------------------------/ menu object and methods : belong in a libraryfunction menuObj(){	this.menubar;	this.menus;	this.headers = new Array();	this.footers = new Array();	this.menuitems = new Array();		// methods	this.addMenu = addMenu;	this.addItem = addItem;	this.load = load;}function load(){	var f = ""; h = "<table class=menubar cellpadding=0 cellspacing=0 style='cursor:pointer'><tr>";	this.menubar = document.getElementById("menubar"); // the menubar container div with ID "menubar"	this.menus = document.getElementById("menus"); // the menu container div with ID "menus"	// create the menu bar and menus	for(var i in this.headers) {		h += this.headers[i];		f += this.footers[i][1];	}	this.menubar.innerHTML = h + "</tr></table>"	this.menus.innerHTML = f;	// create the menu items	for(var i in this.menuitems){		var id = this.menuitems[i][0]; var val = this.menuitems[i][1];		document.getElementById(id).innerHTML += "<div class=menuitem style='width:100%' onmouseover=rollin(this) onmouseout=rollout(this) onmouseup=select("+i+")>" + val + "</div>";	}}function addMenu(id,width,name){	this.headers[this.headers.length] = "<td class=menutop onmouseover=showmenu(this,\'" + id + "\') onmouseout=rollout(this)>" + name + "</td>";	this.footers[this.footers.length] = new Array(id,"<div class=menu id=" + id + " style=\'width:" + width + "\'></div>");}function addItem(id,name,handler){	this.menuitems[this.menuitems.length] = new Array(id,name,handler);}//----------------------------/ menu action handlersvar menuBar = new menuObj();var currentMenu;var timer;var retractTime = 500; // milliseconds before menu auto-retractsfunction showmenu(my,menuid){	if(currentMenu) { clearTimeout(timer); currentMenu.style.visibility = "hidden"; }	currentMenu = document.getElementById(menuid);		// position the menu	var t = 1 + parseInt(my.offsetTop) + parseInt(my.offsetHeight) + parseInt(document.body.topMargin ? document.body.topMargin : 0);	var l = parseInt(my.offsetLeft) + parseInt(document.body.leftMargin ? document.body.leftMargin : 0);	currentMenu.style.top = t + (IE ? 1:1); //8	currentMenu.style.left = l + (IE ? 5:1); //8		// colour the menuheader and reveal the menu	my.style.backgroundColor = menuhilite;	currentMenu.style.visibility = "visible";}function hidemenu(){	currentMenu.style.visibility = "hidden";}function rollin(menuitem){	clearTimeout(timer);	menuitem.style.backgroundColor = menuhilite;}function rollout(menuitem){	menuitem.style.backgroundColor = menucolor;	timer = setTimeout("hidemenu()",retractTime);}function select(item){	hidemenu();	eval(menuBar.menuitems[item][2]);}//-----------------------------/ define and add the menus in this pagevar menucolor = "#DCDCDC";  // Gainsboro  // menubackground, same as cssMenuvar menuhilite = "Silver";  // DarkGray// this function defines the menubar, menus, menuitems and select handlersfunction initMenus(){	if(menuBar.menubar) return; // menus already loaded		// first add the menus to the menubar (id,width,description)	menuBar.addMenu("hom","100","Home");	menuBar.addMenu("iwa","120","Work");	menuBar.addMenu("fam","155","Fun");	menuBar.addMenu("con","130","Contact");		// next add the menu items to the menus (id,description,selecthandler)	menuBar.addItem("hom","Go perite","go('perite')");		menuBar.addItem("iwa","iWave","go('iwave')");	menuBar.addItem("iwa","OnPix","go('onpix')");	menuBar.addItem("iwa","Redleg Media","go('simon')");	menuBar.addItem("iwa","Perite","go('oldperite')");	menuBar.addItem("fam","Truck construction","go('truck')");	menuBar.addItem("fam","2005 Oz trip photos","go('2005')");	menuBar.addItem("fam","2007 Oz trip photos","go('2007')");	menuBar.addItem("fam","2009 Oz trip photos","go('2009')");	menuBar.addItem("fam","Ham radio","go('vk7jj')");	// menuBar.addItem("fam","VK7YBI","go('vk7ybi')");	// menuBar.addItem("fam","Family","go('family')");			menuBar.addItem("con","Contact info","go('contact')");	menuBar.addItem("con","Home location","go('loc')");	menuBar.addItem("con","Find us mobile...","go('aprsfi')");	// menuBar.addItem("con","Track the truck...","go('aprs-truck')");	// menuBar.addItem("con","Track the van...","go('aprs-van')");		// finally load the menubar and (invisible) menus	menuBar.load();}//--------------------/ go handler// calculate the root so that our page references still work when inside subsitesvar root = location.protocol + "//" + location.host + "/";var pagebase = location.href.substring(0,location.href.lastIndexOf("/")+1);  // not used yetfunction go(where){	if(location.host == "localhost") root = "";	// alert(root + "default.htm"); return;	switch(where){			case "perite" :			// window.location = "default.asp";			window.location = root + "";			break;				// work stuff menu		case "iwave" :  // use the old web site			window.open(root + "iwave/default.htm","iWave");			break;		case "onpix" :			window.location = root + "perite/onpix.htm";			break;		case "simon" :			window.open(root + "redleg/default.htm");			break;		case "oldperite" :			window.location = root + "perite/perite.htm";			break;					// personal stuff menu		case "family" :			// window.location = root + "family.htm";			window.location = root + "perite/family.htm";			break;					case "2005" :			window.location = root + "perite/2005-1.htm";			break;					case "2007" :			window.location = root + "perite/2007-1.htm";			break;					case "2009" :			window.location = root + "perite/2009-1.htm";			break;					case "truck" :			window.location = root + "perite/truck-1.htm";			// window.location = root + "soon.htm";			break;					case "vk7jj" :			window.location = root + "vk7jj/default.htm";			break;					case "vk7ybi" :			window.location = root + "vk7ybi/default.htm";			break;					// contact menu		case "contact" :			window.location = root + "perite/contact.htm";			break;		case "loc" :			window.location = root + "perite/contact-more.htm";			break;		case "aprs-truck" :			window.location = root + "perite/aprs-truck.htm";			break;		case "aprs-van" :			window.location = root + "perite/aprs-van.htm";			break;		case "aprsfi" :			// window.open("http://www.findu.com/cgi-bin/find.cgi?call=vk7jj-9&units=metric");			window.open(root + "vk7jj/aprs_b.html");			break;							}}