
// this function is need to work around 
// a bug in IE related to element attributes
function hasClass(obj) {
	var result = false;
	if( obj ){
		var oClass = obj.getAttributeNode("class");
		result = (	oClass != null 
				&&	oClass.value != "left"
				&&	oClass.value != "right" );
	}
	return result;
}  
  
function stripe(args) {
	// the flag we'll use to keep track of 
	// whether the current row is odd or even
	var even = false;
	// if arguments are provided to specify the colours
	// of the even & odd rows, then use the them;
	// otherwise use the following defaults:
	var id = args.id ? args.id : "zebra_grid";		
	var evenColor = args.evenColor ? args.evenColor : "#fff";//arguments[1] ? arguments[1] : "#fff";
	var oddColor =  args.oddColor ? args.oddColor : "#eee";//arguments[2] ? arguments[2] : "#eee";
	var headerColor = args.headerColor ? args.headerColor : '#E0E0EF';
	var firstRowHeader = args.firstRowHeader ? args.firstRowHeader : true;
	// obtain a reference to the desired table
	// if no such table exists, abort
	var table = document.getElementById(id);
	if ( !table ) { return; }
	// by definition, tables can have more than one tbody
	// element, so we'll have to get the list of child
	// &lt;tbody&gt;s 
	var tbodies = table.getElementsByTagName( "tbody" );
	// and iterate through them...
	for ( var h = 0; h < tbodies.length; h++ ) {
		// find all the &lt;tr&gt; elements... 
		var trs = tbodies[h].getElementsByTagName("tr");
		// ... and iterate through them
		for (var i = 0; i < trs.length; i++) {
			// get all the cells in this row...
			var tds = trs[i].getElementsByTagName("td");
			// and iterate through them...
			for (var j = 0; j < tds.length; j++) {
				var td = tds[j];
				if( firstRowHeader && i == 0 ){
					td.style.backgroundColor = headerColor;
				}
				// avoid cells that have a class attribute
				// or backgroundColor style
				else if (! hasClass(td) && ! td.style.backgroundColor) {
					td.style.backgroundColor = even ? evenColor : oddColor;
				}
				
				if(j==0){
					td.style.borderRight = "1px solid #C0C0E6";
				}
			}
			// flip from odd to even, or vice-versa
			even =  ! even;
		}
	}
}
  
jQuery(document).ready(function() {
	stripe(	{
			 id				:'zebra_grid'
			,evenColor		:'#FFFFFF'
			,oddColor		:'#F0F0FF'
			,headerColor	:'#EFEFEF'
			,firstRowHeaders:true
	});
});