// script to stripe rows in a table
// based upon a script from
// http://www.alistapart.com/d/stripedtables/script.txt
//
// will skip rows that have either 
//	a class or background color applied to them.
// modified: oct 1 2006		by: mjb

function stripe(id) {
    var even = false;
  
    // if arguments are provided to specify the class
    // of the even & odd rows, then use the them;
    // otherwise use the following defaults:
    var oddColor = arguments[1] ? arguments[1] : "oddrow";
    var evenColor = arguments[2] ? arguments[2] : "evenrow";
  
    // obtain a reference to the desired table
    // if no such table exists, abort
    if (document.getElementById) var table = document.getElementById(id);
    else if (document.all) var table = document.all[id];
    // fail silently
    if (!table)  return; 
    
    // by definition, tables can have more than one tbody
    // element, so we'll have to get the list of child
    // <tbody>s 
    var tbodies = table.getElementsByTagName("TBODY");

    // and iterate through them...
    for (var h = 0; h < tbodies.length; h++) {

		// find all the <tr> elements... 
		var trs = tbodies[h].getElementsByTagName("TR");

		// ... and iterate through them
		for (var i = 0; i < trs.length; i++) {

        	// avoid rows that have a class attribute or backgroundColor style
			if (!( hasClass(trs[i]) || trs[i].style.backgroundColor || trs[i].getAttribute("bgcolor"))) {

				trs[i].className = even ? evenColor : oddColor;

				even =  ! even;
    	    }
		}
    }
}

// this function is needed to work around 
// a bug in IE related to element attributes
function hasClass(obj) {
	return  (obj.getAttributeNode("class")) ? obj.getAttributeNode("class").value : false ;
}   


