// copyright Paul Appleby, Toronto, ON, Canada

var menuBG="#cccccc";
var menucount=0;//total number of menus.
var allmenus=new Array();// This contains the names of all submenu IDs for use in killAll() function.
var menu=new Array();
var parentscount=0;//total number of menus that have parents.
var parents=new Array();//A 1 dimensional array added to after each menu is converted to submenus if a menu has a parent.
						//At the same time each element that has a parent will add the parent's name to the array parents[thisid][menu parent] array.
var num_of_items;// The number of items in a submenu. We need this to calculate the height of each DIV or LAYER.
var grandads=new Array();//The array of each child elements grandfathers, great grandfathers, etc.

//The menu properties further below afer the following functions are elements in a 1 dimensional array.

//This function creates the menus by writing the elements of each menu array
//in its proper place as we create the DIVs, LAYERs and TABLEs.
//Each element in the menu array was given its value in the addmenu() calls below.	

function addheader(){
	if (document.getElementById  || document.all){
		document.write(''

		+'<div id="'+menu[0]+'" style="position:absolute; left:'+(menu[1])+';top:'+menu[2]+';width:'+(menu[3]+2)+';height:'+(menu[4]+2)+';background-color:'+menu[5]+';visibility:'+menu[9]+';">'
			+'<table cellpadding="0" cellspacing="1" border="0">'
				+'<tr><td id="'+menu[0]+'cell" align="center" class="nav" width="'+menu[3]+'" height="'+menu[4]+'" bgcolor=\''+menu[6]+'\' onmouseover="className=\'navover\';killAll();show(\''+menu[10]+'\');bgColor=\''+menu[7]+'\';" onmouseout="className=\'nav\';hide(\''+menu[10]+'\');bgColor=\''+menu[8]+'\';" align="left" valign="middle" onclick="clickme(\''+menu[12]+'\',\''+menu[0]+'cell\',\''+menu[8]+'\')">'+menu[11]+'</td></tr>'
			+'</table>'
		+'</div>'
		+'');			
	}
										
	if (document.layers){
		document.write(''
													
		+'<layer id="'+menu[0]+'" left="'+(menu[1])+'" top="'+menu[2]+'" width="'+(menu[3]+2)+'" height="'+(menu[4]+2)+'" bgcolor="'+menu[5]+'" visibility="'+menu[9]+'">'
			+'<layer id="'+menu[0]+'over" left="1" top="1" bgcolor="'+menu[7]+'" onmouseover="killAll();show(\''+menu[10]+'\'); ns4_href=\''+menu[12]+'\'; this.captureEvents(Event.CLICK); this.onClick=clickit;" onmouseout="hide(\''+menu[10]+'\');movedown(\''+menu[0]+'\',\''+menu[0]+'\');">'
				+'<table cellpadding="0" cellspacing="0" border="0"><tr><td class="navover" width="'+menu[3]+'" height="'+menu[4]+'" align="left" valign="middle">'+menu[11]+'</td></tr></table>'
			+'</layer>'
			+'<layer id="'+menu[0]+'out" left="1" top="1" bgcolor="'+menu[6]+'" onmouseover="killAll();show(\''+menu[10]+'\');moveup(\''+menu[0]+'\',\''+menu[0]+'\');" onmouseout="hide(\''+menu[10]+'\');">'
				+'<table cellpadding="0" cellspacing="0" border="0"><tr><td class="nav" width="'+menu[3]+'" height="'+menu[4]+'" align="left" valign="middle" onclick="'+menu[12]+';">'+menu[11]+'</td></tr></table>'
			+'</layer>'
		+'</layer>'
		+'');
	}
}

