// JavaScript Document
addEvent(window, 'load', init);

function init() { 
		//get all the links and elements into various arrays
		
		// variable nav should point to the DIV that contains a list of links
		//the links should be structured as:
		//<ul><li><a herf="link">text</a></li></ul>
		var nav = document.getElementById('navigation');
		
		//Get the first list in the NAV div...
		//this is in case there are drop down menus
		//that are built with other UL elements
		var ul = nav.getElementsByTagName('ul')[0];
		
		//get all the LI into an array
		var li = ul.getElementsByTagName('li');
		
		//get all the A elements into an array
		var a = ul.getElementsByTagName('a');
		
		//get the current URL as a string
		var url = window.location.href;
		url = url.toString();
		
	for (var i = 0; i < a.length; i++){
		//cycle through all the A elements in the Array
		//and turn each into a string
		compare = a[i].toString();
		
		//compare the current array string
		//to the current url
		if (compare == url) {
			
			//if they match, get the LI element with the same array position
			//this should be the parent element of the A element
			var selected = li[i];
			//...and apply an ID
			selected.setAttribute('id', 'selected');
		}
	}
}
