// 
//	TYGR Productions Interactive Statistics
//	
//	This file contains JavaScript support functions for TYGR Productions' Interactive Statistics.  The code contained herein
//  is NOT in the public domain.  This file is provided for download to personal computers and is only authorized for personal 
//  use in conjuction with TYGR Productions' Interactive Statistics.  Copying or reposting this file in whole or in part on 
//  any web server or other network server, or reusing any portion of the code is not allowed without express written consent 
//  of the author.  Any commercial use is strictly prohibited.
//	
//	Copyright (c) 2005, 2006 by Jon T. Camp.  All rights reserved.
// 
function setSort(tableData, nSortIndex) 
{
	tableData.SortIndex = nSortIndex;
	sortPointers(tableData);
	loadTable(tableData);
	
	if (bDefaultFormat) 
	{
		tableData.StatusElement.firstChild.nodeValue = 
			"Sorted by " + tableData.Status[tableData.SortIndex];
	}
	else 
	{
		tableData.StatusElement.innerHTML = 
			"&nbsp;Sorted by " + tableData.Status[tableData.SortIndex];
	}
	
	drawHighlight(tableData);
}

function sortPointers(tableData) 
{
	var aPointers = [];
	var aSorted = [];
	var aValues = [];

	loadValues(tableData, tableData.SortIndex, aValues);
	sortValues(tableData, tableData.SortIndex, aPointers, aSorted, aValues);
	for (var i = 0; i < aPointers.length; i++) tableData.Ptr[i] = aPointers[i];
}
