 </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;">
+      autoWinnerMatchesHtml = """  
+<h4>Auto Winners due to Result of last Match</h4>
+<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></th>
+      <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>   
+"""
+      
+    @currentMatch = null
+    
+    $.each window.matches, (index, match) =>
+      if match['winner_competitor'] == undefined
+        @currentMatch = match
+        @currentMatchIndex = index
+        
+        return false
+    
+    if from_start == true && @currentMatch == null 
+      alert 'No matches to rate left.'
+      
+      return false
+    
+    modalBodyHtml = ''
+    modalTitle = ''
+    modalFooterHtml = ''
+    
+    if @currentMatch == null 
+      modalTitle = 'No matches to rate left.' 
+      modalFooterHtml = """
+<p>
+  <button type="button" class="cancel_tournament_button" class="btn">Save match results and close window</button>
+</p>      
+"""      
+    else
+      modalTitle = "Appoint Winner (#{@matchesLeft} matches left)"
+      radioButtons = []
+      competitorStrings = []
+      i = 0
+      
+      $.each @currentMatch['competitors'], (index, competitorId) =>
+        checked = ' checked="checked"'
+        checked = '' if i == 1
+        radioButtons.push ('<input type="radio" ' + checked + ' name="winner" value="' + competitorId + '" style="position:relative; top:-5px "/>')
+        competitorStrings.push @nameOfCompetitor(competitorId, true)  
+          
+        i += 1
+      modalBodyHtml += """  
+<div class="controls" style="margin-left:50px">
   <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>
+    <tr>      
+      <td style="width:325px">
+        #{competitorStrings[0]}
+      </td>
+      <td>#{radioButtons[0]}</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>
+      <td>#{radioButtons[1]}</td>
+      <td>
+        &nbsp;&nbsp;&nbsp;
+      </td>
+      <td style="width:325px">
+        #{competitorStrings[1]}
+      </td>
     </tr>
   </table>
-  <table class="table table-striped">
-    <thead>
-      <tr class="odd">
-        <th></th>
-        <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>     
-"""    
+"""
+      modalFooterHtml = """
+<p>
+  <button type="button" class="cancel_tournament_button" class="btn">Save match results and close window</button> &nbsp;&nbsp;&nbsp;&nbsp;
+  <button type="button" class="select_winner_button" class="btn btn-primary">Submit</button>
+</p>
+"""
+      
+    modalBodyHtml += autoWinnerMatchesHtml
+       
+    html = """
+<form class="form-inline" style="margin:0px;">
+  <div class="modal-header">
+    <button type="button" id="close_bootstrap_modal_button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+    <h3>#{modalTitle}</h3>
+  </div>
+  <div class="modal-body" style="overflow-y:none;">
+    #{modalBodyHtml}
+  </div>
+  <div class="modal-footer" style="text-align:left;">
+    #{modalFooterHtml}
+  </div>
+</form>
+"""
 
     $('#bootstrap_modal').html(html)
     $('.bootstrap_tooltip').tooltip()
     @currentAutoWinnerMatches = []
+    
+    return true
     
   letWinnerWinMatchesAgainstCompetitorsWhichLoseAgainstLoser: (winnerId, loserId) ->
     @defeatedCompetitorsByCompetitor[loserId] ||= []

    
    @appointWinnerOfMatch(@currentMatchIndex, winnerId, loserId, true)
    
    unless @nextMatch()
      @sortByMostWins()
      $('#bootstrap_modal').modal('hide')
      
  appointWinnerOfMatch: (matchIndex, winnerId, loserId, decrementMatchesLeft) ->
    window.matches[matchIndex]['winner_competitor'] = winnerId

    
    @matchesLeft = matchesWithoutWinner.length
    
    if @nextMatch(true)
      $('#bootstrap_modal').modal('show')
      
  removeMatchesOfNonExistingCompetitors: () ->
