}
        unset($_POST);
        $form = drupal_get_form("vals_soc_project_form", $obj, $target);
        if ($originalPath) {
            $form['#action'] = url($originalPath);
        }
        // Process the submit button which uses ajax
        //$form['submit'] = ajax_pre_render_element($form['submit']);
        // Build renderable array
        // 		$build = array(
        // 				'form' => $form,
        // 				'#attached' => $form['submit']['#attached'], // This will attach all needed JS behaviors onto the page
        // 		);
        renderForm($form, $target);
        break;
    case 'delete':
        $type = altSubValue($_POST, 'type', '');
        $id = altSubValue($_POST, 'id', '');
        if (!isValidOrganisationType($type)) {
            echo jsonBadResult(t('There is no such type we can delete'));
        } elseif (count(Proposal::getProposalsPerProject($id))) {
            echo jsonBadResult(t('You cannot delte the project; there are already students working on a proposal for this project. You can still edit it though.'));
        } else {
            $result = Groups::removeGroup($type, $id);
            ThreadedComments::getInstance()->removethreadsForEntity($id, $type);
            echo $result ? jsonGoodResult(true, '', array('extra' => $mine ? array('mine' => 1) : '')) : jsonBadResult();
        }
        break;
    default:
        echo "No such action: " . $_GET['action'];
}
     $selected_prev_set = false;
     if ($was_selected == 1) {
         $selected_prev_set = true;
     }
     if (!$selected_prev_set) {
         // update the project
         $props['proposal_id'] = $proposal_id;
         $props['selected'] = $is_final;
         if ($is_final) {
             $props['state'] = 'preselected';
         }
         $result = Project::changeProject($props, $project_id);
         //send message back giving status & success message
         if ($result) {
             // fire our emails
             $all_proposals_for_this_project = Proposal::getProposalsPerProject($project_id, null, true);
             module_load_include('inc', 'vals_soc', 'includes/module/vals_soc.mail');
             notify_students_and_supervisors_of_project_status_update($all_proposals_for_this_project, $proposal_id, $is_final);
             echo t('Changes successfully made.');
         } else {
             echo t('There was a problem updating your project preferences.');
         }
     } else {
         // send message back saying mentor has already made his decision & can't change it
         echo t('You already have chosen a final proposal for this project, you cannot change it now, unless the students chooses another offer.');
     }
     break;
 case 'list_my_offers':
     try {
         if (!Users::isStudent()) {
             echo jsonBadResult(t('Only students can accept project offers'));