Index: print_mail.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/print/print_mail/print_mail.inc,v
retrieving revision 1.2.2.24
diff -u -p -r1.2.2.24 print_mail.inc
--- print_mail.inc	20 Aug 2009 02:19:19 -0000	1.2.2.24
+++ print_mail.inc	6 Oct 2009 18:54:50 -0000
@@ -37,7 +37,7 @@ function print_mail_form($form_state) {
 
   // Remove the printmail/ prefix
   $path = explode('/', $_GET['q']);
-  unset($path[0]);
+  unset($path[0], $path[1]);
   $path = implode('/', $path);
   if (is_numeric($path)) {
     $path = 'node/'. $path;
Index: print_mail.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/print/print_mail/print_mail.module,v
retrieving revision 1.1.2.39
diff -u -p -r1.1.2.39 print_mail.module
--- print_mail.module	20 Aug 2009 02:19:19 -0000	1.1.2.39
+++ print_mail.module	6 Oct 2009 18:54:50 -0000
@@ -53,18 +53,33 @@ function print_mail_theme() {
  */
 function print_mail_menu() {
   $items = array();
-
-  $items[PRINTMAIL_PATH] = array(
-    'title' => 'Send page by e-mail',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('print_mail_form'),
-    'access arguments' => array('access send to friend'),
-    'type' => MENU_CALLBACK,
-    'file' => 'print_mail.inc',
-  );
-  $items[PRINTMAIL_PATH .'/'. PRINTMAIL_PATH] = array(
-    'page callback' => 'drupal_access_denied',
-  );
+  
+  if (!module_exists('ctools')) {
+    $items[PRINTMAIL_PATH . '/nojs'] = array(
+      'title' => 'Send page by e-mail',
+      'page callback' => 'drupal_get_form',
+      'page arguments' => array('print_mail_form'),
+      'access arguments' => array('access send to friend'),
+      'type' => MENU_CALLBACK,
+      'file' => 'print_mail.inc',
+    );
+    $items[PRINTMAIL_PATH .'/nojs/'. PRINTMAIL_PATH] = array(
+      'page callback' => 'drupal_access_denied',
+    );
+  }
+  else {
+    $items[PRINTMAIL_PATH . '/%ctools_js'] = array(
+      'title' => 'Send page by e-mail',
+      'page callback' => 'print_mail_ctools',
+      'page arguments' => array(1, 'print_mail_form'),
+      'access arguments' => array('access send to friend'),
+      'type' => MENU_CALLBACK,
+      'file' => 'print_mail.inc',
+    );
+    $items[PRINTMAIL_PATH .'/%ctools_js/'. PRINTMAIL_PATH] = array(
+      'page callback' => 'drupal_access_denied',
+    );
+  }
   $items['admin/settings/print/email'] = array(
     'title' => 'e-mail',
     'page callback' => 'drupal_get_form',
@@ -138,7 +153,7 @@ function print_mail_link($type, $node = 
 
     // Show book link
     if ($allowed_type === PRINT_ALLOW_BOOK_LINK) {
-      $links['book_mail'] = array('href' => PRINTMAIL_PATH .'/book/export/html/'. $node->nid,
+      $links['book_mail'] = array('href' => PRINTMAIL_PATH .'/nojs/book/export/html/'. $node->nid,
                                  'title' => $format['text'],
                                  'attributes' => $format['attributes'],
                                  'html' => $format['html'],
@@ -161,7 +176,7 @@ function print_mail_link($type, $node = 
         $path = $node->nid;
       }
 
-      $links['print_mail'] = array('href' => PRINTMAIL_PATH .'/'. $path,
+      $links['print_mail'] = array('href' => PRINTMAIL_PATH .'/nojs/'. $path,
                                   'title' => $format['text'],
                                   'attributes' => $format['attributes'],
                                   'html' => $format['html'],
@@ -491,3 +506,34 @@ function print_mail_link_allowed($args) 
   }
   return FALSE;
 }
+
+/**
+ * CTools modal callback to share by email
+ *
+ * @param boolean $js
+ *  Whether or not to return a json repsonse
+ *
+ * @param string $form_id
+ *  The form to render
+ * @return string
+ *  Either HTML or JSON according to the $js parameter
+ */
+function print_mail_ctools($js, $form_id) {
+  if ($js) {
+    ctools_include('modal');
+    ctools_include('ajax');
+    $commands = array();
+    $form_state = array(
+      'ajax' => TRUE,
+      'title' => t('Send page by email'),
+    );
+    $commands = ctools_modal_form_wrapper($form_id, $form_state);
+    if (empty($commands)) {
+      $commands[] = ctools_modal_command_dismiss();
+    }
+    return ctools_ajax_render($commands);
+  }
+  else {
+    return drupal_get_form($form_id);
+  }
+}
