function AA_regie_Track($event, $round, $layout, $cat, $disc)
 {
     require './lib/cl_gui_menulist.lib.php';
     require './lib/cl_gui_resulttable.lib.php';
     require './config.inc.php';
     require './lib/common.lib.php';
     require './lib/results.lib.php';
     $relay = AA_checkRelay($event);
     // check, if this is a relay event
     $status = AA_getRoundStatus($round);
     $combined = AA_checkCombined(0, $round);
     $eval = AA_results_getEvaluationType($round);
     if ($eval == $cfgEvalType[$strEvalTypeAll] || $eval == $cfgEvalType[$strEvalTypeHeat] && isset($eventType['club'])) {
         // eval all heats together
         $heatorder = "";
     } else {
         // default: rank results per heat
         $heatorder = "serie.xSerie, ";
     }
     // show qualification info if another round follows
     $nextRound = AA_getNextRound($event, $round);
     if ($nextRound > 0) {
         $result = mysql_query("\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tQualifikationSieger\r\n\t\t\t\t\t, QualifikationLeistung\r\n\t\t\t\tFROM\r\n\t\t\t\t\trunde\r\n\t\t\t\tWHERE xRunde = {$round}\r\n\t\t\t");
         if (mysql_errno() > 0) {
             // DB error
             AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
         } else {
             if (($row = mysql_fetch_row($result)) == TRUE) {
             }
             echo "{$strQualification}: {$row['0']} {$strQualifyTop}, {$row['1']} {$strQualifyPerformance}";
             echo "<p/>";
         }
         // ET DB error
         mysql_free_result($result);
     }
     // ET next round
     mysql_query("\r\n                LOCK TABLES\r\n                    resultat READ\r\n                    , serie READ\r\n                    , start READ                    \r\n                    , serienstart READ\r\n                     , runde as r READ  \r\n                    , resultat as r READ\r\n                    , serie as s READ\r\n                    , start as st READ                    \r\n                    , serienstart as ss READ\r\n                    , anmeldung as a READ \r\n                    , athlet as at READ \r\n                    , verein as v READ \r\n                    , anlage as an READ \r\n                    , rundentyp as rt READ   \r\n                    , tempTrack WRITE\r\n            ");
     mysql_query("TRUNCATE TABLE tempTrack");
     // if this is a combined event, rank all rounds togheter
     $roundSQL = "";
     if ($combined) {
         $roundSQL = "WHERE serie.xRunde IN (";
         $res_c = mysql_query("SELECT xRunde FROM runde WHERE xWettkampf = {$event}");
         while ($row_c = mysql_fetch_array($res_c)) {
             $roundSQL .= $row_c[0] . ",";
         }
         $roundSQL = substr($roundSQL, 0, -1) . ")";
     } else {
         $roundSQL = "WHERE serie.xRunde = {$round}";
     }
     if (mysql_errno() > 0) {
         // DB error
         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
     } else {
         $sql = "SELECT DISTINCT \r\n                           resultat.Leistung, \r\n                           serienstart.xSerienstart, \r\n                           serienstart.xSerie, \r\n                           serienstart.xStart, \r\n                           serie.Wind \r\n                     FROM \r\n                           resultat \r\n                           LEFT JOIN serienstart USING(xSerienstart) \r\n                           LEFT JOIN serie USING(xSerie) \r\n                           " . $roundSQL . " \r\n                     ORDER BY " . $heatorder . "\r\n                            resultat.Leistung ASC;";
         $result = mysql_query($sql);
         $heat = 0;
         $perf = 0;
         $perfRounded = 0;
         $i = 0;
         $rank = 0;
         while ($row = mysql_fetch_row($result)) {
             // check on codes < 0
             if ($row[0] < 0) {
                 mysql_query("INSERT INTO tempTrack SET" . " Leistung = " . $row[0] . " , xSerienstart = " . $row[1] . " , xSerie = " . $row[2] . " , rang = 0");
             } else {
                 if (!($eval == $cfgEvalType[$strEvalTypeHeat] && isset($eventType['club']))) {
                     if ($eval != $cfgEvalType[$strEvalTypeAll] && $heat != $row[2]) {
                         $i = 0;
                         // restart ranking   (not SVM with single heat)
                         $perf = 0;
                         $perfRounded = 0;
                     }
                 }
                 $i++;
                 // increment ranking
                 if ($perf < $row[0]) {
                     // compare with previous performance
                     $rank = $i;
                     // next rank (only if not same performance)
                 }
                 mysql_query("INSERT INTO tempTrack SET " . " Leistung = " . $row[0] . " , xSerienstart = " . $row[1] . " , xSerie = " . $row[2] . " , rang = " . $rank);
                 if (mysql_errno() > 0) {
                     AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                 }
                 if (mysql_errno() > 0) {
                     AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                 }
                 $heat = $row[2];
                 // keep current heat ID
                 $perf = $row[0];
                 // keep current performance
             }
             mysql_free_result($temp);
         }
         // display all athletes
         if ($relay == FALSE) {
             // single event
             $query = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tr.Bahnen\r\n\t\t\t\t\t, rt.Name\r\n\t\t\t\t\t, rt.Typ\r\n\t\t\t\t\t, s.xSerie\r\n\t\t\t\t\t, s.Bezeichnung\r\n\t\t\t\t\t, s.Wind\r\n\t\t\t\t\t, s.Film\r\n\t\t\t\t\t, s.Status\r\n\t\t\t\t\t, ss.xSerienstart\r\n\t\t\t\t\t, ss.Position\r\n\t\t\t\t\t, ss.Rang\r\n\t\t\t\t\t, ss.Qualifikation\r\n\t\t\t\t\t, a.Startnummer\r\n\t\t\t\t\t, at.Name\r\n\t\t\t\t\t, at.Vorname\r\n\t\t\t\t\t, at.Jahrgang\r\n\t\t\t\t\t, v.Name\r\n\t\t\t\t\t, LPAD(s.Bezeichnung,5,'0') as heatid\r\n\t\t\t\t\t, at.Land\r\n\t\t\t\t\t, st.Bestleistung\r\n\t\t\t\t\t, at.xAthlet\r\n                    , t.rang  \r\n                    , if (ss.Rang = 0, 999999, ss.Rang) as orderRang    \r\n\t\t\t\tFROM\r\n\t\t\t\t\trunde AS r\r\n\t\t\t\t\tLEFT JOIN serie AS s ON (s.xRunde = r.xRunde)\r\n\t\t\t\t\tLEFT JOIN serienstart AS ss ON (ss.xSerie = s.xSerie)\r\n\t\t\t\t\tLEFT JOIN start AS st ON (st.xStart = ss.xStart)\r\n\t\t\t\t\tLEFT JOIN anmeldung AS a ON (a.xAnmeldung = st.xAnmeldung)\r\n\t\t\t\t\tLEFT JOIN athlet AS at ON (at.xAthlet = a.xAthlet)\r\n\t\t\t\t\tLEFT JOIN verein AS v  ON (v.xVerein = at.xVerein)\r\n                    LEFT JOIN tempTrack AS t ON (t.xSerienstart = ss.xSerienstart)  \r\n\t\t\t\t    LEFT JOIN rundentyp AS rt ON rt.xRundentyp = r.xRundentyp\r\n\t\t\t\t    LEFT JOIN anlage AS an ON an.xAnlage = s.xAnlage\r\n\t\t\t\tWHERE \r\n                    r.xRunde = {$round}    \t\t\t\t\r\n\t\t\t\tORDER BY\r\n\t\t\t\t\theatid\r\n\t\t\t\t\t, orderRang\r\n\t\t\t";
         } else {
             // relay event
             $query = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tr.Bahnen\r\n\t\t\t\t\t, rt.Name\r\n\t\t\t\t\t, rt.Typ\r\n\t\t\t\t\t, s.xSerie\r\n\t\t\t\t\t, s.Bezeichnung\r\n\t\t\t\t\t, s.Wind\r\n\t\t\t\t\t, s.Film\r\n\t\t\t\t\t, s.Status\r\n\t\t\t\t\t, ss.xSerienstart\r\n\t\t\t\t\t, ss.Position\r\n\t\t\t\t\t, ss.Rang\r\n\t\t\t\t\t, ss.Qualifikation\r\n\t\t\t\t\t, sf.Name\r\n\t\t\t\t\t, v.Name\r\n\t\t\t\t\t, LPAD(s.Bezeichnung,5,'0') as heatid\r\n\t\t\t\t\t, r.xRunde\r\n\t\t\t\t\t, st.xStart\r\n                    , t.rang \r\n                    , if (ss.Rang = 0, 999999, ss.Rang) as orderRang    \r\n\t\t\t\tFROM\r\n\t\t\t\t\trunde AS r\r\n\t\t\t\t\tLEFT JOIN serie AS s ON (s.xRunde = r.xRunde)\r\n\t\t\t\t\tLEFT JOIN serienstart AS ss  ON (ss.xSerie = s.xSerie )\r\n\t\t\t\t\tLEFT JOIN start AS st ON (st.xStart = ss.xStart) \r\n\t\t\t\t\tLEFT JOIN staffel AS sf ON (sf.xStaffel = st.xStaffel) \r\n\t\t\t\t\tLEFT JOIN verein AS v ON (v.xVerein = sf.xVerein) \r\n                    LEFT JOIN tempTrack AS t ON (t.xSerienstart = ss.xSerienstart)   \r\n\t\t\t\t    LEFT JOIN rundentyp AS rt ON rt.xRundentyp = r.xRundentyp\r\n\t\t\t\t    LEFT JOIN anlage AS an ON an.xAnlage = s.xAnlage\r\n\t\t\t\tWHERE \r\n                    r.xRunde = {$round}  \t\t\t\t\r\n\t\t\t\tORDER BY\r\n\t\t\t\t\theatid\r\n\t\t\t\t\t, orderRang\r\n\t\t\t";
         }
         $result = mysql_query($query);
         if (mysql_errno() > 0) {
             // DB error
             AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
         } else {
             // initialize variables
             $h = 0;
             // heat counter
             $p = 0;
             // position counter (to evaluate empty heats
             $tracks = 0;
             $resTable = new GUI_TrackResultTable($round, $layout, $status, $nextRound);
             $resTable->printHeatTitleRegie($cat, $disc);
             while ($row = mysql_fetch_row($result)) {
                 $p++;
                 // increment position counter
                 /*
                  *  Heat headerline
                  */
                 if ($h != $row[3]) {
                     $tracks = $row[0];
                     // keep nbr of planned tracks
                     // fill previous heat with empty tracks
                     if ($p > 1) {
                         $resTable->printEmptyTracks($p, $tracks, 5 + $c);
                     }
                     $h = $row[3];
                     // keep heat ID
                     $p = 1;
                     // start with track one
                     if (is_null($row[1])) {
                         // only one round
                         $title = "{$strFinalround} {$row['4']}";
                     } else {
                         // more than one round
                         $title = "{$row['1']}: {$row['2']}{$row['4']}";
                     }
                     // increment colspan to include ranking and qualification
                     $c = 0;
                     if ($status == $cfgRoundStatus['results_done']) {
                         $c++;
                         if ($nextRound > 0) {
                             $c++;
                         }
                     }
                     $resTable->printHeatTitle($row[3], $row[4], $title, $row[7], $row[6], $row[5], 'regie', $relay);
                     if ($relay == FALSE) {
                         // athlete display
                         $resTable->printAthleteHeader('regie');
                     } else {
                         // relay display
                         $resTable->printRelayHeader('regie');
                     }
                 }
                 // ET new heat
                 /*
                  * Empty tracks
                  */
                 if ($layout == $cfgDisciplineType[$strDiscTypeTrack] || $layout == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $layout == $cfgDisciplineType[$strDiscTypeRelay]) {
                     // current track and athlete's position not identical
                     if ($p < $row[9]) {
                         $p = $resTable->printEmptyTracks($p, $row[9] - 1, 6 + $c);
                     }
                 }
                 // ET empty tracks
                 /*
                  * Athlete/Relay data lines
                  */
                 // get performance
                 $perf = '';
                 $perfRounded = '';
                 $res = mysql_query("\r\n\t\t\t\t\tSELECT\r\n\t\t\t\t\t\trs.xResultat\r\n\t\t\t\t\t\t, rs.Leistung\r\n\t\t\t\t\t\t, rs.Info\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\tresultat AS rs\r\n\t\t\t\t\tWHERE rs.xSerienstart = {$row['8']}\r\n\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\trs.Leistung ASC\r\n\t\t\t\t");
                 if (mysql_errno() > 0) {
                     // DB error
                     AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                 } else {
                     $resrow = mysql_fetch_row($res);
                     if ($resrow != NULL) {
                         // result found
                         $perf = AA_formatResultTime($resrow[1]);
                         $perfRounded = AA_formatResultTime($resrow[1], true);
                     }
                     mysql_free_result($res);
                 }
                 // ET DB error
                 // print lines
                 if ($relay == FALSE) {
                     $resTable->printAthleteLine($row[9], $row[12], "{$row['13']} {$row['14']}", '', '', AA_formatResultTime($row[19], true), $perfRounded, $row[10], $row[11], '', $row[20], 'regie', $row[21]);
                 } else {
                     // relay
                     // get Athletes
                     $arrAthletes = array();
                     $sql = "SELECT at.Vorname, at.Name FROM\r\n\t\t\t\t\t\t\t\tstaffelathlet as sfat\r\n\t\t\t\t\t\t\t\tLEFT JOIN start as st ON sfat.xAthletenstart = st.xStart\r\n\t\t\t\t\t\t\t\tLEFT JOIN anmeldung as a USING(xAnmeldung)\r\n\t\t\t\t\t\t\t\tLEFT JOIN athlet as at USING(xAthlet)\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tsfat.xStaffelstart = {$row['16']}\r\n\t\t\t\t\t\t\tAND\tsfat.xRunde = {$row['15']}\r\n\t\t\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\t\t\tsfat.Position";
                     $res_at = mysql_query($sql);
                     if (mysql_errno() > 0) {
                         // DB error
                         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                     } else {
                         while ($row_at = mysql_fetch_array($res_at)) {
                             $arrAthletes[] = array($row_at[1], $row_at[0]);
                         }
                     }
                     $arrAthletes = count($arrAthletes) > 0 ? $arrAthletes : 0;
                     $resTable->printRelayLine($row[9], $row[12], $row[13], $perfRounded, $row[10], $row[11], $arrAthletes, 'regie', $row[17]);
                 }
             }
             // Fill last heat with empty tracks for disciplines run in
             // individual tracks
             if ($layout == $cfgDisciplineType[$strDiscTypeTrack] || $layout == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $layout == $cfgDisciplineType[$strDiscTypeRelay]) {
                 if ($p > 0) {
                     // heats set up
                     $p++;
                     $resTable->printEmptyTracks($p, $tracks, 6 + $c);
                 }
             }
             // ET track disciplines
             $resTable->endTable();
             mysql_free_result($result);
         }
         // ET DB error
     }
     mysql_query("UNLOCK TABLES");
 }
 function AA_speaker_Track($event, $round, $layout)
 {
     require './lib/cl_gui_menulist.lib.php';
     require './lib/cl_gui_resulttable.lib.php';
     require './lib/cl_performance.lib.php';
     require './config.inc.php';
     require './lib/common.lib.php';
     $mergedMain = AA_checkMainRound($round);
     if ($mergedMain != 1) {
         $relay = AA_checkRelay($event);
         // check, if this is a relay event
         $status = AA_getRoundStatus($round);
         $svm = AA_checkSVM(0, $round);
         // decide whether to show club or team name
         // No action yet
         if ($status == $cfgRoundStatus['open'] || $status == $cfgRoundStatus['enrolement_done'] || $status == $cfgRoundStatus['heats_in_progress']) {
             AA_printWarningMsg($strHeatsNotDone);
         } else {
             if ($status == $cfgRoundStatus['enrolement_pending']) {
                 AA_printWarningMsg($strEnrolementNotDone);
             } else {
                 if ($status >= $cfgRoundStatus['heats_done']) {
                     // show link to rankinglist if results done
                     if ($status == $cfgRoundStatus['results_done']) {
                         $menu = new GUI_Menulist();
                         $menu->addButton("print_rankinglist.php?event={$event}&round={$round}&type=single&formaction=speaker&show_efforts=none", $GLOBALS['strRankingList']);
                         $menu->addButton("print_rankinglist.php?event={$event}&round={$round}&type=single&formaction=speaker&show_efforts=sb_pb", $GLOBALS['strRankingListEfforts']);
                         $menu->printMenu();
                         echo "<p/>";
                     }
                     // show qualification info if another round follows
                     $nextRound = AA_getNextRound($event, $round);
                     if ($nextRound > 0) {
                         $result = mysql_query("\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tQualifikationSieger\r\n\t\t\t\t\t, QualifikationLeistung\r\n\t\t\t\tFROM\r\n\t\t\t\t\trunde\r\n\t\t\t\tWHERE xRunde = {$round}\r\n\t\t\t");
                         if (mysql_errno() > 0) {
                             // DB error
                             AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                         } else {
                             if (($row = mysql_fetch_row($result)) == TRUE) {
                             }
                             echo "{$strQualification}: {$row['0']} {$strQualifyTop}, {$row['1']} {$strQualifyPerformance}";
                             echo "<p/>";
                         }
                         // ET DB error
                         mysql_free_result($result);
                     }
                     // ET next round
                     // display all athletes
                     if ($relay == FALSE) {
                         // single event
                         $query = "\r\n                SELECT\r\n                    r.Bahnen\r\n                    , rt.Name\r\n                    , rt.Typ\r\n                    , s.xSerie\r\n                    , s.Bezeichnung\r\n                    , s.Wind\r\n                    , s.Film\r\n                    , s.Status\r\n                    , ss.xSerienstart\r\n                    , ss.Position\r\n                    , ss.Rang\r\n                    , ss.Qualifikation\r\n                    , a.Startnummer\r\n                    , at.Name\r\n                    , at.Vorname\r\n                    , at.Jahrgang\r\n                    , if('" . $svm . "', te.Name, IF(a.Vereinsinfo = '', v.Name, a.Vereinsinfo))  \r\n                    , LPAD(s.Bezeichnung,5,'0') as heatid\r\n                    , at.Land\r\n                    , st.Bestleistung\r\n                    , at.xAthlet\r\n                FROM\r\n                    runde AS r\r\n                    LEFT JOIN serie AS s ON (s.xRunde = r.xRunde)\r\n                    LEFT JOIN serienstart AS ss ON (ss.xSerie = s.xSerie   )\r\n                    LEFT JOIN start AS st ON (st.xStart = ss.xStart)\r\n                    LEFT JOIN anmeldung AS a ON (a.xAnmeldung = st.xAnmeldung)\r\n                    LEFT JOIN athlet AS at ON (at.xAthlet = a.xAthlet)\r\n                    LEFT JOIN verein AS v ON (v.xVerein = at.xVerein)\r\n                     LEFT JOIN team AS te ON(a.xTeam = te.xTeam)\r\n                    LEFT JOIN rundentyp_" . $_COOKIE['language'] . " AS rt ON rt.xRundentyp = r.xRundentyp\r\n                    LEFT JOIN anlage AS an ON an.xAnlage = s.xAnlage\r\n                WHERE \r\n                    r.xRunde = {$round} \r\n                ORDER BY\r\n                    heatid\r\n                    , ss.Position\r\n            ";
                     } else {
                         // relay event
                         $query = "\r\n                SELECT\r\n                    r.Bahnen\r\n                    , rt.Name\r\n                    , rt.Typ\r\n                    , s.xSerie\r\n                    , s.Bezeichnung\r\n                    , s.Wind\r\n                    , s.Film\r\n                    , s.Status\r\n                    , ss.xSerienstart\r\n                    , ss.Position\r\n                    , ss.Rang\r\n                    , ss.Qualifikation\r\n                    , sf.Name\r\n                    , if('" . $svm . "', te.Name, v.Name)  \r\n                    , LPAD(s.Bezeichnung,5,'0') as heatid\r\n                    , r.xRunde\r\n                    , st.xStart\r\n                FROM\r\n                    runde AS r\r\n                    LEFT JOIN serie AS s ON (s.xRunde = r.xRunde)\r\n                    LEFT JOIN serienstart AS ss ON (ss.xSerie = s.xSerie)\r\n                    LEFT JOIN start AS st ON (st.xStart = ss.xStart )\r\n                    LEFT JOIN staffel AS sf ON (sf.xStaffel = st.xStaffel  )\r\n                    LEFT JOIN verein AS v ON (v.xVerein = sf.xVerein)\r\n                    LEFT JOIN team AS te ON(sf.xTeam = te.xTeam)\r\n                    LEFT JOIN rundentyp_" . $_COOKIE['language'] . " AS rt ON rt.xRundentyp = r.xRundentyp\r\n                    LEFT JOIN anlage AS an ON an.xAnlage = s.xAnlage\r\n                WHERE \r\n                    r.xRunde = {$round}  \r\n                ORDER BY\r\n                    heatid\r\n                    , ss.Position";
                     }
                     $result = mysql_query($query);
                     if (mysql_errno() > 0) {
                         // DB error
                         AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                     } else {
                         // initialize variables
                         $h = 0;
                         // heat counter
                         $p = 0;
                         // position counter (to evaluate empty heats
                         $tracks = 0;
                         $resTable = new GUI_TrackResultTable($round, $layout, $status, $nextRound);
                         while ($row = mysql_fetch_row($result)) {
                             $p++;
                             // increment position counter
                             /*
                              *  Heat headerline
                              */
                             if ($h != $row[3]) {
                                 $tracks = $row[0];
                                 // keep nbr of planned tracks
                                 // fill previous heat with empty tracks
                                 if ($p > 1) {
                                     $resTable->printEmptyTracks($p, $tracks, 5 + $c);
                                 }
                                 $h = $row[3];
                                 // keep heat ID
                                 $p = 1;
                                 // start with track one
                                 if (is_null($row[1])) {
                                     // only one round
                                     $title = "{$strFinalround} {$row['4']}";
                                 } else {
                                     // more than one round
                                     $title = "{$row['1']}: {$row['2']}{$row['4']}";
                                 }
                                 // increment colspan to include ranking and qualification
                                 $c = 0;
                                 if ($status == $cfgRoundStatus['results_done']) {
                                     $c++;
                                     if ($nextRound > 0) {
                                         $c++;
                                     }
                                 }
                                 $resTable->printHeatTitle($row[3], $row[4], $title, $row[7], $row[6], $row[5]);
                                 if ($relay == FALSE) {
                                     // athlete display
                                     $resTable->printAthleteHeader('', $round);
                                 } else {
                                     // relay display
                                     $resTable->printRelayHeader('', $round);
                                 }
                             }
                             // ET new heat
                             /*
                              * Empty tracks
                              */
                             if ($layout == $cfgDisciplineType[$strDiscTypeTrack] || $layout == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $layout == $cfgDisciplineType[$strDiscTypeRelay]) {
                                 // current track and athlete's position not identical
                                 if ($p < $row[9]) {
                                     $p = $resTable->printEmptyTracks($p, $row[9] - 1, 6 + $c);
                                 }
                             }
                             // ET empty tracks
                             /*
                              * Athlete/Relay data lines
                              */
                             // get performance
                             $perf = '';
                             $perfRounded = '';
                             $res = mysql_query("\r\n\t\t\t\t\tSELECT\r\n\t\t\t\t\t\trs.xResultat\r\n\t\t\t\t\t\t, rs.Leistung\r\n\t\t\t\t\t\t, rs.Info\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t\tresultat AS rs\r\n\t\t\t\t\tWHERE rs.xSerienstart = {$row['8']}\r\n\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\trs.Leistung ASC\r\n\t\t\t\t");
                             if (mysql_errno() > 0) {
                                 // DB error
                                 AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                             } else {
                                 $resrow = mysql_fetch_row($res);
                                 if ($resrow != NULL) {
                                     // result found
                                     $perf = AA_formatResultTime($resrow[1]);
                                     $perfRounded = AA_formatResultTime($resrow[1], true);
                                 }
                                 mysql_free_result($res);
                             }
                             // ET DB error
                             // print lines
                             if ($relay == FALSE) {
                                 $resTable->printAthleteLine($row[9], $row[12], "{$row['13']} {$row['14']}", AA_formatYearOfBirth($row[15]), $row[16], AA_formatResultTime($row[19], true), $perfRounded, $row[10], $row[11], $row[18], $row[20]);
                             } else {
                                 // relay
                                 // get Athletes
                                 $arrAthletes = array();
                                 $sql = "SELECT at.Vorname, at.Name, at.Jahrgang, a.Startnummer FROM\r\n\t\t\t\t\t\t\t\tstaffelathlet as sfat\r\n\t\t\t\t\t\t\t\tLEFT JOIN start as st ON sfat.xAthletenstart = st.xStart\r\n\t\t\t\t\t\t\t\tLEFT JOIN anmeldung as a USING(xAnmeldung)\r\n\t\t\t\t\t\t\t\tLEFT JOIN athlet as at USING(xAthlet)\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tsfat.xStaffelstart = {$row['16']}\r\n\t\t\t\t\t\t\tAND\tsfat.xRunde = {$row['15']}\r\n\t\t\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\t\t\tsfat.Position";
                                 $res_at = mysql_query($sql);
                                 if (mysql_errno() > 0) {
                                     // DB error
                                     AA_printErrorMsg(mysql_errno() . ": " . mysql_error());
                                 } else {
                                     while ($row_at = mysql_fetch_array($res_at)) {
                                         $arrAthletes[] = array($row_at[1], $row_at[0], AA_formatYearOfBirth($row_at[2]), $row_at[3]);
                                     }
                                 }
                                 $arrAthletes = count($arrAthletes) > 0 ? $arrAthletes : 0;
                                 $resTable->printRelayLine($row[9], $row[12], $row[13], $perfRounded, $row[10], $row[11], $arrAthletes);
                             }
                         }
                         // Fill last heat with empty tracks for disciplines run in
                         // individual tracks
                         if ($layout == $cfgDisciplineType[$strDiscTypeTrack] || $layout == $cfgDisciplineType[$strDiscTypeTrackNoWind] || $layout == $cfgDisciplineType[$strDiscTypeRelay]) {
                             if ($p > 0) {
                                 // heats set up
                                 $p++;
                                 $resTable->printEmptyTracks($p, $tracks, 6 + $c);
                             }
                         }
                         // ET track disciplines
                         $resTable->endTable();
                         mysql_free_result($result);
                     }
                     // ET DB error
                 }
             }
         }
         // ET heat seeding done
     } else {
         AA_printErrorMsg($strErrMergedRoundSpeaker);
     }
 }