 function loadAll(section, page){
  if (page == null) {
    page = 1;
  }
  if(section == 'posts'){
  ajaxRead('posts-content.php', 'content', page);
  ajaxRead('comments-sidebar.php', 'sidebar1');
  ajaxRead('photos-sidebar.php', 'sidebar2');
  ajaxRead('videos-sidebar.php', 'sidebar3');
  }
  else if(section == 'photos'){
  ajaxRead('photos-content.php', 'content', page);
  ajaxRead('posts-sidebar.php', 'sidebar1');
  ajaxRead('comments-sidebar.php', 'sidebar2');
  ajaxRead('videos-sidebar.php', 'sidebar3');
  }
  else if(section == 'videos'){
  ajaxRead('videos-content.php', 'content', page)
  ajaxRead('posts-sidebar.php', 'sidebar1');
  ajaxRead('comments-sidebar.php', 'sidebar2');
  ajaxRead('photos-sidebar.php', 'sidebar3');
  }
  else {
  return;
  }
 }

 function loadContent(section, page){
  if (page == null) {
    page = 1;
  }
  if(section == 'posts'){
  ajaxRead('posts-content.php', 'content', page);
  updateForm(page);
  }
  else if(section == 'photos'){
  ajaxRead('photos-content.php', 'content', page);
  }
  else if(section == 'videos'){
  ajaxRead('videos-content.php', 'content', page)
  }
  else if(section == 'links'){
  ajaxRead('links-content.php', 'content', page)
  }
  else {
  return;
  }
 }



 function ajaxRead(file, target, page){
  if (page != null) {
    file = file + "?page=" + page;
  }
  var xmlObj = null;
  if(window.XMLHttpRequest){
      xmlObj = new XMLHttpRequest();
  } else if(window.ActiveXObject){
      xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
  } else {
      return;
  }
  xmlObj.onreadystatechange = function(){
    if(xmlObj.readyState == 4){
       updateSite(xmlObj.responseText, target);
     }
    }
    xmlObj.open ('GET', file, true);
    xmlObj.send ('');
  }

 function updateSite(data, target){
  document.getElementById(target).innerHTML = data;
 }

 function updateForm(data){
   document.forms[0].pageselect.options[selectedIndex].value = data-1;
 }

