// This function came from an article titled "Alter Table Row
// Background Colors Using JavaScript" by Kennet Svanberg.
//     http://www.sitepoint.com/article/background-colors-javascript/
// Accessed 5/17/2009
// Modified by Alyce Brady to add comments and rename the "alternate"
// function to "alternateRows".

// The alternateRows function defined in this file associates the "odd"
// and "even" class names with alternating rows in a given table.
// To use the alternateRows function, create an HTML table with an
// id.  When the page loads, call the alternateRows function for that
// table.  For example:
//  <html>
//  …
//  <style>
//   .odd{background-color: white;}
//   .even{background-color: gray;}
//  </style>
//  …
//  <body onload="alternateRows('thetable')">
//  <table id="thetable">
//  <tr><td>…</td></tr>
//  </table>
//  …

// Associates the "odd" and "even" class names with alternating rows in
// the table with the specified id.
//    @param id  The id name/string for the table to modify
function alternateRows(id){
 if(document.getElementsByTagName){  
   var table = document.getElementById(id);  
   var rows = table.getElementsByTagName("tr");  
   for(i = 0; i < rows.length; i++){          
 //manipulate rows
     if(i % 2 == 0){
       rows[i].className = "even";
     }else{
       rows[i].className = "odd";
     }      
   }
 }
}
