var ajax = new sack();

function sortResults(sel)
{
// Specifying which file to get	
	ajax.requestFile = sel;
	//alert(ajax.requestFile)
// Specify function that will be executed after file has been found
	ajax.onCompletion = createResults;
	ajax.onInteractive = showStatus;
// Execute AJAX function
	ajax.runAJAX();
}

function showStatus(){
	window.status = 'sorting...';
}

function createResults()
{
	var tbls = document.getElementById('resulttable');
	
	var newrows = new Array();
// Executing the response from Ajax as Javascript code
	//alert(ajax.response);
	eval(ajax.response);
	
	updaterows(tbls,newrows);
	window.status='Done';
}

function updaterows(tbls,newrows){
	var i;
	var j;
	var count = tbls.rows.length;
	var offset = count - newrows.length;
	//alert(count)
	//change content of rows
	//start from row2
	for(i=0;i<newrows.length;i++){
		for(j=0;j<newrows[i].length;j++){
			tbls.rows[i+offset].cells[j].innerHTML = newrows[i][j];
		}
	}

}