default:
            $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/AutoCompleteList.js?release=" . html_encode(APPLICATION_VERSION) . "\"></script>";
            $PROCESSED["prov_state"] = isset($PROCESSED["province_id"]) && $PROCESSED["province_id"] ? (int) $PROCESSED["province_id"] : (isset($PROCESSED["apartment_province"]) && $PROCESSED["apartment_province"] ? $PROCESSED["apartment_province"] : "");
            $ONLOAD[] = "provStateFunction(\$F(\$('addApartmentForm')['countries_id']))";
            $ONLOAD[] = "display_key_contact(" . $super_for_keys . ")";
            /**
             * Determine whether the Google Maps can be shown.
             */
            if (defined("GOOGLE_MAPS_API") && GOOGLE_MAPS_API != "") {
                $HEAD[] = "<script type=\"text/javascript\" src=\"" . GOOGLE_MAPS_API . "\"></script>";
                $ONLOAD[] = "initialize()";
                if (isset($PROCESSED["apartment_latitude"]) && $PROCESSED["apartment_latitude"] && isset($PROCESSED["apartment_longitude"]) && $PROCESSED["apartment_longitude"]) {
                    $ONLOAD[] = "addPointToMap('" . $PROCESSED["apartment_latitude"] . "', '" . $PROCESSED["apartment_longitude"] . "')";
                }
            }
            load_rte("advanced");
            ?>
			<h1>Add Apartment</h1>
			<?php 
            if ($ERROR) {
                echo display_error();
            }
            ?>
			<script type="text/javascript">
			var googleMap = null;
			var updater = null;


				function display_key_contact(display) {
					if (display) {
						$('keys_from_super').checked = true;
            $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/AutoCompleteList.js?release=" . html_encode(APPLICATION_VERSION) . "\"></script>";
            /**
             * Compiles the full list of faculty members.
             */
            $AUTHOR_LIST = array();
            $query = "\tSELECT a.`id` AS `proxy_id`, CONCAT_WS(', ', a.`lastname`, a.`firstname`) AS `fullname`, a.`organisation_id`\n\t\t\t\t\t\tFROM `" . AUTH_DATABASE . "`.`user_data` AS a\n\t\t\t\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_access` AS b\n\t\t\t\t\t\tON b.`user_id` = a.`id`\n\t\t\t\t\t\tWHERE b.`app_id` = '" . AUTH_APP_ID . "'\n\t\t\t\t\t\tAND (b.`group` = 'faculty' OR (b.`group` = 'resident' AND b.`role` = 'lecturer') OR b.`group` = 'staff' OR b.`group` = 'medtech')\n\t\t\t\t\t\tORDER BY a.`lastname` ASC, a.`firstname` ASC";
            $results = $db->GetAll($query);
            if ($results) {
                foreach ($results as $result) {
                    $AUTHOR_LIST[$result["proxy_id"]] = array('proxy_id' => $result["proxy_id"], 'fullname' => $result["fullname"], 'organisation_id' => $result['organisation_id']);
                }
            }
            /**
             * Load the rich text editor.
             */
            load_rte();
            if ($ERROR) {
                echo display_error();
            }
            ?>
			<form action="<?php 
            echo ENTRADA_URL;
            ?>
/admin/evaluations/forms?section=add&amp;step=2" method="post" id="addEvaluationForm">
				<table style="width: 100%" cellspacing="0" cellpadding="2" border="0" summary="Adding Evaluation Form">
					<colgroup>
						<col style="width: 3%" />
						<col style="width: 20%" />
						<col style="width: 77%" />
					</colgroup>
					<tfoot>
 /**
  * Non-required field "associated_faculty" / Associated Faculty (array of proxy ids).
  * This is actually accomplished after the event is inserted below.
  */
 if (isset($_POST["associated_director"])) {
     $associated_director = explode(',', $_POST["associated_director"]);
     foreach ($associated_director as $contact_order => $proxy_id) {
         if ($proxy_id = clean_input($proxy_id, array("trim", "int")) && array_key_exists($proxy_id, $DIRECTOR_LIST)) {
             $chosen_course_directors[(int) $contact_order] = $proxy_id;
         }
     }
 }
 /**
  * Load the rich text editor.
  */
 load_rte("minimal");
 $HEAD[] = "<script type=\"text/javascript\" src=\"" . ENTRADA_URL . "/javascript/jquery/jquery.timepicker.js\"></script>\n";
 ?>
 <h1>Add Assignment Drop Box</h1>
 <?php 
 if ($ERROR) {
     echo display_error();
 }
 ?>
 <script type="text/javascript">
     jQuery(document).ready(function() {
         jQuery('.datepicker').datepicker({
             dateFormat: 'yy-mm-dd'
         });
         jQuery(".timepicker").timepicker({
             showPeriodLabels: false
         }
     }
 }
 if ($COMMUNITY_ID && $PAGE_ID) {
     $query = "SELECT * FROM `communities` WHERE `community_id` = " . $db->qstr($COMMUNITY_ID) . " AND `community_active` = '1'";
     $community_details = $db->GetRow($query);
     if ($community_details) {
         $BREADCRUMB[] = array("url" => ENTRADA_URL . "/community" . $community_details["community_url"], "title" => limit_chars($community_details["community_title"], 50));
         $BREADCRUMB[] = array("url" => ENTRADA_URL . "/community" . $community_details["community_url"] . ":pages", "title" => "Manage Pages");
         $query = "\tSELECT * FROM `community_members`\n\t\t\t\t\t\tWHERE `community_id` = " . $db->qstr($COMMUNITY_ID) . "\n\t\t\t\t\t\tAND `proxy_id` = " . $db->qstr($ENTRADA_USER->getActiveId()) . "\n\t\t\t\t\t\tAND `member_active` = '1'\n\t\t\t\t\t\tAND `member_acl` = '1'";
         $result = $db->GetRow($query);
         if ($result && $PAGE_ID != "home" && (isset($page_type) && $page_type != "home")) {
             $query = "SELECT * FROM `community_pages` WHERE `cpage_id` = " . $db->qstr($PAGE_ID) . " AND `community_id` = " . $db->qstr($COMMUNITY_ID) . " AND `page_active` = '1'";
             $page_details = $db->GetRow($query);
             if ($page_details) {
                 load_rte($PAGE_TYPE == "default" || $PAGE_TYPE == "course" ? "communityadvanced" : "communitybasic");
                 $BREADCRUMB[] = array("url" => "", "title" => "Edit Page");
                 if (!isset($PAGE_TYPE) || $page_details["page_type"] == "course") {
                     $PAGE_TYPE = $page_details["page_type"];
                     $results = $db->GetAll("SELECT `course_id` FROM `community_courses` WHERE `community_id` = " . $db->qstr($COMMUNITY_ID));
                     $course_ids = array();
                     $course_ids_string = "";
                     foreach ($results as $course_id) {
                         $course_ids[] = $course_id["course_id"];
                         if ($course_ids_string) {
                             $course_ids_string .= "," . $course_id["course_id"];
                         } else {
                             $course_ids_string .= $course_id["course_id"];
                         }
                     }
                     $query = "\tSELECT `organisation_id` FROM `courses` WHERE `course_id` = " . $db->qstr($results[0]["course_id"]);
/**
 * Function will load Rich Text Editor into the page <head></head>
 * causing all textareas on the page to be replaced with rte's.
 *
 * @param array $buttons
 * @return true
 */
function communities_load_rte($buttons = array(), $plugins = array(), $other_options = array())
{
    if (!is_array($buttons) || !count($buttons)) {
        $buttons = "community";
    }
    return load_rte($buttons, $plugins, $other_options);
}
                            $wrote_html = $mspr->saveMSPRFile("html", $edit_html, $ts);
                            $wrote_pdf = $mspr->saveMSPRFile("pdf", $pdf, $ts);
                            if ($wrote_html && $wrote_pdf) {
                                $mspr->setGeneratedTimestamp($ts);
                                success_redirect($success_url, $success_title, "Successfully edited HTML and generated PDF.");
                            }
                        } else {
                            error_redirect(ENTRADA_URL . "/admin/users/manage/students?section=mspr-edit&id=" . $PROXY_ID . "&from=" . $from . $rev_append, "Edit MSPR", "No content provided. Cannot create empty MSPR.");
                        }
                    } else {
                        if ($REVISION) {
                            $html_file = $mspr->getMSPRFile("html", $REVISION);
                        } else {
                            $html_file = $mspr->getMSPRFile("html");
                        }
                        load_rte("mspr");
                        ?>
						<h1>Edit MSPR: <?php 
                        echo $user->getFullName();
                        ?>
</h1>
						<form method="post">
						<input type="hidden" name="action" value="save" />
						<textarea id="edit-html" name="edit-html" style="width: 100%; height: 300px;" cols="65" rows="20"><?php 
                        echo html_encode(trim($html_file));
                        ?>
</textarea>
						<input class="btn btn-primary" type="submit" value="Save Changes" />
						</form>
						<?php 
                    }
            $start_year = date("Y") - ($timestamp < strtotime(ACADEMIC_YEAR_START_DATE) ? 1 : 0);
            $PROCESSED["report_date"] = $timestamp;
            $PROCESSED["report_start"] = strtotime("September 1st " . $start_year . " 00:00:00");
            $PROCESSED["report_finish"] = strtotime("August 31st " . ($start_year + 1) . " 23:59:59");
            $PROCESSED["report_title"] = $org->getAAMCInstitutionName() . " Curriculum " . date("Y", $PROCESSED["report_start"]) . "-" . date("Y", $PROCESSED["report_finish"]);
            break;
    }
    // Display Content
    switch ($STEP) {
        case 2:
            display_status_messages();
            break;
        case 1:
        default:
            display_status_messages();
            load_rte("basic");
            ?>
			<form action="<?php 
            echo ENTRADA_RELATIVE;
            ?>
/admin/reports/aamc?section=add&amp;step=2" method="post" id="addAAMCCiReport">
				<table style="width: 100%" cellspacing="0" cellpadding="2" border="0" summary="Creating AAMC Curriclum Inventory Report">
					<colgroup>
						<col style="width: 3%" />
						<col style="width: 20%" />
						<col style="width: 77%" />
					</colgroup>
					<tfoot>
						<tr>
							<td colspan="3" style="padding-top: 25px">
								<table style="width: 100%" cellspacing="0" cellpadding="0" border="0">