﻿// general javascript functions

function init() {
	setMenuStyle();
	external();
}

function setMenuStyle() {
	// set the style for the menu item for the current page
	var sPath = window.location.pathname;
	//split the path up into parts based upon the forward slashes
	var sPathParts = sPath.split('/');
	//alert(sPathParts[1]);
	//find out what the third part is (the section name)
	switch(sPathParts[1]){
		case 'index.htm':
			sId = 'index';
			break
		case '':
			sId = 'index';
			break
		default:
			sId = sPathParts[1];
	}
	//set the style of the menu tab based upon the users current page
	var eMenu = document.getElementById(sId);
	eMenu.className = 'selected';
}

// give anchors with attribute rel="external" a target attribute of "_blank"

function external() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i < anchors.length; i++) { 
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
		anchor.target = "_blank";

	}
}
window.onload = init;