<?
global $lang;

if ( isset( $this -> _entries ) && is_array( $this -> _entries ) ) foreach ( $this -> _entries as $entry )
{
	?>
		<div class='guest_book_entry'>
			<div class='guest_book_signature'>
				<span><?=$entry['signature'];?></span>
				<?=$entry['date'];?>
			</div>
			<div class='text'><?=$entry['text'];?></div>
		</div>
	<?
}
else
{
	?><div class='alert'><?=$lang -> getTrans( 'T_BRAK_WPISOW_KSIEGA_GOSCI' );?></div><?
}
?>
<div class='guest_book_add_entry'>
  <table id="table_contact">
    <tr>
      <td style='width:20%; text-align:right;'>
        <?=ucfirst( $lang -> getTrans( 'T_PODPIS' ) );?>:
      </td>
      <td>
        <input type='text' id="signature" name='signature' style='width:150px;'>
      </td>
    </tr>
    <tr>
      <td style='text-align:right;'>
        <?=ucfirst( $lang -> getTrans( 'T_TRESC' ) );?>:
      </td>
      <td>
        <textarea id="text" name='text' cols='30' rows='6' style='width:300px;'></textarea>
      </td>
    </tr>
    <tr>
      <td style='text-align:right;'>
        <?=ucfirst( $lang -> getTrans( 'T_KOD' ) );?>:
      </td>
      <td>
        <input type="text" id="captcha_code" name="captcha_code" maxlength="6">
      </td>
    </tr>
    <tr>
      <td></td>
      <td>
        <img id="captcha" src="/resources/securimage/securimage_show.php" alt="CAPTCHA Image" />
      </td>
    </tr>
    <tr>
      <td style='text-align:center; padding-top:10px;' colspan='2'>
        <div class='button' onClick='sendGuestBookEntry()'><?=$lang -> getTrans( 'T_DODAJ_WPIS' );?></div>
      </td>
    </tr>
  </table>
</div>
<script type='text/javascript'>
  function sendGuestBookEntry()
  {
    var signature = $("#signature").val();
    var code      = $("#captcha_code").val();
    var text      = $("#text").val();
    $.prompt('<?=$lang -> getTrans( 'T_TRWA_WYSYLANIE_FORMULARZA' );?>');
    xajax_sendGuestBookEntry( signature , text , code , '<?=date( 'Y-m-d H:i:s' );?>' , '<?=\System::getSessionVar( 'token' );?>' );
  }
</script>