
function populateLeftBar()
{
	var domainName = "http://www.richbruin.org/";
	
	// Work out the name of the current page
	var thisPagePath = window.location.pathname;
	var thisPage = thisPagePath.substring(thisPagePath.lastIndexOf('/') + 1);
	
	// Set up an array listing the name of all of the pages
	var pageNameArray = new Array();
	pageNameArray[0] = "Home";
	pageNameArray[1] = "About Me";
	pageNameArray[2] = "News";
	pageNameArray[3] = "Work";
	pageNameArray[4] = "My Interests";
	pageNameArray[5] = "My Publications";
	pageNameArray[6] = "Glossary";
	pageNameArray[7] = "Links";
	
	// Set up an array of the filename of all of the pages
	var pageFileNameArray = new Array();
	pageFileNameArray[0] = "index.html";
	pageFileNameArray[1] = "aboutme.html";
	pageFileNameArray[2] = "news.html";
	pageFileNameArray[3] = "work.html";
	pageFileNameArray[4] = "myinterests.html";
	pageFileNameArray[5] = "documents.html";
	pageFileNameArray[6] = "glossary.html";
	pageFileNameArray[7] = "links.html";
	
	// Set up an array for names of sections within pages
	var sectionNameArray = new Array();
	sectionNameArray[0] = "";
	sectionNameArray[1] = "Who Am I?;Contacts";
	sectionNameArray[2] = "";
	sectionNameArray[3] = "Current;Previous";
	sectionNameArray[4] = "Computing;General";
	sectionNameArray[5] = "Qualifications;Published;Unpublished;Posters";
	sectionNameArray[6] = "";
	sectionNameArray[7] = "Work related;Colleagues;General";

	// Set up an array of anchors to use for the page sections
	var sectionAnchorArray = new Array();
	sectionAnchorArray[0] = "";
	sectionAnchorArray[1] = "whoami;contacts";
	sectionAnchorArray[2] = "";
	sectionAnchorArray[3] = "current;previous";
	sectionAnchorArray[4] = "computing;general";
	sectionAnchorArray[5] = "qualifications;published;unpublished;posters";
	sectionAnchorArray[6] = "";
	sectionAnchorArray[7] = "work;general";

	// Work out the contents of the left bar div - for pages other than
	// the current page put a link. Otherwise output just the name
	var boxContents = "<ul>";
	
	for(ctr = 0; ctr < pageNameArray.length; ctr++)
	{
		var thisPageName = pageNameArray[ctr];
		var thisPageFilename = pageFileNameArray[ctr];
		var thisMenuItem = "";
		
		if ( thisPage == "" )
		{
			thisPage = "index.html";
		}
		
		if ( thisPage == thisPageFilename )
		{
			var thisPageSubsections = sectionNameArray[ctr];
			if ( thisPageSubsections != "" )
			{
				thisMenuItem = "<li class='currentPageName'>" + thisPageName;
				thisMenuItem = thisMenuItem + "<ul>"
				
				var subsections = thisPageSubsections.split(";");
				var subsectionAnchors = sectionAnchorArray[ctr].split(";");
				
				for(ctr2 = 0; ctr2 < subsections.length; ctr2++)
				{
					thisMenuItem = thisMenuItem + "<li><a class='subsectionLinks' href='#" + subsectionAnchors[ctr2] + "'>"+ subsections[ctr2] + "</a></li>";
				}
				
				thisMenuItem = thisMenuItem + "</ul>";
				
				thisMenuItem = thisMenuItem + "</li>";
			}
			else
			{
				thisMenuItem = "<li class='currentPageName'>" + thisPageName + "</li>";
			}
		}
		else
		{
			thisMenuItem = "<li><a class='navigationLinks' href='" + domainName + thisPageFilename + "'>" + thisPageName + "</a></li>";
		}
		
		boxContents = boxContents + "\n" + thisMenuItem;
	}
	
	boxContents = boxContents + "</ul>";
	// Now we have all of the different entries to be output - grab the
	// left bar box and put the text into it
	var leftBar = document.getElementById("leftBar");
	leftBar.innerHTML = boxContents;
	
}

// A simple method to output my email address in a 'safe' way
function outputEmail()
{
	var myname = "rich";
	var middleBit = "@";
	var domain = "richbruin";
	var TLDN = "org";
	var dot = ".";
	var longerString = myname + middleBit + domain + dot + TLDN;
	var mail = "mai";
	var to = "lto:";
	
	var emailBit = document.getElementById("email");
	emailBit.innerHTML = "<a href='" + mail + to + longerString + "'>" + longerString + "</a>";
}