<?php
include ("txt/header.php");
?> 
<script language="JavaScript">
auth="notauth";
<?php
if (isset($cookpass_auc) && isset($cookname_auc)) {
echo "auth=\"yes\";\n";
}
?>
function check(p) {
if (auth=="yes") {
if (form.bid.value=="" || isNaN(form.bid.value) || form.bid.value<=p) {
alert ("Заполните правильно обязательные поля!");
}
else {
form.submit();
}
}
else {
alert ("Авторизуйтесь, пожалуйста!");
}
}
</script>
<table width="560" border="0" cellspacing="0" cellpadding="0">
<tr> 
<td height="22" class="menu">
<div align="center">
Просмотр товара
</div>
</td>
</tr>
<tr> 
<td align="center" valign="top" class="menu"><table width="560" border="0" cellspacing="1" cellpadding="0">
<tr>
<td align="center" valign="top" bgcolor="#FFFFFF"><table width="550" border="0" cellspacing="5" cellpadding="0">
<tr> 
<td>
<center>
<?php
if (isset($_GET['com'])) {
$com=$_GET['com'];
}
if (!isset($com) || $com==" ") {
die('Не выбран товар!');
} 
$com=mysql_escape_string($com);
$query="select * from goods where (first='$com')";
$res=mysql_query($query);
$total=mysql_num_rows($res);
if ($total<=0) {
die('Такой товар не существует!');
}
$row=mysql_fetch_assoc($res);
$name=$row["name"];
$name=stripslashes($name);
$cat=$row["parent"];
$query="select name from subcategories where (first='$cat')";
$cats=mysql_query($query);
$rowcats=mysql_fetch_assoc($cats);
$name_of_category=$rowcats["name"];
$type=$row["type"];
$typeshow=str_replace ("one","Уникальный",$type);
$typeshow=str_replace ("mult","Несколько одинаковых",$typeshow);
$typeshow=str_replace ("unlim","Неограниченное количество",$typeshow);
$price=$row["price"];
$mprice=$row["mprice"];
$quantity=$row["quantity"];
$descr=$row["descr"];
$descr=stripslashes($descr);
$photo=$row["photo"];
$bid_of_good=$row["bid"];
if ($bid_of_good==0) {
$bid_of_good="нет";
}
$buyer=$row["buyer"];
if ($buyer=="no") {
$buyer_show="нет предложений";
}
else {
$query="select name from users where (crcname='$buyer')";
$user_res=mysql_query($query);
$row_user=mysql_fetch_assoc($user_res);
$buyer_show=$row_user["name"];
$buyer_show="<a href=\"profile.php?user=$buyer\"><u>$buyer_show</u></a>";
}
$id=$row["first"];
?>
<center>
<br>
<table class='t'>
<tr bgcolor=white>
<td><b>Название:</b></td><td><center><?php echo $name; ?></td>
</tr>
<tr bgcolor=white>
<td><b>Категория:</b></td><td><center><?php echo "<a href='goods.php?subcat=$cat'><u>$name_of_category</a></u>"; ?></td>
</tr>
<tr bgcolor=white>
<td><b>Тип аукциона:</b></td><td><center><?php echo $typeshow; ?></td>
</tr>
<tr bgcolor=white>
<td><b>Начальная цена:</b></td><td><center><?php echo $price; ?></td>
</tr>
<tr bgcolor=white>
<td><b>Цена моментальной продажи:</b></td><td><center><?php echo $mprice; ?></td>
</tr>
<?php
if ($type=="one") {
echo "<tr bgcolor=white>";
echo "<td><b>Текущая ставка: </b></td><td><center>$bid_of_good</td>";
echo "</tr>";
echo "<tr bgcolor=white>";
echo "<td><b>Наивысшую цену предложил: </b></td><td><center>$buyer_show</td>";
echo "</tr>";
}
if ($type=="mult") {
echo "<tr bgcolor=white><td><b>Количество:</b></td><td><center>$quantity</td></tr>";
}
?>
<tr bgcolor=white>
<td><b>Описание:</b></td><td><?php echo $descr; ?></td>
</tr>
</table>
<br>
<form action="bid.php" name=form method="post">
Сумма 
<?php
if ($type=="one") {
if ($bid_of_good=="нет") {
echo "(не менее $price): ";
}
else {
echo "(более $bid_of_good): ";
}
echo "<input type=text size=7 maxlength=15 name='bid'> ";
}
else {
echo "$price ";
echo "<input type=hidden name=bid value='$price'>";
}
?>
<input type=hidden name=com value='<?php echo "$com"; ?>'>
<input type=button value="<?php if ($type=="one") { echo "Сделать ставку"; } else { echo "Купить"; } ?>" onClick="check(<?php if ($bid_of_good=="нет") { echo $price-0.00001;} else { echo $bid_of_good; } ?>)"> 
<?php
if ($type=="mult") {
echo "(один товар из $quantity имеющихся)"; 
}
?>
</form>
<center>
<?php
if (file_exists("photos/$photo") && $photo!="") {
echo "<img src='photos/$photo'>";
}
?>
</td>
</tr>
</table></td>
</tr>
</table></td></tr></table>
<br>
</td>
</tr>
</table></td>
</tr>
<?php
include ("txt/footer.php");
?> 