function addsub(){
										
	//First we need to calculate the height needed for the DIV or LAYER containing the border color.
	num_of_items=(menu.length-11)/3;//Each item or subtitle in the submenu array is accompanied by a child element and a link element, so we divide by 3.
	//The formula below for NS6 and IE is based on various empirical results. E.g. 2 - 20's needed 43px and 4 - 20's needed 85!
	//It's actually based on the (num of items * item height) + (cellspacing of 1px * (num of items -1)) + 2px.
	if (document.getElementById  || document.all){ht=( (menu[5]*num_of_items) + (num_of_items+1) ) }
										
	//If the sub has a parent we will need to use it in the menu's main div or layer tag.
	if (menu[1]!=null){
		//alert(menu[1]);
		showparent="show(\'"+menu[1]+"\');";
		//killparent="killParent(\'"+menu[1]+"\');";
		killparent="killParent(\'"+menu[0]+"\');";
	}else{
		showparent="";
		killparent="";
	}
										
	if (document.getElementById  || document.all){
		document.write(''
		+'<div id="'+menu[0]+'" style="position:absolute;left:'+(menu[2])+';top:'+menu[3]+';width:'+(menu[4]+2)+';height:'+ht+';background-color:'+menu[6]+';visibility:'+menu[10]+';" onmouseover="show(\''+menu[0]+'\');'+showparent+'" onmouseout="hide(\''+menu[0]+'\');'+killparent+'">'
			+'<table cellpadding="0" cellspacing="1" border="0">'
		+'');
											
		for (i=11; i<menu.length; i=i+3){
			//Add here the if menu[child]=="" then var child="" else child=show(menu[child)
			if (menu[i+1]==null){
				childshow="";
				childhide="";
				//alert (menu[i]+" has no child");//This works.
			}else{
				childshow="show(\'"+menu[i+1]+"\');";
				childhide="hidechild(\'"+menu[i+1]+"\');";
			}
			document.write('<tr><td id=\''+menu[0]+i+'\' align="center" class="nav" width="'+menu[4]+'" height="'+menu[5]+'" bgcolor=\''+menu[7]+'\' onmouseover="className=\'navover\';bgColor=\''+menu[8]+'\';'+childshow+'"; onmouseout="className=\'nav\';bgColor=\''+menu[9]+'\';'+childhide+'"; align="left" valign="middle" onclick="clickme(\''+menu[i+2]+'\',\''+menu[0]+i+'\',\''+menu[9]+'\');">'+menu[i]+'</td></tr>');
		}
		document.write(''		
			+'</table>'
		+'</div>'
		+'');
	}
										
	if (document.layers){
		ht=(menu[5]*num_of_items)+2;
		document.write(''
		+'<layer id="'+menu[0]+'" left="'+(menu[2])+'" top="'+menu[3]+'" width="'+(menu[4]+2)+'" height="'+ht+'" bgcolor="'+menu[6]+'" visibility="'+menu[10]+'" onmouseover="show(\''+menu[0]+'\');'+showparent+'" onmouseout="hide(\''+menu[0]+'\');'+killparent+'killAll();">'
		+'');
		var item_top=1;
			for (i=11; i<menu.length; i=i+3){
				if (menu[i+1]==null){
					childshow="";
					childhide="";
				}else{
					childshow="show(\'"+menu[i+1]+"\');";
					childhide="hidechild(\'"+menu[i+1]+"\');";
				}
													
				//This next layer is for NS4 which cannot dynamically access the font colour.
				document.write(''		
				+'<layer id="'+menu[0]+i+'over" left="1" top="'+item_top+'" bgcolor="'+menu[8]+'" onmouseover="'+childshow+'; ns4_href=\''+menu[i+2]+'\'; this.captureEvents(Event.CLICK); this.onClick=clickit;" onmouseout="'+childhide+';movedown(\''+menu[0]+'\',\''+menu[0]+i+'\');">'
					+'<table cellpadding="0" cellspacing="0" border="0"><tr><td class="navover" width="'+menu[4]+'" height="'+menu[5]+'" align="left" valign="middle">'+menu[i]
				+'');
				if (i!=menu.length-3){//The last item does not get a <br> and <hr>.
					document.write(''	
					+'<br><hr noshade width="'+menu[4]+'">'
					+'');
				}
				document.write(''
				+'</td></tr></table>'
				+'</layer>'
				+'');
													
				document.write(''		
				+'<layer id="'+menu[0]+i+'out" left="1" top="'+item_top+'" bgcolor="'+menu[7]+'" onmouseover="'+childshow+';moveup(\''+menu[0]+'\',\''+menu[0]+i+'\');" onmouseout="'+childhide+'">'
					+'<table cellpadding="0" cellspacing="0" border="0"><tr><td class="nav" width="'+menu[4]+'" height="'+menu[5]+'" align="left" valign="middle">'+menu[i]
				+'');
				if (i!=menu.length-3){//The last item does not get a <br> and <hr>.
					document.write(''	
					+'<br><hr noshade width="'+menu[4]+'">'
					+'');
				}
				document.write(''
				+'</td></tr></table>'
				+'</layer>'
				+'');
				item_top=item_top+menu[5];
			}
		document.write(''	
		+'</layer>'
		+'');
	}
	allmenus[menucount]=menu[0];// Need this array for killAll() function.
	menucount++;// Need this for the line above.
	if (menu[1]){
		parents[parentscount]=menu[0];//This is an array of children's names and allows us to get the id's of sub menus that have parents.
		thisid=menu[0];
		parents[thisid]=new Array();//This menu is an associative array of the menus' parents.
		parents[thisid][0] = menu[1];//This element holds this menu's parent's name.
		parentscount++;
	}	
}	

