diff -urp hosting/client/CVS/Entries /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/client/CVS/Entries
--- hosting/client/CVS/Entries	2008-10-16 19:38:11.000000000 +0800
+++ /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/client/CVS/Entries	2008-10-16 17:32:29.000000000 +0800
@@ -1,4 +1,4 @@
-/hosting_client.info/1.1/Mon Jun  2 18:59:11 2008//
-/hosting_client.install/1.3/Wed Oct 15 08:09:47 2008//
-/hosting_client.module/1.10/Wed Oct  8 03:19:37 2008//
+/hosting_client.info/1.1/Wed Oct 15 04:44:34 2008//
+/hosting_client.install/1.3/Thu Oct 16 09:32:29 2008//
+/hosting_client.module/1.10/Wed Oct 15 04:44:34 2008//
 D
diff -urp hosting/cron/CVS/Entries /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/cron/CVS/Entries
--- hosting/cron/CVS/Entries	2008-10-16 19:38:11.000000000 +0800
+++ /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/cron/CVS/Entries	2008-10-16 17:32:29.000000000 +0800
@@ -1,3 +1,3 @@
-/hosting_cron.info/1.1/Wed Feb 13 00:25:35 2008//
-/hosting_cron.module/1.3/Sat Jun 21 17:16:50 2008//
+/hosting_cron.info/1.1/Wed Oct 15 04:44:34 2008//
+/hosting_cron.module/1.3/Wed Oct 15 04:44:34 2008//
 D
diff -urp hosting/CVS/Entries /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/CVS/Entries
--- hosting/CVS/Entries	2008-10-16 19:38:11.000000000 +0800
+++ /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/CVS/Entries	2008-10-16 17:32:29.000000000 +0800
@@ -1,15 +1,3 @@
-/hosting.css/1.5/Fri Jun 27 05:12:10 2008//
-/hosting.info/1.6/Thu Jun 19 21:17:31 2008//
-/hosting.install/1.24/Wed Oct 15 08:12:14 2008//
-/hosting.js/1.1/Fri Jun 27 05:12:10 2008//
-/hosting.module/1.65/Sun Oct 12 23:47:47 2008//
-/hosting.queues.inc/1.12/Fri Jun 27 15:19:36 2008//
-/hosting.templates.inc/1.1/Fri Jun 20 16:07:20 2008//
-/hosting.wizard.css/1.1/Sat Jun 21 17:12:52 2008//
-/hosting.wizard.inc/1.20/Fri Oct 10 06:47:37 2008//
-/hosting.wizard.js/1.1/Sat Jun 21 17:12:52 2008//
-/hosting_help.inc/1.14/Fri Aug 22 13:06:06 2008//
-/info.png/1.1/Fri Jun 27 05:12:10 2008/-kb/
 D/action////
 D/client////
 D/cron////
@@ -21,3 +9,15 @@ D/site////
 D/stats////
 D/task////
 D/web_server////
+/hosting.css/1.5/Wed Oct 15 04:44:34 2008//
+/hosting.info/1.6/Wed Oct 15 04:44:34 2008//
+/hosting.install/1.24/Thu Oct 16 09:32:28 2008//
+/hosting.js/1.1/Wed Oct 15 04:44:34 2008//
+/hosting.module/1.65/Wed Oct 15 04:44:34 2008//
+/hosting.queues.inc/1.12/Wed Oct 15 04:44:34 2008//
+/hosting.templates.inc/1.1/Wed Oct 15 04:44:34 2008//
+/hosting.wizard.css/1.1/Wed Oct 15 04:44:34 2008//
+/hosting.wizard.inc/1.20/Wed Oct 15 04:44:34 2008//
+/hosting.wizard.js/1.1/Wed Oct 15 04:44:34 2008//
+/hosting_help.inc/1.14/Wed Oct 15 04:44:34 2008//
+/info.png/1.1/Wed Oct 15 04:44:34 2008/-kb/
diff -urp hosting/db_server/CVS/Entries /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/db_server/CVS/Entries
--- hosting/db_server/CVS/Entries	2008-10-16 19:38:11.000000000 +0800
+++ /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/db_server/CVS/Entries	2008-10-16 17:32:29.000000000 +0800
@@ -1,4 +1,4 @@
-/hosting_db_server.info/1.1/Mon Jun  2 20:40:17 2008//
-/hosting_db_server.install/1.2/Wed Oct 15 06:49:25 2008//
-/hosting_db_server.module/1.11/Tue Oct 14 22:03:27 2008//
+/hosting_db_server.info/1.1/Wed Oct 15 04:44:34 2008//
+/hosting_db_server.install/1.2/Thu Oct 16 09:32:29 2008//
+/hosting_db_server.module/1.11/Wed Oct 15 04:44:34 2008//
 D
