
// create an array to store the responses from our ajax requests (, which are generated through the "sack()" object defined in the ajax_sack javascript library (ajax_sack.js)).  The only reason to create this as an array instead of a regular variable is in case we want to make multiple ajax requests simultaneously -- we'd need an associative array to keep track of which response was a result of which request, and a way to access the completed responses. 
	var dynamicContent_ajaxObjects = new Array();   

// create another array to act as a cache for previously-requested data.  This array will store data according to the full path of the requested file, including all arguments.  (i.e, in the array, the data associated with the path "http://...nav.php?select=Education" is different than the data associated with the path "http://...nav.php?select=Experience")
	var jsCache = new Array();

	var enableCache = true;   // enable or disable cache functionality here


	function ajax_loadContent(pathToFile,divID) {  // function to load content from file, based on the path to the file including all arguments (i.e, "...parent=...&select=...)

	// if the cache is enabled, and the requested file path matches one already stored in the array, then load that file path's associated data from the cache instead of requesting it from the file all over again.	
		if(enableCache && jsCache[pathToFile]){  
// alert ("Debug: It's from cache: '" + pathToFile + "'")	;
			document.getElementById(divID).innerHTML = jsCache[pathToFile];  // display the data from the array in the div with the given divID
			return;
		}
		
		var ajaxIndex = dynamicContent_ajaxObjects.length;  //  store the length of the dynamicContent_ajaxObjects array in the variable ajaxIndex.  This will be used to add an additional element to the array.  (If the length is 2, then the array already has elements 0 & 1 defined; the next element would be dynamicContent_ajaxObjects[2] )  
		
		document.getElementById(divID).innerHTML = 'Loading content...';  // display a "loading" message in the div identified by divID

		dynamicContent_ajaxObjects[ajaxIndex] = new sack(); // create a new sack() object; this object will be accessed by reference to the array element dynamicContent_ajaxObjects[ajaxIndex]

		dynamicContent_ajaxObjects[ajaxIndex].requestFile = pathToFile; // same as saying, "set sack().requestFile equal to [path to file]"

		dynamicContent_ajaxObjects[ajaxIndex].onCompletion = function() { ajax_showContent(pathToFile,divID,ajaxIndex); };  // once ajax is finished (i.e, request has been sent, & response has been received), call the function  ajax_showContent, passing it the divID, ajaxIndex, and pathToFile arguments.  

		dynamicContent_ajaxObjects[ajaxIndex].runAJAX();  // execute the Ajax call
	
	}


	// function to display the content returned in response to Ajax call executed above; and to store the response in the cache, if enabled.
	function ajax_showContent(pathToFile,divID,ajaxIndex)	{

		document.getElementById(divID).innerHTML = dynamicContent_ajaxObjects[ajaxIndex].response;  // display the response in the div with the given divID

		if(enableCache){  // if the cache is enabled, store the response in the cache array, in the element identified as [pathToFile] 
			jsCache[pathToFile] = dynamicContent_ajaxObjects[ajaxIndex].response;
		}
		
		dynamicContent_ajaxObjects[ajaxIndex] = false;  // clear the current index from the dynamicContent_ajaxObjects array.  (No need to keep it in the array -- and thus in memory -- once we're finished with it.)
	}