addheader(menu=[			
"services_head",		//id #0
12,				//left position #1
132,					//top position #2
80,					//width #3
24,					//height of EACH item #4
"#7f7c18",			//border color #5
"#9e9a50",			//menuBG color #6
"#FFFFFF",			//menuBG mouseover color #7
"#9e9a50",			//menuBG mouseout color #8
"visible",			//visibility #9
"services",			//submenu child id #10
"Services","#"		//title #11 and its link #12 (use "#" if no link used.)
]);

addsub(menu=[			
"services",			//id #0
,					//parent id #1 also in quotes.
12,				//left position #2
162,					//top position #3
150,					//width #4
24,					//height of EACH item #5
"#7f7c18",			//border color #6
"#9e9a50",			//menuBG color #7
"#FFFFFF",			//menuBG mouseover color #8
"#9e9a50",			//menuBG mouseout color #9
"hidden",			//visibility #10
"Chair Massage<img src='/images/spacer_transp.gif' width='40' height='1' border='0'>",,"chair_massage.php",		//item 1 #11, its child #12 and link #13 (use "#" if no link used.)
"Wellness Fairs<img src='/images/spacer_transp.gif' width='38' height='1' border='0'>",,"wellness_fairs.php",		//item 2 #14, its child #15 and its link #16 (use "#" if no link used.)
"Workplace Wellness<img src='/images/spacer_transp.gif' width='1' height='1' border='0'>",,"workplace_wellness.php"		//item 2 #14, its child #15 and its link #16 (use "#" if no link used.)
]);


addheader(menu=[			
"venues_head",		//id #0
96,				//left position #1
132,					//top position #2
80,					//width #3
24,					//height of EACH item #4
"#7f7c18",			//border color #5
"#9e9a50",			//menuBG color #6
"#FFFFFF",			//menuBG mouseover color #7
"#9e9a50",			//menuBG mouseout color #8
"visible",			//visibility #9
"venues",			//submenu child id #10
"Venues","#"		//title #11 and link #12 (use "#" if no link used.)
]);

addsub(menu=[			
"venues",			//id #0 in quotes.
,					//parent id #1 also in quotes.
96,				//left position #2
162,					//top position #3
200,					//width #4
24,					//height of EACH item #5
"#7f7c18",			//border color #6
"#9e9a50",			//menuBG color #7
"#FFFFFF",			//menuBG mouseover color #8
"#9e9a50",			//menuBG mouseout color #9
"hidden",			//visibility #10
"Work Place Massage<img src='/images/spacer_transp.gif' width='50' height='1' border='0'>",,"workplace_massage.php",		//item 1 # 11, its child #12 and its link #13 (use "#" if no link used.)
"Trade Shows & Conferences<img src='/images/spacer_transp.gif' width='1' height='1' border='0'>",,"trade_shows.php",		//item 2 #14, its child #15 and its link #16 (use "#" if no link used.)
"Golf Tournaments<img src='/images/spacer_transp.gif' width='65' height='1' border='0'>",,"golf.php"		//item 1 # 17, its child #18 and its link #16 (use "#" if no link used.)
]);

