// zebra tables for striping table rows.
// modified to stripe all typo3 content element tables
// instead of objects with ids.
//
// from http://www.alistapart.com/articles/zebratables

// this function is needed to work around 
// a bug in IE related to element attributes
  function hasClass(obj) {
     var result = false;
     if (obj.getAttributeNode("class") != null) {
         result = obj.getAttributeNode("class").value;
     }
     return result;
  }   

 function stripeTables() {
	var mainContent = document.getElementById("main");
	if (!mainContent) { return; };

	var tables = mainContent.getElementsByTagName("table");
	for (var t = 0; t < tables.length; t++) {
   		var even = false;
  
 	   var evenColor = arguments[1] ? arguments[1] : "#ddd";
  	   var oddColor = arguments[2] ? arguments[2] : "transparent";
 		
 		if (tables[t].className != "nostripe") { 
       var tbodies = tables[t].getElementsByTagName("tbody");

       for (var h = 0; h < tbodies.length; h++) {

       	  var trs = tbodies[h].getElementsByTagName("tr");
      
          for (var i = 0; i < trs.length; i++) {
	         var tds = trs[i].getElementsByTagName("td");
             for (var j = 0; j < tds.length; j++) {
    	        var mytd = tds[j];
                mytd.style.backgroundColor = even ? evenColor : oddColor;
             }
             even =  ! even;
          }
       }}
	}
}
  
addEventSimple(window,"load",stripeTables);