Index: misc/tableheader.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/tableheader.js,v
retrieving revision 1.9
diff -u -p -r1.9 tableheader.js
--- misc/tableheader.js	2 Oct 2007 07:09:51 -0000	1.9
+++ misc/tableheader.js	7 Jan 2008 05:05:42 -0000
@@ -6,61 +6,44 @@ Drupal.behaviors.tableHeader = function 
     return;
   }
 
-  // Keep track of all header cells.
-  var cells = [];
+  // Keep track of all cloned headers rows.
+  var headers = [];
 
-  var z = 0;
   $('table thead:not(.tableHeader-processed)', context).each(function () {
     // Find table height.
     var table = $(this).parent('table')[0];
     var height = $(table).addClass('sticky-table').height();
-    var i = 0;
 
-    // Find all header cells.
-    $('th', this).each(function () {
-
-      // Ensure each cell has an element in it.
-      var html = $(this).html();
-      if (html == ' ') {
-        html = '&nbsp;';
-      }
-      if ($(this).children().size() == 0) {
-        html = '<span>'+ html +'</span>';
-      }
+    
+    var header_clone = $(this).clone().insertBefore(this.parentNode).wrap('<table class="sticky-header"></table>').parent().css({
+      position: 'fixed',
+      visibility: 'hidden',
+      top: '0px',
+      left: $(this).offset().left +'px',
+      width: $(this).width() +'px'
+    });
 
-      // Clone and wrap cell contents in sticky wrapper that overlaps the cell's padding.
-      $('<div class="sticky-header" style="position: fixed; visibility: hidden; top: 0px;">'+ html +'</div>').prependTo(this);
-      var div = $('div.sticky-header', this).css({
-        'marginLeft': '-'+ $(this).css('paddingLeft'),
-        'marginRight': '-'+ $(this).css('paddingRight'),
-        'paddingLeft': $(this).css('paddingLeft'),
-        'paddingTop': $(this).css('paddingTop'),
-        'paddingBottom': $(this).css('paddingBottom'),
-        'z-index': ++z
-      })[0];
-      cells.push(div);
-
-      // Adjust width to fit cell/table.
-      var ref = this;
-      if (!i++) {
-        // The first cell is as wide as the table to prevent gaps.
-        ref = table;
-        div.wide = true;
-      }
-      $(div).width(Math.max(0, $(ref).width() - parseInt($(div).css('paddingLeft'))));
+    var thead = $(header_clone)[0];
+    headers.push(thead);
 
-      // Get position and store.
-      div.cell = this;
-      div.table = table;
-      div.stickyMax = height;
-      div.stickyPosition = $(this).offset().top;
+    // Copy cell widths from header to sticky headers.
+    // IE7 chokes on this.
+    var cellcounter = 0;
+    $('th', this).each(function () {
+      $('th', thead).eq(cellcounter++).width($(this).width() - (parseInt($(this).css('paddingLeft')) + parseInt($(this).css('paddingRight'))));
     });
+
+    // Get position and store.
+    thead.thead = this;
+    thead.table = table;
+    thead.stickyMax = height;
+    thead.stickyPosition = $(this).offset().top;
     $(this).addClass('tableHeader-processed');
   });
 
   // Track scrolling.
   var scroll = function() {
-    $(cells).each(function () {
+    $(headers).each(function () {
       // Fetch scrolling position.
       var scroll = document.documentElement.scrollTop || document.body.scrollTop;
       var offset = scroll - this.stickyPosition - 4;
@@ -89,18 +72,13 @@ Drupal.behaviors.tableHeader = function 
         this.savedHeight = $(this).height();
       });
 
-      $('table.sticky-table div.sticky-header').each(function () {
+      $('table.sticky-table thead.sticky-header').each(function () {
         // Get position.
-        this.stickyPosition = $(this.cell).offset().top;
+        this.stickyPosition = $(this.thead).offset().top;
         this.stickyMax = this.table.savedHeight;
 
-        // Reflow the cell.
-        var ref = this.cell;
-        if (this.wide) {
-          // Resize the first cell to fit the table.
-          ref = this.table;
-        }
-        $(this).width(Math.max(0, $(ref).width() - parseInt($(this).css('paddingLeft'))));
+        // Reposition and resize header.
+        $(this).css({left: $(this.table).offset().left +'px', width: Math.max(0, $(this.table).width() - parseInt($(this).css('paddingLeft')))});
       });
 
       // Reset timer
Index: modules/system/system.css
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.css,v
retrieving revision 1.46
diff -u -p -r1.46 system.css
--- modules/system/system.css	22 Dec 2007 22:25:50 -0000	1.46
+++ modules/system/system.css	7 Jan 2008 05:05:42 -0000
@@ -468,7 +468,9 @@ tr.selected td {
 /*
 ** Floating header for tableheader.js
 */
-thead div.sticky-header {
+table.sticky-header {
+  padding: 0;
+  margin: 0;
   background: #fff;
 }
 
Index: themes/garland/style.css
===================================================================
RCS file: /cvs/drupal/drupal/themes/garland/style.css,v
retrieving revision 1.36
diff -u -p -r1.36 style.css
--- themes/garland/style.css	29 Dec 2007 16:02:52 -0000	1.36
+++ themes/garland/style.css	7 Jan 2008 05:05:42 -0000
@@ -201,7 +201,7 @@ thead th {
   font-weight: bold;
 }
 
-thead div.sticky-header {
+thead.sticky-header {
   border-bottom: 2px solid #d3e7f4;
 }
 
