<? global $lang;?>
<fieldset>
  <?
  if ( isset( $this -> _filtr ) )
    include 'templates/data-browse-filtr.php';
  ?>
    <table class='table_browse' style='min-width:500px;'>
      <thead>
        <tr>
        <?
        $i = 0;
        if ( is_array( $this -> _table_headers ) ) foreach ( $this -> _table_headers as $key => $val )
        {
          if ( $i == 1 && $this -> _checkbox )
            echo '<th class="header" style="width: 20px;"></th>';
          ?>
          <th class='header'<? if (!$val['value'] || $val['value'] == 'Lp.') echo "style='width:15px;'";?>
            <?
            if ( isset( $val['sort'] ) )
            {
              ?>
              style='cursor:pointer;'
              onClick="document.location.href='index.php?s=<?=$val['sort'];?>';">
              <?
              if ( $val['way'] == 'ASC')
              {
                ?><img src='../images/system/sico_sort_asc.png'><?
              }
              else if ( $val['way'] == 'DESC' )
              {
                ?><img src='../images/system/sico_sort_desc.png'><?
              }
              echo ucfirst( $val['value'] );
            }
            else
            {
              ?>><?=ucfirst( $val['value'] );?><?
            }
            ?>
          </th>
          <?
          $i++;
        }
        ?>
        </tr>
      </thead>
      <?
      if ( $this -> _row_count )
      {
        ?>
        <tbody>
          <?
          $i = 0;
          foreach ( $this -> _table_values as $key => $val )
          {
          ?>
            <div class="contextMenu" id="menu<?=$i;?>" style='display:none;'>
            <ul>
            <?
            if ( isset( $val[ $lang -> getTrans( 'T_EDYTUJ' ) ] ) )
            {
              ?><li id="open" class="context_menu"><?=$val[ $lang -> getTrans( 'T_EDYTUJ' ) ]['value'];?></li><?
            }
            if ( isset( $val [ $lang -> getTrans( 'T_POKAZ' ) ] ) )
            {
              ?><li id="show" class="context_menu"><?=$val[ $lang -> getTrans( 'T_POKAZ' ) ]['value'];?></li><?
            }
            if ( isset( $val[ $lang -> getTrans( 'T_USUN' ) ] ) )
            {
              ?><li id="delete" class="context_menu"><?=$val[ $lang -> getTrans( 'T_USUN' ) ]['value'];?></li><?
            }
            ?>
            </ul>
            </div>
            <script type='text/javascript'>
            $(document).ready(function(){
              $('.menu<?=$i;?>').contextMenu('menu<?=$i;?>', {
              itemStyle: {
                backgroundColor: '#E5E5E5',
              },
              itemHoverStyle: {
                backgroundColor: '#FFFFFF',
                border: '1px solid #FFFFF',
              }
              });
            });
            </script>
            <tr class="menu<?=$i;?>">
              <?
              $j = 0;
              foreach ( $val as $value )
              {
                ?>
                <td class='row' style='<?=$this -> eprint( $value['style'] );?>'>
                  <?
                  if ( $value['value'] )
                    echo stripslashes( $value['value'] );
                  else
                    echo '-';
                  ?>
                </td>
                <?
                $j++;
              }
              ?>
            </tr>
            <?
            $i++;
          }
          ?>
        </tbody>
        <?
      }
      else
      {
        ?>
        <tr>
          <td colspan='<?=count( $this -> _table_headers );?>' style='text-align:center;'>
            <div class='alert' style='text-align:center;'><?=$lang -> getTrans( 'T_BRAK_WYNIKOW' );?></div>
          </td>
        </tr>
        <?
      }
      ?>
    </table>
    <? include 'templates/data-browse-paging.php'; ?>
</fieldset>
<script type='text/javascript'>
  $(document).ready(function(){
    $("li").children("a").children("span.edit").parent('a').append( '<?=$lang -> getTrans( 'T_EDYTUJ' );?>' );
    $("li").children("a").children("span.delete").parent('a').append( '<?=$lang -> getTrans( 'T_USUN' );?>' );
    $("li").children("a").children("span.show").parent('a').append( '<?=$lang -> getTrans( 'T_POKAZ' );?>' );
    var cssObj = {
      'display' : 'block',
      'height' : '30px',
      'line-height' : '30px',
      'color' : '#000000',
      'font-size' : '10px',
      'padding-left' : '5px',
      'text-transform' : 'uppercase'
    }
    $("li.context_menu").children("a").css( cssObj );
    var cssObj2 = {
      'float' : 'left',
      'margin' : '5px 5px 0 0',
      'color' : '#000000',
      'font-size' : '10px',
      'padding-left' : '5px',
      'text-transform' : 'uppercase'
    }
    $("li.context_menu").children("a").children("span.edit").css( cssObj2 );
    $("li.context_menu").children("a").children("span.delete").css( cssObj2 );
    $("li.context_menu").children("a").children("span.show").css( cssObj2 );
  });
 </script>