/*---------------------------------------------------------------------
	initTableColorAltRows function
		Will use DOM to grab all tables on page, look for a rows within a <thead> tag in each
		to see if this table is a candidate for alternating row colors.,
		then alternate classes "Odd" and "Even" for each table row.

	REQUIREMENTS:
		Place this .js file in the <head> of any page that has tables.
	
	USAGE:
		Make sure function initTableColorAltRows()
		is called in the window.onload event (found in /assets/js/init.js).
-----------------------------------------------------------------------*/

function initTableColorAltRows() {
	if (!document.getElementById) return

	var aTables = document.getElementsByTagName('table');
	for( var i = 0; i < aTables.length; i++ ) {
		//	check to see if there are rows that exist within a <thead>,
		//	if so, this table is a candidate for alternating rows
		if (aTables[i].tHead) {
			for( var j = 0; j < aTables[i].rows.length; j++ ) {
				if (j%2) {
					//aTables[i].rows[j].className = 'Odd';
					cssClassActions('add',aTables[i].rows[j],'Odd');
				} else {
					//aTables[i].rows[j].className = 'Even';
					cssClassActions('add',aTables[i].rows[j],'Even');
				}
			}
		}
	}
	
	var aThead = document.getElementsByTagName('thead');
	for( var i = 0; i < aThead.length; i++ ) {
		for( var j = 0; j < aThead[i].rows.length; j++ ) {
			//aThead[i].rows[j].className = 'TableHead';
			cssClassActions('add',aTables[i].rows[j],'TableHead');
		}
	}
}

/*---------------
	Add to window.onload event
---------------*/
addEvent(window, 'load', initTableColorAltRows, false);