--- link.module.orig	2008-04-16 20:06:16.000000000 -0500
+++ link.module	2008-04-16 22:54:13.000000000 -0500
@@ -100,7 +100,7 @@ function link_field_settings($op, $field
         '#maxlength' => 3,
         '#size' => 3,
       );
-      
+
       $target_options = array(
         'default' => t('Default (no target attribute)'),
         '_top' => t('Open link in window root'),
@@ -116,6 +116,29 @@ function link_field_settings($op, $field
         '#default_value' => $field['attributes']['target'] ? $field['attributes']['target'] : 'default',
         '#options' => $target_options,
       );
+
+      // CTR begin onClick code
+      $onclick_options = array(
+        'default' => t('Default (no onClick attribute)'),
+        'user' => t('Allow the user to specify a value'),
+        'value' => t('Static onClick value: '),
+      );
+
+      $form['attributes']['onClick'] = array(
+        '#type' => 'radios',
+        '#title' => t('OnClick Attribute'),
+        '#default_value' => isset($field['attributes']['onClick']) ? $field['attributes']['onClick'] : 'default',
+        '#options' => $onclick_options,
+        '#description' => t('When output, this link may have an onClick attribute. This attribute is used for executing Javascript code when the link is clicked, and is often useful for opening a link in a pop-up window.'),
+      );
+
+      $form['onclick_value'] = array(
+        '#type' => 'textfield',
+        '#default_value' => $field['onclick_value'],
+        '#size' => '46',
+      );
+      // CTR end onClick code
+
       $form['attributes']['rel'] = array(
         '#type' => 'textfield',
         '#title' => t('Rel Attribute'),
@@ -137,7 +160,7 @@ function link_field_settings($op, $field
       break;
 
     case 'save':
-      return array('attributes', 'display', 'title', 'title_value', 'enable_tokens');
+      return array('attributes', 'display', 'title', 'title_value', 'enable_tokens', 'onclick_value');
 
     case 'database columns':
       return array(
@@ -195,7 +218,15 @@ function theme_link_field_settings($form
   
   // Set Static Title radio option to include the title_value textfield
   $form['title']['value'] = array('#value' => '<div class="container-inline">'. $title_checkbox . $title_value .'</div>');
-  
+
+  // CTR begin onClick code
+  $onclick_value = drupal_render($form['onclick_value']);
+  $onclick_checkbox = drupal_render($form['attributes']['onClick']['value']);
+
+  // Set Static onClick value radio option to include the onclick_value textfield
+  $form['attributes']['onClick']['value'] = array('#value' => '<div class="container-inline">'. $onclick_checkbox . $onclick_value .'</div>');
+  // CTR end onClick code
+
   // Reprint the title radio options with the included textfield
   return drupal_render($form);
 }
@@ -426,6 +457,16 @@ function _link_widget_form(&$form_item, 
       '#return_value' => "_blank",
     );
   }
+  // CTR begin onClick code
+  if ($field['attributes']['onClick'] == 'user') {
+    $form_item['attributes']['onClick'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Code for onClick Attribute'),
+      '#default_value' => $node_field['attributes']['onClick'],
+      '#description' => t('Specify the onClick attribute value here, if any. This attribute is used for executing Javascript code when the link is clicked, and is often useful for opening a link in a pop-up window.'),
+    );
+  }
+  // CTR end onClick code
 }
 
 function _link_widget_prepare(&$node_field, $delta = 0) {
@@ -596,6 +637,13 @@ function link_field_formatter($field, $i
     $query = substr($url, strpos($url, '?') + 1);
     $url = substr($url, 0, strpos($url, '?'));
   }
+
+  // CTR begin onClick code
+  if ($field['attributes']['onClick'] == 'value') {
+    // Use the onClick value defined at the field level
+    $attributes['onClick'] = $field['onclick_value'];
+  }
+  // CTR end onClick code
   
   // Give the link the title 'Link'
   if ($formatter == 'short') {
