--- customerror.module	2008-05-22 01:29:37.000000000 +0200
+++ customerror.module	2008-07-04 16:47:46.000000000 +0200
@@ -62,6 +62,15 @@ function customerror_admin_settings()
   );
 
   $errors = _customerror_enum_errors();
+
+	$themes = system_theme_data();
+  ksort($themes);
+  $options[0] = t('System default');
+  foreach ($themes as $theme) {
+    $options[$theme->name] = $theme->name;
+  }
+	
+	
   foreach($errors as $error_code => $error_desc) {
     $form['customerror_' . $error_code . '_title'] = array(
       '#type' => 'textfield',
@@ -84,6 +93,14 @@ function customerror_admin_settings()
       '#default_value' => variable_get('customerror_' . $error_code . '_php', FALSE),
       '#description' => t('This allows you to include PHP code (enclosed in &lt;?php ?&gt; tags) for the @error_code (@error_desc) message. Note that this can be dangerous in some situations. Make sure that you are aware of the implications.', array('@error_code' => $error_code, '@error_desc' => $error_desc)),
     );
+
+		$form['customerror_' . $error_code . '_theme'] = array(
+	    '#type' => 'select',
+	    '#options' => $options,
+	    '#title' => t(' Theme'),
+	    '#description' => t('Choose which theme the dould be used on the error page.'),
+	    '#default_value' => variable_get('customerror_' . $error_code . '_theme', ($error_code == 403 ? variable_get('admin_theme', 0) : 0)),
+	  );
   }
 
   $form['customerror_redirect'] = array(
@@ -131,7 +148,13 @@ function customerror_simpletest() {
  */
 function customerror_page() {
   $error_code = arg(1);
-
+	
+	global $user, $custom_theme;
+	$theme = variable_get('customerror_' . $error_code . '_theme', ($error_code == 403 ? variable_get('admin_theme', 0) : 0));
+	if(!empty($theme)){
+		$custom_theme = $theme;
+	}
+	
   switch($error_code) {
     case 403:
     case 404:
