// 
//	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 buildTable(tableData) 
{
	var nRows = 0;
	var tbody = tableData.Table.tBodies[0];
	var td;
	var tr;

	for (var i = 0; i < tableData.DataColCount; i++) 
	{
		var nodeElement = tableData.Node.getElementsByTagName(tableData.Elements[i]).item(0);
		var nodeList = nodeElement.getElementsByTagName(tableData.IDs[i]);
		if (nodeList.length > nRows) nRows = nodeList.length;
	}
	
	for (var i = 0; i < nRows; i++) 
	{
		tr = appendRow(tbody);
		if (((i + 1) % 6 == 0) || ((i + 1) % 6 > 3)) tr.className = "tr1";
		tableData.Ptr[i] = i;
		if (!bDefaultFormat) appendCell(tr, "", "border", 1);
		
		for (var j = 0; j < tableData.DataColCount; j++) 
		{
			td = appendCell(tr, "");
			if (tableData.LeftAlign[j]) td.className = "td1";
			if ((!bDefaultFormat) && (j < tableData.DataColCount - 1)) appendCell(tr, "", "tborder", 1);
		}
		
		if (!bDefaultFormat) 
		{
			appendCell(tr, "", "border", 1);
			
			if (bDivideRows) 
			{
				tr = appendRow(tbody);
				appendCell(tr, "", "border", 1);
				appendCell(tr, "", "tborder", tableData.Table.width - 2, tableData.TableColCount - 2);
				appendCell(tr, "", "border", 1);
			}
		}
	}
}
