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

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

  $title=$titlepage = $TEXT['inst-title4'];
  $helppage = $TEXT['inst-help4'];
  require_once "../config.php";
  require_once "../util/top.php";

  if($result2['master'] == 1) puterror2($TEXT['error-loginform4']);
  if($result2['manager'] == 1) puterror2($TEXT['error-loginform4']);
?>
 <img alt="<?php echo $TEXT['inst-add-new']; ?>" src= "../img/insert.png" height="15" align="top" /><a class="boldit" href="addform.php" title="<?php echo $TEXT['inst-add-new-tit']; ?>"><?php echo $TEXT['inst-add-new']; ?></a>
 <br />
 <br />
 <span class="tabledata"><?php echo $TEXT['inst-text1']; ?></span>
<table class="table" border="1" cellpadding="4" cellspacing="0" width="60%">
<?php
     $query = "SELECT * FROM `tbl_razdel_instr` ORDER BY `position`";
     $result = mysql_query($query);
     if(!$result) puterror2($TEXT['error-tbl19']);
       if(mysql_num_rows($result)>0);
         {
           echo "<tr class='tableheadercat'>
            <td>".$TEXT['inst-field1']."</td>
            <td>".$TEXT['tbl-razd']."</td>
            <td>".$TEXT['tbl-position']."</td>
            <td>".$TEXT['tbl-visible']."</td>
            <td colspan=3>".$TEXT['tbl-action']."</td>
                 </tr>";
             while($result_razd = mysql_fetch_array($result,MYSQL_ASSOC))
              {
              if($result_razd['visible']=='show') $razd_vis="<a href=hide.php?razd_id=".$result_razd['razd_id']." title='".$TEXT['tbl-hide-tit3']."'><img alt='".$TEXT['tbl-show']."' src='../img/show.png' height='16' width='16' align='top' /></a>";
                else $razd_vis="<a href=show.php?razd_id=".$result_razd['razd_id']." title='".$TEXT['tbl-show-tit3']."'><img alt='".$TEXT['tbl-hide']."' src='../img/hide.png' height='16' width='16' align='top' /></a>";

                $edit = "<a href=editform.php?razd_id=".$result_razd['razd_id']." title='".$TEXT['tbl-edit-tit-razd']."'>".$TEXT['tbl-edit']."</a>";
                $delete = "<a href=deleteform.php?razd_id=".$result_razd['razd_id']." title='".$TEXT['tbl-delete-tit-razd']."'>".$TEXT['tbl-delete']."</a>";
                $instind = "<a href=instindex.php?razd_id=".$result_razd['razd_id']." title='".$TEXT['tbl-visible-razd']."'>".$result_razd['razdel']."</a>";
                $move_up = "<a href=up-down.php?razd_id=".$result_razd['razd_id']."&amp;position=".$result_razd['position']."&amp;moving=up title='".$TEXT['global-up-down-tit']."'><img alt='up' src='../img/up.png' height='16' width='16' align='top' /></a>";
                $move_down = "<a href=up-down.php?razd_id=".$result_razd['razd_id']."&amp;position=".$result_razd['position']."&amp;moving=down title='".$TEXT['global-up-down-tit']."'><img alt='down' src='../img/down.png' height='16' width='16' align='top' /></a>";

                if(!empty($result_razd['photo']) && file_exists("../".$result_razd['photo']))
               {
                $picture = "<img alt='picture' src='../".$result_razd['photo']."' />";
               }
                else $picture = $TEXT['error-photo-no'];
                ?>
                <tr class='tabledata' onmouseover="this.style.backgroundColor='#cccccc';" onmouseout="this.style.backgroundColor='#ffffff';">
                      <td><?php echo $picture; ?></td>
                      <td><?php echo $instind; ?></td>
                      <td><?php echo $result_razd['position']; ?></td>
                      <td><?php echo $razd_vis; ?></td>
                      <td><?php echo $move_up; ?> <?php echo $move_down; ?></td>
                      <td><?php echo $edit; ?></td>
                      <td><?php echo $delete; ?></td>
                      </tr>
                <?php
              }
         }
?>
</table>
<?php
  require_once "../util/bottom.php";
?>