// http://www.zero1.co.uk HTML AJAX call for loading the menu system
var oldOnload = window.onload;
window.onload = function(){};

var xmlhttp;
var menuContent;

var menuHighlight = Array();

//////////////////////////////////////////////////////////////////////////////////////////
// Edit below here
/*
Assign CSS id's to the <li>'s in the menu.html file.
Using these id's (Right side) link the selected menu item to the page / foler name (Right side)
For example.

menu.html
---------
<li id="menu_title_video_camera_hire">

This file
---------
menuHighlight['video_camera_hire']			= 'menu_title_video_camera_hire';

Now any folder path / page name from the URL that contains "video_camera_hire"
will highlight the <li> with the id of "menu_title_video_camera_hire"

menuHighlight['SEARCH_FOR']					= 'ID TO HIGHLIGHT';
*/
//////////////////////////////////////////////////////////////////////////////////////////
menuHighlight['index.html']	= 'menu_home';
menuHighlight['products.html']	= 'menu_products';
menuHighlight['products-new.html']	= 'menu_products';
menuHighlight['products_sensors.html']	= 'menu_products';
menuHighlight['products_receivers.html']	= 'menu_products';
menuHighlight['products_operator_interface.html']	= 'menu_products';
menuHighlight['products_tms_manager.html']	= 'menu_products';
menuHighlight['products_evaluation_kit.html']	= 'menu_products';


menuHighlight['system_overview.html']	= 'menu_system_overview';
menuHighlight['blog']	= 'menu_news';
menuHighlight['news.html']	= 'menu_news';
menuHighlight['downloads.html']	= 'menu_downloads';
menuHighlight['downloads-new.html']	= 'menu_downloads';

menuHighlight['contact_us.html']	= 'menu_contact_us';
menuHighlight['q_and_a.html']	= 'menu_qa';

menuHighlight['monitoring_tyre_pressures.html']	= 'menu_monitoring_tyre_pressures';
menuHighlight['the_benefits.html']	= 'menu_the_benefits';
menuHighlight['the_company.html']	= 'menu_the_company';



//////////////////////////////////////////////////////////////////////////////////////////
// Edit above here
//////////////////////////////////////////////////////////////////////////////////////////


function highlightMenu()
{
	pathArray = window.location.pathname.split('/');
	
	elementId = 'menu_home';
		
	for(i=0;i<pathArray.length;i++)
	{
		if(menuHighlight[pathArray[i]] != null && menuHighlight[pathArray[i]].length > 0)
		{
			elementId = menuHighlight[pathArray[i]];
			break;
		}
	}
	
	if(elementId.length > 0)
	{
		try
		{
			document.getElementById(elementId).className = 'menu_highlighted';
			document.getElementById(elementId).style.color = '#F19125';
			
					} catch(e) {
			alert('Failed to highlight the menu.');
		}
	}
}

function updateMenu()
{
	try
	{
		highlightMenu();
	} catch(e) {
		alert("Failed to update menu system");
	}
}



if (window.addEventListener)
{
	window.addEventListener("load", updateMenu, false);
} else if (window.attachEvent) {
	window.attachEvent("onload", updateMenu);
} else {
	window.onload = updateMenu;
}
