
  
  // 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 stripeObj(obj) {
    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 evenColor = arguments[1] ? arguments[1] : "#fff";
    var oddColor = arguments[2] ? arguments[2] : "#e4edf1";
  
    var table = obj;
    if (! table) { return; }
    
    var tbodies = table.getElementsByTagName("tbody");
	
    for (var h = 0; h < tbodies.length; h++) {
      var trs = tbodies[h].getElementsByTagName("tr");
      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) {
          var tds = trs[i].getElementsByTagName("td");
          for (var j = 0; j < tds.length; j++) {
            var mytd = tds[j];
            // avoid cells that have a class attribute
            // or backgroundColor style
            if (! hasClass(mytd) &&
                ! mytd.style.backgroundColor) {
              mytd.style.backgroundColor =
                even ? evenColor : oddColor;
            }
          }
        }
        even =  ! even;
      }
    }
  }


//  var requiredStripeClass = 'zebraTable'; //optional variable, defining the class which is required to "stripe" a table. If empty or null, all tables will be "striped"
//var evenColor = '#fff';
//var oddColor = '#e4edf1';
// This method can be called with no arguments or arguments in this order: (requiredStripeClass, evenColor, oddColor)
function stripeAll(){ //stripe all tables, OR all tables containing the "requiredStripeClass" class
	var tList = document.getElementsByTagName('table');
    var requiredStripeClass = arguments[0] ? arguments[0] : "zebraTable";
    var evenColor = arguments[1] ? arguments[1] : "#fff";
    var oddColor = arguments[2] ? arguments[2] : "#e4edf1";
    var t;
	if((typeof evenColor == 'undefined'))
		evenColor = null;
	if((typeof oddColor == 'undefined'))
		oddColor = null;
    for(var x = 0; x < tList.length; x++){
        t = tList[x];
		if((typeof requiredStripeClass != 'undefined') && (requiredStripeClass != null) && (requiredStripeClass != '')){

            var classes = new Array();
            classes = hasClass(t).split(" ");

            for (var i=0;i<classes.length;i++){
                if(classes[i] == requiredStripeClass){
                    stripeObj(t, evenColor, oddColor);
                    break;
                }
            }
        }
		else
            stripeObj(t, evenColor, oddColor);
	}
}
