--- imagemenu/imagemenu.module	2007-03-20 11:44:07.000000000 +0000
+++ new.module	2008-07-01 14:45:34.000000000 +0100
@@ -239,15 +239,15 @@ function imagemenu_add_item_form($mid = 
     '#required' => TRUE,
   );
   $form['imagepath'] = array('#type' => 'textfield',
-    '#title' => t('Image Path'),
+    '#title' => t('Image Name or Path'),
     '#default_value' => $item['imagepath'],
-    '#description' => t('The path to the image.'),
+    '#description' => t('The name of or path to the image.'),
     '#required' => TRUE,
   );
   $form['mouseover'] = array('#type' => 'textfield',
-    '#title' => t('Image Path'),
+    '#title' => t('Image Name or Path'),
     '#default_value' => $item['mouseover'],
-    '#description' => t('Optional. The path to an image to display on mouseover.'),
+    '#description' => t('Optional. The name of or path to an image to display on mouseover.'),
   );
   $form['path'] = array('#type' => 'textfield',
     '#title' => t('Path'),
@@ -285,6 +285,12 @@ function imagemenu_add_item_form($mid = 
 }
 
 function imagemenu_add_item_form_validate($form_id, $form) {
+  // Check for image with the specified name.
+  $detectedPath = get_image_path_from_image_name($form['imagepath']);
+  if ($detectedPath) { $form['imagepath'] = $detectedPath; }
+  $detectedPath = get_image_path_from_image_name($form['mouseover']);
+  if ($detectedPath) { $form['mouseover'] = $detectedPath; }
+
   $check = is_readable($form['imagepath']);
   if (!$check) form_set_error('imagepath', t('File not found.'));
   $check = is_readable($form['mouseover']);
@@ -292,6 +298,12 @@ function imagemenu_add_item_form_validat
 }
 
 function imagemenu_add_item_form_submit($form_id, $form) {
+  // Check for image with the specified name.
+  $detectedPath = get_image_path_from_image_name($form['imagepath']);
+  if ($detectedPath) { $form['imagepath'] = $detectedPath; }
+  $detectedPath = get_image_path_from_image_name($form['mouseover']);
+  if ($detectedPath) { $form['mouseover'] = $detectedPath; }
+  
   if ($form['path'] == 'node') $form['path'] = '<front>';
   if (!$form['mid']) {
     $mid = db_next_id('imagemenu');
@@ -397,7 +409,7 @@ function imagemenu_display($mid, $full =
       $output = imagemenu_build_table_horizontal($mid, $full);
       break;
   }
-  return theme('table', array(), $output);
+  return theme('table', array(), $output, array("class"=>"imagemenu"));
 }
 
 function imagemenu_settings() {
@@ -625,3 +637,16 @@ function _imagemenu_return_parent($mid) 
   $query = db_fetch_object(db_query("SELECT pid FROM {imagemenu} WHERE mid = %d", $mid));
   return $query->pid;
 }
+
+function get_image_path_from_image_name($imageName) {
+  
+  // Load an image with the specified name.
+  $results = db_query('SELECT nid FROM {node} n WHERE n.title = "%s" and n.type ="Image"', $imageName);
+  if (!$results) { return False; }
+  $result = db_fetch_object($results);
+  if (!$result) { return False; }
+  $node = node_load($result->nid);
+
+  // Return the path to the original image.
+  return $node->images["_original"];
+}
