--- service_links.module.orig	2007-03-14 01:25:20.653719750 -0700
+++ service_links.module	2007-03-14 01:42:38.470579250 -0700
@@ -104,6 +104,12 @@
     '#return_value' => 1,
     '#default_value' => variable_get('service_links_show_yahoo', 0),
   );
+  $form['what_links_to_show']['service_links_show_facebook'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Show Facebook link'),
+    '#return_value' => 1,
+    '#default_value' => variable_get('service_links_show_facebook', 0),
+  );
 
   $form['what_links2_to_show'] = array(
     '#type' => 'fieldset',
@@ -294,6 +300,10 @@
   if (variable_get('service_links_show_yahoo', 0)) {
     $links[] = theme('service_links_build_link', t('yahoo'), "http://myweb2.search.yahoo.com/myresults/bookmarklet?u=$url&t=$title", t('Bookmark this post on Yahoo.'), 'yahoo.png');
   }
+  if (variable_get('service_links_show_facebook', 0)) {
+    $onclick = "window.open(\'http://www.facebook.com/sharer.php?u=\'+encodeURIComponent(" . $url . ")+\'&t=\'+encodeURIComponent(" . $title . "), 'sharer','toolbar=0,status=0,width=626,height=436');return false;";
+    $links[] = theme('service_links_build_link', t('facebook'), "http://www.facebook.com/share.php?u=$url", t('Share on Facebook.'), 'facebook.gif', $onclick);
+  }
   if (variable_get('service_links_show_technorati', 0)) {
     $links[] = theme('service_links_build_link', t('technorati'), "http://technorati.com/cosmos/search.html?url=$url", t('Search Technorati for links to this post.'), 'technorati.png');
   }
@@ -307,18 +317,30 @@
   return $links;
 }
 
-function theme_service_links_build_link($text, $url, $title, $image) {
+function theme_service_links_build_link($text, $url, $title, $image, $onclick = NULL) {
   global $base_path;
 
   switch (variable_get('service_links_style', 1)) {
     case 1:
-      $link = '<a href="'. check_url($url) .'" title="'. $title .'" rel="nofollow">'. $text .'</a>';
+      $link = '<a href="'. check_url($url) .'" title="'. $title .'" rel="nofollow"';
+      if ($onclick) {
+        $link .= ' onclick="$onclick"';
+      }
+      $link .= '>'. $text .'</a>';
       break;
     case 2:
-      $link = '<a href="'. check_url($url) .'" title="'. $title .'" rel="nofollow"><img src="'. $base_path . drupal_get_path('module', 'service_links') .'/'. $image .'" alt="'. $text .'" /></a>';
+      $link = '<a href="'. check_url($url) .'" title="'. $title .'" rel="nofollow"';
+      if ($onclick) {
+        $link .= ' onclick="$onclick"';
+      }
+      $link .= '><img src="'. $base_path . drupal_get_path('module', 'service_links') .'/'. $image .'" alt="'. $text .'" /></a>';
       break;
     case 3:
-      $link = '<a href="'. check_url($url) .'" title="'. $title .'" rel="nofollow"><img src="'. $base_path . drupal_get_path('module', 'service_links') .'/'. $image .'" alt="'. $text .'" /> '. $text .'</a>';
+      $link = '<a href="'. check_url($url) .'" title="'. $title .'" rel="nofollow"';
+      if ($onclick) {
+        $link .= ' onclick="$onclick"';
+      }
+      $link .= '><img src="'. $base_path . drupal_get_path('module', 'service_links') .'/'. $image .'" alt="'. $text .'" /> '. $text .'</a>';
       break;
   }
 
