function getFileName () {
	var file = '';
	var loc = window.location.href;
	if (loc.lastIndexOf('.') == -1) return loc.substring(loc.lastIndexOf('/') + 1);
	file = loc.substring(loc.lastIndexOf('/') + 1, loc.lastIndexOf('.'));
	return file;
}

function updateNavi() {
	var navRoot = document.getElementById("navi");
	for (i = 0; i < navRoot.childNodes.length; i++) {
		var node = navRoot.childNodes[i];
		
		if (node.nodeName != "LI") continue;

		var nodeVal = node.firstChild.firstChild.nodeValue;
		
		var fileName = getFileName();
		
		if (nodeVal == fileName) node.className += " current";
	}
}

/**
 * W3C and MS compatible way to attach events.
 */
function listen(ev, el, fn) {
	if (el.addEventListener) {
		el.addEventListener(ev, fn, false);
	} else if (el.attachEvent) {
		return el.attachEvent("on" + ev, fn);
	}
}

listen('load', window, updateNavi);

