/**
 * Extensions to the functionality of the secondary navigation javascript.
 * 
 * Author  : Greg Wilton
 * Version : 2.0 (2008-01-24)
 * Created : 2003-11-18
 */
var NavExt = {
	NAV2_ID: 'nav2xc',
	HIGHLIGHT_CLASS: 'current-page',
	
	/**
	 * Apply a class to the navigation item that points to this page.
	 */
	highlight: function () {
		var parent = document.getElementById(this.NAV2_ID);
		if (parent)  {
			var anchors = parent.getElementsByTagName("a");
			var webpage = document.location;
			var website = webpage.protocol + "//" + webpage.host;
			
			for (var i = anchors.length - 1; i >= 0; i--) {
				var href = anchors[i].href;
				var link = (href.charAt(0) == "/") ? website + "/" + href : href;
				
				if (webpage.href == link) {
					if (anchors[i].className) {
						anchors[i].className += " " + this.HIGHLIGHT_CLASS;
					} else {
						anchors[i].className = this.HIGHLIGHT_CLASS;
					}
					
					return true;
				}
			}
			
		}
		
		return false;
	}
};

