<?php
  ///////////////////////////////////////////////////
  //2010 (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['pho-title8'];
  $helppage = $TEXT['pho-help8'];
  require_once "../config.php";
  require_once "../util/top_layer1.php";

  if($result2['master'] == 1) puterror2($TEXT['error-loginform4']);
  if($result2['manager'] == 1) puterror2($TEXT['error-loginform4']);

  if(empty($_GET['mer_id'])) puterror2($TEXT['error-pho15']);
  if(strlen($_GET['mer_id'])>11) puterror2($TEXT['error-pho13']);
  $_GET['mer_id'] = rep($_GET['mer_id']);

  $mer_id = $_GET['mer_id'];
?>
 <img alt="<?php echo $TEXT['pho-add-new2']; ?>" src= "../img/insert.png" height="15" align="top" /><a class="boldit" href="addphotoform.php?mer_id=<?php echo $mer_id; ?>" title="<?php echo $TEXT['pho-add-new-tit2']; ?>"><?php echo $TEXT['pho-add-new2']; ?></a>
 <p><?php echo $TEXT['pho-field4']; ?></p>
 <?php
  $query = "SELECT * FROM `tbl_photo` WHERE `mer_id`='".$_GET['mer_id']."' ORDER BY `position`";
     $query2 = mysql_query($query);
       if(!$query2) puterror2($TEXT['error-tbl13']);
         if(mysql_num_rows($query2)>0)
         {
  ?>
  <table class="bodytable" width="100%" border="1" cellpadding=5 cellspacing=0>
  <?php
    $td = 0;
    while($photo = mysql_fetch_array($query2,MYSQL_ASSOC))
    {
    if($photo['visible'] == 'hide') $strvisible = "<a href=showphoto.php?photo_id=".$photo['photo_id']."&amp;mer_id=".$_GET['mer_id']." title='".$TEXT['tbl-show-tit7']."'>".$TEXT['tbl-show']."</a>";
      else $strvisible = "<a href=hidephoto.php?photo_id=".$photo['photo_id']."&amp;mer_id=".$_GET['mer_id']." title='".$TEXT['tbl-hide-tit7']."'>".$TEXT['tbl-hide']."</a>";

    if($photo['visible']=='show') $pho_vis="<img alt='picture' src='../img/show.png' height='16' width='16' align='top' />";
      else $pho_vis="<img alt='picture' src='../img/hide.png' height='16' width='16' align='top' />";

    $move_up = "<a href=up-down-pho.php?photo_id=".$photo['photo_id']."&amp;mer_id=".$_GET['mer_id']."&amp;position=".$photo['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-pho.php?photo_id=".$photo['photo_id']."&amp;mer_id=".$_GET['mer_id']."&amp;position=".$photo['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($photo['small']) &&
         $photo['small']!="-" &&
         file_exists("../".$photo['small']))
      {
        $image = "<a href='../".$photo['big']."' target=_blank title='".$photo['description']."'' ><img alt='picture' src=../".$photo['small']." /></a>";
      }
      else $small = $TEXT['error-photo-no'];
      if ($td == 0) echo "<tr class='photos'>";
      echo "<td><table border=0 width=100%><tr align='center'>
              <td colspan=2 class='boldit'>".$photo['name']."</td></tr>
              <tr>
                 <td>$image</td>
                 <td align=center class='tabledata'>
                 ".$TEXT['tbl-position'].":".$photo['position']."<br />".$move_up."".$move_down.
                 "<br />".$pho_vis."<br />".$strvisible."<br />
                 <a href=editphotoform2.php?photo_id=".$photo['photo_id']."&amp;mer_id=".$_GET['mer_id']." title='".$TEXT['tbl-edit-tit-pho']."'>".$TEXT['tbl-edit']."</a><br />
                 <a href=delphoto.php?photo_id=".$photo['photo_id']."&amp;mer_id=".$_GET['mer_id']." title='".$TEXT['tbl-delete-tit-pho']."'>".$TEXT['tbl-delete']."</a></td>
            </tr></table></td>";
      $td++;
      if ($td == 3)
      {
        echo "</tr>";
        $td = 0;
      }
    }
  }
?>
</table>
<?php
  require_once "../util/bottom.php";
?>