       @changeCompetitorsComparisonResult(winnerId, otherLoserId) unless match['winner_competitor'] == undefined
         
       @appointWinnerOfMatch(index, winnerId, otherLoserId, match['winner_competitor'] == undefined)
-      window.matches[index]['winner_competitor'] = winnerId
       window.matches[index]['auto_winner'] = true
+      match = window.matches[index]
+      
+      competitorsWhichAreLoserOfLastMatch = jQuery.map(match['competitors'], (c) =>
+        if c == @otherCompetitorOfMatch(@currentMatch, @currentMatch['winner_competitor'])
+          return c
+      )
+      
+      match['foot_note_competitor'] = loserId
+      
+      if competitorsWhichAreLoserOfLastMatch.length == 1
+        match['auto_winner_reason'] = 'loser has been defeated because he loses against the loser <sup>[1]</sup> of last match'
+      else
+        match['auto_winner_reason'] = 'loser has been defeated because he loses against the loser <sup>[1]</sup> of last auto winner match'
+        
+      @currentAutoWinnerMatches.push match
       
   changeCompetitorsComparisonResult: (winnerId, loserId) ->
     @outmatchedCompetitorsByCompetitor[winnerId] ||= []

    return list
          
  generateMatches: () ->
    $.each @competitors, (index, competitor_id) =>
      @competitorsOfCompetitor[competitor_id] ||= []
        
      $.each @competitors, (index, otherCompetitorId) =>
        @competitorsOfCompetitor[otherCompetitorId] ||= []
        
        if competitor_id != otherCompetitorId && $.inArray(otherCompetitorId, @competitorsOfCompetitor[competitor_id]) == -1
          window.matches.push { competitors: [competitor_id, otherCompetitorId] }
          @competitorsOfCompetitor[competitor_id].push otherCompetitorId
          @competitorsOfCompetitor[otherCompetitorId].push competitor_id
          
  nextMatch: () ->
    @currentMatch = null
    
    $.each window.matches, (index, match) =>

      <button type="button" class="cancel_tournament_button" class="btn">Cancel</button> &nbsp;&nbsp;&nbsp;&nbsp;
      <button type="button" class="select_winner_button" class="btn btn-primary">Submit</button>
    </p>
  </div>
</form>
"""

      $('#bootstrap_modal').html(html)
      
      return true
    
  showCurrentAutoWinnerMatches: () ->
    @currentMatch = window.matches[@currentMatchIndex]
    rows = ""
    
    $.each @currentAutoWinnerMatches, (index, match) =>
      even_or_odd = ''
      
      if index % 2 == 0
        even_or_odd = 'even'
      else
        even_or_odd = 'odd'
        
      rows +=     html = """
<tr class="#{even_or_odd}">
  <td style="width:200px">#{@nameOfCompetitor(match['winner_competitor'], false)}</td>
  <td><input type="radio" checked="checked" disabled="disabled"/></td>
  <td>&nbsp;&nbsp;VS.&nbsp;&nbsp;&nbsp;</td>
  <td><input type="radio" disabled="disabled"/></td>
  <td>&nbsp;&nbsp;&nbsp;</td>
  <td style="width:200px">#{@nameOfCompetitor(@otherCompetitorOfMatch(match, match['winner_competitor']), false)}</td>
  <td style="text-align:center">
    <a class="bootstrap_tooltip" href="#" data-toggle="tooltip" data-html="true" title="#{match['auto_winner_reason']}">
      <i class="icon-question-sign"/>
    </a>
  </td>
  <td style="width:200px">#{@nameOfCompetitor(match['foot_note_competitor'], false)}</td>
</tr>        
"""     
        
    html = """  
<div class="modal-header">
  <button type="button" id="close_bootstrap_modal_button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  <h3>Auto Winners due to Result of last Match</h3>
</div>
<div class="modal-body" style="overflow-y:none;">
  <table>
    <tr>
      <td><strong>Last Match was:&nbsp;&nbsp;</strong></td>
      <td>#{@nameOfCompetitor(@currentMatch['winner_competitor'], false)}</td>
      <td>&nbsp;&nbsp;<input type="radio" checked="checked" disabled="disabled"/></td>
      <td>&nbsp;&nbsp;VS.&nbsp;&nbsp;&nbsp;</td>
      <td><input type="radio" disabled="disabled"/></td>
      <td>&nbsp;&nbsp;&nbsp;</td>
      <td>#{@nameOfCompetitor(@otherCompetitorOfMatch(@currentMatch, @currentMatch['winner_competitor']), false)}</td>
    </tr>
  </table>
  <table class="table table-striped">
    <thead>
      <tr class="odd">
        <th>Winner</th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th>Loser</th>
        <th>Reason</th>
        <th>[1]</th>
      </tr>
    </thead>
    <tbody>
      #{rows}
    </tbody>
  </table>
</div>
<div class="modal-footer" style="text-align:left;">
  <p>
    <button type="button" class="read_current_auto_winner_matches_button" class="btn btn-primary">OK</button>
  </p>
</div>     
"""    

    $('#bootstrap_modal').html(html)
    $('.bootstrap_tooltip').tooltip()
    @currentAutoWinnerMatches = []
    
  letWinnerWinMatchesAgainstCompetitorsWhichLoseAgainstLoser: (winnerId, loserId) ->
    @defeatedCompetitorsByCompetitor[loserId] ||= []
