/*********************************/
/* GLOBAL VARIABLES
/*********************************/
var xmlDoc;
var filename = "menuchange.xml";

/*********************************/
/* 
/*********************************/
/*
Taken from w3schools.com.
Loads an XML file on any browser.
*/
function loadXML(file)
{
	// code for IE
	if (window.ActiveXObject){
	  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	}
	// code for Mozilla, Firefox, Opera, etc.
	else if (document.implementation && document.implementation.createDocument){
	  xmlDoc=document.implementation.createDocument("","",null);
	}
  
	xmlDoc.async=false;
	xmlDoc.load(file);
}

function menuColorChange()
{
	// Extract the document title
	var title = document.title.substring(0, document.title.indexOf("-")-1);
	
	// Load the XML file
	loadXML(filename);
	
	// Load the xml object
	var menu = xmlDoc.getElementsByTagName("page");
	
	// Loop through the xml object
	for (var i=0;i<menu.length;i++){
		// If the window title matches a page title in the xml file
		if (menu[i].childNodes[0].nodeValue == title){
			// Set the main navigation link color
			if (document.getElementById(menu[i].attributes.getNamedItem("mainMenu").value)){
				document.getElementById(menu[i].attributes.getNamedItem("mainMenu").value).style.color = "#930020";
			}
			// If a secondary navigation link exists, set that link's color
			if (document.getElementById(menu[i].attributes.getNamedItem("sideMenu").value)){
				document.getElementById(menu[i].attributes.getNamedItem("sideMenu").value).style.color = "#87432E";
			}
		}
	}
	
	
}