
// Netscape and MSIE friendly writer
function AdvancedWrite()
{
	if( !this.m_colSizes )
	{
		this.m_colSizes = new Array()
		this.m_colSizes[0] = 150
		for( row=1; row<this.m_lines[0].length; row++ )
			this.m_colSizes[row] = 120;
	}

	var virtual_columns = (2*(this.m_lines[0].length-1))+1
	
	var virtual_rows = 3 + 2 * this.m_lines.length
	if( this.m_colTitles && this.m_colTitles.length!=0 )
		virtual_rows += 2
	//virtual_rows = 32
	
	var out = ""
	out += '<TABLE cellSpacing=0 cellPadding=0 border=0>'
	out += '<TBODY>'

	// First Line
	first_line_cols = virtual_columns
	if( !this.m_separateCols )	first_line_cols = this.m_lines[0].length
	out += '<TR class="tblBord">'
	out += '<TD width=1 rowSpan='+ virtual_rows + '><SPACER width=1 height=1 type=block></TD>'
	out += '<TD colSpan='+ first_line_cols +' height=1><SPACER width=1 height=1 type=block></TD>'
	out += '<TD width=1 rowSpan='+ virtual_rows + '><SPACER width=1 height=1 type=block></TD>'
	out += '</TR>'

	// Title line
	out += '<TR class="tblTitleBg">'
	out += '<TD class="tblTextW" nowrap colSpan=' + virtual_columns +' height=20>&nbsp;&nbsp;' + this.m_title + '</TD>'
	out += '</TR>'
	
	// Col Titles
	if( this.m_colTitles && this.m_colTitles.length!=0 )
	{
		out += '<TR class="tblBord">'
		out += '<TD colSpan=' + virtual_columns + ' height=1><SPACER width=1 height=1 type=block></TD>'
		out += '</TR>'

		out += '<TR class="tblCellBg" align=center>'
		out += '<TD width='+ this.m_colSizes[0] + ' height=15>&nbsp;&nbsp;</TD>'
		title_span = 2
		if( !this.m_separateCols )
			title_span = 1
		for( i=1; i<this.m_colTitles.length; i++ )
			out += '<TD width='+ this.m_colSizes[i]+' colSpan='+title_span+'><SPAN class="stext">' + this.m_colTitles[i] + '</SPAN></TD>'
		out += '</TR>'
	}

	// No Lines to display ?
	if( this.m_lines==null || this.m_lines.length==0 )
		return

	// Separations
	out += '<TR class="tblBord">'
	out += '<TD><SPACER width=1 height=1 type=block></TD>'
	for( i=0; i<this.m_lines[0].length-1; i++ )
	{
		if( this.m_separateCols )
			out += '<TD width=1 rowSpan=' + virtual_rows +'><SPACER width=1 height=1 type=block></TD>'
		out += '<TD><SPACER width=1 height=1 type=block></TD>'
	}
	out += '</TR>'

	// Display lines
	col0_class = "tblCellBg"
	cols_class = "stext"
	if(!this.m_firstColAsTitles)	col0_class = "stext";
	if(this.m_colsAsTitles)			cols_class = "tblCellBg";
	
	for( line=0; line<this.m_lines.length; line++ )
	{
		out += '<TR align=center>'
		out += '<TD class="'+col0_class+'" align=left height=15 width='
			+ this.m_colSizes[0]+'><SPAN class="stext">&nbsp;&nbsp;'
			+ this.m_lines[line][0] + '</SPAN></TD>'
		for( row=1; row<this.m_lines[line].length; row++ )
			out += '<TD class="'+cols_class+'" width='+this.m_colSizes[row]+'>&nbsp;' + this.m_lines[line][row] + '&nbsp;</TD>'
		out += '</TR>'

		if( ((line+1)==this.m_lines.length) || this.m_separateLines )
		{
			out += '<TR class="tblBord">'
			out += '<TD colSpan='+virtual_columns+' height=1><SPACER width=1 height=1 type=block></TD>'
			out += '</TR>'
		}
	}

	out += "</TBODY></TABLE>\n"
	return out
}


function SuperArray()
{
	this.m_title		= "No title"
	this.m_colSizes		= null
	this.m_colTitles	= null
	this.m_lines		= null
	this.m_separateLines	= 1
	this.m_separateCols		= 1
	this.m_firstColAsTitles	= 1
	this.m_colsAsTitles		= 0

	this.Write			= AdvancedWrite
}

function SampleArray()
{
	var sample = new SuperArray()
	sample.m_title = "Sample Array"
/*
	sample.m_colTitles = new Array( " ", "P1", "P2", "P3")
	sample.m_lines = new Array(	new Array( "Line1 title", "aaaaaa  Value0", "Value zzz 1", "Value zzz 1"),
								new Array( "Line2 title", "Valueqdd0", "Value2", "Value zzz 1"),
								new Array( "Line3 title", "Vazerer", "Value3", "Value zzz 1") )
*/
	sample.m_colTitles = new Array( " ", "1", "2", "3")
	sample.m_lines = new Array(	new Array( "<B>Player 1</B>", "6", "4", "7"),
								new Array( "Player 2", "2", "6", "5") )
	sample.m_colSizes = new Array(160,50,50,50)

	sample.m_separateLines		= 0
	sample.m_separateCols		= 0
	sample.m_firstColAsTitles	= 1
	sample.m_colsAsTitles		= 1


	return sample
}
