var startRow = 1;
var loading = "";

scrollAction = function(){
	var container = Spry.$('display');
	if(!loading){
		if(container.scrollTop+container.clientHeight == container.scrollHeight){
			startRow = parseInt(startRow) + 10;
			getData();
		}
	}	
}

getData = function(){
	if(!loading){
		loading = true;
		Spry.$('loadingIcon').style.visibility = "visible";	
		Spry.Utils.loadURL("GET", "test.cfc?method=getRecords&_cf_nodebug=true&returnFormat=plain&startRow="+startRow, true, populateData);
	}	
}

populateData = function(request){
	var container = Spry.$('display');
	Spry.$('loadingIcon').style.visibility = "hidden";
	container.innerHTML = container.innerHTML + request.xhRequest.responseText;
	loading = false;
}

//use a load listener to ensure the DOM is ready
Spry.Utils.addLoadListener(function(){
	//attach a scroll listener to the div
	Spry.Utils.addEventListener("display", "scroll", scrollAction, false);
	//get the first batch of data
	getData(1);
});