/* coded by nimai */
if (document.getElementById && document.getElementsByTagName) {

function jumpto(n) {
  var e=document.getElementById('notka'+n);
  var top=e.offsetTop;
    while (e=e.offsetParent)
      top+=e.offsetTop;
  window.scroll(0,top-6);
}

function gramatyka(n) {
  if (n==1) return 'komentarz';
  if (n%100<12 || n%100>14)
    if (n%10>=2 && n%10<=4) return 'komentarze';
  return 'komentarzy';
}

function init() {
  var i,j,e,
  tytuly=new Array(),
  ilekomentow=new Array();
  var notki=document.getElementById('content');

  e=notki.getElementsByTagName('h2');
  for (i=0,j=0;e.length>i;i++)
    if (e[i].className=='tytul') {
      e[i].id='notka'+(j++);
      tytuly.push(e[i].firstChild.innerHTML);
    }
  if (tytuly.length>1) {
    e=notki.getElementsByTagName('span');
    for (i=0;e.length>i;i++)
      if (e[i].className=='nkom')
        ilekomentow.push(eval(e[i].innerHTML));
    var S='<h2 class="tytul short">Spis treści</h2><div class="content"><ol>';
    for(i=0;tytuly.length>i;i++) {
      S+='<li><a href="javascript:jumpto('+i+')"> '+tytuly[i]+'</a>';
      if (ilekomentow[i] > 0)
        S+=' <span class="ncom">('+ilekomentow[i]+' '+gramatyka(ilekomentow[i])+')</span>';
      S+='</li>';
    }
    S+='</ol></div>';
    document.getElementById('tocka').innerHTML=S;
  }
}
window.onload=init;
}