(function () {

add_event_listener(window, "load", select_link);

function select_link() {
		var div = document.getElementById("wrapper-left");
		if( ! div ) { return; }
		var nav = div.getElementsByTagName("nav").item(0);
		if( ! nav ) { return; }
		var list = div.getElementsByTagName("li");
		var this_file = get_file_name(document.location.href);
		if(this_file == "index.html") { return; }
		for( var i=0; i<list.length; i++ ) {
			var anchor = list.item(i).getElementsByTagName("a").item(0);
			if( ! anchor ) { continue; }
			var link_file = get_file_name(anchor.getAttribute("href"));
			if(link_file == this_file) {
				var text = '';
				if(anchor.firstChild) {
					text = anchor.firstChild.nodeValue;
				}
				var span = document.createElement("span");
				span.appendChild( document.createTextNode(text) );
				list.item(i).replaceChild(span, anchor);
				span.style.fontWeight = "bold";
				break;
			}
		}
}

function get_file_name(url) {
	var parts = url.split("/");
	var f = parts.pop();
	var parts2 = f.split("#");
	f = parts2[0];
	if(f == "") { f = "index.html"; }
	return f;
}

function add_event_listener(elm, type, func, useCapture) {
  if(! elm) { return false; }
  if(! useCapture) {
    useCapture = false;
  }
  if(elm.addEventListener) {
    elm.addEventListener(type, func, false);
  } else if(elm.attachEvent) {
    elm.attachEvent('on'+type, func);
  } else {
    return false;
  }
  return true;
}

})();