diff --git a/facebookshare.module b/facebookshare.module
index f0a0d78..bd69cac 100644
--- a/facebookshare.module
+++ b/facebookshare.module
@@ -138,12 +138,17 @@ function theme_facebookshare($variables) {
 function theme_facebookshare_button($variables) {
   $url = $variables['url'];
   $size = $variables['size'];
-  $text = $variables['text'];
+  $text = $variables['text'];
+
+  if ($_SERVER['HTTPS']=='on') {
+    $script_src = 'https://connect.facebook.com/connect.php/js/FB.Share';
+  }
+  else {
+    $script_src = 'http://connect.facebook.com/connect.php/js/FB.Share';
+  }
   $output = '<a name="fb_share" ' .
    'type="' . $size . '" share_url="' . $url . '">' .
    $text . '</a>' .
-   '<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" ' .
-   'type="text/javascript"></script>';
-
+   '<script src="' . $script_src . '" type="text/javascript"></script>';
   return $output;
-}
\ No newline at end of file
+}
