// Zebra Table
// by Dan Gallacher
// This code requires jQuery.
// It is up to you to make sure that the jQuery library is included before this code is executed.

$( function() {
	$( '.zebra' ).each( function(i) {
		var zebra = $(this);
		if( this.tagName ) {
			if( this.tagName.toLowerCase() != 'table' ) zebra = zebra.find( 'table' );
		} else {
			zebra = zebra.find( 'table' );
		}
		if( !zebra ) return true;
		var tbody = zebra.find( 'tbody' );
		if( tbody ) zebra = tbody;
		// jQuery indexes rows starting with 0, which means that jQuery thinks of the first row as even.
		// Humans, usually think of the first row as odd, hence the inverson here.
		zebra.children( 'tr:even' ).addClass( 'odd' );
		zebra.children( 'tr:odd' ).addClass( 'even' );
	} );
} );