/************************************************************************************************************
(C) www.dhtmlgoodies.com, June 2006

This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	

Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.

Thank you!

www.dhtmlgoodies.com
Alf Magne Kalleland

Edited on Mar 1 2008 by Willy Huang for use with the AKPsi E-Rho site

************************************************************************************************************/

var ajaxObjects = new Array(); 
var jsCache = new Array();
var enableCache = false; 

function ajax_loadContent(divId,pathToFile)
{
  if(enableCache && jsCache[pathToFile]){
    document.getElementById(divId).value = jsCache[pathToFile];
    return;
  }
  
  if (pathToFile=="NO_PAGE") {
	  document.getElementById(divId).value = 'Select a page above...';
	  return;
  }
  
  var ajaxIndex = ajaxObjects.length;
  document.getElementById(divId).value = 'Loading content from '+pathToFile+'...';
  ajaxObjects[ajaxIndex] = new sack();
  ajaxObjects[ajaxIndex].requestFile = pathToFile;

  ajaxObjects[ajaxIndex].onCompletion = 
  function(){ ajax_showContent(divId,ajaxIndex,pathToFile); };  

  ajaxObjects[ajaxIndex].runAJAX();  
  
  
} 

function ajax_showContent(divId,ajaxIndex,pathToFile)
{
  document.getElementById(divId).value =
    ajaxObjects[ajaxIndex].response;
  if(enableCache){
    jsCache[pathToFile] = 
    ajaxObjects[ajaxIndex].response;
  }
  ajaxObjects[ajaxIndex] = false;
}



