window.onload = initAll;

function initAll() {
  var allLinks = document.getElementsByTagName("a");
// pobranie wszystkich elementow łączy ("a") ze strony

  for (var i=0; i<allLinks.length; i++) {
// przypisanie wszystkim łączom własciwości onclick
    if (allLinks[i].className.indexOf("menuLink") > -1) {
	  // funckja anonimowa obsługjąca zdarzenie onclick
	  allLinks[i].onclick = function() {return false;}
      allLinks[i].onmouseover = toggleMenu;
    }
  }
}


function toggleMenu() {
//określanie początku i końca menu
  var startMenu = this.href.lastIndexOf("/")+1;
  var stopMenu = this.href.lastIndexOf(".");
  var thisMenuName = this.href.substring(startMenu,stopMenu);

// "zablokowane" wyświetlanie nagłówków
  document.getElementById(thisMenuName).style.display = "block";

  this.parentNode.className = thisMenuName;
  this.parentNode.onmouseout = toggleDivOff; //ukrywanie elementu menu
  this.parentNode.onmouseover = toggleDivOn;  //wyświetlanie elementu
}


function toggleDivOn() {
  document.getElementById(this.className).style.display = "block";
// "zablokowane" wyświetlenei całego elementu div
}


function toggleDivOff() {
  document.getElementById(this.className).style.display = "none";
// ukrywane diva
}
