Пример #1
0
    function HorKnViewDE($mxl, $match, $matchDE, $k_format, $Itemid, $t_single, $s_id)
    {
        if ($mxl) {
            $reslng = $mxl * 7 + 20;
        } else {
            $reslng = 120;
        }
        if ($reslng < 200) {
            $reslng = 120;
        }
        $models = new JSPRO_Models();
        $cfg = new stdClass();
        $cfg->wdth = $reslng + 70;
        $cfg->height = 60;
        $cfg->step = 70;
        $cfg->top_next = 50;
        $kl = '<br />';
        $zz = 2;
        $p = 0;
        $wdth = $cfg->wdth;
        $height = $cfg->height;
        $step = $cfg->step;
        $top_next = $cfg->top_next;
        $fid = $k_format;
        $kl .= '<div id="js-wrapper-top-' . $match[0]->m_id . '" class="js-wrapper-top">
            <div id="js-div-top-scroll-' . $match[0]->m_id . '" class="js-div-top-scroll" style="overflow: auto;"></div>
        </div>';
        $kl .= <<<JS

        <script>
            jQuery(function(){
                jQuery('#js-div-top-scroll-{$match[0]->m_id}').css({'width': jQuery('#js-wrapper-md-{$match[0]->m_id}')[0].scrollWidth+'px'});

                jQuery("#js-wrapper-top-{$match[0]->m_id}").scroll(function(){
                  jQuery("#js-wrapper-md-{$match[0]->m_id}").scrollLeft(jQuery("#js-wrapper-top-{$match[0]->m_id}").scrollLeft());
                });

                jQuery("#js-wrapper-md-{$match[0]->m_id}").scroll(function(){
                  jQuery("#js-wrapper-top-{$match[0]->m_id}").scrollLeft(jQuery("#js-wrapper-md-{$match[0]->m_id}").scrollLeft());
                });
            });
        </script>
JS;
        $kl .= '<div id="js-wrapper-md-' . $match[0]->m_id . '" class="combine-box-new" style="height:' . ($fid / 2 * ($height + $step + 50) + 360 + ($fid / 32 >= 1 ? 200 : 0)) . 'px;position:relative;overflow-x:auto;overflow-y:hidden;border:1px solid #ccc;">';
        $link = '';
        while (floor($fid / $zz) >= 1) {
            for ($i = 0; $i < floor($fid / $zz); $i++) {
                $kl .= '<div style="position:absolute;width:' . $wdth . 'px;height:' . $height . 'px; border:1px solid #aaa; border-left:0px; top:' . ($i * ($height + $step) + $top_next) . 'px; left:' . (20 + $p * $wdth) . 'px;"></div>';
                if ($t_single && isset($match[$i])) {
                    $match[$i]->home = $models->selectPlayerName($match[$i]);
                    $match[$i]->away = $models->selectPlayerName($match[$i], "fn2", "ln2", "nick2");
                }
                if ($p == 0) {
                    if (isset($match[$i]->hm_id)) {
                        if ($t_single) {
                            $link = JRoute::_('index.php?option=com_joomsport&task=player&id=' . $match[$i]->hm_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        } else {
                            $link = JRoute::_('index.php?option=com_joomsport&task=team&tid=' . $match[$i]->hm_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        }
                    }
                    $winclass = "";
                    if ($match[$i]->team2_id == -1 && $match[$i]->team1_id != -1 || $match[$i]->m_played && ($match[$i]->score1 > $match[$i]->score2 || $match[$i]->score1 == $match[$i]->score2 && $match[$i]->aet1 > $match[$i]->aet2 || $match[$i]->score1 == $match[$i]->score2 && $match[$i]->aet1 == $match[$i]->aet2 && $match[$i]->p_winner == $match[$i]->hm_id)) {
                        $winclass = " knwinner";
                    }
                    $kl .= '<div class="field-comb' . $winclass . '" style="position:absolute; top:' . ($i * ($height + $step) + $top_next - 14) . 'px; left:' . (20 + $p * $wdth) . 'px;width:' . ($reslng + 40) . 'px;"><span>' . (isset($match[$i]->score1) && $match[$i]->m_played ? $match[$i]->score1 . ($match[$i]->is_extra ? " (<abbr title='" . JText::_("BLFA_TT_AET") . "'>" . $match[$i]->aet1 . "</abbr>)" : "") : '') . '</span>';
                    //if(isset($match[$i]->home)){
                    $kl .= $match[$i]->team1_id != -1 ? "<a href='" . $link . "' title='" . $match[$i]->home . "'>" . $match[$i]->home . "</a>" : JText::_('BLFA_BYE');
                    //}else{
                    //$kl .="&nbsp;";
                    //}
                    $kl .= '</div>';
                    if (isset($match[$i]->aw_id) && $match[$i]->team2_id != -1) {
                        if ($t_single) {
                            $link = JRoute::_('index.php?option=com_joomsport&task=player&id=' . $match[$i]->aw_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        } else {
                            $link = JRoute::_('index.php?option=com_joomsport&task=team&tid=' . $match[$i]->aw_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        }
                    }
                    if (($match[$i]->m_played || $match[$i]->team1_id == -1 && $match[$i]->team2_id != -1) && $winclass == '') {
                        $winclass = " knwinner";
                    } else {
                        $winclass = "";
                    }
                    $kl .= '<div class="field-comb' . $winclass . '" style="position:absolute; top:' . ($i * ($height + $step) + $height + $top_next - 13) . 'px; left:' . (20 + $p * $wdth) . 'px;width:' . ($reslng + 40) . 'px;"><span>' . (isset($match[$i]->score2) && $match[$i]->m_played ? $match[$i]->score2 . ($match[$i]->is_extra ? " (<abbr title='" . JText::_("BLFA_TT_AET") . "'>" . $match[$i]->aet2 . "</abbr>)" : "") : '') . '</span>';
                    !($kl .= $match[$i]->team2_id != -1 ? "<a href='" . $link . "' title='" . $match[$i]->away . "'>" . $match[$i]->away . "</a>" : JText::_('BLFA_BYE'));
                    //}
                    //else{
                    //$kl .="&nbsp;";
                    //}
                    $kl .= '</div>';
                    /////////////////
                    $match_link = 'index.php?option=com_joomsport&amp;task=view_match&amp;id=' . (isset($match[$i]->id) ? $match[$i]->id : '') . '&amp;Itemid=' . $Itemid;
                    $kl .= isset($match[$i]->id) ? '<div style="position:absolute; top:' . ($i * ($height + $step) + $top_next + $height / 2 - 10) . 'px; left:' . (-20 + ($p + 1) * $wdth) . 'px;"><a href="' . $match_link . '" title="' . JText::_('BL_LINK_DETAILMATCH') . '"><span class="module-menu-editor"><!-- --></span></a></div>' : "";
                    if ($match[$i]->m_played == 0 && $match[$i]->team1_id && $match[$i]->team2_id) {
                        $arr_prev_pl[$p][] = $i;
                    }
                    if (!$match[$i]->team1_id || !$match[$i]->team2_id) {
                        $vetks_null[$p][] = $i;
                    }
                } else {
                    $firstchld_ind = $i * 2 + $fid / 2 * ((pow(2, $p - 1) - 1) / pow(2, $p - 2));
                    //$match[$firstchld_ind]->winner = ($pln && $match[$firstchld_ind]->winner_nick)?($match[$firstchld_ind]->winner_nick):($match[$firstchld_ind]->winner);
                    //$match[$firstchld_ind+1]->winner = ($pln && $match[$firstchld_ind+1]->winner_nick)?$match[$firstchld_ind+1]->winner_nick:$match[$firstchld_ind+1]->winner;
                    $cur_ind = $i + $fid / 2 * ((pow(2, $p) - 1) / pow(2, $p - 1));
                    if ($t_single) {
                        if (isset($match[$firstchld_ind])) {
                            $match[$firstchld_ind]->home = $models->selectPlayerName($match[$firstchld_ind]);
                            $match[$firstchld_ind]->winner = $models->selectPlayerName($match[$firstchld_ind], "winner", "", "winner_nick");
                            $match[$firstchld_ind]->away = $models->selectPlayerName($match[$firstchld_ind], "fn2", "ln2", "nick2");
                        }
                        if (isset($match[$firstchld_ind + 1])) {
                            $match[$firstchld_ind + 1]->home = $models->selectPlayerName($match[$firstchld_ind + 1]);
                            $match[$firstchld_ind + 1]->away = $models->selectPlayerName($match[$firstchld_ind + 1], "fn2", "ln2", "nick2");
                            $match[$firstchld_ind + 1]->winner = $models->selectPlayerName($match[$firstchld_ind + 1], "winner", "", "winner_nick");
                        }
                    }
                    if (isset($match[$firstchld_ind])) {
                        if ($match[$firstchld_ind]->score1 == $match[$firstchld_ind]->score2 && isset($match[$firstchld_ind]->winner)) {
                            if ($match[$firstchld_ind]->aet1 > $match[$firstchld_ind]->aet2) {
                                $match[$firstchld_ind]->winner = $match[$firstchld_ind]->home;
                                $match[$firstchld_ind]->winnerid = $match[$firstchld_ind]->team1_id;
                            } elseif ($match[$firstchld_ind]->aet1 < $match[$firstchld_ind]->aet2) {
                                $match[$firstchld_ind]->winner = $match[$firstchld_ind]->away;
                                $match[$firstchld_ind]->winnerid = $match[$firstchld_ind]->team2_id;
                            } else {
                                if ($match[$firstchld_ind]->p_winner && $match[$firstchld_ind]->p_winner == $match[$firstchld_ind]->team1_id) {
                                    $match[$firstchld_ind]->winner = $match[$firstchld_ind]->home;
                                    $match[$firstchld_ind]->winnerid = $match[$firstchld_ind]->team1_id;
                                } elseif ($match[$firstchld_ind]->p_winner && $match[$firstchld_ind]->p_winner == $match[$firstchld_ind]->team2_id) {
                                    $match[$firstchld_ind]->winner = $match[$firstchld_ind]->away;
                                    $match[$firstchld_ind]->winnerid = $match[$firstchld_ind]->team2_id;
                                } else {
                                    $match[$firstchld_ind]->m_played = 0;
                                }
                            }
                        }
                    }
                    if (isset($match[$firstchld_ind + 1])) {
                        if ($match[$firstchld_ind + 1]->score1 == $match[$firstchld_ind + 1]->score2 && isset($match[$firstchld_ind + 1]->winner)) {
                            if ($match[$firstchld_ind + 1]->aet1 > $match[$firstchld_ind + 1]->aet2) {
                                $match[$firstchld_ind + 1]->winner = $match[$firstchld_ind + 1]->home;
                                $match[$firstchld_ind + 1]->winnerid = $match[$firstchld_ind + 1]->team1_id;
                            } elseif ($match[$firstchld_ind + 1]->aet1 < $match[$firstchld_ind + 1]->aet2) {
                                $match[$firstchld_ind + 1]->winner = $match[$firstchld_ind + 1]->away;
                                $match[$firstchld_ind + 1]->winnerid = $match[$firstchld_ind + 1]->team2_id;
                            } else {
                                if ($match[$firstchld_ind + 1]->p_winner && $match[$firstchld_ind + 1]->p_winner == $match[$firstchld_ind + 1]->team1_id) {
                                    $match[$firstchld_ind + 1]->winner = $match[$firstchld_ind + 1]->home;
                                    $match[$firstchld_ind + 1]->winnerid = $match[$firstchld_ind + 1]->team1_id;
                                } elseif ($match[$firstchld_ind + 1]->p_winner && $match[$firstchld_ind + 1]->p_winner == $match[$firstchld_ind + 1]->team2_id) {
                                    $match[$firstchld_ind + 1]->winner = $match[$firstchld_ind + 1]->away;
                                    $match[$firstchld_ind + 1]->winnerid = $match[$firstchld_ind + 1]->team2_id;
                                } else {
                                    $match[$firstchld_ind + 1]->m_played = 0;
                                }
                            }
                        }
                    }
                    if (isset($match[$firstchld_ind]) && $match[$firstchld_ind]->team1_id == -1 && $match[$firstchld_ind]->away) {
                        $match[$firstchld_ind]->winner = $match[$firstchld_ind]->away;
                        $match[$firstchld_ind]->winnerid = $match[$firstchld_ind]->team2_id;
                        $match[$firstchld_ind]->m_played = 1;
                    }
                    if (isset($match[$firstchld_ind]) && $match[$firstchld_ind]->team2_id == -1 && $match[$firstchld_ind]->home) {
                        $match[$firstchld_ind]->winner = $match[$firstchld_ind]->home;
                        $match[$firstchld_ind]->winnerid = $match[$firstchld_ind]->team1_id;
                        $match[$firstchld_ind]->m_played = 1;
                    }
                    if (isset($match[$firstchld_ind + 1]) && $match[$firstchld_ind + 1]->team1_id == -1 && $match[$firstchld_ind + 1]->away) {
                        $match[$firstchld_ind + 1]->winner = $match[$firstchld_ind + 1]->away;
                        $match[$firstchld_ind + 1]->winnerid = $match[$firstchld_ind + 1]->team2_id;
                        $match[$firstchld_ind + 1]->m_played = 1;
                    }
                    if (isset($match[$firstchld_ind + 1]) && $match[$firstchld_ind + 1]->team2_id == -1 && $match[$firstchld_ind + 1]->home) {
                        $match[$firstchld_ind + 1]->winner = $match[$firstchld_ind + 1]->home;
                        $match[$firstchld_ind + 1]->winnerid = $match[$firstchld_ind + 1]->team1_id;
                        $match[$firstchld_ind + 1]->m_played = 1;
                    }
                    if (isset($match[$firstchld_ind]) && $match[$firstchld_ind]->team1_id == -1 && $match[$firstchld_ind]->team2_id == -1) {
                        $match[$firstchld_ind]->winner = JText::_("BLFA_BYE");
                        $match[$firstchld_ind]->winnerid = -1;
                        $match[$firstchld_ind]->m_played = 1;
                    }
                    if (isset($match[$firstchld_ind + 1]) && $match[$firstchld_ind + 1]->team1_id == -1 && $match[$firstchld_ind + 1]->team2_id == -1) {
                        $match[$firstchld_ind + 1]->winner = JText::_("BLFA_BYE");
                        $match[$firstchld_ind + 1]->winnerid = -1;
                        $match[$firstchld_ind + 1]->m_played = 1;
                    }
                    $winclass = "";
                    if (isset($match[$cur_ind]) && ($match[$cur_ind]->team2_id == -1 && $match[$cur_ind]->team1_id != -1 || $match[$cur_ind]->m_played && ($match[$cur_ind]->score1 > $match[$cur_ind]->score2 || $match[$cur_ind]->score1 == $match[$cur_ind]->score2 && $match[$cur_ind]->aet1 > $match[$cur_ind]->aet2 || $match[$cur_ind]->score1 == $match[$cur_ind]->score2 && $match[$cur_ind]->aet1 == $match[$cur_ind]->aet2 && $match[$cur_ind]->p_winner == $match[$cur_ind]->hm_id))) {
                        $winclass = " knwinner";
                    }
                    $kl .= '<div class="field-comb' . $winclass . '" style="position:absolute; top:' . ($i * ($height + $step) + $top_next - 15) . 'px; left:' . (25 + $p * $wdth) . 'px;width:' . ($reslng + 40) . 'px;"><span>' . (isset($match[$cur_ind]->score1) && $match[$cur_ind]->m_played ? $match[$cur_ind]->score1 . ($match[$cur_ind]->is_extra ? " (<abbr title='" . JText::_("BLFA_TT_AET") . "'>" . $match[$cur_ind]->aet1 . "</abbr>)" : "") : "") . '</span>';
                    if (isset($match[$firstchld_ind]->winnerid)) {
                        if ($t_single) {
                            $link = JRoute::_('index.php?option=com_joomsport&task=player&id=' . $match[$firstchld_ind]->winnerid . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        } else {
                            $link = JRoute::_('index.php?option=com_joomsport&task=team&tid=' . $match[$firstchld_ind]->winnerid . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        }
                    }
                    if (isset($match[$firstchld_ind]->winner) && $match[$firstchld_ind]->m_played) {
                        $kl .= $match[$firstchld_ind]->winner != JText::_("BLFA_BYE") ? "<a href='" . $link . "' title='" . $match[$firstchld_ind]->winner . "'>" . $match[$firstchld_ind]->winner . "</a>" : $match[$firstchld_ind]->winner;
                    }
                    //$kl .= (isset($match[$firstchld_ind]->winner) && $match[$firstchld_ind]->m_played)?("<a href='".$link."' title='".$match[$firstchld_ind]->winner."'>".$match[$firstchld_ind]->winner."</a>"):"";
                    $kl .= '</div>';
                    if (isset($match[$cur_ind]) && ($match[$cur_ind]->m_played || $match[$cur_ind]->team1_id == -1 && $match[$cur_ind]->team2_id != -1) && $winclass == '') {
                        $winclass = " knwinner";
                    } else {
                        $winclass = "";
                    }
                    $kl .= '<div class="field-comb' . $winclass . '" style="position:absolute; top:' . ($i * ($height + $step) + $height + $top_next - 15) . 'px; left:' . (25 + $p * $wdth) . 'px;width:' . ($reslng + 40) . 'px;"><span>' . (isset($match[$cur_ind]->score2) && $match[$cur_ind]->m_played ? $match[$cur_ind]->score2 . ($match[$cur_ind]->is_extra ? " (<abbr title='" . JText::_("BLFA_TT_AET") . "'>" . $match[$cur_ind]->aet2 . "</abbr>)" : "") : "") . '</span>';
                    if (isset($match[$firstchld_ind + 1]->winnerid)) {
                        if ($t_single) {
                            $link = JRoute::_('index.php?option=com_joomsport&task=player&id=' . $match[$firstchld_ind + 1]->winnerid . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        } else {
                            $link = JRoute::_('index.php?option=com_joomsport&task=team&tid=' . $match[$firstchld_ind + 1]->winnerid . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        }
                    }
                    if (isset($match[$firstchld_ind + 1]->winner) && $match[$firstchld_ind + 1]->m_played) {
                        $kl .= $match[$firstchld_ind + 1]->winner != JText::_("BLFA_BYE") ? "<a href='" . $link . "' title='" . $match[$firstchld_ind + 1]->winner . "'>" . $match[$firstchld_ind + 1]->winner . "</a>" : $match[$firstchld_ind + 1]->winner;
                    }
                    //$kl .= (isset($match[$firstchld_ind + 1]->winner) && $match[$firstchld_ind + 1]->m_played)?("<a href='".$link."' title='".$match[$firstchld_ind+1]->winner."'>".$match[$firstchld_ind+1]->winner."</a>"):"";
                    $kl .= '</div>';
                    $match_link = 'index.php?option=com_joomsport&amp;task=view_match&amp;id=' . (isset($match[$cur_ind]->id) ? $match[$cur_ind]->id : '');
                    $kl .= isset($match[$cur_ind]->id) ? '<div style="position:absolute; top:' . ($i * ($height + $step) + $top_next + $height / 2 - 10) . 'px; left:' . (-20 + ($p + 1) * $wdth) . 'px;"><a href="' . $match_link . '" title="' . JText::_('BL_LINK_DETAILMATCH') . '"><span class="module-menu-editor"><!-- --></span></a></div>' : "";
                }
            }
            $top_next += $height / 2;
            $height = $height + $step;
            $step = $height;
            $zz *= 2;
            $p++;
        }
        $winmd_id = $fid - 2;
        $wiinn = '';
        $w_st = $p != 2 ? 200 * ($p - 2) : 0;
        $h_st = 60 * ($height / 240);
        $res = $p == 4 ? 15 : ($p == 5 ? 315 : ($p == 6 ? 735 : 0));
        if ($t_single) {
            if (isset($match[$winmd_id])) {
                $match[$winmd_id]->winner = $models->selectPlayerName($match[$winmd_id], "winner", "", "winner_nick");
            }
        }
        //if(isset($match[$winmd_id]->winner) && $match[$winmd_id]->winner && $match[$winmd_id]->score1 != $match[$winmd_id]->score2 && $match[$winmd_id]->m_played)
        //{
        $link_id = '';
        if (isset($match[$winmd_id]->p_winner) && !$match[$winmd_id]->is_extra && !$match[$winmd_id]->p_winner) {
            $link_id = $match[$winmd_id]->winnerid;
        }
        if (isset($match[$winmd_id]->score1) && $match[$winmd_id]->score1 == $match[$winmd_id]->score2 && $match[$winmd_id]->aet1 != $match[$winmd_id]->aet2) {
            $link_id = $match[$winmd_id]->aet1 > $match[$winmd_id]->aet2 ? $match[$winmd_id]->team1_id : $match[$winmd_id]->team2_id;
        }
        if (!empty($match[$winmd_id]->p_winner)) {
            $link_id = $match[$winmd_id]->p_winner == $match[$winmd_id]->team1_id ? $match[$winmd_id]->team1_id : $match[$winmd_id]->team2_id;
        }
        if ($t_single) {
            $link = JRoute::_('index.php?option=com_joomsport&task=player&id=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
        } else {
            $link = JRoute::_('index.php?option=com_joomsport&task=team&tid=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
        }
        //print_r($match[$winmd_id+1]); +1 -- delete
        if (isset($match[$winmd_id]->winner) && $match[$winmd_id]->winner && $match[$winmd_id]->score1 != $match[$winmd_id]->score2 && $match[$winmd_id]->m_played) {
            $wiinn = "<div class='field-comb' style='width:" . ($reslng + 40) . "px;margin-left:5px !important;margin-top:-17px !important;'>\r\r\n               <span>" . (isset($match[$winmd_id]->score1) && $match[$winmd_id]->m_played && isset($match[$winmd_id + 1]->score1) ? $match[$winmd_id + 1]->score1 . ($match[$winmd_id]->is_extra ? ' (<abbr title="' . JText::_("BLFA_TT_AET") . '">' . $match[$winmd_id]->aet1 . '</abbr>)' : '') : "") . "</span>\r\r\n                <div><div><div class='knres'></div><div class='knlink' style='width:" . $reslng . "px;'><div><div><a href='" . $link . "' title='" . $match[$winmd_id]->winner . "'>" . $match[$winmd_id]->winner . "</a></div></div></div></div></div>\r\r\n            </div>";
        }
        if (isset($match[$winmd_id]->score1) && $match[$winmd_id]->score1 == $match[$winmd_id]->score2 && $match[$winmd_id]->aet1 != $match[$winmd_id]->aet2) {
            $win_player = $match[$winmd_id]->aet1 > $match[$winmd_id]->aet2 ? $match[$winmd_id]->home : $match[$winmd_id]->away;
            $wiinn = "<div class='field-comb' style='width:" . ($reslng + 40) . "px;margin-left:5px !important;margin-top:-17px !important;'>\r\r\n               <span>" . (isset($match[$winmd_id]->score1) && $match[$winmd_id]->m_played ? $match[$winmd_id]->score1 . ($match[$winmd_id]->is_extra ? ' (<abbr title="' . JText::_("BLFA_TT_AET") . '">' . $match[$winmd_id]->aet1 . '</abbr>)' : '') : "") . "</span>\r\r\n                <div><div><div class='knres'></div><div class='knlink' style='width:" . $reslng . "px;'><div><div><a href='" . $link . "' title='" . $win_player . "'>" . $win_player . "</a></div></div></div></div></div>\r\r\n            </div>";
        }
        if (!empty($match[$winmd_id]->p_winner)) {
            $wiinn = "<div class='field-comb' style='width:" . ($reslng + 40) . "px;margin-left:5px !important;margin-top:-17px !important;'>\r\r\n               <span>" . (isset($match[$winmd_id]->score1) && $match[$winmd_id]->m_played ? $match[$winmd_id]->score1 . ($match[$winmd_id]->is_extra ? ' (<abbr title="' . JText::_("BLFA_TT_AET") . '">' . $match[$winmd_id]->aet1 . '</abbr>)' : '') : "") . "</span>\r\r\n                <div><div><div class='knres'></div><div class='knlink' style='width:" . $reslng . "px;'><div><div><a href='" . $link . "' title='" . $match[$winmd_id]->winner . "'>" . $match[$winmd_id]->winner . "</a></div></div></div></div></div>\r\r\n            </div>";
        }
        //}
        if ($fid) {
            $kl .= '<div style="position:absolute;width:' . ($wdth + 30 + $w_st) . 'px;height:' . ($height - $h_st + 30 * ($fid / 4) - ($fid / 4 == 1 ? 15 : 25 * ($fid / 2)) - $res) . 'px; border-top:1px solid #aaa;border-right:1px solid #aaa; top:' . $top_next . 'px; left:' . (20 + $p * $wdth) . 'px;">' . $wiinn . '</div>';
        }
        //$kl .=  '</div>';
        //if($mxl){
        //    $reslng = ($mxl)*7+20;
        //}else{
        //   $reslng = 120;
        //}
        //if($reslng<120) $reslng=120;
        $cfg = new stdClass();
        $cfg->wdth = $reslng + 70;
        $cfg->height = 60;
        $cfg->step = 70;
        $cfg->top_next = 50;
        $wdth = $cfg->wdth;
        $height = $cfg->height;
        $step = $cfg->step;
        $top_next = $cfg->top_next;
        $zz = 4;
        $fid = $k_format;
        $p_last = $p + 1;
        $p = 0;
        $top = 0;
        $p_step = 0;
        $top_step = 60;
        $all_step = 120 * ($fid / 2) + 50 * ($fid / 4 > 4 ? $fid / 8 : $fid / 4);
        $step_block = $fid / $zz > 2 ? 200 : 0;
        $strafe = 0;
        $first = 0;
        $marg = 30;
        $marg1 = 100;
        $m = -1;
        if ($t_single) {
            foreach ($matchDE as $i => $tmp) {
                $matchDE[$i]->home = $models->selectPlayerName($matchDE[$i], 'first_name', 'last_name', 'nick');
                $matchDE[$i]->away = $models->selectPlayerName($matchDE[$i], "fn2", "ln2", "nick2");
                $matchDE[$i]->winner = $matchDE[$i]->hm_id == $matchDE[$i]->winnerid ? $models->selectPlayerName($matchDE[$i], 'first_name', 'last_name', 'nick') : $models->selectPlayerName($matchDE[$i], "fn2", "ln2", "nick2");
                $matchDE[$i]->looser = $matchDE[$i]->hm_id == $matchDE[$i]->looserid ? $models->selectPlayerName($match[$i], 'first_name', 'last_name', 'nick') : $models->selectPlayerName($matchDE[$i], "fn2", "ln2", "nick2");
            }
            foreach ($match as $i => $tmp) {
                $match[$i]->home = $models->selectPlayerName($match[$i], 'first_name', 'last_name', 'nick');
                $match[$i]->away = $models->selectPlayerName($match[$i], "fn2", "ln2", "nick2");
                $match[$i]->winner = $match[$i]->hm_id == $match[$i]->winnerid ? $models->selectPlayerName($match[$i], 'first_name', 'last_name', 'nick') : $models->selectPlayerName($match[$i], "fn2", "ln2", "nick2");
                $match[$i]->looser = $match[$i]->hm_id == $match[$i]->looserid ? $models->selectPlayerName($match[$i], 'first_name', 'last_name', 'nick') : $models->selectPlayerName($match[$i], "fn2", "ln2", "nick2");
            }
        }
        while (floor($fid / $zz) >= 1) {
            $p_step = $p >= 2 ? $p_step + 1 : $p_step + 0;
            $strafe++;
            if ($p == 3 || $p == 4) {
                $top = $p == 3 ? $top + 60 : $top + 210;
            }
            $top_step = $p == 0 || $p == 1 ? $top_step + 0 : $top_step + 60;
            for ($i = 0; $i < floor($fid / $zz); $i++) {
                ////
                if ($t_single && isset($match[$i])) {
                    $match[$i]->home = $models->selectPlayerName($match[$i]);
                    $match[$i]->away = $models->selectPlayerName($match[$i], "fn2", "ln2", "nick2");
                }
                ////
                if ($p == 0) {
                    $firstchld_ind = $i * 2 + $fid / 2 * ((pow(2, $p) - 1) / pow(2, $p - 1));
                    $cur_ind = $i + $fid / 2 * ((pow(2, $p) - 1) / pow(2, $p - 1));
                    if (isset($matchDE[$cur_ind])) {
                        $matchDE[$cur_ind] = $this->getMBy($matchDE[$cur_ind]);
                    }
                    if (isset($match[$firstchld_ind])) {
                        $match[$firstchld_ind] = $this->getMBy($match[$firstchld_ind]);
                    }
                    $kl .= '<div style="position:absolute;width:' . $wdth . 'px;height:' . $height . 'px; border:1px solid #aaa; border-left:0px; top:' . ($i * ($height + $step) + $top_next + $all_step) . 'px; left:' . (20 + $p * $wdth) . 'px;"></div>';
                    ///1
                    if (isset($match[$firstchld_ind]->hm_id)) {
                        if (!$match[$firstchld_ind]->is_extra && !$match[$firstchld_ind]->p_winner && $match[$firstchld_ind]->score1 != $match[$firstchld_ind]->score2) {
                            $link_id = $match[$firstchld_ind]->looserid;
                        }
                        if ($match[$firstchld_ind]->score1 == $match[$firstchld_ind]->score2 && $match[$firstchld_ind]->aet1 != $match[$firstchld_ind]->aet2) {
                            $link_id = $match[$firstchld_ind]->aet1 > $match[$firstchld_ind]->aet2 ? $match[$firstchld_ind]->team2_id : $match[$firstchld_ind]->team1_id;
                        }
                        if ($match[$firstchld_ind]->p_winner) {
                            $link_id = $match[$firstchld_ind]->p_winner == $match[$firstchld_ind]->team1_id ? $match[$firstchld_ind]->team2_id : $match[$firstchld_ind]->team1_id;
                        }
                        if ($t_single) {
                            $link = JRoute::_('index.php?option=com_joomsport&task=player&id=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        } else {
                            $link = JRoute::_('index.php?option=com_joomsport&task=team&tid=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        }
                    }
                    $winclass = "";
                    ////----
                    if (isset($matchDE[$cur_ind])) {
                        if ($matchDE[$cur_ind]->team2_id == -1 && $matchDE[$cur_ind]->team1_id != -1 || $matchDE[$cur_ind]->m_played && ($matchDE[$cur_ind]->score1 > $matchDE[$cur_ind]->score2 || $matchDE[$cur_ind]->score1 == $matchDE[$cur_ind]->score2 && $matchDE[$cur_ind]->aet1 > $matchDE[$cur_ind]->aet2 || $matchDE[$cur_ind]->score1 == $matchDE[$cur_ind]->score2 && $matchDE[$cur_ind]->aet1 == $matchDE[$cur_ind]->aet2 && $matchDE[$cur_ind]->p_winner == $matchDE[$cur_ind]->hm_id)) {
                            $winclass = " knwinner";
                        }
                    }
                    $kl .= '<div class="field-comb' . $winclass . '" style="position:absolute; top:' . ($i * ($height + $step) + $top_next - 20 + $all_step) . 'px; left:' . (20 + $p * $wdth) . 'px;width:' . ($reslng + 40) . 'px;"><span>' . (isset($matchDE[$cur_ind]->score1) && $matchDE[$cur_ind]->m_played ? $matchDE[$cur_ind]->score1 . ($matchDE[$cur_ind]->is_extra ? " (<abbr title='" . JText::_("BLFA_TT_AET") . "'>" . $matchDE[$cur_ind]->aet1 . "</abbr>)" : "") : '') . '</span>';
                    //if($match[$firstchld_ind]->m_played){
                    // $kl .= ($match[$firstchld_ind]->team1_id != -1 && $match[$firstchld_ind]->looser != JText::_('BLFA_BYE'))?("<a href='".$link."' title='".$match[$firstchld_ind]->looser."'>".$match[$firstchld_ind]->looser."</a>"):(JText::_('BLFA_BYE'));
                    //}
                    if (!$match[$firstchld_ind]->is_extra && $match[$firstchld_ind]->m_played && !$match[$firstchld_ind]->p_winner && $match[$firstchld_ind]->score1 != $match[$firstchld_ind]->score2 || ($match[$firstchld_ind]->team1_id == -1 || $match[$firstchld_ind]->team2_id == -1)) {
                        $kl .= $match[$firstchld_ind]->team1_id != -1 && $match[$firstchld_ind]->looser != JText::_('BLFA_BYE') ? "<a href='" . $link . "' title='" . $match[$firstchld_ind]->looser . "'>" . $match[$firstchld_ind]->looser . "</a>" : JText::_('BLFA_BYE');
                    }
                    if ($match[$firstchld_ind]->score1 == $match[$firstchld_ind]->score2 && $match[$firstchld_ind]->aet1 != $match[$firstchld_ind]->aet2) {
                        $kl .= $match[$firstchld_ind]->aet1 > $match[$firstchld_ind]->aet2 ? "<a href='" . $link . "' title='" . $match[$firstchld_ind]->away . "'>" . $match[$firstchld_ind]->away . "</a>" : "<a href='" . $link . "' title='" . $match[$firstchld_ind]->home . "'>" . $match[$firstchld_ind]->home . "</a>";
                    }
                    if ($match[$firstchld_ind]->p_winner) {
                        $kl .= $match[$firstchld_ind]->p_winner == $match[$firstchld_ind]->team1_id ? "<a href='" . $link . "' title='" . $match[$firstchld_ind]->away . "'>" . $match[$firstchld_ind]->away . "</a>" : "<a href='" . $link . "' title='" . $match[$firstchld_ind]->home . "'>" . $match[$firstchld_ind]->home . "</a>";
                    }
                    $kl .= '</div>';
                    ////2
                    if (isset($match[$firstchld_ind + 1]->aw_id) && $match[$firstchld_ind + 1]->team2_id != -1) {
                        if (!$match[$firstchld_ind + 1]->is_extra && !$match[$firstchld_ind + 1]->p_winner && $match[$firstchld_ind + 1]->score1 != $match[$firstchld_ind + 1]->score2) {
                            $link_id = $match[$firstchld_ind + 1]->looserid;
                        }
                        if ($match[$firstchld_ind + 1]->score1 == $match[$firstchld_ind + 1]->score2 && $match[$firstchld_ind + 1]->aet1 != $match[$firstchld_ind + 1]->aet2) {
                            $link_id = $match[$firstchld_ind + 1]->aet1 > $match[$firstchld_ind + 1]->aet2 ? $match[$firstchld_ind + 1]->team2_id : $match[$firstchld_ind + 1]->team1_id;
                        }
                        if ($match[$firstchld_ind + 1]->p_winner) {
                            $link_id = $match[$firstchld_ind + 1]->p_winner == $match[$firstchld_ind + 1]->team1_id ? $match[$firstchld_ind + 1]->team2_id : $match[$firstchld_ind + 1]->team1_id;
                        }
                        if ($t_single) {
                            $link = JRoute::_('index.php?option=com_joomsport&task=player&id=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        } else {
                            $link = JRoute::_('index.php?option=com_joomsport&task=team&tid=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        }
                    }
                    if (isset($matchDE[$cur_ind])) {
                        if (($matchDE[$cur_ind]->m_played || $matchDE[$cur_ind]->team1_id == -1 && $matchDE[$cur_ind]->team2_id != -1) && $winclass == '') {
                            $winclass = " knwinner";
                        } else {
                            $winclass = "";
                        }
                    }
                    $kl .= '<div class="field-comb' . $winclass . '" style="position:absolute; top:' . ($i * ($height + $step) + $height + $top_next - 7 + $all_step) . 'px; left:' . (20 + $p * $wdth) . 'px;width:' . ($reslng + 40) . 'px;"><span>' . (isset($matchDE[$cur_ind]->score2) && $matchDE[$cur_ind]->m_played ? $matchDE[$cur_ind]->score2 . ($matchDE[$cur_ind]->is_extra ? " (<abbr title='" . JText::_("BLFA_TT_AET") . "'>" . $matchDE[$cur_ind]->aet2 . "</abbr>)" : "") : '') . '</span>';
                    if (!$match[$firstchld_ind + 1]->is_extra && !$match[$firstchld_ind + 1]->p_winner && $match[$firstchld_ind + 1]->score1 != $match[$firstchld_ind + 1]->score2 || ($match[$firstchld_ind + 1]->team1_id == -1 || $match[$firstchld_ind + 1]->team2_id == -1)) {
                        $kl .= $match[$firstchld_ind + 1]->looser != JText::_('BLFA_BYE') && ($match[$firstchld_ind + 1]->team1_id != -1 && $match[$firstchld_ind + 1]->team2_id != -1) ? "<a href='" . $link . "' title='" . $match[$firstchld_ind + 1]->looser . "'>" . $match[$firstchld_ind + 1]->looser . "</a>" : JText::_('BLFA_BYE');
                    }
                    if ($match[$firstchld_ind + 1]->score1 == $match[$firstchld_ind + 1]->score2 && $match[$firstchld_ind + 1]->aet1 != $match[$firstchld_ind + 1]->aet2) {
                        $kl .= $match[$firstchld_ind + 1]->aet1 > $match[$firstchld_ind + 1]->aet2 ? "<a href='" . $link . "' title='" . $match[$firstchld_ind + 1]->away . "'>" . $match[$firstchld_ind + 1]->away . "</a>" : "<a href='" . $link . "' title='" . $match[$firstchld_ind + 1]->home . "'>" . $match[$firstchld_ind + 1]->home . "</a>";
                    }
                    if ($match[$firstchld_ind + 1]->p_winner) {
                        $kl .= $match[$firstchld_ind + 1]->p_winner == $match[$firstchld_ind + 1]->team1_id ? "<a href='" . $link . "' title='" . $match[$firstchld_ind + 1]->away . "'>" . $match[$firstchld_ind + 1]->away . "</a>" : "<a href='" . $link . "' title='" . $match[$firstchld_ind + 1]->home . "'>" . $match[$firstchld_ind + 1]->home . "</a>";
                    }
                    $kl .= '</div>';
                    $match_link = 'index.php?option=com_joomsport&amp;task=view_match&amp;id=' . (isset($matchDE[$cur_ind]->id) ? $matchDE[$cur_ind]->id : '') . '&amp;Itemid=' . $Itemid;
                    $kl .= isset($matchDE[$cur_ind]->id) ? '<div style="position:absolute; top:' . ($i * ($height + $step) + $top_next + $height / 2 - 10 + $all_step) . 'px; left:' . (30 + ($p + 1) * $wdth - 50) . 'px;"><a href="' . $match_link . '" title="' . JText::_('BL_LINK_DETAILMATCH') . '"><span class="module-menu-editor"><!-- --></span></a></div>' : "";
                    ////////second
                    if ($fid / 4 != 1) {
                        $firstchld_indDE = $fid / 4 + $i + (floor($fid / 8) == 1 ? 0 : floor($fid / 8));
                        $first = $fid % 16 == 0 && $fid / 16 != 1 ? $fid / 16 : 0;
                        if ($first == 4) {
                            $first = 6;
                        }
                        $tm_step = ceil($fid / 16);
                        $cur_indDE = $cur_ind + floor($fid / 8) + floor($fid / 16);
                    } else {
                        $cur_indDE = $cur_ind;
                        $firstchld_indDE = $firstchld_ind;
                        $tm_step = 1;
                    }
                    $kl .= '<div style="position:absolute;width:' . $wdth . 'px;height:' . $height . 'px; border:1px solid #aaa; border-left:0px; top:' . ($i * ($height + $step) + $top_next + $all_step - 30) . 'px; left:' . (220 + $p * $wdth) . 'px;"></div>';
                    ///1
                    if (isset($match[$firstchld_indDE + 2 + $first]->aw_id) && $match[$firstchld_indDE + 2 + $first]->team2_id != -1) {
                        if (!$match[$firstchld_indDE + 2 + $first]->is_extra && !$match[$firstchld_indDE + 2 + $first]->p_winner && $match[$firstchld_indDE + 2 + $first]->score1 != $match[$firstchld_indDE + 2 + $first]->score2) {
                            $link_id = $match[$firstchld_indDE + 2 + $first]->looserid;
                        }
                        if ($match[$firstchld_indDE + 2 + $first]->score1 == $match[$firstchld_indDE + 2 + $first]->score2 && $match[$firstchld_indDE + 2 + $first]->aet1 != $match[$firstchld_indDE + 2 + $first]->aet2) {
                            $link_id = $match[$firstchld_indDE + 2 + $first]->aet1 > $match[$firstchld_indDE + 2 + $first]->aet2 ? $match[$firstchld_indDE + 2 + $first]->team2_id : $match[$firstchld_indDE + 2 + $first]->team1_id;
                        }
                        if ($match[$firstchld_indDE + 2 + $first]->p_winner) {
                            $link_id = $match[$firstchld_indDE + 2 + $first]->p_winner == $match[$firstchld_indDE + 2 + $first]->team1_id ? $match[$firstchld_indDE + 2 + $first]->team2_id : $match[$firstchld_indDE + 2 + $first]->team1_id;
                        }
                        if ($t_single) {
                            $link = JRoute::_('index.php?option=com_joomsport&task=player&id=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        } else {
                            $link = JRoute::_('index.php?option=com_joomsport&task=team&tid=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        }
                    }
                    if (isset($matchDE[$cur_indDE + $tm_step])) {
                        if ($matchDE[$cur_indDE + $tm_step]->score1 > $matchDE[$cur_indDE + $tm_step]->score2 || ($matchDE[$cur_indDE + $tm_step]->m_played || $matchDE[$cur_indDE + $tm_step]->team1_id == -1 && $matchDE[$cur_indDE + $tm_step]->team2_id != -1) && $winclass == '') {
                            $winclass = " knwinner";
                        } else {
                            $winclass = "";
                        }
                    }
                    $kl .= '<div class="field-comb' . $winclass . '" style="position:absolute; top:' . ($i * ($height + $step) + $top_next - 20 + $all_step - 30) . 'px; left:' . (220 + $p * $wdth) . 'px;width:' . ($reslng + 40) . 'px;"><span>' . (isset($matchDE[$cur_indDE + $tm_step]->score2) && $matchDE[$cur_indDE + $tm_step]->m_played ? $matchDE[$cur_indDE + $tm_step]->score1 . ($matchDE[$cur_indDE + $tm_step]->is_extra ? " (<abbr title='" . JText::_("BLFA_TT_AET") . "'>" . $matchDE[$cur_indDE + $tm_step]->aet2 . "</abbr>)" : "") : '') . '</span>';
                    //if(isset($match[$firstchld_indDE + 2+$first])){
                    //$kl .= ($match[$firstchld_indDE + 2+$first]->team2_id != -1)?("<a href='".$link."' title='".$match[$firstchld_indDE + 2+$first]->looser."'>".(($match[$firstchld_indDE + 2+$first]->m_played)?$match[$firstchld_indDE + 2+$first]->looser:'')."</a>"):(JText::_('BLFA_BYE'));
                    //}
                    if (isset($match[$firstchld_indDE + 2 + $first]->p_winner) && !$match[$firstchld_indDE + 2 + $first]->is_extra && !$match[$firstchld_indDE + 2 + $first]->p_winner && $match[$firstchld_indDE + 2 + $first]->score1 != $match[$firstchld_indDE + 2 + $first]->score2) {
                        $kl .= $match[$firstchld_indDE + 2 + $first]->team1_id != -1 && $match[$firstchld_indDE + 2 + $first]->looser != JText::_('BLFA_BYE') ? "<a href='" . $link . "' title='" . $match[$firstchld_indDE + 2 + $first]->looser . "'>" . $match[$firstchld_indDE + 2 + $first]->looser . "</a>" : JText::_('BLFA_BYE');
                    }
                    if (isset($match[$firstchld_indDE + 2 + $first]->score1) && $match[$firstchld_indDE + 2 + $first]->score1 == $match[$firstchld_indDE + 2 + $first]->score2 && $match[$firstchld_indDE + 2 + $first]->aet1 != $match[$firstchld_indDE + 2 + $first]->aet2) {
                        $kl .= $match[$firstchld_indDE + 2 + $first]->aet1 > $match[$firstchld_indDE + 2 + $first]->aet2 ? "<a href='" . $link . "' title='" . $match[$firstchld_indDE + 2 + $first]->away . "'>" . $match[$firstchld_indDE + 2 + $first]->away . "</a>" : "<a href='" . $link . "' title='" . $match[$firstchld_indDE + 2 + $first]->home . "'>" . $match[$firstchld_indDE + 2 + $first]->home . "</a>";
                    }
                    if (!empty($match[$firstchld_indDE + 2 + $first]->p_winner)) {
                        $kl .= $match[$firstchld_indDE + 2 + $first]->p_winner == $match[$firstchld_indDE + 2 + $first]->team1_id ? "<a href='" . $link . "' title='" . $match[$firstchld_indDE + 2 + $first]->away . "'>" . $match[$firstchld_indDE + 2 + $first]->away . "</a>" : "<a href='" . $link . "' title='" . $match[$firstchld_indDE + 2 + $first]->home . "'>" . $match[$firstchld_indDE + 2 + $first]->home . "</a>";
                    }
                    $kl .= '</div>';
                    ///2
                    if (isset($matchDE[$cur_ind]->aw_id) && $matchDE[$cur_ind]->team2_id != -1) {
                        //$link_id = '';
                        if (!$matchDE[$cur_ind]->is_extra && !$matchDE[$cur_ind]->p_winner && $matchDE[$cur_ind]->score1 != $matchDE[$cur_ind]->score2 || ($matchDE[$cur_ind]->team1_id == -1 || $matchDE[$cur_ind]->team2_id == -1)) {
                            $link_id = $match[$firstchld_ind]->team1_id != -1 || $match[$firstchld_ind]->team2_id != -1 ? $matchDE[$cur_ind]->winnerid : '-1';
                        }
                        if ($matchDE[$cur_ind]->score1 == $matchDE[$cur_ind]->score2 && $matchDE[$cur_ind]->aet1 != $matchDE[$cur_ind]->aet2) {
                            $link_id = $matchDE[$cur_ind]->aet1 > $matchDE[$cur_ind]->aet2 ? $matchDE[$cur_ind]->team1_id : $matchDE[$cur_ind]->team2_id;
                        }
                        if ($matchDE[$cur_ind]->p_winner) {
                            $link_id = $matchDE[$cur_ind]->p_winner == $matchDE[$cur_ind]->team1_id ? $matchDE[$cur_ind]->team1_id : $matchDE[$cur_ind]->team2_id;
                        }
                        if ($t_single) {
                            $link = JRoute::_('index.php?option=com_joomsport&task=player&id=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        } else {
                            $link = JRoute::_('index.php?option=com_joomsport&task=team&tid=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        }
                    }
                    $winclass = "";
                    if (isset($matchDE[$cur_indDE + $tm_step])) {
                        if ($matchDE[$cur_indDE + $tm_step]->score1 < $matchDE[$cur_indDE + $tm_step]->score2 || $matchDE[$cur_indDE + $tm_step]->team2_id == -1 && $matchDE[$cur_indDE + $tm_step]->team1_id != -1 || $matchDE[$cur_indDE + $tm_step]->m_played && ($matchDE[$cur_indDE + $tm_step]->score1 == $matchDE[$cur_indDE + $tm_step]->score2 && $matchDE[$cur_indDE + $tm_step]->aet1 > $matchDE[$cur_indDE + $tm_step]->aet2 || $matchDE[$cur_indDE + $tm_step]->score1 == $matchDE[$cur_indDE + $tm_step]->score2 && $matchDE[$cur_indDE + $tm_step]->aet1 == $matchDE[$cur_indDE + $tm_step]->aet2 && $matchDE[$cur_indDE + $tm_step]->p_winner == $matchDE[$cur_indDE + $tm_step]->hm_id)) {
                            $winclass = " knwinner";
                        }
                    }
                    $kl .= '<div class="field-comb' . $winclass . '" style="position:absolute; top:' . ($i * ($height + $step) + $height + $top_next - 10 + $all_step - 30) . 'px; left:' . (220 + $p * $wdth) . 'px;width:' . ($reslng + 40) . 'px;"><span>' . (isset($matchDE[$cur_indDE + $tm_step]->score1) && $matchDE[$cur_indDE + $tm_step]->m_played ? $matchDE[$cur_indDE + $tm_step]->score2 . ($matchDE[$cur_indDE + $tm_step]->is_extra ? " (<abbr title='" . JText::_("BLFA_TT_AET") . "'>" . $matchDE[$cur_indDE + $tm_step]->aet1 . "</abbr>)" : "") : '') . '</span>';
                    //if(isset($match[$firstchld_ind]) && isset($matchDE[$cur_ind])){ //////----
                    //$kl .= ($match[$firstchld_ind]->team1_id != -1)?("<a href='".$link."' title='".$matchDE[$cur_ind]->winner."'>".(($matchDE[$cur_ind]->m_played)?$matchDE[$cur_ind]->winner:'')."</a>"):(JText::_('BLFA_BYE'));
                    //}
                    //print_r($match[$cur_ind]);
                    if (isset($matchDE[$cur_ind]->is_extra)) {
                        if (!$matchDE[$cur_ind]->is_extra && !$matchDE[$cur_ind]->p_winner && $matchDE[$cur_ind]->score1 != $matchDE[$cur_ind]->score2 || ($matchDE[$cur_ind]->team1_id == -1 || $matchDE[$cur_ind]->team2_id == -1)) {
                            $kl .= $match[$firstchld_ind]->team1_id != -1 || $match[$firstchld_ind]->team2_id != -1 ? "<a href='" . $link . "' title='" . $matchDE[$cur_ind]->winner . "'>" . ($matchDE[$cur_ind]->m_played ? $matchDE[$cur_ind]->winner : '') . "</a>" : JText::_('BLFA_BYE');
                        }
                    }
                    if (isset($matchDE[$cur_ind]->score1) && $matchDE[$cur_ind]->score1 == $matchDE[$cur_ind]->score2 && $matchDE[$cur_ind]->aet1 != $matchDE[$cur_ind]->aet2) {
                        $kl .= $matchDE[$cur_ind]->aet1 > $matchDE[$cur_ind]->aet2 ? "<a href='" . $link . "' title='" . $matchDE[$cur_ind]->home . "'>" . $matchDE[$cur_ind]->home . "</a>" : "<a href='" . $link . "' title='" . $matchDE[$cur_ind]->away . "'>" . $matchDE[$cur_ind]->away . "</a>";
                    }
                    if (!empty($matchDE[$cur_ind]->p_winner)) {
                        $kl .= $matchDE[$cur_ind]->p_winner == $matchDE[$cur_ind]->team1_id ? "<a href='" . $link . "' title='" . $matchDE[$cur_ind]->home . "'>" . $matchDE[$cur_ind]->home . "</a>" : "<a href='" . $link . "' title='" . $matchDE[$cur_ind]->away . "'>" . $matchDE[$cur_ind]->away . "</a>";
                    }
                    $kl .= '</div>';
                    $match_link = 'index.php?option=com_joomsport&amp;task=view_match&amp;id=' . (isset($matchDE[$cur_indDE + $tm_step]->id) ? $matchDE[$cur_indDE + $tm_step]->id : '') . '&amp;Itemid=' . $Itemid;
                    $kl .= isset($matchDE[$cur_ind]->id) ? '<div style="position:absolute; top:' . ($i * ($height + $step) + $top_next + $height / 2 - 10 + $all_step - 30) . 'px; left:' . (-5 + ($p + 1) * $wdth + 180) . 'px;"><a href="' . $match_link . '" title="' . JText::_('BL_LINK_DETAILMATCH') . '"><span class="module-menu-editor"><!-- --></span></a></div>' : "";
                } else {
                    $firstchld_ind = $i * 2 + $fid / 4 * ((pow(2, $p - 1) - 1) / pow(2, $p - 2));
                    $cur_ind = $i + $fid / 2 * ((pow(2, $p) - 1) / pow(2, $p - 1));
                    $firstchld_ind += floor($fid / 8) == 1 ? 0 : floor($fid / 8);
                    $step_block1 = $p == 3 || $p == 4 ? $step_block + ($p == 4 ? 400 : 200) : 0;
                    if ($m != $p) {
                        $marg *= $p;
                        $marg1 *= $p;
                        if ($p > 1) {
                            $marg = $marg + $height / 8 - ($p == 3 ? 30 * $p : ($p == 4 ? 90 * $p + 265 : 0));
                            $marg1 = $marg1 + $height / 8 - ($p == 3 ? 50 * $p + 98 : ($p == 4 ? 200 * $p + 350 : 0));
                            //$p==3?$marg1 = $marg1-(75):"";
                            //$p==4?$marg1 = $marg1-(375):"";
                        }
                    }
                    $m = $p;
                    $f_num = $fid / 8 > 2 ? $fid / 8 : 2;
                    if ($fid == 64 && $strafe == 4) {
                        $f_num += 4;
                    }
                    $kl .= '<div style="position:absolute;width:' . $wdth . 'px;height:' . $height . 'px; border:1px solid #aaa; border-left:0px; top:' . ($i * ($height + $step) + $top_next + $all_step - $marg) . 'px; left:' . (220 + ($p != 1 && $p != 3 && $p != 4 ? $step_block : $step_block1) + $p * $wdth) . 'px;"></div>';
                    if (isset($matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->hm_id)) {
                        if (!$matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->is_extra && !$matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->p_winner && $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->score1 != $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->score2) {
                            $link_id = $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->winnerid;
                        }
                        if ($matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->score1 == $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->score2 && $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->aet1 != $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->aet2) {
                            $link_id = $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->aet1 > $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->aet2 ? $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->team1_id : $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->team2_id;
                        }
                        if ($matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->p_winner) {
                            $link_id = $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->p_winner == $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->team1_id ? $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->team1_id : $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->team2_id;
                        }
                        if ($t_single) {
                            $link = JRoute::_('index.php?option=com_joomsport&task=player&id=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        } else {
                            $link = JRoute::_('index.php?option=com_joomsport&task=team&tid=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        }
                    }
                    $winclass = "";
                    ////----
                    if (isset($matchDE[$cur_ind])) {
                        if ($matchDE[$cur_ind]->team2_id == -1 && $matchDE[$cur_ind]->team1_id != -1 || $matchDE[$cur_ind]->m_played && ($matchDE[$cur_ind]->score1 > $matchDE[$cur_ind]->score2 || $matchDE[$cur_ind]->score1 == $matchDE[$cur_ind]->score2 && $matchDE[$cur_ind]->aet1 > $matchDE[$cur_ind]->aet2 || $matchDE[$cur_ind]->score1 == $matchDE[$cur_ind]->score2 && $matchDE[$cur_ind]->aet1 == $matchDE[$cur_ind]->aet2 && $matchDE[$cur_ind]->p_winner == $matchDE[$cur_ind]->hm_id)) {
                            $winclass = " knwinner";
                        }
                    }
                    $kl .= '<div class="field-comb' . $winclass . '" style="position:absolute; top:' . ($i * ($height + $step) + $top_next - 20 + $all_step - $marg) . 'px; left:' . (225 + ($p != 1 && $p != 3 && $p != 4 ? $step_block : $step_block1) + $p * $wdth) . 'px;width:' . ($reslng + 40) . 'px;"><span>' . (isset($matchDE[$cur_ind]->score1) && $matchDE[$cur_ind]->m_played ? $matchDE[$cur_ind]->score1 . ($matchDE[$cur_ind]->is_extra ? " (<abbr title='" . JText::_("BLFA_TT_AET") . "'>" . $matchDE[$cur_ind]->aet1 . "</abbr>)" : "") : '') . '</span>';
                    //if(isset($matchDE[$firstchld_ind+$f_num+($strafe%3==0?($fid/8):0)+($strafe==4?($strafe+($fid/16)):($strafe==4?14:0))])){
                    //$kl .= ($matchDE[$firstchld_ind+$f_num+($strafe%3==0?($fid/8):0)+($strafe==4?($strafe+($fid/16)):($strafe==4?14:0))]->team1_id != -1)?("<a href='".$link."' title='".$matchDE[$firstchld_ind+$f_num+($strafe%3==0?($fid/8):0)+($strafe==4?($strafe+($fid/16)):($strafe==4?14:0))]->winner."'>".(($matchDE[$firstchld_ind+$f_num+($strafe%3==0?($fid/8):0)+($strafe==4?($strafe+($fid/16)):($strafe==4?14:0))]->m_played)?$matchDE[$firstchld_ind+$f_num+($strafe%3==0?($fid/8):0)+($strafe==4?($strafe+($fid/16)):($strafe==4?14:0))]->winner:' ')."</a>"):(JText::_('BLFA_BYE'));
                    //}
                    if (isset($matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->p_winner) && !$matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->is_extra && !$matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->p_winner) {
                        //&& $matchDE[$firstchld_ind+$f_num+($strafe%3==0?($fid/8):0)+($strafe==4?($strafe+($fid/16)):($strafe==4?14:0))]->score1 == $matchDE[$firstchld_ind+$f_num+($strafe%3==0?($fid/8):0)+($strafe==4?($strafe+($fid/16)):($strafe==4?14:0))]->score2
                        $kl .= $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->team1_id != -1 ? "<a href='" . $link . "' title='" . $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->winner . "'>" . ($matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->m_played ? $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->winner : ' ') . "</a>" : JText::_('BLFA_BYE');
                    }
                    if (isset($matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->score1) && $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->score1 == $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->score2 && $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->aet1 != $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->aet2) {
                        $kl .= $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->aet1 > $matchDE[${$firstchld_ind} + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->aet2 ? "<a href='" . $link . "' title='" . $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->home . "'>" . $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->home . "</a>" : "<a href='" . $link . "' title='" . $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->away . "'>" . $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->away . "</a>";
                    }
                    if (!empty($matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->p_winner)) {
                        $kl .= $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->p_winner == $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->team1_id ? "<a href='" . $link . "' title='" . $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->home . "'>" . $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->home . "</a>" : "<a href='" . $link . "' title='" . $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->away . "'>" . $matchDE[$firstchld_ind + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->away . "</a>";
                    }
                    $kl .= '</div>';
                    //2
                    if (isset($matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->aw_id) && $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->team2_id != -1) {
                        if (!$matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->is_extra && !$matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->p_winner && $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->score1 != $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->score2) {
                            $link_id = $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->winnerid;
                        }
                        if ($matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->score1 == $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->score2 && $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->aet1 != $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->aet2) {
                            $link_id = $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->aet1 > $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->aet2 ? $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->team1_id : $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->team2_id;
                        }
                        if ($matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->p_winner) {
                            $link_id = $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->p_winner == $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->team1_id ? $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->team1_id : $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->team2_id;
                        }
                        if ($t_single) {
                            $link = JRoute::_('index.php?option=com_joomsport&task=player&id=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        } else {
                            $link = JRoute::_('index.php?option=com_joomsport&task=team&tid=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                        }
                    }
                    if (isset($matchDE[$cur_ind])) {
                        if (($matchDE[$cur_ind]->m_played || $matchDE[$cur_ind]->team1_id == -1 && $matchDE[$cur_ind]->team2_id != -1) && $winclass == '') {
                            $winclass = " knwinner";
                        } else {
                            $winclass = "";
                        }
                    }
                    $kl .= '<div class="field-comb' . $winclass . '" style="position:absolute; top:' . ($i * ($height + $step) + $height + $top_next - 20 + $all_step - $marg) . 'px; left:' . (225 + ($p != 1 && $p != 3 && $p != 4 ? $step_block : $step_block1) + $p * $wdth) . 'px;width:' . ($reslng + 40) . 'px;"><span>' . (isset($matchDE[$cur_ind]->score2) && $matchDE[$cur_ind]->m_played ? $matchDE[$cur_ind]->score2 . ($matchDE[$cur_ind]->is_extra ? " (<abbr title='" . JText::_("BLFA_TT_AET") . "'>" . $matchDE[$cur_ind]->aet2 . "</abbr>)" : "") : '') . '</span>';
                    //if(isset($matchDE[$firstchld_ind + 1+$f_num+($strafe%3==0?($fid/8):0)+($strafe==4?($strafe+($fid/16)):($strafe==4?14:0))])){
                    //$kl .= ($matchDE[$firstchld_ind + 1+$f_num+($strafe%3==0?($fid/8):0)+($strafe==4?($strafe+($fid/16)):($strafe==4?14:0))]->team2_id != -1)?("<a href='".$link."' title='".$matchDE[$firstchld_ind + 1+$f_num+($strafe%3==0?($fid/8):0)+($strafe==4?($strafe+($fid/16)):($strafe==4?14:0))]->winner."'>".(($matchDE[$firstchld_ind + 1+$f_num+($strafe%3==0?($fid/8):0)+($strafe==4?($strafe+($fid/16)):($strafe==4?14:0))]->m_played)?$matchDE[$firstchld_ind + 1+$f_num+($strafe%3==0?($fid/8):0)+($strafe==4?($strafe+($fid/16)):($strafe==4?14:0))]->winner:' ')."</a>"):(JText::_('BLFA_BYE'));
                    //}
                    if (isset($matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->p_winner) && !$matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->is_extra && !$matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->p_winner) {
                        // && $matchDE[$firstchld_ind + 1+$f_num+($strafe%3==0?($fid/8):0)+($strafe==4?($strafe+($fid/16)):($strafe==4?14:0))]->score1 == $matchDE[$firstchld_ind + 1+$f_num+($strafe%3==0?($fid/8):0)+($strafe==4?($strafe+($fid/16)):($strafe==4?14:0))]->score2
                        $kl .= $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->team2_id != -1 ? "<a href='" . $link . "' title='" . $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->winner . "'>" . ($matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->m_played ? $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->winner : ' ') . "</a>" : JText::_('BLFA_BYE');
                    }
                    if (isset($matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->score1) && $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->score1 == $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->score2 && $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->aet1 != $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->aet2) {
                        $kl .= $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->aet1 > $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->aet2 ? "<a href='" . $link . "' title='" . $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->home . "'>" . $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->home . "</a>" : "<a href='" . $link . "' title='" . $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->away . "'>" . $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->away . "</a>";
                    }
                    if (!empty($matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->p_winner)) {
                        $kl .= $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->p_winner == $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->team1_id ? "<a href='" . $link . "' title='" . $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->home . "'>" . $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->home . "</a>" : "<a href='" . $link . "' title='" . $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->away . "'>" . $matchDE[$firstchld_ind + 1 + $f_num + ($strafe % 3 == 0 ? $fid / 8 : 0) + ($strafe == 4 ? $strafe + $fid / 16 : ($strafe == 4 ? 14 : 0))]->away . "</a>";
                    }
                    $kl .= '</div>';
                    $match_link = 'index.php?option=com_joomsport&amp;task=view_match&amp;id=' . (isset($matchDE[$cur_ind]->id) ? $matchDE[$cur_ind]->id : '') . '&amp;Itemid=' . $Itemid;
                    $kl .= isset($matchDE[$cur_ind]->id) ? '<div style="position:absolute; top:' . ($i * ($height + $step) + $top_next + $height / 2 - 10 + $all_step - $marg) . 'px; left:' . (50 + ($p + 1) * $wdth - 50 + 180 + ($p != 1 && $p != 3 && $p != 4 ? $step_block : $step_block1)) . 'px;"><a href="' . $match_link . '" title="' . JText::_('BL_LINK_DETAILMATCH') . '"><span class="module-menu-editor"><!-- --></span></a></div>' : "";
                    /////---------------------
                    /////////////
                    ///////////////////////////////////
                    //////////////////////////////////////////////
                    $firstchld_ind_end = $i + $fid / 4 * ((pow(2, $p) - 1) / pow(2, $p - 1));
                    if ($p != 0) {
                        $win_pl = 0;
                        $tab_b = 0;
                        if ($fid == 32 && $strafe == 4) {
                            $win_pl = 6;
                            $tab_b = 3;
                        } else {
                            if ($fid == 64 && $strafe == 4) {
                                $win_pl = 12;
                                $tab_b = 6;
                            } else {
                                if ($fid == 64 && $strafe == 5) {
                                    $win_pl = 14;
                                    $tab_b = 7;
                                }
                            }
                        }
                        $kl .= '<div style="position:absolute;width:' . $wdth . 'px;height:' . $height . 'px; border:1px solid #aaa; border-left:0px; top:' . ($i * ($height + $step) + $top_next + $all_step - $marg1) . 'px; left:' . (420 + ($p != 1 && $p != 3 && $p != 4 ? $step_block : $step_block1) + $p * $wdth) . 'px;"></div>';
                        //1
                        if (isset($match[$firstchld_ind_end + $fid / 2]->hm_id)) {
                            if (!$match[$firstchld_ind_end + $fid / 2]->is_extra && !$match[$firstchld_ind_end + $fid / 2]->p_winner && $match[$firstchld_ind_end + $fid / 2]->score1 != $match[$firstchld_ind_end + $fid / 2]->score2) {
                                $link_id = $match[$firstchld_ind_end + $fid / 2]->looserid;
                            }
                            if ($match[$firstchld_ind_end + $fid / 2]->score1 == $match[$firstchld_ind_end + $fid / 2]->score2 && $match[$firstchld_ind_end + $fid / 2]->aet1 != $match[$firstchld_ind_end + $fid / 2]->aet2) {
                                $link_id = $match[$firstchld_ind_end + $fid / 2]->aet1 > $match[$firstchld_ind_end + $fid / 2]->aet2 ? $match[$firstchld_ind_end + $fid / 2]->team2_id : $match[$firstchld_ind_end + $fid / 2]->team1_id;
                            }
                            if ($match[$firstchld_ind_end + $fid / 2]->p_winner) {
                                $link_id = $match[$firstchld_ind_end + $fid / 2]->p_winner == $match[$firstchld_ind_end + $fid / 2]->team1_id ? $match[$firstchld_ind_end + $fid / 2]->team2_id : $match[$firstchld_ind_end + $fid / 2]->team1_id;
                            }
                            if ($t_single) {
                                $link = JRoute::_('index.php?option=com_joomsport&task=player&id=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                            } else {
                                $link = JRoute::_('index.php?option=com_joomsport&task=team&tid=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                            }
                        }
                        $winclass = "";
                        ////----
                        if (isset($matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)])) {
                            if ($matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->team2_id == -1 && $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->team1_id != -1 || $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->m_played && ($matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->score1 > $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->score2 || $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->score1 == $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->score2 && $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->aet1 > $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->aet2 || $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->score1 == $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->score2 && $matchDE[$cur_ind]->aet1 == $matchDE[$cur_ind]->aet2 && $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->p_winner == $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->hm_id)) {
                                $winclass = " knwinner";
                            }
                        }
                        $kl .= '<div class="field-comb' . $winclass . '" style="position:absolute; top:' . ($i * ($height + $step) + $top_next - 20 + $all_step - $marg1) . 'px; left:' . (425 + ($p != 1 && $p != 3 && $p != 4 ? $step_block : $step_block1) + $p * $wdth) . 'px;width:' . ($reslng + 40) . 'px;"><span>' . (isset($matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->score1) && $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->m_played ? $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->score1 . ($matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->is_extra ? " (<abbr title='" . JText::_("BLFA_TT_AET") . "'>" . $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->aet1 . "</abbr>)" : "") : '') . '</span>';
                        //if(isset($match[$firstchld_ind_end+($fid/2)])){
                        // $kl .= ($match[$firstchld_ind_end+($fid/2)]->team1_id != -1)?("<a href='".$link."' title='".$match[$firstchld_ind_end+($fid/2)]->looser."'>".(($match[$firstchld_ind_end+($fid/2)]->m_played)?$match[$firstchld_ind_end+($fid/2)]->looser:' ')."</a>"):(JText::_('BLFA_BYE'));
                        //}
                        if (isset($match[$firstchld_ind_end + $fid / 2]->p_winner) && !$match[$firstchld_ind_end + $fid / 2]->is_extra && !$match[$firstchld_ind_end + $fid / 2]->p_winner && $match[$firstchld_ind_end + $fid / 2]->score1 != $match[$firstchld_ind_end + $fid / 2]->score2) {
                            $kl .= $match[$firstchld_ind_end + $fid / 2]->team1_id != -1 ? "<a href='" . $link . "' title='" . $match[$firstchld_ind_end + $fid / 2]->looser . "'>" . ($match[$firstchld_ind_end + $fid / 2]->m_played ? $match[$firstchld_ind_end + $fid / 2]->looser : ' ') . "</a>" : JText::_('BLFA_BYE');
                        }
                        if (isset($match[$firstchld_ind_end + $fid / 2]->score1) && $match[$firstchld_ind_end + $fid / 2]->score1 == $match[$firstchld_ind_end + $fid / 2]->score2 && $match[$firstchld_ind_end + $fid / 2]->aet1 != $match[$firstchld_ind_end + $fid / 2]->aet2) {
                            $kl .= $match[$firstchld_ind_end + $fid / 2]->aet1 > $match[$firstchld_ind_end + $fid / 2]->aet2 ? "<a href='" . $link . "' title='" . $match[$firstchld_ind_end + $fid / 2]->away . "'>" . $match[$firstchld_ind_end + $fid / 2]->away . "</a>" : "<a href='" . $link . "' title='" . $match[$firstchld_ind_end + $fid / 2]->home . "'>" . $match[$firstchld_ind_end + $fid / 2]->home . "</a>";
                        }
                        if (!empty($match[$firstchld_ind_end + $fid / 2]->p_winner)) {
                            $kl .= $match[$firstchld_ind_end + $fid / 2]->p_winner == $match[$firstchld_ind_end + $fid / 2]->team1_id ? "<a href='" . $link . "' title='" . $match[$firstchld_ind_end + $fid / 2]->away . "'>" . $match[$firstchld_ind_end + $fid / 2]->away . "</a>" : "<a href='" . $link . "' title='" . $match[$firstchld_ind_end + $fid / 2]->home . "'>" . $match[$firstchld_ind_end + $fid / 2]->home . "</a>";
                        }
                        $kl .= '</div>';
                        //2
                        if (isset($matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)])) {
                            if (isset($matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->aw_id) && $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->team2_id != -1) {
                                if (!$matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->is_extra && !$matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->p_winner && $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->score1 != $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->score2) {
                                    $link_id = $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->winnerid;
                                }
                                if ($matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->score1 == $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->score2 && $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->aet1 != $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->aet2) {
                                    $link_id = $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->aet1 > $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->aet2 ? $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->team2_id : $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->team1_id;
                                }
                                if ($matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->p_winner) {
                                    $link_id = $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->p_winner == $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->team1_id ? $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->team2_id : $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->team1_id;
                                }
                                if ($t_single) {
                                    $link = JRoute::_('index.php?option=com_joomsport&task=player&id=' . $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->winnerid . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                                } else {
                                    $link = JRoute::_('index.php?option=com_joomsport&task=team&tid=' . $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->winnerid . '&sid=' . $s_id . '&Itemid=' . $Itemid);
                                }
                            }
                            if (($matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->m_played || $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->team1_id == -1 && $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->team2_id != -1) && $winclass == '') {
                                $winclass = " knwinner";
                            } else {
                                $winclass = "";
                            }
                        }
                        $kl .= '<div class="field-comb' . $winclass . '" style="position:absolute; top:' . ($i * ($height + $step) + $height + $top_next - 20 + $all_step - $marg1) . 'px; left:' . (425 + ($p != 1 && $p != 3 && $p != 4 ? $step_block : $step_block1) + $p * $wdth) . 'px;width:' . ($reslng + 40) . 'px;"><span>' . (isset($matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->score2) && $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->m_played ? $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->score2 . ($matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->is_extra ? " (<abbr title='" . JText::_("BLFA_TT_AET") . "'>" . $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->aet2 . "</abbr>)" : "") : '') . '</span>';
                        //if(isset($matchDE[$firstchld_ind_end+($fid/4)+($strafe%3==0?($fid/8):0)+$win_pl])){
                        //$kl .= ($matchDE[$firstchld_ind_end+($fid/4)+($strafe%3==0?($fid/8):0)+$win_pl]->team2_id != -1)?("<a href='".$link."' title='".$matchDE[$firstchld_ind_end+($fid/4)+($strafe%3==0?($fid/8):0)+$win_pl]->winner."'>".(($matchDE[$firstchld_ind_end+($fid/4)+($strafe%3==0?($fid/8):0)+$win_pl]->m_played)?$matchDE[$firstchld_ind_end+($fid/4)+($strafe%3==0?($fid/8):0)+$win_pl]->winner:' ')."</a>"):(JText::_('BLFA_BYE'));
                        //}
                        if (isset($matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->p_winner) && !$matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->is_extra && !$matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->p_winner && $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->score1 != $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->score2) {
                            $kl .= $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->team2_id != -1 ? "<a href='" . $link . "' title='" . $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->winner . "'>" . ($matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->m_played ? $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->winner : ' ') . "</a>" : JText::_('BLFA_BYE');
                        }
                        if (isset($matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->score1) && $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->score1 == $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->score2 && $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->aet1 != $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->aet2) {
                            $kl .= $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->aet1 > $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->aet2 ? "<a href='" . $link . "' title='" . $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->home . "'>" . $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->home . "</a>" : "<a href='" . $link . "' title='" . $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->away . "'>" . $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->away . "</a>";
                        }
                        if (!empty($matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->p_winner)) {
                            $kl .= $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->p_winner == $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->team1_id ? "<a href='" . $link . "' title='" . $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->home . "'>" . $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->home . "</a>" : "<a href='" . $link . "' title='" . $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->away . "'>" . $matchDE[$firstchld_ind_end + $fid / 4 + ($strafe % 3 == 0 ? $fid / 8 : 0) + $win_pl]->away . "</a>";
                        }
                        $kl .= '</div>';
                        $match_link = 'index.php?option=com_joomsport&amp;task=view_match&amp;id=' . (isset($matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->id) ? $matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->id : '') . '&amp;Itemid=' . $Itemid;
                        $kl .= isset($matchDE[$cur_ind + $fid / 8 - ($strafe % 3 == 0 ? $fid / 16 : $tab_b)]->id) ? '<div style="position:absolute; top:' . ($i * ($height + $step) + $top_next + $height / 2 - 10 + $all_step - $marg1) . 'px; left:' . (50 + ($p + 1) * $wdth - 50 + 380 + ($p != 1 && $p != 3 && $p != 4 ? $step_block : $step_block1)) . 'px;"><a href="' . $match_link . '" title="' . JText::_('BL_LINK_DETAILMATCH') . '"><span class="module-menu-editor"><!-- --></span></a></div>' : "";
                    }
                }
            }
            $top_next += $height / 2;
            $height = $height + $step;
            $step = $height;
            $zz *= 2;
            $p++;
        }
        //echo $fid;
        $winmd_id = $fid - 3;
        $wiinn = '';
        $res = $p == 3 ? 15 : ($p == 4 ? 115 : ($p == 5 ? 335 : 0));
        if ($fid) {
            $step_line = 100 * ($zz / $fid) * $p;
        }
        if ($t_single) {
            if (isset($matchDE[$winmd_id])) {
                $matchDE[$winmd_id]->winner = $models->selectPlayerName($matchDE[$winmd_id], "winner", "", "winner_nick");
            }
        }
        // if(isset($matchDE[$winmd_id]->winner) && $matchDE[$winmd_id]->winner && $matchDE[$winmd_id]->score1 != $matchDE[$winmd_id]->score2 && $matchDE[$winmd_id]->m_played)
        //{
        ///////////////////////////////
        ////////////////////
        ////////////////
        //////////
        if (isset($matchDE[$winmd_id]->p_winner) && !$matchDE[$winmd_id]->is_extra && !$matchDE[$winmd_id]->p_winner) {
            $link_id = $matchDE[$winmd_id]->winnerid;
        }
        if (isset($matchDE[$winmd_id]->score1) && $matchDE[$winmd_id]->score1 == $matchDE[$winmd_id]->score2 && $matchDE[$winmd_id]->aet1 != $matchDE[$winmd_id]->aet2) {
            $link_id = $matchDE[$winmd_id]->aet1 > $matchDE[$winmd_id]->aet2 ? $matchDE[$winmd_id]->team1_id : $matchDE[$winmd_id]->team2_id;
        }
        if (!empty($matchDE[$winmd_id]->p_winner)) {
            $link_id = $matchDE[$winmd_id]->p_winner == $matchDE[$winmd_id]->team1_id ? $matchDE[$winmd_id]->team1_id : $matchDE[$winmd_id]->team2_id;
        }
        if ($t_single) {
            $link = JRoute::_('index.php?option=com_joomsport&task=player&id=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
        } else {
            $link = JRoute::_('index.php?option=com_joomsport&task=team&tid=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
        }
        // $wiinn .="<span>".((isset($match[$winmd_id+2]->score2) && $match[$winmd_id+2]->m_played)?$match[$winmd_id+2]->score2.($match[$winmd_id+2]->is_extra?' (<abbr title="'.JText::_("BLFA_TT_AET").'">'.$match[$winmd_id+2]->aet2.'</abbr>)':''):"")."</span>";
        //print_R($matchDE[$winmd_id]);
        if (isset($match[$winmd_id]->winner) && $match[$winmd_id]->winner && !empty($matchDE[$winmd_id]->m_played)) {
            $wiinn = "<div class='field-comb' style='width:" . ($reslng + 40) . "px;margin-left:5px !important;margin-top:-17px !important;'>\r\r\n               <span>" . (isset($match[$winmd_id]->score2) && $match[$winmd_id]->m_played ? $match[$winmd_id + 2]->score2 . ($match[$winmd_id]->is_extra ? ' (<abbr title="' . JText::_("BLFA_TT_AET") . '">' . $match[$winmd_id]->aet2 . '</abbr>)' : '') : "") . "</span>\r\r\n                <div><div><div class='knres'></div><div class='knlink' style='width:" . $reslng . "px;'><div><div><a href='" . $link . "' title='" . $matchDE[$winmd_id]->winner . "'>" . $matchDE[$winmd_id]->winner . "</a></div></div></div></div></div>\r\r\n            </div>";
        }
        if (isset($match[$winmd_id]->score1) && $match[$winmd_id]->score1 == $match[$winmd_id]->score2 && $match[$winmd_id]->aet1 != $match[$winmd_id]->aet2) {
            $win_player = $match[$winmd_id]->aet1 > $match[$winmd_id]->aet2 ? $match[$winmd_id]->away : $match[$winmd_id]->home;
            $wiinn = "<div class='field-comb' style='width:" . ($reslng + 40) . "px;margin-left:5px !important;margin-top:-17px !important;'>\r\r\n               <span>" . (isset($match[$winmd_id]->score2) && $match[$winmd_id]->m_played ? $match[$winmd_id]->score2 . ($match[$winmd_id]->is_extra ? ' (<abbr title="' . JText::_("BLFA_TT_AET") . '">' . $match[$winmd_id]->aet2 . '</abbr>)' : '') : "") . "</span>\r\r\n                <div><div><div class='knres'></div><div class='knlink' style='width:" . $reslng . "px;'><div><div><a href='" . $link . "' title='" . $win_player . "'>" . $win_player . "</a></div></div></div></div></div>\r\r\n            </div>";
        }
        if (!empty($match[$winmd_id]->p_winner)) {
            $wiinn = "<div class='field-comb' style='width:" . ($reslng + 40) . "px;margin-left:5px !important;margin-top:-17px !important;'>\r\r\n               <span>" . (isset($match[$winmd_id]->score2) && $match[$winmd_id]->m_played ? $match[$winmd_id]->score2 . ($match[$winmd_id]->is_extra ? ' (<abbr title="' . JText::_("BLFA_TT_AET") . '">' . $match[$winmd_id]->aet2 . '</abbr>)' : '') : "") . "</span>\r\r\n                <div><div><div class='knres'></div><div class='knlink' style='width:" . $reslng . "px;'><div><div><a href='" . $link . "' title='" . $matchDE[$winmd_id]->winner . "'>" . $matchDE[$winmd_id]->winner . "</a></div></div></div></div></div>\r\r\n            </div>";
        }
        //}
        if ($fid) {
            $match_link = 'index.php?option=com_joomsport&amp;task=view_match&amp;id=' . (isset($match[$winmd_id + 2]->id) ? $match[$winmd_id + 2]->id : '') . '&amp;Itemid=' . $Itemid;
            $kl .= '<div style="position:absolute; top:' . (($top_next + $all_step) / 2 + $height / 2 - $height / 4 + 10 * $p) . 'px; left:' . ($step_line + $p * $wdth + $wdth) . 'px;"><a href="' . $match_link . '" title="' . JText::_('BL_LINK_DETAILMATCH') . '"><span class="module-menu-editor"><!-- --></span></a></div>';
            $kl .= '<div style="position:absolute;width:' . ($wdth + 20) . 'px;height:' . $height . 'px; border-top:1px solid #aaa; top:' . ($top_next + $all_step - ($fid / 4 == 1 ? 15 : 25 * ($fid / 2)) - $res) . 'px; left:' . (20 + $step_line + $p * $wdth) . 'px;">' . $wiinn . '</div>';
        }
        //$kl .= '<div style="position:absolute;width:'.$wdth.'px;height:'.($height).'px; border-bottom:1px solid #aaa; top:'.( ($top_next+$all_step)/3).'px; left:'.($step_line + ($p)*$wdth+$wdth).'px;"><div style="margin-left:45px; margin-top:'.((($top_next+$all_step+($fid/4>1?(($fid/8>1)?60*(($fid/4)-1):60):0))/3)).'px;">'.(($match[$winmd_id+2]->m_played)?$match[$winmd_id+2]->winner:'').'</div></div>';
        //if(isset($match[$winmd_id+2]->winner)){
        // $wiiinnn = "<div class='field-comb' style='width:".($reslng+40)."px;margin-left:-35px !important;margin-top:-17px !important;'><div><div><div class='knres'></div><div class='knlink' style='width:".$reslng."px;'><div><div><a href='".$link."' title='".$match[$winmd_id+2]->winner."'>".$match[$winmd_id+2]->winner."</a></div></div></div></div></div></div>";
        //}
        ////////////////////WINER!!!!
        if (isset($match[$winmd_id + 2]->p_winner) && !$match[$winmd_id + 2]->is_extra && !$match[$winmd_id + 2]->p_winner && $match[$winmd_id + 2]->score1 != $match[$winmd_id + 2]->score2) {
            $link_id = $match[$winmd_id + 2]->winnerid;
        }
        if (isset($match[$winmd_id + 2]->score1) && $match[$winmd_id + 2]->score1 == $match[$winmd_id + 2]->score2 && $match[$winmd_id + 2]->aet1 != $match[$winmd_id + 2]->aet2) {
            $link_id = $match[$winmd_id + 2]->aet1 > $match[$winmd_id + 2]->aet2 ? $match[$winmd_id + 2]->team1_id : $match[$winmd_id + 2]->team2_id;
        }
        if (!empty($match[$winmd_id + 2]->p_winner)) {
            $link_id = $match[$winmd_id + 2]->p_winner == $match[$winmd_id + 2]->team1_id ? $match[$winmd_id + 2]->team1_id : $match[$winmd_id + 2]->team2_id;
        }
        if ($t_single) {
            $link = JRoute::_('index.php?option=com_joomsport&task=player&id=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
        } else {
            $link = JRoute::_('index.php?option=com_joomsport&task=team&tid=' . $link_id . '&sid=' . $s_id . '&Itemid=' . $Itemid);
        }
        //////
        if (isset($match[$winmd_id + 2]->winner) && $match[$winmd_id + 2]->winner && $match[$winmd_id + 2]->score1 != $match[$winmd_id + 2]->score2 && $match[$winmd_id + 2]->m_played) {
            $wiiinnn = "<div class='field-comb' style='width:" . ($reslng + 40) . "px;margin-left:-35px !important;margin-top:-17px !important;'><div><div><div class='knres'></div><div class='knlink' style='width:" . $reslng . "px;'><div><div><a href='" . $link . "' title='" . $match[$winmd_id + 2]->winner . "'>" . $match[$winmd_id + 2]->winner . "</a></div></div></div></div></div></div>";
        }
        if (isset($match[$winmd_id + 2]->score1) && $match[$winmd_id + 2]->score1 == $match[$winmd_id + 2]->score2 && $match[$winmd_id + 2]->aet1 != $match[$winmd_id + 2]->aet2) {
            $win_player = $match[$winmd_id + 2]->aet1 > $match[$winmd_id + 2]->aet2 ? $match[$winmd_id + 2]->home : $match[$winmd_id + 2]->away;
            $wiiinnn = "<div class='field-comb' style='width:" . ($reslng + 40) . "px;margin-left:-35px !important;margin-top:-17px !important;'><div><div><div class='knres'></div><div class='knlink' style='width:" . $reslng . "px;'><div><div><a href='" . $link . "' title='" . $win_player . "'>" . $win_player . "</a></div></div></div></div></div></div>";
        }
        if (!empty($match[$winmd_id + 2]->p_winner)) {
            $win_player = $match[$winmd_id + 2]->p_winner == $match[$winmd_id + 2]->team1_id ? $match[$winmd_id + 2]->home : $match[$winmd_id + 2]->away;
            $wiiinnn = "<div class='field-comb' style='width:" . ($reslng + 40) . "px;margin-left:-35px !important;margin-top:-17px !important;'><div><div><div class='knres'></div><div class='knlink' style='width:" . $reslng . "px;'><div><div><a href='" . $link . "' title='" . $win_player . "'>" . $win_player . "</a></div></div></div></div></div></div>";
        }
        //$kl .= '<div style="position:absolute;width:'.$wdth.'px;height:'.($height).'px; border-top:1px solid #aaa; top:'.( ($top_next+$all_step)/2).'px; left:'.($step_line + ($p)*$wdth+$wdth).'px;">'.$wiiinnn.'</div>';
        $kl .= '<div style="position:absolute;width:' . $wdth . 'px;height:' . $height . 'px; border-bottom:1px solid #aaa; top:' . (($top_next + $all_step) / 3 - ($fid / 4 == 2 ? 25 : 15 * ($fid / 4)) - $res - 10 * $p) . 'px; left:' . (40 + $step_line + $p * $wdth + $wdth) . 'px;"><div style="margin-left:45px; margin-top:' . ($top_next + $all_step + ($fid / 4 > 1 ? $fid / 8 > 1 ? 60 * ($fid / 4 - 1) : 60 : 0)) / 3 . 'px;">' . (isset($match[$winmd_id + 2]->m_played) ? $match[$winmd_id + 2]->m_played ? $wiiinnn : '' : '') . '</div></div>';
        $kl .= '</div>';
        return $kl;
    }