// menu.js

var popTimer = 0;

var litNow = new Array();
var menu = new Array();

// Services menu
menu[0] = new Array();
menu[0][0] = new Menu(86, 144, 218, 21, 0, 'navlink-border', 'navlink-menu', 'navlink-hilite');
menu[0][1] = new Item('Hazardous Materials Remediation', './services.shtml');
menu[0][2] = new Item('Asbestos Abatement', './abatement.shtml');
menu[0][3] = new Item('Lead, Paint Abatement', './lead.shtml');
menu[0][4] = new Item('Mold Remediation', './mold.shtml');
menu[0][5] = new Item('Contaminated Soils', './soils.shtml');
menu[0][6] = new Item('Demolition/De-commissioning', './demolition.shtml');
menu[0][7] = new Item('Waste Management', './waste.shtml');
menu[0][8] = new Item('Facility Decontamination', './decontamination.shtml');
menu[0][9] = new Item('Lab Packing', './labpacking.shtml');
menu[0][10] = new Item('PCB Remediation', './pcb.shtml');
menu[0][11] = new Item('Hazardous Waste Hauling', './hauling.shtml');
menu[0][12] = new Item('Underground Storage Tanks', './underground.shtml');
menu[0][13] = new Item('Vapor Extraction/Bioventing', './vapor.shtml');
menu[0][14] = new Item('Insulation', './insulation.shtml');



// Projects menu
menu[1] = new Array();
menu[1][0] = new Menu(305, 144, 214, 21, 0, 'navlink-border', 'navlink-menu', 'navlink-hilite');
menu[1][1] = new Item('Project Management', './projmanagement.shtml');






// Company info menu
menu[2] = new Array();
menu[2][0] = new Menu(518, 144, 213, 21, 0, 'navlink-border', 'navlink-menu', 'navlink-hilite');
menu[2][1] = new Item('Corp. Philosophy', './philosophy.shtml');
menu[2][2] = new Item('Corp. Credentials', './credentials.shtml');
menu[2][3] = new Item('Project Management', './projmanagement.shtml');
menu[2][4] = new Item('Employment', './employment.shtml');
menu[2][5] = new Item('Contact Us', './contact.shtml');

// Links menu
menu[3] = new Array();
menu[3][0] = new Menu(732, 144, 98, 21, 0, 'navlink-border', 'navlink-menu', 'navlink-hilite');
menu[3][1] = new Item('Resources', './resources.shtml');



function writeNavMenus()
{
	if (document.getElementById==false) return;
	
	for (currMenu = 0; currMenu < menu.length; currMenu++) with (menu[currMenu][0]) {

		var str = '';
		var itemX = 0;
		var itemY = 0;
		var menuID = 'menu' + currMenu;

		// The width and height of the menu
		var w = menu[currMenu][0].width;
		var h =  menu[currMenu][0].height;

		var spacing = menu[currMenu][0].spacing;

		for (currItem = 1; currItem < menu[currMenu].length; currItem++) with (menu[currMenu][currItem]) {

			var itemID = 'menu' + currMenu + 'item' + currItem;


			// Create a div text string with appropriate styles/properties.
			str += '<div id="' + itemID + '" style="position: absolute; left: ' + itemX + '; top: ' + itemY + '; width: ' + w + '; height: ' + h + ';">';

			// Add contents of item
			str += '<table width="' + w + '" border="0" cellspacing="0" cellpadding="0"><tr>';
			str += '<td class="'+ menu[currMenu][0].cellClass +'" onclick="(location.href=\'' + menu[currMenu][currItem].href + '\')" height="' + h + '"';
			str += 'onmouseover="(this.className=\'' + menu[currMenu][0].hiliteClass + '\'); popOver(' + currMenu + ')" onmouseout="(this.className=\'' + menu[currMenu][0].cellClass + '\'); popOut(' + currMenu + ')"'
			str += '>';
			str += '<a class="' + menu[currMenu][0].linkClass + '" href="' + menu[currMenu][currItem].href + '">' + menu[currMenu][currItem].text + '</a>';
			str += '</td></tr></table></div>';
			
			itemY += h + spacing;
		}
		
		var newDiv = document.createElement('div');
		document.getElementsByTagName('body').item(0).appendChild(newDiv);
		newDiv.id = menuID;
		newDiv.innerHTML = str;
		newDiv.style.position = 'absolute';
		newDiv.style.left = menu[currMenu][0].x;
		newDiv.style.top = menu[currMenu][0].y;
		newDiv.style.display="none";

	}
}


function Menu(x, y, width, height, spacing, cellClass, linkClass, hiliteClass) {

	// Position and size settings.
	this.x = x;
	this.y = y;
	this.width = width; //width of menu
	this.height = height; //height of each item in menu
	this.spacing = spacing; //the space between each item in menu

	// The stylesheet class used for item borders and the text within items.
	this.cellClass = cellClass;
	this.linkClass = linkClass;
	this.hiliteClass = hiliteClass;
}


function Item(text, href) {
	this.text = text;
	this.href = href;
}


function popOver(menuNum) {
	
	clearTimeout(popTimer);
	hideAllBut(menuNum);
	
	var targetID;
	targetID = "menu" + menuNum;
	targetElement = document.getElementById(targetID);
	targetElement.style.display="";
}



function popOut(menuNum) {
	popTimer = setTimeout('hideAll()', 200);
}


function hideAllBut(menuNum) {
	var targetID;
	for (count = 0; count < menu.length; count++) {
		if (count != menuNum) {
			targetID = "menu" + count;
			targetElement = document.getElementById(targetID);
			targetElement.style.display="none";
		}
	}
}


function hideAll() {
	var targetID;
	for (count = 0; count < menu.length; count++) {
		targetID = "menu" + count;
		targetElement = document.getElementById(targetID);
		targetElement.style.display="none";
	}
}