diff -urp hosting/hosting.info /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/hosting.info
--- hosting/hosting.info	2008-10-16 19:38:11.000000000 +0800
+++ /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/hosting.info	2008-10-16 19:36:50.000000000 +0800
@@ -1,4 +1,4 @@
 name = Hosting
 description = Allow this Drupal site to deploy hosted sites.
 package = Hosting
-dependencies = provision views views_ui hosting_task hosting_client hosting_db_server hosting_package hosting_platform hosting_site hosting_web_server
+dependencies = provision views views_ui hosting_task hosting_client hosting_db_server hosting_package hosting_platform hosting_site hosting_web_server ahah_forms dynamic_subform
diff -urp hosting/package/CVS/Entries /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/package/CVS/Entries
--- hosting/package/CVS/Entries	2008-10-16 19:38:11.000000000 +0800
+++ /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/package/CVS/Entries	2008-10-16 17:32:30.000000000 +0800
@@ -1,4 +1,4 @@
-/hosting_package.info/1.1/Mon Jun  2 18:59:12 2008//
-/hosting_package.install/1.4/Wed Oct 15 06:49:25 2008//
 /hosting_package.module/1.11/Tue Oct 14 22:03:27 2008//
+/hosting_package.info/1.1/Wed Oct 15 04:44:34 2008//
+/hosting_package.install/1.4/Thu Oct 16 09:32:30 2008//
 D
diff -urp hosting/package/hosting_package.module /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/package/hosting_package.module
--- hosting/package/hosting_package.module	2008-10-16 19:38:11.000000000 +0800
+++ /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/package/hosting_package.module	2008-10-16 17:34:50.000000000 +0800
@@ -33,8 +33,19 @@ function hosting_package_release_access(
   return hosting_access($op, $node);
 }
 
