// 
//	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 by Jon T. Camp.  All rights reserved.
// 
function dataColToTableCol(nDataCol) 
{
	if (bDefaultFormat) return nDataCol;
	else return (nDataCol * 2) + 1;
}

function dataColToTableHeaderCol(tableData, nDataCol)
{
	// special case
	if (tableData.Table.id == "tableTotalId")
	{
		if (nDataCol == 0) return (bDefaultFormat ? 0 : 1);
		else if (nDataCol > 6) return (bDefaultFormat ? nDataCol - 4 : ((nDataCol - 4) * 2) + 1);
		else return (bDefaultFormat ? nDataCol - 1 : (nDataCol - 1) * 2);
	}
	else
	{
		if (bDefaultFormat) return nDataCol;
		else return (nDataCol * 2) + 1;
	}
}

function dataColToTableHeaderRow(tableData, nDataCol)
{
	// special case
	if (tableData.Table.id == "tableTotalId")
	{
		if ((nDataCol == 0) || (nDataCol > 6)) return (bDefaultFormat ? 1 : 3);
		else return (bDefaultFormat ? 2 : 5);
	}
	else return (bDefaultFormat ? 1 : 3);
}

function dataColToTableHeaderRowSpan(tableData, nDataCol)
{
	// special case
	if (tableData.Table.id == "tableTotalId")
	{
		if ((nDataCol == 0) || (nDataCol > 6)) return (bDefaultFormat ? 2 : 3);
		else return 1;
	}
	else return 1;
}

function dataRowToTableRow(nDataRow) 
{
	if ((!bDefaultFormat) && (bDivideRows)) return nDataRow * 2;
	else return nDataRow;
}

function tableColToDataCol(nTableCol) 
{
	if (bDefaultFormat) return nTableCol;
	else return (nTableCol - 1) / 2;
}

function tableHeaderColToDataCol(tableData, nTableCol, nTableRow)
{
	// special case
	if (tableData.Table.id == "tableTotalId")
	{
		if (bDefaultFormat)
		{
			if (nTableRow == 1) return (nTableCol == 0 ? 0 : nTableCol + 4);
			else return nTableCol + 1;
		}
		else
		{
			if (nTableRow == 3) return (nTableCol == 1 ? 0 : ((nTableCol - 1) / 2) + 4);
			else return (nTableCol / 2) + 1;
		}
	}
	else
	{	
		if (bDefaultFormat) return nTableCol;
		else return (nTableCol - 1) / 2;
	}
}

function tableRowToDataRow(nTableRow) 
{
	if ((!bDefaultFormat) && (bDivideRows)) return nTableRow / 2;
	else return nTableRow;
}

