--- civicrmtheme.original	2011-02-12 14:20:53.410056001 +1100
+++ civicrmtheme.module	2011-02-12 14:52:44.330056856 +1100
@@ -1,28 +1,67 @@
 <?php
-// $Id: civicrmtheme.module,v 1.1.2.2 2010/08/19 07:27:41 kurund Exp $
+// $Id: civicrm_theme.module,v 1.2.2.3 2009/01/13 16:52:04 douggreen Exp $
 
 function civicrmtheme_init() {
   if (arg(0) == 'civicrm') {
-    // Initialize civicrm object.
-    civicrm_initialize();
-
-    // Get the menu items.
-    $args = explode('/', $_GET['q']);
-    $path = implode('/', $args);
-
-    // Get the menu for above URL.
-    $item = CRM_Core_Menu::get($path);
-
-    // Check if the page is public according to CiviCRM, otherwise use the
-    // administration theme.
-    if (isset($item['is_public']) && $item['is_public']) {
-      $theme_var = 'civicrmtheme';
-    }
-    else {
-      $theme_var = 'civicrm_admin_theme';
-    }
-
     global $custom_theme;
+    switch (arg(1)) {
+      case 'admin':
+        $theme_var = 'civicrm_admin_theme';
+        break;
+      case 'dashboard':
+        $theme_var = 'civicrm_admin_theme';
+        break;
+      case 'mailing':
+        $theme_var = 'civicrm_admin_theme';
+        break;
+      case 'report':
+        $theme_var = 'civicrm_admin_theme';
+        break;
+      case 'group':
+        $theme_var = 'civicrm_admin_theme';
+        break;
+      case 'import':
+        $theme_var = 'civicrm_admin_theme';
+        break;
+      case 'event':
+        if (arg(2) == '' || arg(2) == 'manage') {
+          $theme_var = 'civicrm_admin_theme';
+        }
+        break;
+        if (arg(2) == '' || arg(2) == 'report') {
+          $theme_var = 'civicrm_admin_theme';
+        }
+        break;
+        if (arg(2) == '' || arg(2) == 'import') {
+          $theme_var = 'civicrm_admin_theme';
+        }
+        break;
+        if (arg(2) == '' || arg(2) == 'search') {
+          $theme_var = 'civicrm_admin_theme';
+        }
+        break;
+      case 'contribute':
+        if (arg(2) == '' || arg(2) == 'import') {
+          $theme_var = 'civicrm_admin_theme';
+        }
+        break;
+        if (arg(2) == '' || arg(2) == 'add') {
+          $theme_var = 'civicrm_admin_theme';
+        }
+        break;
+        if (arg(2) == '' || arg(2) == 'search') {
+          $theme_var = 'civicrm_admin_theme';
+        }
+        break;
+      case 'contact':
+        if (arg(2) == '' || arg(2) == 'search') {
+          $theme_var = 'civicrm_admin_theme';
+        }
+        break;
+      default:
+        $theme_var = 'civicrm_theme';
+        break;
+    }
     if ($theme_var && ($custom_theme = variable_get($theme_var, '0')) != '0') {
       $path = drupal_get_path('module', 'system');
       drupal_add_css($path .'/admin.css', 'module');
@@ -37,15 +76,15 @@
       '#type' => 'select',
       '#options' => $form['admin_theme']['#options'],
       '#title' => t('CiviCRM Administration theme'),
-      '#description' => t('Choose which theme the CiviCRM administration/backend pages should display in.'),
+      '#description' => t('Choose which theme the CiviCRM administration pages should display in.'),
       '#default_value' => variable_get('civicrm_admin_theme', ''),
     );
-    $newform['civicrmtheme'] = array(
+    $newform['civicrm_theme'] = array(
       '#type' => 'select',
       '#options' => $form['admin_theme']['#options'],
       '#title' => t('CiviCRM User theme'),
-      '#description' => t('Choose which theme the CiviCRM frontend pages should display in.'),
-      '#default_value' => variable_get('civicrmtheme', ''),
+      '#description' => t('Choose which theme the CiviCRM user pages should display in.'),
+      '#default_value' => variable_get('civicrm_theme', ''),
     );
     $form = array_merge(array_slice($form, 0, 1), $newform, array_slice($form, 1));
   }
