Your module needs to implement hook_form_alter() to add '#ajax' arrays to the elements that trigger a change in the form. The #ajax elements will include 'wrapper' and 'callback' elements that specify the html ID of the part of the form to replace and a function in your module that returns the part of the form that is being replaced.
For example, if the element 'my-element' should be replaced, add
'#prefix' => '<div id="my-element-id">',
'#suffix' => '</div>'
to the form array with key 'my-element'. The element that triggers the replacement will get
'#ajax' => array(
'wrapper' => 'my-element-id',
'callback' => 'my_callback',
'method' => 'replace',
),
Here is the callback function:
function my_callback($form, &$form_state) {
return $form['my-element'];
}
Your hook_form_alter() will also hide or show/show elements and generate your custom messaging depending on $form_state (which it will read when the ajax callback happens).