// zy_colortable.js
//
// Brief: Render different colors row by row in table.
// Author: zy
//
var COLOR_TABLE_CLASS = "zy_color_table";

function color_table_setrowcolor(oTable, oddClass, evenClass)
{
	color_table_resetcolor(oTable);
	for ( var i = 1; i < oTable.rows.length; i++ )
	{
		if ( i % 2 == 0 )
			oTable.rows[i].className = evenClass;
		else
			oTable.rows[i].className = oddClass;
	}
}

function color_table_resetcolor(oTable)
{
	for ( var i = 1; i < oTable.rows.length; i++ )
	{
		oTable.rows[i].className = "";
		for (var j = 0; j < oTable.rows[i].cells.length; j++ )
			oTable.rows[i].cells[j].className = "";
	}
}

function color_table_init()
{
	if ( aUA_TYPE[UA_IE] )
		var className = "className";
	else
		var className = "class";

	var tbls = document.getElementsByTagName("table");

	for ( var i = 0; i < tbls.length; i++ )
	{
		// alert(tbls[i].getAttribute(className));
		if ( tbls[i].getAttribute(className) == COLOR_TABLE_CLASS )
		{
			color_table_setrowcolor(tbls[i], "ctblTrOdd", "ctblTrEven");
		}
	}
}

addEventX(window, "load", color_table_init);
