?>
</span>
										<td style="vertical-align: middle;"><span style="font-size: 30px; margin-top: 10px;"><?php 
    echo getCountry(mysql_result($querymodal, 0, 'destination'), "alt") . " " . mysql_result($querymodal, 0, 'destination');
    ?>
</span><br/><span style="font-size: 10px;"><?php 
    echo mysql_result($querydest, 0, 'Name');
    ?>
</span>
									</tr>
									<tr style="border-bottom: 1px solid #444">
										<td><b>Aircraft</b> <a href="http://www.airliners.net/search/photo.search?q=<?php 
    echo str_ireplace(" ", "+", aircraftname(mysql_result($querymodal, 0, 'acft')));
    ?>
+<?php 
    echo str_ireplace(" ", "+", airlinename(mysql_result($querymodal, 0, 'flightnumber'), "name"));
    ?>
" target="_blank" style="color: #333;" onMouseOver="this.style.color='#F00'" onMouseOut="this.style.color='#333'"><i class="icon-camera" title="Click here to see pictures of this aircraft"></i></a></td>
										<td><b>Departure Time</b></td>
										<td><b>Arrival Time</b></td>
									</tr>
									<tr height="60px">
										<td style="vertical-align: middle;"><span style="font-size: 30px;"><?php 
    echo aircraftname(mysql_result($querymodal, 0, 'acft'));
    ?>
</span><br/><span style="font-size: 10px;"><?php 
    echo aircraftname(mysql_result($querymodal, 0, 'acft'), "name");
    ?>
</span></td>
										<td style="vertical-align: middle;"><span style="font-size: 30px; margin-top: 10px;"><?php 
    if (mysql_result($querymodal, 0, 'deptime') != "----") {
        $querydest = mysqlexec($sqlconn, $querydest);
        change_db($sqlconn, $rfedatabase);
        if (file_exists("logos/" . substr(mysql_result($query, $i, 'flightnumber'), 0, 3) . ".gif")) {
            $logo = '<img src="logos/' . substr(mysql_result($query, $i, 'flightnumber'), 0, 3) . '.gif"/> | ';
        } else {
            $logo = '';
        }
        ?>
						<div class="accordion-group">
							<div class="accordion-heading">
								<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapse<?php 
        echo $i;
        ?>
">
									<?php 
        echo $logo . mysql_result($query, $i, "flightnumber") . " (" . airlinename(mysql_result($query, $i, 'flightnumber')) . ") | " . mysql_result($query, $i, 'origin') . "-" . mysql_result($query, $i, 'destination');
        ?>
								</a>
							</div>
							
							<div id="collapse<?php 
        echo $i;
        ?>
" class="accordion-body collapse">
								<div class="accordion-inner">
									
									<div class="accordion" id="accordflt<?php 
        echo $i;
        ?>
">
										<div class="accordion-group">
						<h2>RFE ' . mysql_result($queryconfig, 0, 'aptname') . '</h2>
						<h3>Booking System</h3>
					</td>
				</tr>
				<tr>
					<td colspan=2>
						<p>Dear <strong>' . substr(mysql_result($querymodal, 0, "name"), 0, strpos(mysql_result($querymodal, 0, "name"), " ")) . '</strong>,</p><p>we\'re sending this e-mail to you in order to <strong>confirm</strong> the <strong>intention</strong> of reservation of the detailed flight below:</p>

						<table class="flight" width="100%" border=0 cellpadding=0 cellspacing=0>
							<tr>
								<td style="border-bottom: 1px solid #444"><b>Flight</b></td>
								<td style="border-bottom: 1px solid #444"><b>Departure</b></td>
								<td style="border-bottom: 1px solid #444"><b>Arrival</b></td>
							</tr>
							<tr height="60px">
								<td style="vertical-align: middle;"><span style="font-size: 30px;">' . mysql_result($querymodal, 0, 'flightnumber') . '</span><br/><span style="font-size: 10px;">' . airlinename(mysql_result($querymodal, 0, 'flightnumber')) . '</span></td>
								<td style="vertical-align: middle;"><span style="font-size: 30px;"><img style="vertical-align: middle;" src="' . getCountry(mysql_result($querymodal, 0, 'origin'), 'norm', '48', 'full') . '"> ' . mysql_result($querymodal, 0, 'origin') . '</span><br/><span style="font-size: 10px;">' . mysql_result($queryorig, 0, 'Name') . '</span>
								<td style="vertical-align: middle;"><span style="font-size: 30px;"><img style="vertical-align: middle;" src="' . getCountry(mysql_result($querymodal, 0, 'destination'), 'norm', '48', 'full') . '"> ' . mysql_result($querymodal, 0, 'destination') . '</span><br/><span style="font-size: 10px;">' . mysql_result($querydest, 0, 'Name') . '</span>
							</tr>
							<tr style="border-bottom: 1px solid #444">
								<td style="border-bottom: 1px solid #444"><b>Aircraft</b></td>
								<td style="border-bottom: 1px solid #444"><b>Departure Time</b></td>
								<td style="border-bottom: 1px solid #444"><b>Arrival Time</b></td>
							</tr>
							<tr height="60px">
								<td style="vertical-align: middle;"><span style="font-size: 30px;">' . aircraftname(mysql_result($querymodal, 0, 'acft')) . '</span><br/><span style="font-size: 10px;">' . aircraftname(mysql_result($querymodal, 0, 'acft'), "name") . '</span></td>
								<td style="vertical-align: middle;"><span style="font-size: 30px;">';
    if (mysql_result($querymodal, 0, 'deptime') != "----") {
        $msg .= mysql_result($querymodal, 0, 'deptime');
    } else {
        $msg .= '<span style="color: red;">' . timeOperation(mysql_result($querymodal, 0, 'arrtime'), flighttime(mysql_result($querymodal, 0, 'origin'), mysql_result($querymodal, 0, 'destination'), mysql_result($querymodal, 0, 'acft')), "diff") . '</span>';
                $remTime = "Taxi In";
            } else {
                $remTime = "On Blocks";
            }
        } else {
            $timeRem = $distRem / $onlineData[8];
            $remHours = floor($timeRem);
            $remMinutes = $timeRem - $remHours;
            $remMinutes = round($remMinutes * 60);
            $remTime = sprintf("%02.0f", $remHours) . "h" . sprintf("%02.0f", $remMinutes) . ' to go';
        }
    }
    $modal .= '
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
		<h3>' . $onlineData[0] . ' <small>' . airlinename($onlineData[0]) . '</small></h3>
	</div>
	<div id="modalFlightsbody" class="modal-body">
		<table width="100%" border=0 cellpadding=0>
			<tr>
				<td>Flown by <b>' . mysql_result($querymodal, 0, 'name') . '</b> (' . mysql_result($querymodal, 0, 'vid') . ').</td>
				<td>' . $simVersion . '</td>
			</tr>
		</table><br/>
				<table width="100%" border=0 cellpadding=0>
					<tr style="border-bottom: 1px solid #444">
						<td><b>Flight</b></td>
						<td><b>Departure</b></td>
						<td><b>Arrival</b></td>
					</tr>
					<tr height="40px">
