﻿// ReformatResults.js

// Author: T.Allen
// May 2008
setTimeout("ReformatTable();",0);
function ReformatTable()
{
    // to get from excel to grid containing links... it's a little more complicated than it should be!
    
    // obtain a reference to the desired table
    // if no such table exists, abort
    var table = document.getElementById("ctl00_cplCountyPool_gvResults");
    if (! table) { return; }
    
    // by definition, tables can have more than one tbody
    // element, so we'll have to get the list of child
    // <tbody>'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++) {
        // get all the cells in this row...
        var tds = trs[i].getElementsByTagName("td");
        // and iterate through them...
        for (var j = 0; j < tds.length; j++) {
          var mytd = tds[j];
          var mytdtext = mytd.innerHTML;
          mytdtext=mytdtext.replace(/&amp;/g,"&");
          mytdtext=mytdtext.replace(/&lt;/g,"<");
          mytdtext=mytdtext.replace(/&gt;/g,">");
          mytd.innerHTML=mytdtext;
        }
        var ths = trs[i].getElementsByTagName("th");
        // and iterate through them...
        for (var j = 0; j < ths.length; j++) {
          var myth = ths[j];
          var mythtext = myth.innerHTML;
          mythtext=mythtext.replace("MatchCard","<img src='../Resources/pdficon_small.gif' />");
          myth.innerHTML=mythtext;
        }
      }
    }
    return;
}


