code: function computeTableHeaderCellIndexes(t) {
                  var matrix = [];
                  var lookup = {};
                  var thead = t.getElementsByTagName('THEAD')[0];
                  var trs = thead.getElementsByTagName('TR');
  
                  for (var i = 0; i < trs.length; i++) {
                      var cells = trs[i].cells;
                      for (var j = 0; j < cells.length; j++) {
                          var c = cells[j];
  
                          var rowIndex = c.parentNode.rowIndex;
                          var cellId = rowIndex + "-" + c.cellIndex;
                          var rowSpan = c.rowSpan || 1;
                          var colSpan = c.colSpan || 1
                          var firstAvailCol;
                          if (typeof(matrix[rowIndex]) == "undefined") {
                              matrix[rowIndex] = [];
                          }
                          // Find first available column in the first row
                          for (var k = 0; k < matrix[rowIndex].length + 1; k++) {
                              if (typeof(matrix[rowIndex][k]) == "undefined") {
                                  firstAvailCol = k;
                                  break;
                              }
                          }
                          lookup[cellId] = firstAvailCol;
                          for (var k = rowIndex; k < rowIndex + rowSpan; k++) {
                              if (typeof(matrix[k]) == "undefined") {
                                  matrix[k] = [];
                              }
                              var matrixrow = matrix[k];
                              for (var l = firstAvailCol; l < firstAvailCol + colSpan; l++) {
                                  matrixrow[l] = "x";
                              }
                          }
                      }
                  }
                  return lookup;
              }
docs: from: http://www.javascripttoolbox.com/lib/table/examples.php http://www.javascripttoolbox.com/temp/table_cellindex.html