Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.497
diff -u -p -r1.497 theme.inc
--- includes/theme.inc	2 Jul 2009 04:27:22 -0000	1.497
+++ includes/theme.inc	10 Jul 2009 15:44:03 -0000
@@ -1703,17 +1703,29 @@ function theme_more_link($url, $title) {
 }
 
 /**
- * Execute hook_footer() which is run at the end of the page right before the
- * close of the body tag.
+ * Execute hook_html_top() which allows adding markup at the start of the 
+ * body tag.
+ *
+ * @return
+ *   A string containing the results of the hook_html_top() calls.
+ */
+function theme_html_top() {
+  $top = module_invoke_all('html_top');
+  return drupal_render($top);
+}
+
+/**
+ * Execute hook_html_bottom() which is run at the end of the page right before
+ * the close of the body tag.
  *
  * @param $main (optional)
  *   Whether the current page is the front page of the site.
  * @return
- *   A string containing the results of the hook_footer() calls.
+ *   A string containing the results of the hook_html_bottom() calls.
  */
-function theme_closure($main = 0) {
-  $footer = module_invoke_all('footer', $main);
-  return implode("\n", $footer) . drupal_get_js('footer');
+function theme_html_bottom() {
+  $bottom = module_invoke_all('html_bottom');
+  return drupal_render($bottom) . drupal_get_js('footer');
 }
 
 /**
@@ -1950,8 +1962,9 @@ function template_preprocess_page(&$vari
   // using an associated GRDDL profile.
   $variables['rdf_namespaces']    = drupal_get_rdf_namespaces();
   $variables['grddl_profile']     = 'http://ns.inria.fr/grddl/rdfa/';
-  // Closure should be filled last.
-  $variables['closure']           = theme('closure');
+  $variables['html_top']          = theme('html_top');
+  // html_bottom should be filled last.
+  $variables['html_bottom']       = theme('html_bottom');
 
   if ($node = menu_get_object()) {
     $variables['node'] = $node;
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.930
diff -u -p -r1.930 common.inc
--- includes/common.inc	4 Jul 2009 18:26:42 -0000	1.930
+++ includes/common.inc	10 Jul 2009 15:44:04 -0000
@@ -4104,8 +4104,11 @@ function drupal_common_theme() {
     'more_link' => array(
       'arguments' => array('url' => NULL, 'title' => NULL)
     ),
-    'closure' => array(
-      'arguments' => array('main' => 0),
+    'html_top' => array(
+      'arguments' => array(),
+    ),
+    'html_bottom' => array(
+      'arguments' => array(),
     ),
     'blocks' => array(
       'arguments' => array('region' => NULL),
Index: includes/theme.maintenance.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.maintenance.inc,v
retrieving revision 1.30
diff -u -p -r1.30 theme.maintenance.inc
--- includes/theme.maintenance.inc	6 Jun 2009 16:05:26 -0000	1.30
+++ includes/theme.maintenance.inc	10 Jul 2009 15:44:04 -0000
@@ -273,7 +273,8 @@ function template_preprocess_maintenance
   $variables['scripts']           = drupal_get_js();
   $variables['tabs']              = '';
   $variables['title']             = drupal_get_title();
-  $variables['closure']           = '';
+  $variables['html_top']          = '';
+  $variables['html_bottom']       = '';
 
   // Compile a list of classes that are going to be applied to the body element.
   $variables['classes_array'][] = 'in-maintenance';
Index: modules/system/page.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/page.tpl.php,v
retrieving revision 1.24
diff -u -p -r1.24 page.tpl.php
--- modules/system/page.tpl.php	4 Jul 2009 05:21:15 -0000	1.24
+++ modules/system/page.tpl.php	10 Jul 2009 15:44:04 -0000
@@ -71,6 +71,7 @@
  *
  * Page content (in order of occurrence in the default page.tpl.php):
  * - $title: The page title, for use in the actual HTML content.
+ * - $html_top: Markup to output at the top of the HTML page in the body tag.
  * - $messages: HTML for status and error messages. Should be displayed prominently.
  * - $tabs: Tabs linking to any sub-pages beneath the current page (e.g., the view
  *   and edit tabs when displaying a node).
@@ -83,8 +84,9 @@
  *
  * Footer/closing data:
  * - $footer : The footer region.
- * - $closure: Final closing markup from any modules that have altered the page.
- *   This variable should always be output last, after all other dynamic content.
+ * - $html_bottom: Final closing markup from any modules that have altered the
+ *   page. This variable should always be output last, after all other dynamic 
+ *   content.
  *
  * @see template_preprocess()
  * @see template_preprocess_page()
@@ -104,11 +106,8 @@
 </head>
 <body class="<?php print $classes; ?>">
 
-  <?php if ($page_top): ?>
-    <div id="page-top-region" class="clearfix">
-      <?php print $page_top; ?>
-    </div>
-  <?php endif; ?>
+  <?php print $html_top ?>
+
   <div id="page-wrapper"><div id="page">
 
     <div id="header"><div class="section clearfix">
@@ -197,7 +196,7 @@
 
   </div></div> <!-- /#page, /#page-wrapper -->
 
-  <?php print $closure; ?>
+  <?php print $html_bottom; ?>
 
 </body>
 </html>
Index: modules/system/system.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.api.php,v
retrieving revision 1.47
diff -u -p -r1.47 system.api.php
--- modules/system/system.api.php	5 Jul 2009 18:00:10 -0000	1.47
+++ modules/system/system.api.php	10 Jul 2009 15:44:04 -0000
@@ -148,22 +148,43 @@ function hook_exit($destination = NULL) 
 }
 
 /**
- * Insert closing HTML.
+ * Insert opening elements.
  *
- * This hook enables modules to insert HTML just before the \</body\> closing
+ * This hook enables modules to insert elements just after the \<body\> opening
+ * tag of web pages. This is useful for navigation or other elements, which
+ * should be early in the HTML source order.
+ *
+ * @return
+ *   A renderable array to be inserted, keyed by the hook_html_top 
+ *   implementation.
+ */
+function hook_html_top() {
+  if (user_access('access toolbar') && !toolbar_suppress()) {
+    return array('toolbar' => toolbar_build());
+  }
+}
+
+/**
+ * Insert closing elements.
+ *
+ * This hook enables modules to insert elements just before the \</body\> closing
  * tag of web pages. This is useful for adding JavaScript code to the footer
  * and for outputting debug information. It is not possible to add JavaScript
  * to the header at this point, and developers wishing to do so should use
  * hook_init() instead.
  *
- * @param $main
- *   Whether the current page is the front page of the site.
  * @return
- *   The HTML to be inserted.
+ *   A renderable array to be inserted, keyed by the hook_html_bottom
+ *   implementation.
  */
-function hook_footer($main = 0) {
+function hook_html_bottom() {
   if (variable_get('dev_query', 0)) {
-    return '<div style="clear:both;">' . devel_query_table() . '</div>';
+    return array(
+      'devel' => array(
+        '#type' => 'markup',
+        '#value' => '<div style="clear:both;">' . devel_query_table() . '</div>',
+      ),
+    );
   }
 }
 
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.722
diff -u -p -r1.722 system.module
--- modules/system/system.module	5 Jul 2009 18:00:10 -0000	1.722
+++ modules/system/system.module	10 Jul 2009 15:44:04 -0000
@@ -1822,7 +1831,6 @@ function _system_get_theme_data() {
         'footer' => 'Footer',
         'highlight' => 'Highlighted content',
         'help' => 'Help',
-        'page_top' => 'Page top',
       ),
       'description' => '',
       'features' => array(
Index: themes/garland/page.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/garland/page.tpl.php,v
retrieving revision 1.28
diff -u -p -r1.28 page.tpl.php
--- themes/garland/page.tpl.php	4 Jul 2009 05:21:15 -0000	1.28
+++ themes/garland/page.tpl.php	10 Jul 2009 15:44:04 -0000
@@ -15,11 +15,7 @@
   </head>
   <body class="<?php print $classes ?>">
 
-  <?php if ($page_top): ?>
-    <div id="page-top-region" class="clearfix">
-      <?php print $page_top; ?>
-    </div>
-  <?php endif; ?>
+  <?php print $html_top ?>
 
   <div id="header-region" class="clearfix"><?php print $header ?></div>
 
@@ -75,6 +71,6 @@
     </div> <!-- /#container -->
   </div> <!-- /#wrapper -->
 
-  <?php print $closure ?>
+  <?php print $html_bottom ?>
   </body>
 </html>
Index: modules/toolbar/toolbar.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/toolbar/toolbar.module,v
retrieving revision 1.2
diff -u -p -r1.2 toolbar.module
--- modules/toolbar/toolbar.module	5 Jul 2009 18:00:11 -0000	1.2
+++ modules/toolbar/toolbar.module	10 Jul 2009 15:44:04 -0000
@@ -31,13 +31,13 @@ function toolbar_theme($existing, $type,
 }
 
 /**
- * Implementation of hook_page_alter().
+ * Implementation of hook_html_top().
  * 
- * Add admin toolbar to the page_top region automatically.
+ * Add admin toolbar to the page automatically.
  */
-function toolbar_page_alter(&$page) {
-  if (user_access('access toolbar')) {
-    $page['page_top']['toolbar'] = toolbar_build();
+function toolbar_html_top() {
+  if (user_access('access toolbar') && !toolbar_suppress()) {
+    return array('toolbar' => toolbar_build());
   }
 }
 
@@ -184,3 +184,14 @@ function toolbar_in_active_trail($path) 
   }
   return in_array($path, $active_paths);
 }
+
+/**
+ * Let other modules, such as the overlay suppress the toolbar module output.
+ */
+function toolbar_suppress($suppress = NULL) {
+  $is_suppressed = &drupal_static(__FUNCTION__, FALSE);
+  if (isset($suppress)) {
+    $is_suppressed = $suppress;
+  }
+  return $is_suppressed;
+}
