Index: modules/book/book-admin-table.tpl.php
===================================================================
RCS file: modules/book/book-admin-table.tpl.php
diff -N modules/book/book-admin-table.tpl.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/book/book-admin-table.tpl.php	18 Jul 2007 05:33:21 -0000
@@ -0,0 +1,45 @@
+<?php
+// $Id
+/**
+ * @file book-admin-table.tpl.php
+ * Default theme implementation to configure book outlines.
+ *
+ * Available variables:
+ * - $outline: Array of node controls for book outlines.
+ *
+ * Each $node in $outline contains:
+ * - $node->depth: Depth of the node in outline.
+ * - $node->title_input: Input box for node titles.
+ * - $node->weight_select: Drop-down menu for setting weights.
+ * - $node->view_link: Link to view node.
+ * - $node->edit_link: Link to edit node.
+ * - $node->delete_link: Link to delete node.
+ *
+ * @see template_preprocess_book_admin_table()
+ * @see theme_book_admin_table()
+ */
+?>
+<?php drupal_add_js('misc/tableheader.js'); ?>
+
+<table>
+  <thead>
+    <tr>
+      <th><?php print t('Title'); ?></th>
+      <th><?php print t('Weight'); ?></th>
+      <th colspan="3"><?php print t('Operations'); ?></th>
+    </tr>
+  </thead>
+  <tbody>
+    <?php $row = 0; ?>
+    <?php foreach ($outline as $node): ?>
+      <tr class="<?php print $row % 2 == 0 ? 'odd' : 'even'; ?>">
+        <td><div style="padding-left:<?php print 25 * $node->depth; ?>px;"><?php print $node->title_input; ?></div></td>
+        <td><?php print $node->weight_select; ?></td>
+        <td><?php print $node->view_link; ?></td>
+        <td><?php print $node->edit_link; ?></td>
+        <td><?php print $node->delete_link; ?></td>
+      </tr>
+      <?php $row++; ?>
+    <?php endforeach; ?>
+  </tbody>
+</table>
Index: modules/book/book-export-html.tpl.php
===================================================================
RCS file: modules/book/book-export-html.tpl.php
diff -N modules/book/book-export-html.tpl.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/book/book-export-html.tpl.php	18 Jul 2007 05:33:21 -0000
@@ -0,0 +1,33 @@
+<?php
+// $Id
+/**
+ * @file book-export-html.tpl.php
+ * Default theme implementation for printed version of book outline.
+ *
+ * Available variables:
+ * - $title: Top level node title.
+ * - $head: Header tags.
+ * - $language: Language code. e.g. "en" for english.
+ * - $language_rtl: TRUE or FALSE depending on right to left language scripts.
+ * - $base_url: URL to home page.
+ * - $content: Nodes within the current outline..
+ *
+ * @see template_preprocess_book_export_html()
+ * @see theme_book_export_html()
+ */
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language; ?>" xml:lang="<?php print $language; ?>">
+  <head>
+    <title><?php print $title; ?></title>
+    <?php print $head; ?>
+    <base href="<?php print $base_url; ?>" />
+    <style type="text/css">@import <?php print url('misc/print.css') ?></style>
+    <?php if ($language_rtl): ?>
+      <style type="text/css">@import <?php print url('misc/print-rtl.css') ?></style>
+    <?php endif; ?>
+  </head>
+  <body>
+    <?php print $content ?>
+  </body>
+</html>
Index: modules/book/book-navigation.tpl.php
===================================================================
RCS file: modules/book/book-navigation.tpl.php
diff -N modules/book/book-navigation.tpl.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/book/book-navigation.tpl.php	18 Jul 2007 05:33:21 -0000
@@ -0,0 +1,26 @@
+<?php
+// $Id
+/**
+ * @file book-navigation.tpl.php
+ * Default theme implementation to navigate books. Presented under nodes that
+ * are a part of book outlines.
+ *
+ * Available variables:
+ * - $tree: The immediate children of the current node as an unordered list.
+ * - $links: Previous, parent and next links combined. $prev, $parent and
+ *   $next can also be used.
+ *
+ * @see template_preprocess_book_navigation()
+ * @see theme_book_navigation()
+ */
+?>
+<?php if ($tree || $links): ?>
+  <div class="book-navigation">
+    <?php print $tree; ?>
+    <?php if ($links): ?>
+    <div class="page-links clear-block">
+      <?php print $links; ?>
+    </div>
+    <?php endif; ?>
+  </div>
+<?php endif; ?>
Index: modules/book/book.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.module,v
retrieving revision 1.428
diff -u -p -r1.428 book.module
--- modules/book/book.module	3 Jul 2007 19:29:32 -0000	1.428
+++ modules/book/book.module	18 Jul 2007 05:33:22 -0000
@@ -25,12 +25,15 @@ function book_node_info() {
 function book_theme() {
   return array(
     'book_navigation' => array(
+      'file' => 'book-navigation',
       'arguments' => array('node' => NULL),
     ),
     'book_export_html' => array(
+      'file' => 'book-export-html',
       'arguments' => array('title' => NULL, 'content' => NULL),
     ),
     'book_admin_table' => array(
+      'file' => 'book-admin-table',
       'arguments' => array('form' => NULL),
     ),
   );
@@ -475,44 +478,41 @@ function book_nodeapi(&$node, $op, $teas
 }
 
 /**
- * Prepares the links to children (TOC) and forward/backward
- * navigation for a node presented as a book page.
+ * Process variables for book-navigation.tpl.php.
  *
- * @ingroup themeable
+ * The $variables array contains the following arguments:
+ * - $node
+ *
+ * @see book-navigation.tpl.php
+ * @see theme_book_navigation()
  */
-function theme_book_navigation($node) {
-  $output = '';
-  $links = '';
-
-  if ($node->nid) {
-    $tree = book_tree($node->nid);
-
-    if ($prev = book_prev($node)) {
+function template_preprocess_book_navigation(&$variables) {
+  // Setup defaults.
+  $variables['tree'] = '';
+  $variables['prev'] = '';
+  $variables['parent'] = '';
+  $variables['next'] = '';
+  $variables['links'] = '';
+  if ($variables['node']->nid) {
+    if ($tree = book_tree($variables['node']->nid)) {
+      $variables['tree'] = $tree;
+    }
+    if ($prev = book_prev($variables['node'])) {
       drupal_add_link(array('rel' => 'prev', 'href' => url('node/'. $prev->nid)));
-      $links .= l(t('‹ ') . $prev->title, 'node/'. $prev->nid, array('class' => 'page-previous', 'title' => t('Go to previous page')));
+      $variables['prev'] = l(t('‹ ') . $prev->title, 'node/'. $prev->nid, array('class' => 'page-previous', 'title' => t('Go to previous page')));
+      $variables['links'] .= $variables['prev'];
     }
-    if ($node->parent) {
-      drupal_add_link(array('rel' => 'up', 'href' => url('node/'. $node->parent)));
-      $links .= l(t('up'), 'node/'. $node->parent, array('class' => 'page-up', 'title' => t('Go to parent page')));
+    if ($variables['node']->parent) {
+      drupal_add_link(array('rel' => 'up', 'href' => url('node/'. $variables['node']->parent)));
+      $variables['parent'] = l(t('up'), 'node/'. $variables['node']->parent, array('class' => 'page-up', 'title' => t('Go to parent page')));
+      $variables['links'] .= $variables['parent'];
     }
-    if ($next = book_next($node)) {
+    if ($next = book_next($variables['node'])) {
       drupal_add_link(array('rel' => 'next', 'href' => url('node/'. $next->nid)));
-      $links .= l($next->title . t(' ›'), 'node/'. $next->nid, array('class' => 'page-next', 'title' => t('Go to next page')));
-    }
-
-    if (isset($tree) || isset($links)) {
-      $output = '<div class="book-navigation">';
-      if (isset($tree)) {
-        $output .= $tree;
-      }
-      if (isset($links)) {
-        $output .= '<div class="page-links clear-block">'. $links .'</div>';
-      }
-      $output .= '</div>';
+      $variables['next'] = l($next->title . t(' ›'), 'node/'. $next->nid, array('class' => 'page-next', 'title' => t('Go to next page')));
+      $variables['links'] .= $variables['next'];
     }
   }
-
-  return $output;
 }
 
 /**
@@ -561,28 +561,31 @@ function book_toc($exclude = 0) {
  */
 function book_tree_recurse($nid, $depth, $children, $unfold = array()) {
   $output = '';
+  
   if ($depth > 0) {
     if (isset($children[$nid])) {
       foreach ($children[$nid] as $foo => $node) {
+        
+        $lvl = 1;
+        $in_active_trail = FALSE;
         if (in_array($node->nid, $unfold)) {
-          if ($tree = book_tree_recurse($node->nid, $depth - 1, $children, $unfold)) {
-            $output .= '<li class="expanded">';
-            $output .= l($node->title, 'node/'. $node->nid);
-            $output .= '<ul class="menu">'. $tree .'</ul>';
-            $output .= '</li>';
-          }
-          else {
-            $output .= '<li class="leaf">'. l($node->title, 'node/'. $node->nid) .'</li>';
-          }
+          $lvl = $depth - 1;
+          $in_active_trail = TRUE;
         }
-        else {
-          if ($tree = book_tree_recurse($node->nid, 1, $children)) {
-            $output .= '<li class="collapsed">'. l($node->title, 'node/'. $node->nid) .'</li>';
-          }
-          else {
-            $output .= '<li class="leaf">'. l($node->title, 'node/'. $node->nid) .'</li>';
+        
+        $has_children = FALSE;
+        $menu = '';
+        if ($tree = book_tree_recurse($node->nid, $lvl, $children, $unfold)) {
+          $has_children = TRUE;
+          // Prevent level 1 runs from rendering a menu tree.
+          if ($lvl !== 1) {
+            $menu = theme('menu_tree', $tree);
           }
         }
+        
+        $link = theme('menu_item_link', array('title' => $node->title, 'href' => 'node/'. $node->nid, 'options' => array()));
+
+        $output .= theme('menu_item', $link, $has_children, $menu, $in_active_trail);
       }
     }
   }
@@ -604,7 +607,7 @@ function book_tree($parent = 0, $depth =
   }
 
   if ($tree = book_tree_recurse($parent, $depth, $children, $unfold)) {
-    return '<ul class="menu">'. $tree .'</ul>';
+    return theme('menu_tree', $tree);
   }
 }
 
@@ -698,24 +701,22 @@ function book_export_html($nid, $depth) 
 }
 
 /**
- * How the book's HTML export should be themed
+ * Process variables for book-export-html.tpl.php.
+ *
+ * The $variables array contains the following arguments:
+ * - $title
+ * - $content
  *
- * @ingroup themeable
+ * @see book-export-html.tpl.php
+ * @see theme_book_export_html()
  */
-function theme_book_export_html($title, $content) {
+function template_preprocess_book_export_html(&$variables) {
   global $base_url, $language;
-  $html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
-  $html .= '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">';
-  $html .= "<head>\n<title>". $title ."</title>\n";
-  $html .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
-  $html .= '<base href="'. $base_url .'/" />'."\n";
-  $html .= "<style type=\"text/css\">\n@import url(misc/print.css);\n";
-  if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) {
-    $html .= "@import url(misc/print-rtl.css);\n";
-  }
-  $html .= "</style>\n";
-  $html .= "</head>\n<body>\n". $content ."\n</body>\n</html>\n";
-  return $html;
+
+  $variables['base_url'] = $base_url;
+  $variables['language'] = $language->language;
+  $variables['language_rtl'] = (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) ? TRUE : FALSE;
+  $variables['head'] = drupal_get_html_head();
 }
 
 /**
@@ -859,23 +860,27 @@ function _book_admin_table_tree($node, $
   return $form;
 }
 
-function theme_book_admin_table($form) {
-  $header = array(t('Title'), t('Weight'), array('data' => t('Operations'), 'colspan' => '3'));
-
-  $rows = array();
+/**
+ * Process variables for book-admin-table.tpl.php.
+ *
+ * The $variables array contains the following arguments:
+ * - $form
+ *
+ * @see book-admin-table.tpl.php
+ * @see theme_book_admin_table()
+ */
+function template_preprocess_book_admin_table(&$variables) {
+  $form = $variables['form'];
+  $pid = $form[0]['nid']['#value'];
   foreach (element_children($form) as $key) {
     $nid = $form[$key]['nid']['#value'];
-    $pid = $form[0]['nid']['#value'];
-    $rows[] = array(
-      '<div style="padding-left: '. (25 * $form[$key]['depth']['#value']) .'px;">'. drupal_render($form[$key]['title']) .'</div>',
-      drupal_render($form[$key]['weight']),
-      l(t('view'), 'node/'. $nid),
-      l(t('edit'), 'node/'. $nid .'/edit'),
-      l(t('delete'), 'node/'. $nid .'/delete', array('query' => 'destination=admin/content/book'. (arg(3) == 'orphan' ? '/orphan' : '') . ($pid != $nid ? '/'. $pid : ''))),
-    );
+    $variables['outline'][$key]->depth = $form[$key]['depth']['#value'];
+    $variables['outline'][$key]->title_input = drupal_render($form[$key]['title']);
+    $variables['outline'][$key]->weight_select = drupal_render($form[$key]['weight']);
+    $variables['outline'][$key]->view_link = l(t('view'), 'node/'. $nid);
+    $variables['outline'][$key]->edit_link = l(t('edit'), 'node/'. $nid .'/edit');
+    $variables['outline'][$key]->delete_link = l(t('delete'), 'node/'. $nid .'/delete', array('query' => 'destination=admin/content/book'. (arg(3) == 'orphan' ? '/orphan' : '') . ($pid != $nid ? '/'. $pid : '')));
   }
-
-  return theme('table', $header, $rows);
 }
 
 /**
