/*
 Because some of the walks on the walks' programme take up two rows, this script has been designed to highlight both rows together in such cases. A row is deemed to be the lower part of a double row if its cell containing the 'time' is empty. Call this the 'test-cell'. In rare cases a walk may not have the time specified and would wrongly be considered part of the entry for the row above. By including a 'non breaking space', in the test-cell, (when updating the walks' programme say), the row is not coupled with the one above. 

Using the attribute 'colspan' to join up cells in a row could effect whether two rows were paired up or not. For example, if the test-cell is joined to adjacent cells and the combination is empty, then any following joined-up cells will affect the pairing of rows, depending on whether they have any content or not. If they have content, the rows don't pair up. If they are empty, they do! Correct operation will always occur if the test-cell is isolated from other cells,

*/
function highlightRows() {
  oldBgColr = new Array;
  highBgColr = "#bbb";
  if(!document.getElementsByTagName) return false;
  var tbls = document.getElementsByTagName("table");
  for (var i = 0; i<tbls.length; i++){ //for i
      var rows = tbls[i].getElementsByTagName("tr");
      for ( j=1; j<(rows.length-1) ; j++) {  // for j, (first row does not contain a walk. Table does not include any headings and last row is blank.)
          partAbove = false;
          partBelow = false;
          numRow = rows.length;
          tBody = false;
          rows[j].onmouseover = function() { // anon 1
              partAbove = false;
              partBelow = false;
              hiLitePos = -1;
  	   	     oldBgColr[1] = this.style.backgroundColor;
  	   	     this.style.backgroundColor = highBgColr;
  	   	     
  	   	    var  hdOrBodyElem = this.parentNode;
  	   	    tNode = hdOrBodyElem.nodeName;
  	   	     if (tNode == "TBODY"){ tBody = true;}
  	   	     if(tBody){//if 1
  	   	     rowCopy = new Array;
  	   	     rowCopy = hdOrBodyElem.getElementsByTagName("tr");
  	   	     for(i=2; i< rowCopy.length-2; i++){  // Note:  Selection is from tbody (not table) and so hiLitePos (below) is limited to between 2 and rowCopy.length-2,
  	   	                                                        // in order to keep possible highlighting of a row above or below the present line, within bounds of tabulated walks.
  	   	     if(rowCopy[i] == this){ //if 2
  	   	     hiLitePos = i;
  	   	     i = rowCopy.length;
  	   	     } // end of if 2
  	   	     } //end of for i
  	   	     if(hiLitePos != -1){ // if 2a
  	   	     oldBgColr[0] = rowCopy[hiLitePos-1].style.backgroundColor;
  	   	     
  	   	     oldBgColr[2] = rowCopy[hiLitePos+1].style.backgroundColor;
  	   	     
  	   	       var tdTxtHere="";
  	   	       var tdTxtDown ="";
  	   	     var cells1 = new Array;
  	   	     var cells2 = new Array;
  	   	     cells1 =rowCopy[hiLitePos].getElementsByTagName("td");
  	   	     cells2 =rowCopy[hiLitePos+1].getElementsByTagName("td");
  	   	    if(cells1[1]){ tdTxtHere = getTextValue(cells1[1]); } // Assumption:  walk-times appear in 2nd cell, cells1[1], unless row extends from row above
  	   	     if(tdTxtHere == undefined) { // if3
  	   	      partAbove = true;  //  this row extends from row above
  	   	     } // end of if 3
  	   	     
  	   	     if(cells2[1]){var tdTxtDown = getTextValue(cells2[1]); } //2nd cell, next row down
  	   	    
  	   	      if (tdTxtDown == undefined) { // if 4
                    partBelow = true;  // row extends below present row
  	   	     } // end of if 4
  	   	      if(partBelow) {rowCopy[hiLitePos+1].style.backgroundColor = highBgColr;}
  	   	      if(partAbove) {rowCopy[hiLitePos-1].style.backgroundColor = highBgColr;}
  	   	      } // end of if 2a
  	   	    } // end of if1
  	   	    } // end of onmouseover  
  	   	rows[j].onmouseout = function() { // anon 2
             this.style.backgroundColor =oldBgColr[1]; 
                  
  	   	     if (tBody && hiLitePos != -1){ //if5
  	   	        rowCopy[hiLitePos-1].style.backgroundColor = oldBgColr[0];
                rowCopy[hiLitePos+1].style.backgroundColor = oldBgColr[2];
  	   	      } // end of if 5
  	      }  //end of onmouseout 
      }  // end of for j
  	}   //end of for i
}   //eof highlightRows  	     
  	   	     
  	   	     
  


addLoadEvent(highlightRows);