 
function showPage() {
   window.location.hash = this.identifier;
   getPage(this.identifier);
}

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 current;

   var pageCount = 11;

   var index;
   var hash = window.location.hash;
   if (hash) {
      index = hash.split("#")[1];
   }

   for (var i = 1; i <= pageCount; i++) {
      var id = 'part' + i;
      var nav = Navigation.addNavigationNode(past,id,showPage);
      if (!past) {
        home = nav;
      }
      past = nav;
      if (index && id == index)
        current = nav;
   }

   Navigation.setHome(home);
  
   if (!current) {
      Navigation.setCurrentPage(home);
   } else {
      Navigation.setCurrentPage(current);
   }

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

