/* Make the nav position fixed, but only if it fits in the browser window.
Tested in IE7 and Firefox, exclludes IE5.5. To work in IE6 or higher, 
the browser should be forced to standards mode by adding a doctype declaration to the html page, eg:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
*/


neoarchaic.HiliteNav= function(subnav, flashnav){
	//Check for ie 5.5 and exclude it from the script
	if (!document.getElementById){
		return;
	}
	this.subnavid = subnav;
	this.flashnavid = flashnav;
	this.addEvent(window, "load", "hiliteNav")
}

neoarchaic.protoObj = {
	className: "HiliteFlash",
	
	checkFlash: function(){
		if (neoarchaic.objswap != undefined){
			if (!neoarchaic.objswap.hasFlash){
				this.menu.style.display = "block";
				return false;
			}
		}
		return true;
	},
	
	
	hiliteNav: function(){
		//Hilite the subnav: Hilite the link whose pathmane matches the window's pathname
		var subnav = document.getElementById(this.subnavid)
		if (subnav) {
			var ar = window.location.pathname.split("/")
			var name = ar[ar.length-1]	
			var elements = subnav.getElementsByTagName("a");
				for (var i = 0; i<elements.length; i++){
					var e = elements[i];	
					if((e.pathname.indexOf (name) != -1) && e.id != "menulink"){						
						e.className += " activelink";
					}
			}	
		}
		
		//Hilite the flash nav 
		var flash = document.getElementById(this.flashnavid);
		if (!flash){
			return;
		}
		if (flash.hiliteNav){
			flash.hiliteNav(document.body.className);
		}else{
			if (this.checkFlash()){
				var me = this;
				setTimeout(function () { me.hiliteNav(); }, 500);
			}
		}
	}
}
	
neoarchaic.Core.extend(neoarchaic.HiliteNav, null, neoarchaic.protoObj);
delete neoarchaic.protoObj;

neoarchaic.Core.newObject("hilite_nav", "HiliteNav", "subnav", "flashnav")


