--- C:/Documents and Settings/John/Bureau/search404/search404.module	Fri Jun 26 12:47:06 2009
+++ C:/www/website/testecommerce/sites/all/modules/search404/search404.module	Fri Aug 14 12:55:25 2009
@@ -99,7 +99,29 @@
  * Beware of messy code
  */
 function search404_page() {
+  global $language;
+  
+  
   drupal_set_title(t('Page not found'));
+  
+  $output = '';
+  if ($tnid = variable_get('search404_tnid', 0)) {
+    // Load node
+	if ($node = node_load($tnid)) {
+	  // Get translations
+	  $translations = translation_node_get_translations($node->tnid);
+	
+	  // If translation for current language, get full node
+	  if (isset($translations[$language->language])) $node = node_load($translations[$language->language]->nid);
+	
+	  // Set status in case of node is not published
+	  $node->status = 1;
+	
+	  // Get node content
+	  $output = node_view($node, FALSE, TRUE);
+	}
+  }
+  
   if (module_exists('search') && user_access('search content')) {
     $keys = "";
     // if apachesolr_search is installed use apachesolr_search instead default node search
@@ -131,7 +153,10 @@
           drupal_goto();
         }
         else {
-          drupal_set_message(t('The page you requested does not exist. For your convenience, a search was performed using the query %keys.', array('%keys' => check_plain($keys))), 'error');
+          if (!$output) {
+		    drupal_set_message(t('The page you requested does not exist. For your convenience, a search was performed using the query %keys.', array('%keys' => check_plain($keys))), 'error');
+		  }
+		  
           if (isset($results) && is_array($results) && count($results) > 0) {
             drupal_add_css(drupal_get_path('module', 'search') .'/search.css', 'module', 'all', FALSE);
             // EVIL HAXX!
@@ -152,7 +177,7 @@
       }
     }
     // Construct the search form.
-    $output = drupal_get_form('search_form', NULL, $keys, $type_search) . $results;
+    $output .= drupal_get_form('search_form', NULL, $keys, $type_search) . $results;
   }
   
   /*
@@ -202,6 +227,16 @@
     '#default_value' => variable_get('search404_do_google_cse', false),
   );
   
+  $form['search404_tnid'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Nid of the node to show under search box'),
+    '#description' => t('If you want to show a node under the search box, put his node id here (if translatable node, use his source nid).'),
+    '#default_value' => variable_get('search404_tnid', ''),
+	'#size' => 10,
+	'#maxlength' => 10,
+	'#element_validate' => array('search404_tnid_validate'),
+  );
+  
   $form['advanced'] = array(
     '#type' => 'fieldset',
     '#title' => t('Advanced settings'),
@@ -246,3 +281,10 @@
   );
   return system_settings_form($form);
 }
+
+function search404_tnid_validate($element, &$form_state) {
+  // Try to load node
+  if (!($node = node_load($element['#value']))) {
+    form_error($element, t('Incorrect node identifier.'));
+  }
+}
\ No newline at end of file
