/* 
 * Synopsis: 1. Add different colors to odd and even rows 2. Mark the selectedRow
 * Function: stripe
 * Params:
 *   tableId : The table id 
*/ 
function stripe(tableId) { 	
 	if((selectedRow = getSelectedRow()) != '')
 		markSelectedRow(selectedRow);
    // the flag we'll use to keep track of 
    // whether the current row is odd or even
    var even = false;
  
    // obtain a reference to the desired table
    // if no such table exists, abort
    var table = document.getElementById(tableId);
    if (! table) {  return; }
    
    // by definition, tables can have more than one tbody
    // element, so we'll have to get the list of child
    // &lt;tbody&gt;s 
    var tbodies = table.getElementsByTagName("tbody");

    // and iterate through them...
    for (var h = 0; h < tbodies.length; h++) {
      // find all the &lt;tr&gt; elements... 
      var trs = tbodies[h].getElementsByTagName("tr");      
      // ... and iterate through them
      for (var i = 0; i < trs.length; i++) {        
 		if(trs[i].style.display != '' || trs[i].className.indexOf('selected') >= 0) {
 		  continue;
 		}
 		
 		// Give TR-tag a class containing a style for the background color
 		trs[i].className = even ? 'even' : 'odd';
        
        // flip from odd to even, or vice-versa
        even = !even;
     }
   }
}

/* 
 * Synopsis: Mark the selected row with a unique color
 * Function: markSelectedRow
 * Params:
 *   rowId : The row id 
*/    
function markSelectedRow(rowId) {
  var row = document.getElementById(rowId);
  if (row) {
    row.className = 'selected';	
  }
}


