diff -urp formblock-dev/formblock.css formblock/formblock.css
--- formblock-dev/formblock.css	2008-12-10 03:42:39.000000000 +0100
+++ formblock/formblock.css	2009-06-10 11:42:44.000000000 +0200
@@ -1,7 +1,11 @@
-/* $Id: formblock.css,v 1.1.4.3 2008/12/10 02:42:39 mikeyp Exp $ */
+/* $Id: formblock.css,v 1.1.2.3 2009/05/13 08:21:41 mikeyp Exp $ */
 
-div#block-formblock-contact_site .form-text,
 div#block-formblock-user_register .form-text {
   display: block;
   width: 95%;
+}
+
+/* Reset the fixed width of input form text fields to use a dynamic width depending on the parent elements */
+div.sidebar div.block-formblock input[type=text] {
+  width: 100%;
 }
\ No newline at end of file
diff -urp formblock-dev/formblock.info formblock/formblock.info
--- formblock-dev/formblock.info	2008-12-10 13:06:17.000000000 +0100
+++ formblock/formblock.info	2009-06-10 11:57:26.000000000 +0200
@@ -1,10 +1,9 @@
-; $Id: formblock.info,v 1.3 2007/12/18 02:37:50 mikeyp Exp $
+; $Id: formblock.info,v 1.1.2.1 2007/06/18 23:06:44 dww Exp $
 name = Form block
-description = Enables the presentation of node creation forms in blocks. This is particularly useful for including forms on panels.
-core = 6.x
-; Information added by drupal.org packaging script on 2008-12-10
-version = "6.x-1.x-dev"
-core = "6.x"
+description = Enables the presentation of node creation forms, user registration form and all contact form categories in blocks. This is particularly useful for including forms on panels.
+
+; Information added by drupal.org packaging script on 2009-05-13
+version = "5.x-1.x-dev"
 project = "formblock"
-datestamp = "1228910777"
+datestamp = "1242216845"
 
diff -urp formblock-dev/formblock.module formblock/formblock.module
--- formblock-dev/formblock.module	2008-12-10 03:42:39.000000000 +0100
+++ formblock/formblock.module	2009-06-10 11:38:03.000000000 +0200
@@ -1,10 +1,10 @@
 <?php
-// $Id: formblock.module,v 1.4.2.2 2008/12/10 02:42:39 mikeyp Exp $
+// $Id: formblock.module,v 1.2.2.4 2009/05/13 08:21:41 mikeyp Exp $
 
 /**
  * Implementation of hook_form_alter().
  */
-function formblock_form_alter(&$form, $form_state, $form_id) {
+function formblock_form_alter($form_id, &$form) {
   if ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
     $options = array(t('Disabled'), t('Enabled'));
     $form['formblock'] = array(
@@ -20,6 +20,23 @@ function formblock_form_alter(&$form, $f
       '#description' => t('Enable this option to make the entry form for this content type available as a block.'),
     );
   }
+
+  // Modify the contact form: remove the category popup field and re-insert it as hidden field
+  // Only modify if when calling it as block (controlled by $_SESSION['formblock_contact_form_category'])
+  if ('contact_mail_page' == $form_id && isset($_SESSION['formblock_contact_form_category'])) {
+    // Remove the category popup field
+    unset($form['cid']);
+
+    // Build a new cid form field
+    $form['cid'] = array(
+      '#type' => 'hidden',
+      '#value' => $_SESSION['formblock_contact_form_category'],
+    );
+
+    // Forget the category so we don't modify the form next time with a wrong category
+    // or modify the site-wide contact form at the /contact path
+    unset($_SESSION['formblock_contact_form_category']);
+  }
 }
 
 /**
@@ -38,13 +55,19 @@ function formblock_block($op = 'list', $
       }
       $blocks['user_register'] = array(
         'info' => t('User registration form'));
-      if (module_exists('contact')) {
-        $blocks['contact_site'] = array(
-          'info' => t('Site-wide contact form'));
-      }
+
+      // Add one block for every contact category 
+      $blocks = array_merge($blocks, formblock_contact_form_get_categories());
+
       return $blocks;
 
     case 'view':
+      // Get the contact form category from $delta
+      if (preg_match('/contact_form_(\d+)/', $delta, $matches)) {
+        $delta = 'contact_form';
+        $contact_form_category = $matches[1];
+      }
+      
       switch ($delta) {
         case 'user_register':
           global $user;
@@ -57,28 +80,11 @@ function formblock_block($op = 'list', $
             );
           }
           break;
-
-        case 'contact_site':
-          if (user_access('access site-wide contact form') && module_exists('contact')) {
-            if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3))) {
-              $content = t("You cannot send more than %number messages per hour. Please try again later.", array('%number' => variable_get('contact_hourly_threshold', 3)));
-            }
-            else {
-              drupal_add_css(drupal_get_path('module', 'formblock'). '/formblock.css', 'module', 'all');
-              module_load_include('inc', 'contact', 'contact.pages');
-              $content = drupal_get_form('contact_mail_page');
-            }
-            return array(
-              'subject' => t('Contact'),
-              'content' => $content,
-            );
-          }
-          break;
-
+        case 'contact_form':
+          return formblock_contact_form_content($contact_form_category);
         default:
           return formblock_get_block($delta);
-
-    }
+      }      
   }
 }
 
@@ -87,8 +93,6 @@ function formblock_block($op = 'list', $
  */
 function formblock_get_block($type) {
   if (node_access('create', $type)) {
-    // Include page handler for node_add()
-    module_load_include('inc', 'node', 'node.pages');
     // Note title before rendering of form.
     $title = drupal_get_title();
     $form = node_add($type);
@@ -101,3 +105,57 @@ function formblock_get_block($type) {
     );
   }
 }
+
+/**
+ * Get the HTML code for the contact form
+ *
+ * @param int $category The contact.cid of the contact form category from the database
+ * @return array Content/title array for Blocks
+ * @author Bernhard Fürst <bernhard.fuerst@fuerstnet.de
+ **/
+function formblock_contact_form_content($category) {
+  // Get data about existing contact categories (formatted in block array)
+  $blocks = formblock_contact_form_get_categories();
+  
+  // Extract block title
+  $content['subject'] = $blocks[$category]['info'];
+
+  // Don't allow misuse by using the contact form too often
+  if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3))) {
+    $content['content'] = t("You cannot send more than %number messages per hour. Please try again later.", array('%number' => variable_get('contact_hourly_threshold', 3)));
+    return $content;
+  }
+
+  // Need to know about the category in formblock_form_alter() 
+  $_SESSION['formblock_contact_form_category'] = $category;
+
+  // Get the HTML code for the contact form
+  $content['content'] = drupal_get_form('contact_mail_page');
+
+  // Add some modifications to the CSS
+  drupal_add_css(drupal_get_path('module', 'formblock'). '/formblock.css', 'module', 'all');
+
+  return $content;
+}
+
+/**
+ * Get the contact form categories and format it as block array
+ *
+ * @return array Contact form categories formatted as block array
+ * @author Bernhard Fürst <bernhard.fuerst@fuerstnet.de
+ **/
+function formblock_contact_form_get_categories() {
+  
+  // Check if the contact module is enabled
+  if (!module_exists('contact')) {
+    return array();
+  }
+  
+  $blocks = array();
+  $result = db_query('SELECT cid, category FROM {contact} ORDER BY weight, category');
+  while ($category = db_fetch_object($result)) {
+    $blocks['contact_form_' . $category->cid]['info'] = sprintf('%s: %s', t('Contact form'), $category->category);
+  }
+  return $blocks;
+}
+