addheader(menu=[			
"request_quote_head",		//id #0
180,				//left position #1
132,					//top position #2
130,					//width #3
24,					//height of EACH item #4
"#7f7c18",			//border color #5
"#9e9a50",			//menuBG color #6
"#FFFFFF",			//menuBG mouseover color #7
"#9e9a50",			//menuBG mouseout color #8
"visible",			//visibility #9
"",			//submenu child id #10
"Request a Quote","request_quote.php"		//title #11 and its link #12 (use "#" if no link used.)
]);

addheader(menu=[			
"pricing_head",		//id #0
314,				//left position #1
132,					//top position #2
80,					//width #3
24,					//height of EACH item #4
"#7f7c18",			//border color #5
"#9e9a50",			//menuBG color #6
"#FFFFFF",			//menuBG mouseover color #7
"#9e9a50",			//menuBG mouseout color #8
"visible",			//visibility #9
"",			//submenu child id #10
"Pricing","pricing.php"		//title #11 and its link #12 (use "#" if no link used.)
]);

addheader(menu=[			
"faqs_head",		//id #0
398,				//left position #1
132,					//top position #2
80,					//width #3
24,					//height of EACH item #4
"#7f7c18",			//border color #5
"#9e9a50",			//menuBG color #6
"#FFFFFF",			//menuBG mouseover color #7
"#9e9a50",			//menuBG mouseout color #8
"visible",			//visibility #9
"",			//submenu child id #10
"FAQs","faqs.php"		//title #11 and its link #12 (use "#" if no link used.)
]);

addheader(menu=[			
"about_us_head",		//id #0
482,				//left position #1
132,					//top position #2
80,					//width #3
24,					//height of EACH item #4
"#7f7c18",			//border color #5
"#9e9a50",			//menuBG color #6
"#FFFFFF",			//menuBG mouseover color #7
"#9e9a50",			//menuBG mouseout color #8
"visible",			//visibility #9
"",			//submenu child id #10
"About Us","about_us.php"		//title #11 and its link #12 (use "#" if no link used.)
]);

addheader(menu=[			
"contact_us_head",		//id #0
566,				//left position #1
132,					//top position #2
80,					//width #3
24,					//height of EACH item #4
"#7f7c18",			//border color #5
"#9e9a50",			//menuBG color #6
"#FFFFFF",			//menuBG mouseover color #7
"#9e9a50",			//menuBG mouseout color #8
"visible",			//visibility #9
"",			//submenu child id #10
"Contact Us","contact_us.php"		//title #11 and its link #12 (use "#" if no link used.)
]);


addheader(menu=[			
"ee_facts_head",		//id #0
650,				//left position #1
132,					//top position #2
80,					//width #3
24,					//height of EACH item #4
"#7f7c18",			//border color #5
"#9e9a50",			//menuBG color #6
"#FFFFFF",			//menuBG mouseover color #7
"#9e9a50",			//menuBG mouseout color #8
"visible",			//visibility #9
"",			//submenu child id #10
"EE Facts","ee_facts.php"		//title #11 and its link #12 (use "#" if no link used.)
]);
addheader(menu=[			
"products_head",		//id #0
734,				//left position #1
132,					//top position #2
80,					//width #3
24,					//height of EACH item #4
"#7f7c18",			//border color #5
"#9e9a50",			//menuBG color #6
"#FFFFFF",			//menuBG mouseover color #7
"#9e9a50",			//menuBG mouseout color #8
"visible",			//visibility #9
"",			//submenu child id #10
"Products","products.php"		//title #11 and its link #12 (use "#" if no link used.)
]);
addheader(menu=[			
"news_head",		//id #0
818,				//left position #1
132,					//top position #2
125,					//width #3
24,					//height of EACH item #4
"#7f7c18",			//border color #5
"#9e9a50",			//menuBG color #6
"#FFFFFF",			//menuBG mouseover color #7
"#9e9a50",			//menuBG mouseout color #8
"visible",			//visibility #9
"",			//submenu child id #10
"News & Resources","news_and_resources.php"		//title #11 and its link #12 (use "#" if no link used.)
]);

