function showSection(id) {
  var uls = document.getElementsByTagName("ul");
  for (var i=0; i < uls.length; i++ ) {
    if (uls[i].className.indexOf("section") == -1) continue;
    if (uls[i].getAttribute("id") != id) {
      uls[i].style.display = "none";
    } else {
      uls[i].style.display = "block";
    }
	}
}

function prepareInternalnav(id) {
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
  if (!document.getElementById("bottommenu")) return false;
  var nav = document.getElementById("bottommenu");
  var links = nav.getElementsByTagName("a");
  for (var i=0; i < links.length; i++ ) {
    var sectionId = links[i].getAttribute("href").split("#")[1];
    if (!document.getElementById(sectionId)) continue;
    document.getElementById(sectionId).style.display = "none";
    links[i].destination = sectionId;
    links[i].onclick = function() {
      showSection(this.destination);
      return false;
    }
  }
	showSection('');
}


function showSection2(id) {
  var uls = document.getElementsByTagName("ul");
  for (var i=0; i < uls.length; i++ ) {
    if (uls[i].className.indexOf("sub2") == -1) continue;
    if (uls[i].getAttribute("id") != id) {
      uls[i].style.display = "none";
    } else {
      uls[i].style.display = "block";
    }
	}
}

function prepareInternalnav2(id) {
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
  if (!document.getElementById("menuwrap")) return false;
  var nav = document.getElementById("menuwrap");
  var links = nav.getElementsByTagName("a");
  for (var i=0; i < links.length; i++ ) {
    var sectionId = links[i].getAttribute("href").split("#")[1];
    if (!document.getElementById(sectionId)) continue;
    document.getElementById(sectionId).style.display = "none";
    links[i].destination = sectionId;
    links[i].onclick = function() {
      showSection2(this.destination);
      return false;
    }
  }
	showSection('');
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
addLoadEvent(prepareInternalnav);
addLoadEvent(prepareInternalnav2);