imagecopymerge($image, $flag, -100, -210, 0, 0, $insert_x, $insert_y, 12);
// Write the text
$name = explode(" ", mysql_result($query, 0, "name"));
$lastname = array_pop($name);
$displayname = $lastname . " / ";
foreach ($name as $eachname) {
    $displayname .= $eachname . " ";
}
imagettftext($image, 7, 0, 18, 23, $font_color, $font_file_3, "FLIGHT");
imagettftext($image, 13, 0, 17, 40, $black, $font_file_1, strtoupper(trim(airlinename(mysql_result($query, 0, 'flightnumber')))));
imagettftext($image, 7, 0, 236, 23, $font_color, $font_file_3, "LEG");
imagettftext($image, 13, 0, 235, 40, $black, $font_file_1, strtoupper(trim(mysql_result($query, 0, 'origin') . " TO " . mysql_result($query, 0, 'destination'))));
imagettftext($image, 7, 0, 375, 23, $font_color, $font_file_3, "CAPTAIN");
imagettftext($image, 13, 0, 374, 40, $black, $font_file_1, strtoupper(trim($displayname)));
imagettftext($image, 7, 0, 578, 23, $font_color, $font_file_3, "FLIGHT");
imagettftext($image, 13, 0, 577, 40, $black, $font_file_1, strtoupper(trim(airlinename(mysql_result($query, 0, 'flightnumber')))));
imagettftext($image, 9, 0, 19, 93, $font_color, $font_file_3, "CAPTAIN");
imagettftext($image, 20, 0, 17, 125, $black, $font_file_1, strtoupper(trim($displayname)));
imagettftext($image, 9, 0, 19, 158, $font_color, $font_file_3, "GATE");
imagettftext($image, 20, 0, 17, 192, $black, $font_file_1, strtoupper(trim(mysql_result($query, 0, 'gate'))));
imagettftext($image, 9, 0, 139, 158, $font_color, $font_file_3, "SLOT");
imagettftext($image, 20, 0, 137, 192, $black, $font_file_1, strtoupper(trim(mysql_result($query, 0, 'reftime'))));
imagettftext($image, 13, 0, 217, 192, $black, $font_file_1, strtoupper(trim("UTC  " . $eventdate)));
imagettftext($image, 9, 0, 448, 158, $font_color, $font_file_3, "ACFT");
imagettftext($image, 20, 0, 446, 192, $black, $font_file_1, strtoupper(trim(aircraftname(mysql_result($query, 0, 'acft')))));
imagettftext($image, 9, 0, 578, 93, $font_color, $font_file_3, "CAPTAIN");
imagettftext($image, 11, 0, 576, 120, $black, $font_file_1, strtoupper(trim($displayname)));
imagettftext($image, 9, 0, 578, 158, $font_color, $font_file_3, "GATE");
imagettftext($image, 20, 0, 576, 192, $black, $font_file_1, strtoupper(trim(mysql_result($query, 0, 'gate'))));
imagettftext($image, 9, 0, 676, 158, $font_color, $font_file_3, "SLOT");
imagettftext($image, 20, 0, 676, 192, $black, $font_file_1, str_replace(":", "", strtoupper(trim(mysql_result($query, 0, 'reftime') . "Z"))));