var state = 'hidden';
var disappeardelay=0;  //menu disappear speed onMouseout (in miliseconds)
var outputText = '';
var delayhide;
var delayhide2;

var absoluteLocation = '/';
var htmlLocation = '/';
var justLeftSub = 'no';
var inSub = 'no';
var showingSub = 'no';
var activeSubMenu = 0;

var page_mainMenu = 0;
var page_subMenu = 0;
var page_home = 'home';

var menu1List = new Array()
menu1List[0] = new menuItem(absoluteLocation+'daily.php', 'Daily Rental', 'no');
menu1List[1] = new menuItem(absoluteLocation+'contractServices.php', 'Contract Traffic Control', 'no');
menu1List[2] = new menuItem(absoluteLocation+'striping.php', 'Striping', 'no');
menu1List[3] = new menuItem(absoluteLocation+'sgInstallation.php', 'Sign & Guardrail Installation', 'no');
menu1List[4] = new menuItem(absoluteLocation+'csupply.php', 'Contractor Supply & Equipment Sales', 'no');
menu1List[5] = new menuItem(absoluteLocation+'specialtyServices.php', 'Specialty Services', 'yes');

var menu2List = new Array()
menu2List[0] = new menuItem(absoluteLocation+'about.php', 'About Us', 'no');
menu2List[1] = new menuItem(absoluteLocation+'management.php', 'Management Team', 'no');
menu2List[2] = new menuItem(absoluteLocation+'careers.php', 'Careers', 'no');
menu2List[3] = new menuItem(absoluteLocation+'news.php', 'News & Events', 'yes');

var menu3List = new Array()
menu3List[0] = new menuItem(absoluteLocation+'contactUsForm/contactUs.php', 'Contact Us', 'no');
menu3List[1] = new menuItem(absoluteLocation+'branchLocator/branchLocator.php', 'Locate a Branch', 'yes');

var homeList = new Array()
homeList[0] = new menuItem(absoluteLocation+'index.php', 'Highway Technologies Home', 'no');
homeList[0] = new menuItem(absoluteLocation+'terms.php', 'Terms of Use', 'no');
homeList[1] = new menuItem(absoluteLocation+'map.php', 'Site Map', 'yes');

var pageMenus = new Array()
pageMenus[0] = new menuObject(homeList, 'home', absoluteLocation+'index.php');
pageMenus[1] = new menuObject(menu1List, 'prodServ', absoluteLocation+'daily.php');
pageMenus[2] = new menuObject(menu2List, 'about', absoluteLocation+'about.php');
pageMenus[3] = new menuObject(menu3List, 'contact', absoluteLocation+'contactUsForm/contactUs.php');

var offFunctions = new Array()
offFunctions[0] = 'delay_hideAll';
offFunctions[1] = 'delay_showProdServ';
offFunctions[2] = 'delay_showAbout';
offFunctions[3] = 'delay_showContact';

function writeMenus(mainMenu, subMenu, home){
	page_mainMenu = mainMenu;
	page_subMenu = subMenu;
	page_home = home;
	
	document.write('<div id="MenuDiv" onmouseover="inSub=\'yes\'; enterSubMenu();"'+
			'onmouseout="inSub=\'no\'; showingSub=\'no\'; showHomeMenu();" style="background: #ffffff;">');

	for (i=1; i<pageMenus.length; i++) {
		pageMenus[i].offFunc = offFunctions[mainMenu];
		
		if (i==mainMenu) {
			pageMenus[i].visibility = 'visible';
			pageMenus[i].over = '-over';
		}
		if (home == 'home'){
			pageMenus[i].offFunc = 'delay_hideAll';
		}
		document.write(pageMenus[i].writeDivText() + '<p class="globalMenu2paragraph">');

		for (j=0; j<pageMenus[i].menuItems.length; j++) {
		  if (i==mainMenu & j==subMenu & home!='home') pageMenus[i].menuItems[j].active = '_active'
		  document.write(pageMenus[i].menuItems[j].writeItemHTML())
		} // for j
		document.write("</div>");
	} // for i

	document.write('</div>');
	
	document.write('<div id="globalMenu1">');
	for (i=1; i<pageMenus.length; i++) {
		document.write(pageMenus[i].writeLinkText(i));
		if (i<(pageMenus.length-1)) document.write('<img src="'+absoluteLocation+'images/menu_middleBar.gif">');
	} // for i
	document.write('<img src="'+absoluteLocation+'images/menu_endBar.gif"></div>');
	if (home == 'home') hideAll();
}
function writeHeader(){
document.write('<a href="'+absoluteLocation+'index.php"><div id="logo"></div></a>' +
		'');	
}
function writeKnowMorePanel(){
document.write('<a href="'+absoluteLocation+'contactUsForm/contactUs.php" style="text-decoration:none">' +
			'<div id="interiorMainPanel2">' +
				'<div id="mainPanelBG_icon" style="background: url(\''+htmlLocation+'images/mainPanelBG_icon_knowMore.gif\');"></div>' +
				'<div id="mainPanelBG_knowMore"></div>' +
				'<div id="mainPanelText">We are looking forward to hearing from you.</div>' +
				'<div id="contactUs"></div>' +
			'</div>' +
		'</a>');
}
function writeLocatorPanel(){
document.write('<a href="'+absoluteLocation+'branchLocator/branchLocator.php" style="text-decoration:none">' +
			'<div id="homePanel" style="position: relative; background: url(\''+htmlLocation+'images/homePanel_bg_locator.gif\');">' +
				'<div id="mainPanelBG_locator"></div>' +
				'<div id="mainPanelText" style="top: 53px;width:230px;">Find one of our many locations throughout North America.</div>' +
				'<div id="learnMore"></div>' +
			'</div>' +
		'</a>');
}

