/************************************************************************************************
JS						hh_nav0.js
Objective			Allow navigation bar to work on this site. Code is based on Suckerfish
							( http://www.htmldog.com/articles/suckerfish/ ).
version				2.0		7/12/2005 Added keyboard accessibility features.
										Added IE/Mac fix.
										Rewrote main() to handle specific browsers.
							1.0		1/1/2004 Original
Copyright			@ 2005 hhDesigns. All rights reserved.
************************************************************************************************/
	/*---------------------------------------------------------------------------------------------
	function			(PUBLIC) sfHover
								Mimic hover pseudo-class
	Returns				(NOTHING)
	Notes					1.	Ensure that all HTML tags are uppercase.
								2.	IE fix only and is not needed for all other browswers.
								3.	Fix for IE/Mac. 
	---------------------------------------------------------------------------------------------*/
	sfHover = function() {
		var sfEls = document.getElementById("nav-bar").getElementsByTagName("li");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=(this.className.length>0? " ": "") + "sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), "");
			}
		}
	}
	/*---------------------------------------------------------------------------------------------
	function			(PUBLIC) mcAccessible
								Allow keyboard access to navigation bar on this site
	Returns				(NOTHING)
	Notes					1.	Ensure that all HTML tags are uppercase.
	---------------------------------------------------------------------------------------------*/
	mcAccessible = function() {
		var mcEls = document.getElementById("nav-bar").getElementsByTagName("a");
		for (var i=0; i<mcEls.length; i++) {
			mcEls[i].onfocus=function() {
				/* a:focus */
				this.className+=(this.className.length>0? " ": "") + "sffocus";
				 /*li < a:focus */
				this.parentNode.className+=(this.parentNode.className.length>0? " ": "") + "sfhover";
				if(this.parentNode.parentNode.parentNode.nodeName == "li") {
					/* li < ul < li < a:focus */
					this.parentNode.parentNode.parentNode.className+=(this.parentNode.parentNode.parentNode.className.length>0? " ": "") + "sfhover";
					if(this.parentNode.parentNode.parentNode.parentNode.parentNode.nodeName == "li") {
						/* li < ul < li < ul < li < a:focus */
						this.parentNode.parentNode.parentNode.parentNode.parentNode.className+=(this.parentNode.parentNode.parentNode.parentNode.parentNode.className.length>0? " ": "") + "sfhover";
					}
				}
			}
			mcEls[i].onblur=function() {
				this.className=this.className.replace(new RegExp("( ?|^)sffocus\\b"), "");
				this.parentNode.className=this.parentNode.className.replace(new RegExp("( ?|^)sfhover\\b"), "");
				if(this.parentNode.parentNode.parentNode.nodeName == "li") {
					this.parentNode.parentNode.parentNode.className=this.parentNode.parentNode.parentNode.className.replace(new RegExp("( ?|^)sfhover\\b"), "");
					if(this.parentNode.parentNode.parentNode.parentNode.parentNode.nodeName == "li") {
						this.parentNode.parentNode.parentNode.parentNode.parentNode.className=this.parentNode.parentNode.parentNode.parentNode.parentNode.className.replace(new RegExp("( ?|^)sfhover\\b"), "");
					}
				}
			}
		}
	}
	/*---------------------------------------------------------------------------------------------
								(PUBLIC) main
								Enable hover pseudo class and accessibility access to navigation bar on this
								site depending on browser specific functions
	Notes					1.	See below
	---------------------------------------------------------------------------------------------*/
	/* Gecko, Safari, Konqueror and Standard browsers*/
	if(window.addEventListener) window.addEventListener('load', mcAccessible, false);
	/* Opera 7 */
	else if(document.addEventListener) document.addEventListener('load', mcAccessible, false);
	/* IE/Win */
	else if(window.attachEvent) {
		window.attachEvent('onload', sfHover);
		window.attachEvent('onload', mcAccessible);
	/* IE5, IE/Mac */
	} else {
		if(typeof window.onload == 'function') {
			var existing = onload;
			window.onload = function() {
				existing();
				sfHover();
				mcAccessible();
			}
		} else {
			window.onload = function() {
				sfHover();
				mcAccessible();
			}
		}
	}
	