diff --git special_menu_items.module special_menu_items.module
index f10c1d4..ee1919b 100644
--- special_menu_items.module
+++ special_menu_items.module
@@ -1,15 +1,15 @@
-<?php 
-//$Id$
+<?php
+//$Id: special_menu_items.module,v 1.6 2010/02/21 12:30:33 servit Exp $
 
 /**
  * @file
- *  Module to enable placeholder or separator menu items.Placeholder is a menu item which is 
- *  actually not a link. Something like this is useful with drop down menus where we want to 
- *  have a parent link which is actually not linking to a page but which is just acting as a 
+ *  Module to enable placeholder or separator menu items.Placeholder is a menu item which is
+ *  actually not a link. Something like this is useful with drop down menus where we want to
+ *  have a parent link which is actually not linking to a page but which is just acting as a
  *  parent and grouping some children below it.
- *  A separator menu item is something like "-------" which is also not linking anywhere but 
+ *  A separator menu item is something like "-------" which is also not linking anywhere but
  *  merely a mean to structure menus.
- * 
+ *
  *  Written by Tamir Al Zoubi and Karim Djelid - Servit Open Source Solutions - www.servit.ch
  */
 
@@ -17,23 +17,23 @@
 *Implementation of hook_menu()
 */
 function special_menu_items_menu() {
-  
+
   //Add nolink and separator as a dummy pages.
   $noLink    = 'nolink';
   $separator = 'separator';
-  
+
   $items[$noLink] = array(
   'page callback' => 'special_menu_items_dummy',
-  'access callback'=>TRUE, 
+  'access callback'=>TRUE,
   'type' => MENU_CALLBACK,
   );
-  
+
   $items[$separator] = array(
   'page callback' => 'special_menu_items_dummy',
   'access callback'=>TRUE,
   'type' => MENU_CALLBACK,
   );
-  
+
   $items['admin/settings/special_menu_items'] = array(
     'title' => 'Special Menu Items',
     'description' => 'Configure Special Menu Items.',
@@ -42,7 +42,7 @@ function special_menu_items_menu() {
     'access arguments' => array('administer site configuration'),
     'type' => MENU_NORMAL_ITEM,
   );
-  
+
  return $items;
 }
 
@@ -72,7 +72,7 @@ function special_menu_itemsoverwrite_menu_item($link, $has_children, $menu = '',
   if ($in_active_trail) {
     $class .= ' active-trail';
   }
-  
+
   if(strpos($link,'class="nolink"')!==false) {
     $class.=' nolink-li';
   }
@@ -82,39 +82,41 @@ if(strpos($link,'class="separator"')!==false) {
   return '<li class="'. $class .'">'. $link . $menu ."</li>\n";
 }
 
-/**
+/** 
  * Override of theme_menu_item_link()
- * This function will render link if it is "nolink" or "separator". Otherwise it will call originally 
- * overwriten menu_item_link function. 
+ * This function will render link if it is "nolink" or "separator". Otherwise it will call originally
+ * overwriten menu_item_link function.
  */
-function special_menu_itemsoverwrite_menu_item_link($link) {   
-  $theme_overwrite=variable_get('oldtheme_menu_item_link',null);
-  
+function special_menu_itemsoverwrite_menu_item_link($link) {
+  global $theme_key;
+  $theme_overwrite=variable_get('oldtheme_menu_item_link', array());
+  $theme_overwrite=$theme_overwrite[$theme_key];
+
   if (empty($link['localized_options'])) {
     $link['localized_options'] = array();
   }
-  
+
   if(strpos($link['href'], 'nolink') === 0) {
     // Allow if the menu link is nolink:
     $link['localized_options']['html'] = TRUE;
-    
+
     //Retrieve tag for nolink menu item
     $tag=variable_get('special_menu_items_nolink_tag','<span>');
-    
+
     //Set class for nolink
     $css='nolink';
- 
+
     //Return HTML span instead of a link
     return render_menu_item($tag,$link['title'],$css);
   }
   else if(strpos($link['href'], 'separator') === 0) {
     // Allow if the menu link is separator
     $link['localized_options']['html'] = TRUE;
-    
+
     //Retrieve tags and value for separator menu item
     $tag=variable_get('special_menu_items_separator_tag','<span>');
     $value=variable_get('special_menu_items_separator_value','<hr>');
-    
+
     //Set class for separator
     $css='separator';
 
@@ -130,15 +132,15 @@ function special_menu_itemsoverwrite_menu_item_link($link) {
  */
 function render_menu_item($tag,$value,$css=null){
 $length=strlen($tag);
-   
+
     //Validate the tags
       if($tag[0]=='<' && $tag[$length-1]=='>'){
         $closingtag=str_replace('<','</',$tag);
         if($css)
-            $tag=str_replace('>',' class="'.$css.'">',$tag);        
+            $tag=str_replace('>',' class="'.$css.'">',$tag);
       }
       else{
-        if($css){       
+        if($css){
         $classtag='<'.$tag.' class="'.$css.'">';
         $tag='<'.$tag.'>';
         $closingtag=str_replace('<','</',$tag);
@@ -148,7 +150,7 @@ $length=strlen($tag);
         $tag='<'.$tag.'>';
         $closingtag=str_replace('<','</',$tag);
         }
-      }  
+      }
   return $tag.$value.$closingtag;
 }
 
@@ -157,14 +159,16 @@ $length=strlen($tag);
  * We replace theme_menu_item_link with our own function.
  */
 function special_menu_items_theme_registry_alter(&$theme_registry) {
-  
+  global $theme_key;
+
   // Save previous value from registry in case another theme overwrites menu_item_link
-  $theme_overwrite = $theme_registry['menu_item_link']['function']; 
-  
+  $theme_overwrite = variable_get('oldtheme_menu_item_link', array());
+  $theme_overwrite[$theme_key] = $theme_registry['menu_item_link']['function'];
+
   //Store the value
   variable_set('oldtheme_menu_item_link', $theme_overwrite);
-  
-  // Replace theme_menu_item_link with our special_menu_itemsoverwrite_menu_item_link. 
+
+  // Replace theme_menu_item_link with our special_menu_itemsoverwrite_menu_item_link.
    $theme_registry['menu_item_link']['function'] = 'special_menu_itemsoverwrite_menu_item_link';
    $theme_registry['menu_item_link']['theme paths'] = drupal_get_path('module','special_menu_items');;
    $theme_registry['menu_item']['function'] = 'special_menu_itemsoverwrite_menu_item';
@@ -175,10 +179,10 @@ function special_menu_items_theme_registry_alter(&$theme_registry) {
  * Description changed, added nolink and separator as path types.
  */
 function special_menu_items_form_alter(&$form, $form_state, $form_id) {
- 
+
   if ($form_id=='menu_edit_item') {
     $default_value=$form['menu']['link_path']['#default_value'];
-    
+
       if(preg_match('/^nolink\/[0-9]+$/',$default_value))
       {
         $default_value='nolink';
@@ -187,10 +191,10 @@ function special_menu_items_form_alter(&$form, $form_state, $form_id) {
       {
         $default_value='separator';
       }
-  
+
     $form['menu']['link_path']['#default_value'] = $default_value;
-    $form['menu']['link_path']['#description']=  t('The path this menu item links to. This can be an internal Drupal path such as %add-node or an external URL such as %drupal. Enter %front to link to the front page, enter "nolink" to generate non-linkable item, enter "separator" to generate separator item.', array('%front' => '<front>', '%add-node' => 'node/add', '%drupal' => 'http://drupal.org')); 
-  } 
+    $form['menu']['link_path']['#description']=  t('The path this menu item links to. This can be an internal Drupal path such as %add-node or an external URL such as %drupal. Enter %front to link to the front page, enter "nolink" to generate non-linkable item, enter "separator" to generate separator item.', array('%front' => '<front>', '%add-node' => 'node/add', '%drupal' => 'http://drupal.org'));
+  }
 }
 
 /**
@@ -202,11 +206,11 @@ function special_menu_items_init() {
   $breadcrumb = drupal_get_breadcrumb();
 
   foreach($breadcrumb as $key=>$crumb){
-    
+
     if(strlen(strstr($crumb,'nolink'))>0) {
       $crumb=strip_tags($crumb);
       $tag=variable_get('special_menu_items_nolink_tag','<span>');
-      $breadcrumb[$key]=render_menu_item($tag,$crumb);      
+      $breadcrumb[$key]=render_menu_item($tag,$crumb);
     }
   }
   drupal_set_breadcrumb($breadcrumb);
@@ -218,29 +222,29 @@ function special_menu_items_init() {
  * @return
  * The settings form used by Special Menu Items.
  */
-function special_menu_items_admin_settings_form() { 
+function special_menu_items_admin_settings_form() {
   $form['special_menu_items_nolink_tag'] = array(
     '#type' => 'textfield',
     '#title' => t('HTML tag for "nolink"'),
     '#description' => t('By default, Special Menu Items will use a span tag for the nolink menu item. Here you can specify your own tag.'),
     '#default_value' => variable_get('special_menu_items_nolink_tag', '<span>'),
-  
+
   );
-  
+
   $form['special_menu_items_separator_tag'] = array(
     '#type' => 'textfield',
     '#title' => t('HTML tag for "separator"'),
     '#description' => t('By default, Special Menu Items will use a span tag for the separator menu item. Here you can specify your own tag.'),
     '#default_value' => variable_get('special_menu_items_separator_tag', '<span>'),
-  
+
   );
-  
+
     $form['special_menu_items_separator_value'] = array(
     '#type' => 'textfield',
     '#title' => t('Value to be displayed for the "separator"'),
     '#description' => t('By default, Special Menu Items will use a "&lt;hr&gt;" value for the separator. You can specify your own value for the separator.'),
     '#default_value' => variable_get('special_menu_items_separator_value', '<hr>'),
-  
+
   );
 
   return system_settings_form($form);
@@ -250,14 +254,14 @@ function special_menu_items_footer() {
   if(strpos($_GET['q'],'admin/build/menu-customize')!== false)
   {
     //do all links in db
-    global $db_type;  
+    global $db_type;
     if ($db_type == 'pgsql') {
         db_query("UPDATE {menu_links} SET link_path=link_path||'/'||mlid WHERE (link_path='nolink' OR link_path='separator') AND hidden != -1");
     }
     else {
         db_query("UPDATE {menu_links} SET link_path=CONCAT(CONCAT(link_path,'/'),mlid) WHERE (link_path='nolink' OR link_path='separator') AND hidden!=-1");
     }
-	
+
 	cache_clear_all();
   }
 }
\ No newline at end of file