function writeMgmtPanel(){
document.write(
			'<div id="interiorMainPanel2">' +
				'<div style="width:322px;height:129px;"><a href="'+absoluteLocation+'management.php" style="text-decoration:none"><img src=\''+htmlLocation+'images/mod_mgmt.gif\'></a></div>' +
				'<div id="mainPanelText" style="width:270px;">Focus, commitment, and leadership pave the road to our company\'s success.</div>' +
			'</div>' +
		'</a>');
}

function writeContactInfoPanel(){
	// begin contact callout box 
	document.write('<div class="side-mod">' +
			'<div class="mod-top">' +
				'<img src=\"'+htmlLocation+'images/mainPanelBG_contactUs.gif" width="115px" height="30px" />' +
			'</div>' +
			'<p style="font-size:11px;">' +
			'<strong>To reach us by phone or fax:</strong><br>' +
			'630.932.4600 main<br>' +
			'630.932.7611 fax<br>' +
			'<br>' +
			'<strong>To reach us by e-mail, send a message to:</strong><br>' +
			'<a class="contentPanel2_midInfo" href="mailto:info@hwy-tech.com">info@hwy-tech.com</a><br>' +
			'<br>' +
			'<strong>Our postal address is:</strong><br>' +
			'Highway Technologies, Inc.<br>' +
			'880 N. Addison Rd.<br>' +
			'Villa park, IL 60181<br>' +					
			'</p>' +
			'<div class="mod-bot"></div>' +
	 '</div>');
}
		 
