<?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-photo'];

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

  if(empty($_GET['mer_id'])) puterror($TEXT['error-mer1']);
  if(strlen($_GET['mer_id'])>11) puterror($TEXT['error-mer2']);
  $_GET['mer_id'] = rep($_GET['mer_id']);

  $mer_id = $_GET['mer_id'];

     $query_mer = "SELECT * FROM `tbl_meropriyatiya` WHERE `mer_id` = '$mer_id'";
     $result_mer = mysql_query($query_mer);
     if(!$result_mer) puterror($TEXT['error-tbl12']);
       if(mysql_num_rows($result_mer)>0);
         $result_merop = mysql_fetch_array($result_mer,MYSQL_ASSOC);
         $meropriyatie = $result_merop['meropriyatie'];
?>
<span class='photoalbtit'><?php echo $meropriyatie; ?></span>
<br />
<br />
<table border="0" width="100%">
<?php
  $query = "SELECT * FROM `tbl_photo` WHERE `mer_id`='".$_GET['mer_id']."' AND `visible`='show' ORDER BY position ";
     $query2 = mysql_query($query);
       if(!$query2) puterror($TEXT['error-tbl13']);
       if(mysql_num_rows($query2)>0)
        {
         $td = 0;
         while($photo = mysql_fetch_array($query2,MYSQL_ASSOC))
         {
         $sm = preg_replace("/\.\.+./","",$photo['small']);
         $big = preg_replace("/\.\.+./","",$photo['big']);
          if(!empty($photo['small']) && file_exists($sm))
           {
           $ext = strrchr($photo['small'], ".");
           $image = "<a href='".$big."' target=_blank title='".$photo['description']."'><img alt='picture'  src='".$sm."'></a>";
           if($td == 0)
            {
             echo "<tr>";
            }
           if($td < 7) 
            {
           ?>
<td>
<table border=0 width=100%>
 <tr align=center><td><?php echo $image; ?></td></tr>
 <tr><td class="photoname"><?php echo $photo['name']; ?></td></tr>
</table>
</td><?php
            $td++;
            }
           if($td == 5)
            {
             echo "</tr>";
             $td = 0;
            }
           }
         }
         if($td > 0 && $td < 5)
          {
           echo "</tr>";
          }
        }
?>
</table>
<?php
  require_once "utils/bottom.php";
?>