<script type="text/javascript">
 
  ax_change_id = -1;

  $("tr.NotesTableRow").click(function(){
    selectNotesTr(this.id)});
    
  $("span#lemma-notes-count").empty();
  $("span#lemma-notes-count").append("{{ messages|length }}");

</script>

<div id='add_lemma_note'>
  <form class="lemma-notes-form" method="post"> {% csrf_token %}
    {{ add_note_form.as_p }}
    <p class="lexeme-save">
      <button type="submit" id="lemma-notes-form-submit">
        Zapisz
      </button>
      <button type="reset" id="lemma-notes-form-cancel">
        Wyczyść
      </button>
    </p>
  </form>
</div>

<div id="show_lemma_notes">
  {% if messages %}
    <p>
      <strong>Notatki:</strong>
    </p>
    <table class='ChangeControlTable' id='lemma-notes-table'>
	  <tr> 
	    <td class='ColumnHeader'>Data dodania:</td> 
	    <td class='ColumnHeader'>Temat wiadomości:</td>
	    <td class='ColumnHeader'>Nadawca:</td>
	  </tr>
	  {% for message in messages %}
	    <tr class='NotesTableRow' id="note_{{message.id}}"> 
		  <td>{{message.time}}</td> 
		  <td>{{message.topic}}</td>
		  <td>{{message.sender.username}}</td>
	    </tr>
	  {% endfor %}
    </table>	
  {% endif %}
  {% if private_messages %}
    <p>
      <strong>Prywatne notatki:</strong>
    </p>
    <table class='ChangeControlTable' id='lemma-notes-table'>
	  <tr> 
	    <td class='ColumnHeader'>Data modyfikacji:</td> 
	    <td class='ColumnHeader'>Temat wiadomości:</td>
	    <td class='ColumnHeader'>Nadawca:</td>
	  </tr>
	  {% for message in private_messages %}
	    <tr class='NotesTableRow' id="note_{{message.id}}"> 
		  <td>{{message.time}}</td> 
		  <td>{{message.topic}}</td>
		  <td>{{message.sender.username}}</td>
	    </tr>
	  {% endfor %}
    </table>	
  {% endif %} 
  <p>
    <button type="button" id="remove_lemma_note" style="width:120px">Usuń</button>
    <button type="button" id="modify_lemma_note" style="width:120px">Modyfikuj</button>
  </p>
  <p id="lemma_note_text">
  </p>
</div>

<script type="text/javascript">
$(document).ready(function() {
  $("button#remove_lemma_note").click(function(){removeLemmaNote(window.selected_notes_row_id)});
  $("button#modify_lemma_note").click(function(){modifyLemmaNote(window.selected_notes_row_id, '.lemma-notes-form')});
  $('.lemma-notes-form #id_message_text').width($(window).width() - $('#left').width() - 60)
});
</script>