function writeFooter(){
	writeFooter(0);
}
function writeFooter(menuItemNumber){
document.write('<div id="footerBar"></div>' +
		'<div id="footerDiv">' +
			'<font id="footerText">' +
			'<a href="'+absoluteLocation+'index.php">Highway Technologies Home</a> | <a href="'+absoluteLocation+'terms.php">Terms of Use</a> | <a href="'+absoluteLocation+'map.php">Site Map</a><br>' +
			'Copyright &copy; 2007 Highway Technologies, Inc.<br>' +
			'An equal opportunity employer.<br>' +
			'</font>' +
		'</div>');
}
function showHomeMenu(){
   if (showingSub=='no'){
	switch (page_mainMenu) {
		case 1: 
			show_prodServ();
			break;
		case 2: 
			show_about();
			break;
		case 3: 
			show_contact();
			break;
		default: 
			hideAll();
	}
   }
}
function showSubMenu(){
	switch (activeSubMenu) {
		case 1: 
			show_prodServ();
			break;
		case 2: 
			show_about();
			break;
		case 3: 
			show_contact();
			break;
		default: 
			hideAll();
	}
}
function mouseOutMenu(){
	justLeftSub = 'yes';
	showingSub = 'no';
	showHomeMenu();
}
function enterSubMenu(){
	if(justLeftSub == 'yes') showSubMenu();
}
function show_prodServ(){
	show('prodServMenuDiv');
	hide('aboutMenuDiv');
	hide('contactMenuDiv');
//	show('globalMenuLine');
	document.menu_prodServ.src=absoluteLocation+'images/menu_prodServ-over.gif';
	document.menu_about.src=absoluteLocation+'images/menu_about.gif';
	document.menu_contact.src=absoluteLocation+'images/menu_contact.gif';
}
function show_about(){
	hide('prodServMenuDiv');
	show('aboutMenuDiv');
	hide('contactMenuDiv');
//	show('globalMenuLine');
	document.menu_prodServ.src=absoluteLocation+'images/menu_prodServ.gif';
	document.menu_about.src=absoluteLocation+'images/menu_about-over.gif';
	document.menu_contact.src=absoluteLocation+'images/menu_contact.gif';
}
function show_contact(){
	hide('prodServMenuDiv');
	hide('aboutMenuDiv');
	show('contactMenuDiv');

//	show('globalMenuLine');
	document.menu_prodServ.src=absoluteLocation+'images/menu_prodServ.gif';
	document.menu_about.src=absoluteLocation+'images/menu_about.gif';
	document.menu_contact.src=absoluteLocation+'images/menu_contact-over.gif';
}
function hideAll(){
	hide('prodServMenuDiv');
	hide('aboutMenuDiv');
	hide('contactMenuDiv');
//	hide('globalMenuLine');
	document.menu_prodServ.src=absoluteLocation+'images/menu_prodServ.gif';
	document.menu_about.src=absoluteLocation+'images/menu_about.gif';
	document.menu_contact.src=absoluteLocation+'images/menu_contact.gif';
}
function menuItem(hrefLink, text, isLast) {
	this.active = '';
	this.hrefLink = hrefLink;
	this.text = text;
	this.isLast = isLast;
	this.writeItemHTML = writeItemHTML;
}
function writeItemHTML() {
	var itemHTMLreturn = '<font id="globalMenu2' + this.active + '"><a href="' + this.hrefLink + '">' + this.text + '</a></font>';
	if (this.isLast != 'yes') itemHTMLreturn = itemHTMLreturn + ' <font id="globalMenu2_divider">| </font>';
	return itemHTMLreturn;
}
function menuObject(items, menuName, hrefLink) {
	this.visibility = 'hidden';
	this.over = '';
	this.menuItems = items;
	this.menuName = menuName;
	this.hrefLink = hrefLink;
	this.offFunc = 'delay_hideAll';
	this.writeLinkText = writeLinkText;
	this.writeDivText = writeDivText;
}
function writeDivText() {
	var divTextreturn = '<div id="' + this.menuName + 'MenuDiv" style="visibility:' + this.visibility +';">';
	return divTextreturn;
}
function writeLinkText(currentSub) {
	var linkTextreturn = '<a href="' + this.hrefLink + '" ' +
		'onmouseover="activeSubMenu='+currentSub+'; showingSub=\'yes\'; showSubMenu();" ' +
		'onmousedown="activeSubMenu='+currentSub+'; showingSub=\'yes\'; showSubMenu();" ' +
		'onmouseout="mouseOutMenu();" ' +
		'onmouseup="mouseOutMenu();" ' +
		'><img name="menu_' + this.menuName + '" src="'+absoluteLocation+'images/menu_' + 
		this.menuName + this.over + '.gif"></a>';
	return linkTextreturn;
}
function show(layer_ref) {
	if (state == 'visible') {
	state = 'visible';
	}
	else {
	state = 'visible';
	}
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
	eval( "document.all." + layer_ref + ".style.visibility = state");
	}
	if (document.layers) { //IS NETSCAPE 4 or below
	document.layers[layer_ref].visibility = state;
	}
	if (document.getElementById && !document.all) {
	maxwell_smart = document.getElementById(layer_ref);
	maxwell_smart.style.visibility = state;
	}
}
function hide(layer_ref) {
	if (state == 'visible') {
	state = 'hidden';
	}
	else {
	state = 'hidden';
	}
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
	eval( "document.all." + layer_ref + ".style.visibility = state");
	}
	if (document.layers) { //IS NETSCAPE 4 or below
	document.layers[layer_ref].visibility = state;
	}
	if (document.getElementById && !document.all) {
	maxwell_smart = document.getElementById(layer_ref);
	maxwell_smart.style.visibility = state;
	}
}
