/*

	JavaScript Highlight Current link.
	Standards Compliant Popup Script
	Author : Kevin Cannon
	http://www.multiblah.com
	Last Edited: 12.12.2004
	Version 1.0

	Description:
	Searches through the document looking for links, and applies the class 'currentlink' 
	to any links which link to the current document. This means you can easily highlight the current link
	without any server side coding.

	Inspired by Inigo Surguy's version at: http://www.surguy.net/menu/highlight.html
	The script has been rewritten from scratched, and improved, to make it more portable, 
	and more in tune with the 'spirit' of webstandards. (e.g. separating behavior, from structure)

	Changes:
	4/10/2004 - Added in AddLoadEvent function which piggybacks code onto window.onLoad
*/

// Main function, called when the page loads
// Searches through the document looking for links
// Changes class of the current link to /currentlink
function highlightCurrentLink() {
  
	var currentLocation = document.location.href;
	var targetNode;

	targetNode = document;
	
	// You can speed up this script, by preventing it searching through the entire document
	// Uncomment the line below, and it will only search through the tag with ID 'navigation'
	
	//targetNode = document.getElementById("navigation");
	
	links = targetNode.getElementsByTagName("a");

	// Search thorugh all links
	for (i=0; i<links.length; i++) {
		linkHref = links[i].href;
		
		if (linkHref==currentLocation) {
			// Set class for different browsers, if link is this link
			links[i].setAttribute("className", "currentlink");
			links[i].setAttribute("class", "currentlink");      
		}
	}
}

// Piggy-back fucntion onto onLoad event ............................................
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(highlightCurrentLink);