-function hosting_get_profiles() {
-  $profiles = _hosting_package_load(array('package_type' => 'profile'));
+function hosting_get_profiles($platform) {
+  if(!$platform) {
+    $platform = HOSTING_DEFAULT_PLATFORM;
+  }
+  $result = db_query('SELECT n.nid FROM {node} n LEFT JOIN {hosting_package} hp ON n.nid = hp.nid 
+                                                 LEFT JOIN {hosting_package_release} hpr ON hp.nid = hpr.package 
+                                                 LEFT JOIN {hosting_package_instance} hpi ON hpr.nid = hpi.release_id 
+                                                 LEFT JOIN {hosting_platform} l ON hpi.rid = l.nid 
+                                                 WHERE l.nid = %d AND hp.package_type = "profile"', $platform);
+
+  while ($nid = db_fetch_object($result)) {
+    $profiles[$nid->nid] = node_load(array('nid' => $nid->nid));
+  }
 
   foreach ($profiles as $profile) {
     $return[$profile->nid] = $profile->title;
@@ -42,8 +53,8 @@ function hosting_get_profiles() {
   return $return;
 }
 
-function hosting_get_profile_languages() {
-  $result = db_query("SELECT DISTINCT(language) FROM {hosting_package_languages}");
+function hosting_get_profile_languages($profile) {
+  $result = db_query("SELECT DISTINCT(language) FROM {hosting_package_languages} WHERE nid = %d", $profile);
   while ($language = db_fetch_object($result)) {
     $languages[] = $language->language;
   }
Only in /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/package: .hosting_package.module.swp
diff -urp hosting/platform/CVS/Entries /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/platform/CVS/Entries
--- hosting/platform/CVS/Entries	2008-10-16 19:38:11.000000000 +0800
+++ /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/platform/CVS/Entries	2008-10-16 17:32:30.000000000 +0800
@@ -1,4 +1,4 @@
-/hosting_platform.info/1.1/Mon Jun  2 18:59:12 2008//
-/hosting_platform.install/1.2/Wed Oct 15 06:49:25 2008//
-/hosting_platform.module/1.15/Thu Oct 16 06:17:41 2008//
+/hosting_platform.info/1.1/Wed Oct 15 04:44:34 2008//
+/hosting_platform.install/1.2/Thu Oct 16 09:32:30 2008//
+/hosting_platform.module/1.15/Thu Oct 16 09:32:30 2008//
 D
diff -urp hosting/site/CVS/Entries /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/site/CVS/Entries
--- hosting/site/CVS/Entries	2008-10-16 19:38:11.000000000 +0800
+++ /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/site/CVS/Entries	2008-10-16 17:32:30.000000000 +0800
@@ -1,5 +1,5 @@
-/hosting_site.info/1.2/Thu Jun 12 03:24:45 2008//
-/hosting_site.install/1.3/Wed Oct 15 06:49:25 2008//
 /hosting_site.module/1.22/Fri Oct 10 06:47:38 2008//
-/hosting_site_status.inc/1.2/Tue Jun  3 01:57:16 2008//
+/hosting_site.info/1.2/Wed Oct 15 04:44:34 2008//
+/hosting_site.install/1.3/Thu Oct 16 09:32:30 2008//
+/hosting_site_status.inc/1.2/Wed Oct 15 04:44:34 2008//
 D
diff -urp hosting/site/hosting_site.module /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/site/hosting_site.module
--- hosting/site/hosting_site.module	2008-10-16 19:38:11.000000000 +0800
+++ /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/site/hosting_site.module	2008-10-16 17:44:33.000000000 +0800
@@ -173,6 +173,87 @@ function hosting_site_hosting_post_delet
   db_query("UPDATE {hosting_site} SET status=%d WHERE nid=%d", HOSTING_SITE_DELETED, $task->rid);
 }
 
+// AHAH function to render the subform
+function _hosting_site_ahah_subform() {
+  $subform = dynamic_subform_get_prepped('site_node_form', 'hosting_site_subform');
+  print drupal_render($subform);
+  exit();
+}
+
+// The AHAH subform
+function hosting_site_subform($form_values) {
+  $form = array();
+
+  $platforms = _hosting_get_platforms();
+  if (sizeof($platforms) > 1) {
+    $form['platform'] = array(
+      '#type' => 'radios',
+      '#title' => t('Platform'),
+      '#description' => t('The platform you want the site to be hosted on.'),
+      '#options' => $platforms,
+      '#default_value' => $node->platform,
+      '#attributes' => array('class' => 'hosting-platform-options'),
+      '#ahah_bindings' => array (
+        array(
+          'wrapper' => 'hosting-site-subform',
+          'selector' => 'input.hosting-platform-options',
+          'event' => 'click',
+          'path' => 'hosting/site/hosting_site_ahah_subform',
+        ),
+        array(
+          'wrapper' => 'hosting-site-subform',
+          'selector' => 'input.hosting-profile-options',
+          'event' => 'click',
+          'path' => 'hosting/site/hosting_site_ahah_subform',
+        ),
+      )
+    );
+  }
+  else {
+    if ($platforms) {
+      $platforms = HOSTING_DEFAULT_PLATFORM;
+    }
+    $form['platform'] = array('#type' => 'value', '#value' => key($platforms));
+  }
+  
+  // If a platform is selected, load the relavant profiles
+  if ($form_values['platform']) {
+    $profiles = hosting_get_profiles($form_values['platform']);
+    if (sizeof($profiles) > 1) {
+      $form['profile'] = array(
+        '#type' => 'radios',
+        '#title' => t('Install profile'),
+        '#description' => t('The type of site to install.'),
+        '#options' => $profiles,
+        '#default_value' => $node->profile,
+        '#attributes' => array('class' => 'hosting-profile-options'),
+      );
+    }
+    else {
+      $form['profile'] = array('#type' => 'value', '#value' => key($profiles));
+    }
+  }
+
+  // If a profile is selected, load the relavant languages
+  if ($form_values['profile']) {
+    $languages = hosting_get_profile_languages($form_values['profile']);
+    if (sizeof($languages) > 1) {
+      $form['language'] = array(
+        '#type' => 'radios',
+        '#title' => t('Language'),
+        '#description' => t('The language of your site.'),
+        '#options' => $languages,
+        '#default_value' => ($node->language) ? $node->language : 'en',
+      );
+    }
+    else {
+      $form['language'] = array('#type' => 'hidden', '#value' => 'en');
+    }
+  }
+
+  return $form;
+}
+
 /**
  * Implementation of hook_form
  *
@@ -180,7 +261,7 @@ function hosting_site_hosting_post_delet
  */
 function hosting_site_form($node) {
   $type = node_get_types('type', $node);
-  
+
   // We need to define form elements for the node's title and body.
   $form['title'] = array(
     '#type' => 'textfield',
@@ -203,49 +284,14 @@ function hosting_site_form($node) {
     $form['client'] = array('#type' => 'value', '#value' => key($clients));
   }
 
-  $platforms = _hosting_get_platforms();
-  if (sizeof($platforms) > 1) {
-    $form['platform'] = array(
-      '#type' => 'radios',
-      '#title' => t('Platform'),
-      '#description' => t('The platform you want the site to be hosted on.'),
-      '#options' => $platforms,
-      '#default_value' => $node->platform,
-    );
-  }
-  else {
-    $form['platform'] = array('#type' => 'value', '#value' => key($platforms));
-  }
-
-
-  $profiles = hosting_get_profiles();
-  if (sizeof($profiles) > 1) {
-    $form['profile'] = array(
-      '#type' => 'radios',
-      '#title' => t('Install profile'),
-      '#description' => t('The type of site to install.'),
-      '#options' => $profiles,
-      '#default_value' => $node->profile,
-    );
-  }
-  else {
-    $form['profile'] = array('#type' => 'value', '#value' => key($profiles));
-  }
-
-  $languages = hosting_get_profile_languages();
-  // @todo Implement jquery AHAH selectors, to filter the available languages.
-  if (sizeof($languages) > 1) {
-    $form['language'] = array(
-      '#type' => 'radios',
-      '#title' => t('Language'),
-      '#description' => t('The type of site to install.'),
-      '#options' => $languages,
-      '#default_value' => ($node->language) ? $node->language : 'en',
-    );
-  }
-  else {
-    $form['language'] = array('#type' => 'value', '#value' => 'en');
-  }
+  // Placeholder for AHAH subform
+  $form['site_subform'] = array(
+    '#type' => 'item',
+    '#prefix' => '<div id = "hosting-site-subform">',
+    '#suffix' => '</div>',
+  );
+  // Pre-embed the AHAH subform
+  $form['site_subform'] += dynamic_subform_get_embedded('site_node_form', 'hosting_site_subform', array());
 
   $db_servers = _hosting_get_db_servers();
   if (sizeof($db_servers) > 1) {
@@ -498,5 +544,11 @@ function hosting_site_menu($may_cache = 
     'type' => MENU_CALLBACK,
     'access' => TRUE
   );
+   $items[] = array(
+     'path' => 'hosting/site/hosting_site_ahah_subform',
+     'callback' => '_hosting_site_ahah_subform',
+     'type' => MENU_CALLBACK,
+     'access' => TRUE,
+   );
   return $items;
 }
Only in /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/site: .hosting_site.module.swp
diff -urp hosting/stats/CVS/Entries /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/stats/CVS/Entries
--- hosting/stats/CVS/Entries	2008-10-16 19:38:11.000000000 +0800
+++ /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/stats/CVS/Entries	2008-10-16 17:32:30.000000000 +0800
@@ -1,4 +1,4 @@
-/hosting_stats.info/1.2/Fri Jun 20 16:07:21 2008//
-/hosting_stats.install/1.2/Fri Jun 20 16:07:21 2008//
-/hosting_stats.module/1.3/Fri Jun 20 21:33:11 2008//
+/hosting_stats.info/1.2/Wed Oct 15 04:44:34 2008//
+/hosting_stats.install/1.2/Wed Oct 15 04:44:34 2008//
+/hosting_stats.module/1.3/Wed Oct 15 04:44:34 2008//
 D
diff -urp hosting/task/CVS/Entries /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/task/CVS/Entries
--- hosting/task/CVS/Entries	2008-10-16 19:38:11.000000000 +0800
+++ /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/task/CVS/Entries	2008-10-16 17:32:31.000000000 +0800
@@ -1,4 +1,4 @@
-/hosting_task.info/1.1/Thu Jun 19 21:17:31 2008//
-/hosting_task.install/1.3/Wed Oct 15 06:49:26 2008//
-/hosting_task.module/1.19/Fri Oct 10 06:47:38 2008//
+/hosting_task.info/1.1/Wed Oct 15 04:44:34 2008//
+/hosting_task.install/1.3/Thu Oct 16 09:32:31 2008//
+/hosting_task.module/1.19/Wed Oct 15 04:44:34 2008//
 D
diff -urp hosting/web_server/CVS/Entries /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/web_server/CVS/Entries
--- hosting/web_server/CVS/Entries	2008-10-16 19:38:11.000000000 +0800
+++ /opt/lampp/htdocs/aegir/profiles/hostmaster/modules/hosting/web_server/CVS/Entries	2008-10-16 17:32:31.000000000 +0800
@@ -1,4 +1,4 @@
-/hosting_web_server.info/1.1/Mon Jun  2 18:59:12 2008//
-/hosting_web_server.install/1.2/Wed Oct 15 06:49:26 2008//
-/hosting_web_server.module/1.10/Wed Oct  8 03:19:38 2008//
+/hosting_web_server.info/1.1/Wed Oct 15 04:44:34 2008//
+/hosting_web_server.install/1.2/Thu Oct 16 09:32:31 2008//
+/hosting_web_server.module/1.10/Wed Oct 15 04:44:34 2008//
 D
