</fieldset>

							<div style="clear: both;">&nbsp;</div>

							<?php 
while ($c = $coords->fetch(PDO::FETCH_OBJ)) {
    $CurrentLat = $c->Latitude;
    $CurrentLng = $c->Longitude;
    $CurrentTimeStamp = $c->TimeStamp;
    if ($PrevTimeStamp == "") {
        $PrevLat = $c->Latitude;
        $PrevLng = $c->Longitude;
        $PrevTimeStamp = $c->TimeStamp;
    }
    $TimeDiff = strtotime($CurrentTimeStamp) - strtotime($PrevTimeStamp);
    $PosDiff = GPSMaps::VGCD($CurrentLat, $CurrentLng, $PrevLat, $PrevLng);
    if ($TimeDiff == 0 || $PosDiff == 0) {
        // Do Nothing
    } else {
        $MilesPerHour = round($PosDiff / $TimeDiff * 2.2369362920544, 2);
        if ($MilesPerHour > 10 && $MilesPerHour < 100) {
            $Speed[] = $MilesPerHour;
            if ($MilesPerHour > 75) {
                $SpeedAlert++;
            }
        } else {
            $coordtotal--;
        }
        if ($PrevMPH != '') {
            if (abs($PrevMPH - $MilesPerHour) > 30) {
                $HarshBrakingFastAccel++;
    //								echo "CLOSEST DISTANCES 200m " . ${"Reached_" . $j} . " " . ${"Reached_Job_" . $j} . " @ " . ${"Reached_Timestamp_" . $j} . "<br />";
    //							}
} else {
    for ($k = 0; $k < count($RouteArray); $k++) {
        $RegenLat = substr($RouteArray[$k], 1, 8);
        $RegenLng = substr($RouteArray[$k], 11, 9);
        $RegenTimeStamp = $RouteTimeStampArray[$k];
        for ($l = 0; $l < $jobscount; $l++) {
            if (!${"Reached_" . $l} != '') {
                ${"Reached_" . $l} = 500;
            }
            $jobLat = $jobLng = "";
            $jobLat = $jobs[$l]["Lat"];
            $jobLng = $jobs[$l]["Lng"];
            $houseNum = $jobs[$l]["JobName"];
            $distance = round(GPSMaps::VGCD($RegenLat, $RegenLng, $jobLat, $jobLng, 6371000), 3);
            if ($distance < 500) {
                if (${"Reached_" . $l} > $distance) {
                    ${"Reached_" . $l} = $distance;
                    ${"Reached_Job_" . $l} = $jobs[$l]["JobName"];
                    ${"Reached_Timestamp_" . $l} = $RegenTimeStamp;
                }
            }
            //echo "Regen LAT is $RegenLat AND Regen LNG is $RegenLng <-truck house-> $houseNum | $jobLat AND LNG $jobLng [distance in m $distance] <br />";
            empty($jobLat);
            empty($jobLng);
        }
    }
    //							for($m = 0; $m < $jobscount; $m++ )
    //							{
    //								echo "CLOSEST DISTANCES 200m " . ${"Reached_" . $m} . " " . ${"Reached_Job_" . $m} . " @ " . ${"Reached_Timestamp_" . $m} . "<br />";