<?php
  ///////////////////////////////////////////////////
  //2007 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////

  $lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0,2);
  if(is_file ("lang/".$lang.".php")) include "lang/".$lang.".php";
     else include "lang/ru.php";

  $title=$titlepage=$TEXT['global-inst'];

  require_once "config.php";
  require_once "utils/top_razd_inst.php";

  if(strlen($_GET['k'])>8) puterror2($TEXT['error-paging1']);
  if(empty($_GET['k'])) $_GET['k']=0;
  $stop_r = $_GET['k'];
  if($stop_r == 0) $lim_ogr = "20";
   else $lim_ogr = $stop_r.",20";

  $ktblvis = $stop_r+20;
  $str = $ktblvis/20;
?>
<table class="table" border="0" cellpadding="1" cellspacing="0" width="70%">
<?php
  $query1 = "SELECT * FROM `tbl_razdel_instr` WHERE `visible` = 'show' ORDER BY position LIMIT $lim_ogr";
  $result = mysql_query($query1);
    if(!$result) puterror($TEXT['error-tbl19']);
       if(mysql_num_rows($result)>0);
        {
           while($razd = mysql_fetch_array($result,MYSQL_ASSOC))
             {
             $sm = preg_replace("/\.\.+./","",$razd['photo']);
              if(!empty($razd['photo']) && file_exists($sm)) $ima = "<img alt='picture' src='personal/".$razd['photo']."'>";
               else $ima = " &nbsp; ";
                echo "<tr align='left'>
                       <td width='3%' >".$ima."</td>
                       <td><a href='instructions.php?razd_id=".$razd['razd_id']."'><span class='support4'>".$razd['razdel']."</span></a></td>
                      </tr>";
             }
        }
?>
</table>
     <?php
       $query_count = mysql_query("SELECT COUNT(razd_id) FROM tbl_razdel_instr WHERE `visible` = 'show' ");
       $coun_rows = mysql_result($query_count, 0);
               $pag = $coun_rows/20;
               if($pag<=1) $pag = ceil($pag);
                else
                {
                 ?>
                  <hr align="center" width="80%"/>
                  <table align="center" border="0" cellpadding="0" cellspacing="0" width="60%" >
                   <tr align="center">
                    <td>
                <?php
                $pag=ceil($pag);
                $strn = $str-5;
                if($strn<1) $strn=1;
                $strk = $str+5;
                for($i=$strn; $i<=$pag; $i++)
                 {
                  if($i<=$strk)
                  {
                    if($i==$str)
                    {
                      $k = $i*20-20;
                      $kvis=$k+20;
                      $nvis=$k;
                      echo $pg = " <a class='zagolovok' href='razdel_inst.php?k=".$k."' title='".$TEXT['zhurn-details2'].$nvis.$TEXT['zhurn-details1'].$kvis."'>".$i."</a>";
                    }
                    else
                    {
                    $k = $i*20-20;
                    $kvis=$k+20;
                    $nvis=$k;
                    echo $pg = " <a href='razdel_inst.php?k=".$k."' title='".$TEXT['zhurn-details2'].$nvis.$TEXT['zhurn-details1'].$kvis."'>[".$i."]</a>";
                    }
                  }
                 }
                 ?>
                    <select name='k' onchange=window.location.href=this.options[this.selectedIndex].value;>
                    <?php
                    for($j=1; $j<=$pag; $j++)
                    {
                     $k = $j*20-20;
                     if($k == $_GET['k']) echo "<option selected value=razdel_inst.php?k=".$k.">".$j."</option>";
                       else echo "<option value=razdel_inst.php?k=".$k.">".$j."</option>";
                    }
                    ?>
                    </select>
                    </td>
                   </tr>
                  </table>
                 <?php
                }
               ?>
</div>
<?php
  require_once "utils/bottom.php";
?>