
function showPage() {
   getPage(this.identifier);
   var main = aaElem('main');
}

function getPage(page) {
      if (!Navigation.xmlhttp) Navigation.xmlhttp = aaGetXmlHttpRequest();
      var qry = "page=" + page;
      var url = 'get_page.php?' + qry;
      Navigation.xmlhttp.open('GET', url, true);
      Navigation.xmlhttp.onreadystatechange = printPage;
      Navigation.xmlhttp.send(null);
}

function printPage() {
  if(Navigation.xmlhttp.readyState == 4 
               && Navigation.xmlhttp.status == 200) {

   var content = aaElem('page');
   if (!content) {
      content = document.createElement('div');
      content.id = 'page';
      aaElem('main').appendChild(content);
   }
   content.innerHTML = Navigation.xmlhttp.responseText; 
  } 
}

aaManageEvent(window,'load',function() {
   var past;
   var home;
   var pageCount = 11;
   for (var i = 1; i <= pageCount; i++) {
      var id = 'part' + i;
      var nav = Navigation.addNavigationNode(past,id,showPage);
      if (!past) {
         home = nav;
      }
      past = nav;
   }

   // Ustawienie strony: startowej i bieżącej
   Navigation.setHome(home);
   Navigation.setCurrentPage(home);

   aaManageEvent(aaElem('next'),'click',aaBindObjMethod(Navigation,Navigation.nextPage));
   aaManageEvent(aaElem('previous'),'click',aaBindObjMethod(Navigation,Navigation.prevPage));
   aaManageEvent(aaElem('home'),'click', Navigation.returnHome);
});

