// JavaScript Document

function scriptInit() {
if (!document.getElementById) {
	return;
	}
}

// Set up Event Listener - the script that allows us to use the addEvent call below

function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
	elm.addEventListener(evType, fn, useCapture);
	return true;
	} else if (elm.attachEvent) {
	var r = elm.attachEvent('on' + evType, fn);
	return r;
	} else {
	elm['on' + evType] = fn;
	}
}


function getURL() {
  var url = document.location.href;
  return parseURL(url);
}

function parseURL (url) {
  var fileName = url.split("/");
  fileName = (fileName[fileName.length-1]);
  return fileName;
}


function getDir() {
  var dir = document.location.href;
  return parseDir(dir);
}

function parseDir (url) {
  var dirName = url.split("/");
  dirName = (dirName[dirName.length-2]);
  dirName=dirName+".html";
  return dirName;
}


function topNav() {
  var currentLocation = getURL();
  var nav = document.getElementById("topNav");
  //alert(document.getElementById("navigation"));

  links = nav.getElementsByTagName("a");

  for (i=0; i<links.length; i++) {

    linkHref = links[i].getAttribute("href")
	linkHref = parseURL(linkHref);

    if (linkHref==currentLocation) {
      links[i].setAttribute("className", "active");
	  links[i].setAttribute("class", "active");

   }

  }
  
}
/*
function topMainNav() {
  var currentLocation = getURL();
  var nav = document.getElementById("mainNav");
  //alert(document.getElementById("navigation"));

  links = nav.getElementsByTagName("a");

  for (i=0; i<links.length; i++) {

    linkHref = links[i].getAttribute("href")
	linkHref = parseURL(linkHref);

    if (linkHref==currentLocation) {
      links[i].setAttribute("className", "active");
	  links[i].setAttribute("class", "active");

   }

  }
  
}
*/

addEvent(window, 'load', topNav, false);
//addEvent(window, 'load', topMainNav, false);

