// ----- Global Vars ----- \\
var currentTitle = '';
var currentURL = '';
var currentSection = '';
var currentPage = '';
var currentFile = '';


// ----- Gets curent location and returns the path from the root ----- \\
var thisURL = window.location + '';
var urlPair = thisURL.split('//');
if (urlPair.length > 1) thisURL = urlPair[1];
var dirArray = thisURL.split('/');
var linkArray = dirArray.slice(1);

for(i=0; i < linkArray.length; i++){
	currentURL = currentURL + "/" + linkArray[i];
}
currentFile = linkArray[linkArray.length - 1];



// ----- Loads xml ----- \\
function loadPageConfig(){
	if (window.ActiveXObject){ // Internet Explorer
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
		xmlDoc.load("/Includes/XML/PageConfig.xml");
		writeList();
 	}else{ // Other Browsers
		xmlDoc = document.implementation.createDocument("", "", null);
 		xmlDoc.load("/Includes/XML/PageConfig.xml");
		xmlDoc.onload = writeList;
	}
}


// ----- Parses xml and sets global variables to the current page ----- \\
function writeList(){
	var pages = xmlDoc.getElementsByTagName('page');
 	
	for (i=0; i < pages.length; i++){
		if(currentURL == pages[i].getAttribute('url')){  
			currentTitle = pages[i].getAttribute('title');
			currentSection = pages[i].getAttribute('section');
			currentPage = pages[i].getAttribute('page');
			
			
			if(currentPage != "Home"){
				loadBreadcrumbs();
			}
			loadSiteNav();
		}
	}
}
