// JavaScript Document

function trimAndInsert(rawContent,containerID,startText,endText,theUrl){
	var theContainer=document.getElementById(containerID);
	var theContent=rawContent;
	var theStart=theContent.indexOf(startText);
	var theEnd=theContent.indexOf(endText);
	var theSlice=theContent.slice(theStart,theEnd);
	theContainer.innerHTML=theSlice;
}

function getPage(url,placeHolderID,startText,endText){
	new Ajax.Request(url,
	    {
	    method: 'get',
	    onSuccess: function(processPage){
	       	var theResponseText=processPage.responseText || 'Nothing was returned';
           	trimAndInsert(theResponseText,placeHolderID,startText,endText,url);
           },
	    onFailure: function(){
			document.getElementById(placeHolderID).innerHTML='There was a problem getting information from the server.<br />Please try again in a few moments.';
	    }
	});
}

function getAspx(url,placeHolderID){
	/*{success: placeHolderID} means that the container div will only be updated if thers is a successful response to the XMLhttpRequest call. */
	new Ajax.Updater({success: placeHolderID},url,{
		evalScripts: true
	});
}
