// $Id: navigation.js,v 1.7 2006/09/10 21:54:47 excellent Exp $
var navigation = new Object();
navigation.init = function() {
	if (document.getElementById) {
		this.navid = this.id();
		if (this.navid) {
			this.branches = this.navid.split("-");
			var branch_id = "nav_menu_link";
			for (var i = 0; i < this.branches.length; i++) {
				branch_id += "-" + this.branches[i];
				var branch = document.getElementById(branch_id);
				if (branch) {
					branch.className += " active";
					branch.removeAttribute("href");
					branch.className += " nolink";
					if (branch.parentNode) branch.parentNode.className += " active";
				}
			}
		}
		var menus = document.getElementById("menubars");
		if (document.getElementsByTagName) {
			var heads = menus.getElementsByTagName("li");
			for (var i = 0; i < heads.length; i++) {
				if (heads[i].className.search(/head/) >= 0 && heads[i].className.search(/active/) == -1) {
					heads[i].onmouseover = function() {
						this.className += " hover";
						if (this.getElementsByTagName("li").length > 0) document.getElementById("menubackground").className = this.parentNode.id;
						return false;
					}
					heads[i].onmouseout = function() {
						this.className = this.className.replace(/ hover/, "");
						document.getElementById("menubackground").className = "none";
						return false;
					}
				}
			}
		}
		var scrollTop = document.getElementById("scrollTop");
		if (scrollTop) {
			var content = document.getElementById("content");
			scrollTop.onclick = function() {document.getElementById("content").scrollTop = 0}
			try {
				content.onscroll = function() {
					var scrollTop = document.getElementById("scrollTop");
					if (this.scrollTop > 0) scrollTop.className = "visible";
					else scrollTop.className = "";
				}
			} catch(e) {
				scrollTop.className = "visible";
			}
		}
	}
}
navigation.onload = (window.onload) ? window.onload : function () {};
window.onload = function () {navigation.onload(); navigation.init()};
navigation.id = function () {
	if (location.pathname.match(/.*\/nav:/))  var navid = location.pathname.replace(/.*\/nav:/, "");
	else if (location.search.match(/.*navid=/))  var navid = location.search.replace(/.*navid=/, "").replace(/&.*/, "");
	return navid;
}
navigation.link = function () {
	var parameters = this.link.arguments;
	if (parameters.length == 1) return true;
	switch (parameters[1]) {
		case "popup" :
			if (parameters[3]) {
				var width = parseInt (parameters[3].replace(/.*width=/, ""));
				var height = parseInt (parameters[3].replace(/.*height=/, ""));
				var newWindow = window.open(parameters[0].href, parameters[2], parameters[3]);
				if (width && height && window.resizeTo) try {newWindow.resizeTo (width, height)} catch (e) {};
				try {newWindow.moveTo(0,0)} catch (e) {};
			} else {
				var newWindow = window.open(parameters[0].href, parameters[2]);
			}
			newWindow.focus();
			if (window.event) event.cancelBubble = true;
			return false;
		default :
	}
	return true;
}