var dynamicContent_ajaxObjects = new Array(); 
   var jsCache = new Array();
var enableCache = false; 
 
  
function ajax_loadContent(divId,pathToFile)
{

 if(enableCache && jsCache[pathToFile]){
    document.getElementById(divId).innerHTML = jsCache[pathToFile];
    return;
  }
  var ajaxIndex = dynamicContent_ajaxObjects.length;
  //document.getElementById(divId).innerHTML = 'Loading content...';
  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 evalScript(scripts)
{	try
	{	if(scripts != '')	
		{	var script = "";
			scripts = scripts.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){
	       	                         if (scripts !== null) script += arguments[1] + '\n';
 	        	                        return '';});
			if(script) (window.execScript) ? window.execScript(script) : window.setTimeout(script, 0);
		}
		return false;
	}
	catch(e)
	{	
	}
}
function ajax_showContent(divId,ajaxIndex,pathToFile)
{

  var newdiv = document.createElement("newdiv");
  newdiv.innerHTML = dynamicContent_ajaxObjects[ajaxIndex].response;
  var container = document.getElementById(divId);

  if(container.hasChildNodes()){
	  while(container.childNodes.length >0){
		  container.removeChild(container.firstChild);
	  }
  }
  container.appendChild(newdiv);

  if(enableCache){
    jsCache[pathToFile] =
    dynamicContent_ajaxObjects[ajaxIndex].response;
  }
  evalScript(newdiv.innerHTML);
  dynamicContent_ajaxObjects[ajaxIndex] = false;
}

function addPoint(divId,points)
{
  document.getElementById(divId).innerHTML = points;
  dynamicContent_ajaxObjects[ajaxIndex] = false;
}
