--- link_to_us/link_to_us.module.orig	2009-01-04 21:47:49.000000000 -0800
+++ link_to_us/link_to_us.module	2009-01-04 22:03:38.000000000 -0800
@@ -265,14 +265,31 @@
   $path = url($path, array('absolute' => TRUE));
   if (variable_get('link_to_us_textlink', NULL)) {
     $links[] = array(
+      'help' => t('Paste HTML for a Text-Only link:'),
       'link' => '<a href="'. $path .'" title="'. $title .'">'. $title .'</a>',
       'banner' => '',
+      'id' => 'link-to-us-text-link',
     );
   }
+  $count = 1;
   foreach ($images as $imagepath => $image) {
+    // The following is not 100% correct because
+    // 1. two files can have the same name and different extensions
+    // 2. two files can use different case and have the same name (Linux only)
+    // So to be 100% safe we should probably check with an array that it is indeed unique
+    $id = basename($imagepath);
+    $id = preg_replace(array('/\..*/', '/-/'), array('', '_'), $id);
+    if (!$id) {
+      // just in case the filename starts with a period
+      $id = 'id'. $count;
+      $count++;
+    }
+    $id = 'link_to_us_'. check_plain(drupal_strtolower($id));
     $links[] = array(
+      'help' => t('Paste HTML for this Banner as a Link:'),
       'link' => '<a href="'. $path .'" title="'. $title .'"><img src="'. url($imagepath, array('absolute' => TRUE)) .'" alt="'. $title .'" title="'. $title .'"></a>',
       'banner' => '<img src="'. url($imagepath, array('absolute' => TRUE)) .'" alt="'. $title .'" title="'. $title .'">',
+      'id' => $id,
     );
   }
   drupal_set_title(t('Link to !title page', array('!title' => $title)));
@@ -281,21 +298,16 @@
 
 function theme_link_to_us_banners($links) {
   
-  $output = '<div class="content link-to-us-header">'. check_markup(variable_get('link_to_us_header', '')) .'</div>';
+  $output = '<div class="content link-to-us">';
+  $output .= '<div class="link-to-us-header">'. check_markup(variable_get('link_to_us_header', '')) .'</div>';
   if (count($links)) {
     foreach ($links as $link) {
-      if (empty($link['banner'])) {
-        $output .= '<div class="banner-help">'. t('Paste HTML for a Text-Only link:') .'</div>';
-        $output .= '<div class="banner-link">'. $link['link'] .'</div>';
-        $output .= '<input size="60" readonly="readonly" id="linkurl" type="text" class="link_input" tabindex="400" value="'. check_plain($link['link']) .'"/>';
-      }
-      else {
-        $output .= '<div class="banner-help">'. t('Paste HTML for this Banner as a Link:') .'</div>';
-        $output .= '<div class="banner-link">'. $link['banner'] .'</div>';
-        $output .= '<input size="60" readonly="readonly" id="linkurl" type="text" class="link_input" tabindex="400" value="'. check_plain($link['link']) .'"/>';
-      }
+      $output .= '<div class="link-to-us-banner-help">'. $link['help'] .'</div>';
+      $output .= '<div class="link-to-us-banner-link">'. (empty($link['banner']) ? $link['link'] : $link['banner']) .'</div>';
+      $output .= '<input size="60" readonly="readonly" id="'. $link['id'] .'" type="text" class="link-to-us-link" tabindex="400" value="'. check_plain($link['link']) .'"/>';
     }
   }
+  $output .= '</div>';
   return $output;
 }
 
