<? if ( is_array( $this -> _messages ) ):?>
  <div id="messages">
    <div id="title"><span class="icon right" onclick="showMessages();"></span>Komunikaty:</div>
    <div id="content">
      <? foreach ( $this -> _messages as $msg ):?>
        <div class="message">
          <div class="text">
            <a href="<?= $msg['link'];?>">
              <?= $msg['text'];?>
            </a>
          </div>
          <a class="delete" href="#" onclick="$( this ).parent( '.message' ).hide(); xajax_markMessageAsReaded( <?= $msg['id'];?> ); return false;">
            <i class="icon-delete"></i>
          </a>
          <div class="date"><span><?= date( 'H:i', strtotime( $msg['date'] ) );?></span><br /><?= date( 'Y-m-d', strtotime( $msg['date'] ) );?></div>
          <div class="clearfix"></div>
        </div>
      <? endforeach;?>
    </div>
  </div>
  <div id="messages-show">
    <span class="icon left" onclick="hideMessages();"></span>
  </div>
<? endif; ?>
<script type="text/javascript">
  function showMessages() {
     $( "#messages" ).animate({
      right: "-400"
      }, 500, function(){
        $( "#messages-show" ).animate({
          right: "0"
          }, 500
        )
    });
  }
  
  function hideMessages() {
     $( "#messages-show" ).animate({
      right: "-35"
      }, 500, function(){
        $( "#messages" ).animate({
          right: "0"
          }, 500
        )
    });
  }
</script>
