// JavaScript Document
// This function will automatically alternate table row background colors by assigning classes.
// It will also give the first table row's <td> a class as well.
// You must give the table an id and add the function call script after the end of the table (the table must exist before this will work).
function alternate(tableId, tableheadercolor, evenRowColor, oddRowColor){		// id is the name of the table that it being passed in during the function call.
 if(document.getElementsByTagName){  
   var table = document.getElementById(tableId);
   var rows = table.getElementsByTagName("tr");		// this will assign all rows to an array called "rows"
   for(i = 0; i < rows.length; i++){          		// this loops through the array of rows to see how many there are
 //manipulate rows
 

     if(i == 0){		// if this is the first row in the array (a header row), we want to give the <td> tags a class
	 //var headerRow = rows[0].getElementsByTagName("tr");
	 rows[0].className = tableheadercolor;
	 }else if(i % 2 == 0){							// now we determine which rows are odd and which are even.
       rows[i].className = evenRowColor;		// if the row is even(divisible by 2 in the previous step) we assign a class.
     }else {
       rows[i].className = oddRowColor;			// these are the odd rows and get a different class assignment.
     }      
   }
 }
}


