<?
global $lang;
?>
<div class='article_draw'>
	<? if ( $this -> _article -> _values['print'] ):?>
		<a class='print' href='print.php?art=<?= $this -> _article -> _values['id'];?>' target='_blank'>
			<img src='images/system/sico_print.png' alt='<?= $lang -> getTrans('T_DRUKUJ' );?>' style='border:0px;'>
		</a>
  <? endif;?>
  <? if ( $this -> _article -> _values['show_title'] ):?>
		<div class='article_draw_title'>
			<?= stripslashes( $this -> _article -> _values['title'] );?>
		</div>
  <? endif;?>
  <? if ( $this -> _article -> _values['show_date'] ):?>
    <div class='article_draw_date'>
      <?= $lang -> getTrans( 'T_DATA_PUBLIKACJI' );?>: <?= date( 'H:i d/m/Y', strtotime( $this -> _article -> _values['date_add'] ) );?>
    </div>
  <? endif;?>
  <? if ( $this -> _article -> _values['show_author'] ):?>
    <div class='article_draw_author'>
      <? 
        $user = \user\FUser::getUserName( $this -> _article -> _values['author'] );
        echo $user['name'] . ' ' . $user['surname'];
      ?>
    </div>
  <? endif;?>
  <? if ( $this -> _article -> _values['thumbnail'] ):?>
    <div class="article-left">
      <div class="article_img">
        <div style="background: url( 'resources/thumber.php?img=<?= $this -> _article -> _values['thumbnail'];?>&h=150&w=150' ) no-repeat center;"></div>
      </div>
    </div>
    <div class="article-right">
  <? endif;?>
    <div class='article_draw_text'><?= $this -> _article -> getModifyText();?></div>
    <? if ( is_array( $this -> _article -> _values['images'] ) ):?>
      <div class="article_gallery">
        <? foreach ( $this -> _article -> _values['images'] as $img ):?>
          <a href='<?=$img['src'];?>' class="fancybox-buttons" rel='<?= $this -> _article -> _values['id'];?>'>
            <div class="gallery_picture">
              <div style="background: url( 'resources/thumber.php?img=<?= $img['src'];?>&h=200&w=200' ) no-repeat center;"></div>
            </div>
          </a>
          <? endforeach;?>
        <div class="clear"></div>
      </div>
    <? endif;?>
    <? if ( is_array( $this -> _article -> _values['files'] ) ):?>
      <ul class="article_files">
        <? foreach ( $this -> _article -> _values['files'] as $file ):?>
          <li>
            <a href="pobierz,<?= $file['id'];?>">
              <?= $file['name'];?>
            </a>
          </li>
        <? endforeach;?>
      </ul>
    <? endif;?>
    <div class="clearfix"></div>
  <? if ( $this -> _article -> _values['thumbnail'] ):?>
    </div>
    <div class="clearfix"></div>
  <? endif;?>
</div>
<a href="#" class="article_back" onClick="javascript:history.go(-1); return false;"><?= $lang -> getTrans( 'T_WSTECZ' );?></a>
<div class="clearfix"></div>
<? if ( $this -> _article -> _values['comments_enabled'] ):?>
  <div class="comments_container" id="comments_container_<?= $this -> _article -> _values['id'];?>">
    <? 
      if ( is_array( $this -> _article -> _values['comments'] ) ) foreach ( $this -> _article -> _values['comments'] as $comment )
      {
        ?>
          <div class="comments">
            <div class="comments_author"><?= $comment['author'];?></div>
            <div class="comments_date"><?= $comment['date_add'];?></div>
            <div class="comments_text"><?= $comment['text'];?></div>
          </div>
        <?
      }
    ?>
  </div>
  <div id="comment_form">
    <form method="POST" action="" id="comment_form_add">
      <input type="hidden" name="rw" value="add_comment" />
      <input type="hidden" name="article_id" value="<?= $this -> _article -> _values['id'];?>" />
      <input type="hidden" name="check" value="<?= mktime();?>" />
      <div class="group">
        <label><?= $lang -> getTrans( 'T_AUTOR' );?></label>
        <div class="content">
          <input type="text" name="author" id="author" />
        </div>
      </div>
      <div class="group">
        <label><?= $lang -> getTrans( 'T_TRESC' );?></label>
        <div class="content">
          <textarea name="text" id="text"></textarea>
        </div>
      </div>
      <div class="group">
        <label><?= $lang -> getTrans( 'T_KOD' );?></label>
        <div class="content">
          <img id="captcha" src="/resources/securimage/securimage_show.php" alt="CAPTCHA Image" />
          <input type="text" name="captcha_code" id="captcha_code" size="10" maxlength="6" />
          <a href="#" onclick="document.getElementById('captcha').src = '/resources/securimage/securimage_show.php?' + Math.random(); return false"><?= $lang -> getTrans( 'T_ODSWIEZ' );?></a>
        </div>
      </div>
      <div class="group">
        <label></label>
        <div class="content">
          <a href="#" class="button" onclick="sendCommentForm(); return false;"><?= $lang -> getTrans( 'T_DODAJ_KOMENTARZ' );?></a>
        </div>
      </div>
    </form>
  </div>
<? endif;?>

<script type="text/javascript">  
  function sendCommentForm()
  {
    if ( $( "#author" ).val() == '' ) {
      $( '#author' ).addClass( 'error' );
      return false;
    } else
      $( '#author' ).removeClass( 'error' );
    
    if ( $( "#text" ).val() == '' ) {
      $( '#text' ).addClass( 'error' );
      return false;
    } else
      $( '#text' ).removeClass( 'error' );
    
    
    if ( $( "#captcha_code" ).val() == '' ) {
      $( '#captcha_code' ).addClass( 'error' );
      return false;
    } else
      $( '#captcha_code' ).removeClass( 'error' );    
    
    $( '#comment_form_add' ).submit();
  }
</script>