// menu.js

var popTimer = 0;

var litNow = new Array();
var menu = new Array();

// Support menu
menu[0] = new Array();
menu[0][0] = new Menu(110, 129, 155, 20, 0, 'navlink-border', 'navlink-menu', 'navlink-hilite');
menu[0][1] = new Item('Submit Trouble ticket', 'http://www.tek911.com/tt.shtml');
menu[0][2] = new Item('Networking', './nw.shtml');
menu[0][3] = new Item('DSL', './dsl.shtml');
menu[0][4] = new Item('Check Web Mail', 'http://alrnet.com/wm/index.htm');
menu[0][5] = new Item('Admin', 'http://alrnet.com/cpanel/');


// Services menu
menu[1] = new Array();
menu[1][0] = new Menu(266, 129, 170, 20, 0, 'navlink-border', 'navlink-menu', 'navlink-hilite');
menu[1][1] = new Item('Consulting', 'http://www.tek911.com');
menu[1][2] = new Item('Online Application', 'http://www.tek911.com/application.shtml');
menu[1][3] = new Item('Request More Info', './request.shtml');
menu[1][4] = new Item('Web Hosting', './webhosting.shtml');
menu[1][5] = new Item('Email Hosting', './webhosting.shtml');
menu[1][6] = new Item('Anti Spam', './aspam.shtml');
menu[1][7] = new Item('Domain Name Registration', './registration.shtml');


// Legal menu
menu[2] = new Array();
menu[2][0] = new Menu(435, 129, 193, 20, 0, 'navlink-border', 'navlink-menu', 'navlink-hilite');
menu[2][1] = new Item('Web Site Hosting', 'http://www.tek911.com/legal-hosting.shtml');
menu[2][2] = new Item('Copyright Infringement', 'http://www.tek911.com/legal-copyright.shtml');
menu[2][3] = new Item('Acceptable Use', 'http://www.tek911.com/legal-acceptuse.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";
	}
}

