//Load Language Toggle
$(document).ready(function(){

	// Get the page matrix > Page maps english file to french equivalents
	$.getJSON( "/js/languageToggleMatrix.js" ,
       function(data){
		  
		 //Get the current URL, appending index.html to folder levels
		 thisURL = getURL();
		 
		 //Each page in the JSON
         $.each(data.pages, function(i,page){
			
			//If the curent URL matchs the JSON, create the button to the other language equivalent.
			if(thisURL == page.english)
				setLangLink(page.french);
			else if(thisURL == page.french)
				setLangLink(page.english);
        });
	});
	
});


//Gets the URL and formats it properly!
function getURL(){
	theURL = window.location.pathname;
	if(!theURL.match(".html"))
	{
		theURL = theURL + "index.html";
	}
	return theURL;
}

//Set the language toggle link.
function setLangLink(url)
{
	$(".main_nav_francais a").attr("href", url);
}

if(window.location.pathname.match(/fr/))
{
	var addthis_config = {
		 ui_language: "fr"
	}
}