<?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['pho-title2'];
  $helppage = $TEXT['pho-help2'];

  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(!isset($button)) $button = $TEXT['btn_add'];
  if(!isset($action)) $action = "addphoto.php";
  if(!isset($showhide)) $visible = "checked";

  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'];
  $query = "SELECT MAX(position) AS position FROM `tbl_photo` WHERE `mer_id`='".$_GET['mer_id']."'";
     $query2 = mysql_query($query);
       if(!$query2) puterror2($TEXT['error-tbl13']);
         $res = mysql_fetch_array($query2);
         $pos = $res['position'] + 1;
?>
<form  enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<table>
  <tr><td class="useraddedit"><?php echo $TEXT['tbl-nazv']; ?></td><td class="useraddedit"><input size=50 maxlength=100 class="inputmandatory" type=text name=name /></td></tr>
  <tr><td class="useraddedit"><?php echo $TEXT['tbl-descr']; ?></td><td class="useraddedit"><textarea class=input name="descrip" cols="50" rows="5" /></textarea></td></tr>
  <tr><td class="useraddedit"><?php echo $TEXT['tbl-pic']; ?></td><td class="useraddedit"><input class="inputmandatory" type=file name=image /></td></tr>
  <tr><td class="useraddedit"><?php echo $TEXT['photo_obr']; ?></td><td>
    <select name="photo_obr">
  <option value='1' selected><?php echo $TEXT['photo_no']; ?>
  <option value='2' ><?php echo $TEXT['photo_rec_l']; ?>
  <option value='3' ><?php echo $TEXT['photo_rec_v']; ?>
  <option value='4' ><?php echo $TEXT['photo_rec_l_t']; ?>
  <option value='5' ><?php echo $TEXT['photo_rec_v_t']; ?>
    </select>
   </td></tr>
  <tr><td class="useraddedit"><?php echo $TEXT['tbl-pic2']; ?></td><td class="useraddedit"><input class="inputmandatory"  type=file name=image2 /></td></tr>
  <tr><td class="useraddedit"><?php echo $TEXT['tbl-position']; ?></td><td class="useraddedit"><input size=11 maxlength=11 class="inputmandatory" type=text name=position value="<?php echo $pos; ?>" /></td></tr>
  <tr><td class="useraddedit"><?php echo $TEXT['tbl-show']; ?></td><td><input type=checkbox name=visible <?php echo $visible; ?> /></td></tr>
  <tr><td></td><td>
<input class="button" type=submit value='<?php echo $button; ?>' />
<input type=hidden name=mer_id value='<?php echo $mer_id; ?>' />
</td></tr>
</table>
</form>
<?php
  require_once "../util/bottom.php";
?>