Table JavaScript: Alternating columns

Here's a simple script for enabling alternating CSS classes on a table.

// ALT script
function createAlternatingRows(table, className) {
var tbodys = table.getElementsByTagName('tbody');
if (tbodys.length > 0)
table = tbodys[0];
var rows = table.getElementsByTagName('tr');
for (var i=0; i<rows.length; i++) {
if (i%2==0) rows[i].className = className;
}
}
createAlternatingRows(document.getElementById('myTable'), 'alt'); 

Just send it a table and a classname it and it handle the rest. It's setup to ignore <thead> and <tfoot> tags and it will overwrite other classes.