Index: sharethis.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/sharethis/sharethis.module,v
retrieving revision 1.7
diff -u -r1.7 sharethis.module
--- sharethis.module	31 Aug 2008 22:09:51 -0000	1.7
+++ sharethis.module	26 Nov 2008 19:55:52 -0000
@@ -1,12 +1,5 @@
 <?php
-/**
- * Implementation of hook_init().
- */
-function sharethis_init() {
-if( variable_get('sharethis_type', 0) == 'sharethis_this') {
-    drupal_set_html_head(variable_get('sharethis_sharethis_this_code', 0));
-  }
-}
+
 /**
  * Implementation of hook_perm().
  */
@@ -122,7 +115,7 @@
           if(!$teaser || variable_get('sharethis_teaser', 1)) {
           if (variable_get('sharethis_sharethis_this_where', 0) == '1') {
             if (_sharethis_sharethis_this_show($node->type, $node->nid) && user_access('use share this')) {
-              
+              sharethis_add_js();
               $linkage = url("node/$node->nid", array('absolute' => TRUE));
               $ntitle = urlencode(check_plain($node->title));
             // the $node object doesn't contain a path, so it has to be built
@@ -161,6 +154,7 @@
         if (_sharethis_sharethis_this_show($node->type, $node->nid) && 
 
         user_access('use share this')) {
+          sharethis_add_js();
           $linkage = url("node/$node->nid", array('absolute' => TRUE));
           $ntitle = urlencode(check_plain($node->title));
           $links['sharethis_sharethis_this_'. $node->nid] = array(
@@ -181,6 +175,16 @@
   }
 }
 
+/**
+ * Makes sure the ShareThis JavaScript has been added to the top of the page.
+ */
+function sharethis_add_js() {
+  static $added = FALSE;
+  if (!$added && variable_get('sharethis_type', 0) == 'sharethis_this') {
+    drupal_set_html_head(variable_get('sharethis_sharethis_this_code', 0));
+    $added = TRUE;
+  }
+}
 
 /**
  * Check if the service links should be displayed for the node type/category.
