var dynamicContent_ajaxObjects = new Array();
var jsCache                    = new Array();
var enableCache                = false;

//JQuery AJAX// (Requires JQuery Include Scripts)
function JQAjax(TargetElement,pathToFile,LoadingCode,FollowingFunction)
	{
	$.ajaxSetup ({cache: false });
	if(FollowingFunction!=null)
		{
		$('#'+TargetElement).html(LoadingCode).load(pathToFile,null,function(){eval(FollowingFunction)});
		}
	else
		{
		$('#'+TargetElement).html(LoadingCode).load(pathToFile,null);
		}
	}
///////////////

function ajax_loadContent(divId,pathToFile,LoadingCode)
{
  if(enableCache && jsCache[pathToFile]){
    document.getElementById(divId).innerHTML = jsCache[pathToFile];
    return;
  }
  
  var ajaxIndex = dynamicContent_ajaxObjects.length;
	if(LoadingCode!='')
		{
		document.getElementById(divId).innerHTML = 	LoadingCode;
		}
  dynamicContent_ajaxObjects[ajaxIndex] = new sack();
  dynamicContent_ajaxObjects[ajaxIndex].requestFile = pathToFile;

  dynamicContent_ajaxObjects[ajaxIndex].onCompletion =
  function(){ ajax_showContent(divId,ajaxIndex,pathToFile); };  

  dynamicContent_ajaxObjects[ajaxIndex].runAJAX();
}

function ajax_showContent(divId,ajaxIndex,pathToFile)
{
  document.getElementById(divId).innerHTML =
    dynamicContent_ajaxObjects[ajaxIndex].response;
  if(enableCache){
    jsCache[pathToFile] =
    dynamicContent_ajaxObjects[ajaxIndex].response;
  }
  dynamicContent_ajaxObjects[ajaxIndex] = false;
}

function ajax_loadContentWithFunction(divId,pathToFile,LoadingCode,EndOfExecutionFunction)
{
  if(enableCache && jsCache[pathToFile]){
    document.getElementById(divId).innerHTML = jsCache[pathToFile];
    return;
  }
  
  var ajaxIndex = dynamicContent_ajaxObjects.length;
	if(LoadingCode!='')
		{
		document.getElementById(divId).innerHTML = 	LoadingCode;
		}
  dynamicContent_ajaxObjects[ajaxIndex] = new sack();
  dynamicContent_ajaxObjects[ajaxIndex].requestFile = pathToFile;

  dynamicContent_ajaxObjects[ajaxIndex].onCompletion =
  function(){ ajax_showContentWithFunction(divId,ajaxIndex,pathToFile,EndOfExecutionFunction); };  

  dynamicContent_ajaxObjects[ajaxIndex].runAJAX();
}

function ajax_showContentWithFunction(divId,ajaxIndex,pathToFile,EndOfExecutionFunction)
{
  document.getElementById(divId).innerHTML =
    dynamicContent_ajaxObjects[ajaxIndex].response;
  if(enableCache){
    jsCache[pathToFile] =
    dynamicContent_ajaxObjects[ajaxIndex].response;
  }
  dynamicContent_ajaxObjects[ajaxIndex] = false;
	eval(EndOfExecutionFunction);
}

