Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.409
diff -u -p -r1.409 theme.inc
--- includes/theme.inc	9 Jan 2008 22:01:29 -0000	1.409
+++ includes/theme.inc	15 Jan 2008 00:30:24 -0000
@@ -1228,6 +1228,15 @@ function theme_submenu($links) {
  *   An HTML string representing the table.
  */
 function theme_table($header, $rows, $attributes = array(), $caption = NULL) {
+
+  // Add sticky headers, if applicable.
+  if (count($header)) {
+    drupal_add_js('misc/tableheader.js');
+    // Add 'sticky-enabled' class to the table to identify it for JS.
+    // This is needed to target tables constructed by this function.
+    $attributes['class'] = empty($attributes['class']) ? 'sticky-enabled' : $attributes['class'] .' sticky-enabled';
+  }
+
   $output = '<table'. drupal_attributes($attributes) .">\n";
 
   if (isset($caption)) {
@@ -1236,9 +1245,6 @@ function theme_table($header, $rows, $at
 
   // Format the table header:
   if (count($header)) {
-    // Include JS for sticky headers.
-    drupal_add_js('misc/tableheader.js');
-
     $ts = tablesort_init($header);
     // HTML requires that the thead tag has tr tags in it follwed by tbody
     // tags. Using ternary operator to check and see if we have any rows.
Index: misc/tableheader.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/tableheader.js,v
retrieving revision 1.12
diff -u -p -r1.12 tableheader.js
--- misc/tableheader.js	13 Jan 2008 21:21:53 -0000	1.12
+++ misc/tableheader.js	15 Jan 2008 00:30:24 -0000
@@ -9,7 +9,7 @@ Drupal.behaviors.tableHeader = function 
   // Keep track of all cloned table headers.
   var headers = [];
 
-  $('table thead:not(.tableHeader-processed)', context).each(function () {
+  $('table.sticky-enabled thead:not(.tableHeader-processed)', context).each(function () {
     // Clone thead so it inherits original jQuery properties.
     var headerClone = $(this).clone(true).insertBefore(this.parentNode).wrap('<table class="sticky-header"></table>').parent().css({
       position: 'fixed',
