function display_machine_type_info($user, $machine_type_id, $graph_div_prefix = "machine_type_info")
{
    try {
        $machineType = new MachineType($user->dbConn, $machine_type_id);
    } catch (Exception $e) {
        echo "This machine_type does not exist. Please select another machine_type and try again.";
        return;
    }
    $userFacility = new Facility($user->dbConn, $user->facility['id']);
    foreach ($userFacility->machines as $machine) {
        $machine = new Machine($userFacility->dbConn, $machine['id']);
        if ($machine->machineType['id'] == $machine_type_id) {
            echo "<h2>" . escape_output($machine->name) . "</h2>\n";
            display_machine_info($user, $machine->id, $graph_div_prefix . "_" . $machine->id);
        }
    }
}
            display_error("Error: Insufficient privileges", "You may only modify your own facility's machines.");
            break;
        }
        echo "<h1>Modify a machine</h1>\r\n";
        display_machine_edit_form($user, intval($_REQUEST['id']));
        break;
    case 'show':
        if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
            display_error("Error: Invalid machine ID", "Please check your ID and try again.");
            break;
        }
        //ensure that user has sufficient privileges to view this machine.
        $machineObject = $database->queryFirstRow("SELECT * FROM `machines` WHERE `id` = " . intval($_REQUEST['id']) . " LIMIT 1");
        if (!$machineObject) {
            display_error("Error: Invalid machine ID", "Please check your ID and try again.");
            break;
        } elseif (intval($machineObject['facility_id']) != $user->facility['id']) {
            display_error("Error: Insufficient privileges", "You may only view your own facility's machines.");
            break;
        }
        echo "<h1>" . escape_output($machineObject['name']) . " - History <small>(<a href='machine.php?action=edit&id=" . intval($_REQUEST['id']) . "'>edit</a>)</small></h1>\r\n";
        display_machine_info($user, intval($_REQUEST['id']));
        break;
    default:
    case 'index':
        echo "<h1>Machines</h1>\r\n";
        display_machines($user);
        echo "<a href='machine.php?action=new'>Add a new machine</a><br />\r\n";
        break;
}
display_footer();