--- jquerymenu/jquerymenu.module.orig	Mon Jul 12 16:52:22 2010
+++ jquerymenu/jquerymenu.module	Mon Jul 12 17:05:38 2010
@@ -87,6 +87,12 @@
     '#description' => t('If checked the edit link will display when hovering over menu items to those having administration privileges. This setting will only affect menus directly created by the jquery menu module. Other modules that implement the edit link will have their own settings.'),
     '#default_value' => variable_get('jq_edit_link', 1),
     );
+   $form['jq_insertlistitemid'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Assign HTML ID to list items.'),
+    '#description' => t('If checked each jquerymenu list item will be assigned a unique HTML id. This can be used to theme specific list items with CSS.'),
+    '#default_value' => variable_get('jq_insert_list_item_id', 0),
+    );
   $form['jq_submit'] = array(
     '#type' => 'submit',
     '#value' => t('Save'),
@@ -99,6 +105,8 @@
   variable_set('jq_menu_animate', $animate);
   $editlink = $form_state['values']['jq_editlink'];
   variable_set('jq_edit_link', $editlink);
+  $insertlistitemid = $form_state['values']['jq_insertlistitemid'];
+  variable_set('jq_insert_list_item_id', $insertlistitemid);  
   $choices = $form_state['values']['jq_activate'];
   $result = db_query("SELECT menu_name FROM {jquerymenus}");
   $enabledmenus = array();
@@ -201,17 +209,25 @@
     return $url_array;
   
   }
-function recursive_link_creator($items = array(), $trail) {
+function recursive_link_creator($items = array(), $trail, $parentid = '') {
+  static $menucount = 0;
+  if ($parentid == '') {
+    $menucount++;
+    $parentid = $menucount;
+  }   
+    
   $url_array = $trail;
   $i = 0;
   if (!empty($items)) {
     foreach ($items as $item) {
+      $count++;
+      $id = $parentid . '-' . $count;
       $classes = array();
       $state = 'closed';
       // If there are submenu items we assign the parent a class.
       if (!empty($item['link']['has_children'])) {
         $nextlevel = '';
-        $nextlevel = recursive_link_creator($item['below'],$url_array);
+        $nextlevel = recursive_link_creator($item['below'],$url_array,$id);
         if (!empty($nextlevel)) {
           $classes[] = 'parent';
         }
@@ -280,10 +296,10 @@
         $path = $item['link']['href'];
       }
       if ($item['link']['hidden'] == 1 && !empty($item['link']['has_children'])) {
-        $output .= recursive_link_creator($item['below'], $url_array);
+        $output .= recursive_link_creator($item['below'], $url_array, $id);
       }
       if ($item['link']['hidden'] != 1 && $item['link']['hidden'] != -1) {
-        $output .= '<li'. (empty($classes) ? '>' : ' class="'. implode(' ', $classes) .'">');
+        $output .= '<li ' . (variable_get('jq_insert_list_item_id', 0) ? 'id="jqmenu-' . $id . '" ' : '') . (empty($classes) ? '>' : ' class="'. implode(' ', $classes) .'">');
         $output .= theme('jqmenu_links', $item['link']['title'], $path, $options, $state, $classes, $item['link']['has_children'], $editpath, $edit_text, $edit_access);
           if (!empty($item['link']['has_children'])) {
             if (!empty($nextlevel)) {
