function hide_all_entries() {
    var entries = document.getElementsByClassName('entry');
    for (i = 0; i < entries.length; i++) {
        entries[i].style.display = "none";
	var e_m = entries[i].id.concat("_m");
	var m = document.getElementById(e_m);
	if (m != null) {
	  m.style.fontWeight = "normal";
	}
    }
}

function on_hash_change() {
  select_entry(get_entry(), false);
}

function select_entry(target, update_url) {
  hide_all_entries();
  document.getElementById(target).style.display = "block";
  var e_m = target.concat("_m");
  var m = document.getElementById(e_m);
  if (m != null) {
    m.style.fontWeight = "bold";
  }
  if (update_url) {
    window.onhashchange = null;
    window.location.hash = target;
    window.onhashchange = on_hash_change;
  }
}

function get_entry() {
  var id = window.location.hash.substring(1);
  if (document.getElementById(id) != null) {
    return id;
  } else {
    return "welcome";
  }
}

function initialize_entries() {
    hide_all_entries();
    document.getElementById('toc').scrollTop = 0;
    select_entry(get_entry(), false);
    document.getElementById('content').style.visibility = "visible";
}

