<?php require_once 'protect.php'; ?>
<?php
$resultph = $mysqli->query("SELECT COUNT(id) FROM extras WHERE type=0 AND item_id=$id");
$rows = $resultph->fetch_row();
$rowsph = $rows[0];

$resultpr = $mysqli->query("SELECT id FROM prices WHERE item_id=$id");
$rowspr = mysqli_num_rows($resultpr);
?>
<div class="<?php if ((($image==1 AND $imgitem==0) OR $rowsph>0) AND $typec==2) { echo 'divitem1'; } else { echo 'boximage imgleft'; }?>">
<?php if ($imgitem==1) { ?>
<?php
$result21 = $mysqli->query("SELECT id, insert_id FROM extras WHERE type=0 AND item_id=$id GROUP BY insert_id ORDER BY priority");
$nrrows21 = mysqli_num_rows($result21);
$row = $result21->fetch_array();
$photoid1=$row['insert_id'];
?>
<?php if ($nrrows21>0) { ?>
<a id="thumb<?php echo $photoid1 ?>" href="<?php echo $filepath ?>photos/<?php echo $photoid1 ?>.jpg" onclick="return hs.expand(this)">
<img src="<?php echo $codepath ?>includes/image.php?image=<?php echo $imagepath ?>photos/<?php echo $photoid1 ?>.jpg&amp;nwidth=600" class="<?php if ($typec<2) { echo 'img-info'; } else { echo 'img-gen'; }?>" alt="<?php echo $name ?>" title="<?php echo $name ?>"></a>
<?php } ?>
<?php }else {?>
<?php if ($image==1) { 
list($width, $height) = getimagesize($imgsize."items/".$id.".jpg");
?>
<?php if ($width>500 OR $height>500) { ?>
<a id="thumb<?php echo $id ?>" href="<?php echo $filepath ?>items/<?php echo $id ?>.jpg" onclick="return hs.expand(this)">
<img src="<?php echo $codepath ?>includes/image.php?image=<?php echo $imagepath ?>items/<?php echo $id ?>.jpg&amp;nwidth=600" class="<?php if ($typec<2) { echo 'img-info'; } else { echo 'img-gen'; }?>" alt="<?php echo $name ?>" title="<?php echo $name ?>"></a>
<?php }else{?>
<img src="<?php echo $codepath ?>includes/image.php?image=<?php echo $imagepath ?>items/<?php echo $id ?>.jpg&amp;nwidth=600" class="<?php if ($typec<2) { echo 'img-info'; } else { echo 'img-gen'; }?>" title="<?php echo $name ?>">
<?php } ?>
<?php } ?>
<?php } ?>
<?php if ($url) { ?><div class="margtop20"><a href="<?php echo $url ?>" target="_blank" class="links"><span class="icon fa-link"></span> <?php echo str_replace(array('http://', 'https://'), '', $url); ?></a></div><?php } ?>
</div>
<div<?php if ((($image==1 AND $imgitem==0) OR $rowsph>0) AND $typec==2) { ?> class="divitem2"<?php } ?>>
<?php if ($itemdate) { ?><div class="divdateitem"><?php echo $itemdate ?></div><?php } ?>
<?php if ($code) { ?>
<div class="color3 tstyle"><?php echo $textcode ?> <?php echo $code ?></div>
<?php } ?>
<?php
if ($type==3 OR $type==5) { 
$weight = intval($weight);
}
if ($weight<1) { 
$weight = $weight*$weightunit;
}
if ($weight!='0.00') { ?>
<div class="color3 tstyle"> <?php echo $textweight ?> <?php echo $weight ?> <?php echo $unitweight ?> </div>
<?php } ?>
<div class="divdetails"><?php echo $details ?> 
<div class="titlesec color2"><?php echo $secategory1 ?> <?php if ($secategory1) { echo '&raquo;'; } ?>  <?php echo $secategory ?></div>
</div>
<?php if ($extra) { ?><div class="boxextra"><?php echo $textextra ?> <?php echo $extra ?></div><?php } ?>
<div class="margbottom20"><?php echo $text ?></div>
</div>
<!--specs -->
<div class="divitem3">
<?php
$result11 = $mysqli->query("SELECT * FROM categories WHERE type=3 AND lang_id=$lang AND publish='yes' ORDER BY priority");
while($row = $result11->fetch_array()) {	
$scatid=$row['insert_id'];
$scategory=$row['name'];

$result12 = $mysqli->query("SELECT id FROM extras WHERE type=1 AND item_id=$id AND category_id='$scatid' AND lang_id=$lang");
$nrrows12 = mysqli_num_rows($result12);
?>
<?php if ($nrrows12>0) {?>
<div class="divextras">
<div class="extrascat color3 bordercolor2"><?php echo $scategory ?></div>
<div class="arrowcat color2"></div>
<?php
$result13 = $mysqli->query("SELECT * FROM extras WHERE type=1 AND item_id=$id AND category_id='$scatid' AND lang_id=$lang ORDER BY priority");
while($row = $result13->fetch_array()) {	
$extraid=$row['insert_id'];
$extra=$row['name'];
$color=$row['color'];
$simage=$row['image'];
$sfile=$row['file'];
?>
<div class="divextra">
<?php if ($color) {?><div class="divcolor" style="background: #<?php echo $color ?>;"></div><?php } ?>
<?php if ($simage==1) { 
list($width, $height) = getimagesize($imgsize."extras/".$extraid.".jpg");
?>
<?php if ($width>500 OR $height>500) { ?>
<a id="thumb<?php echo $extraid ?>" href="<?php echo $filepath ?>extras/<?php echo $extraid ?>.jpg" onclick="return hs.expand(this)"><img src="<?php echo $codepath ?>includes/image.php?image=<?php echo $imagepath ?>extras/<?php echo $extraid ?>.jpg&amp;nwidth=200" class="img-extra" alt="<?php echo $extra ?>" title="<?php echo $extra ?>"></a>
<?php }else{?>
<img src="<?php echo $codepath ?>includes/image.php?image=<?php echo $imagepath ?>extras/<?php echo $extraid ?>.jpg&amp;nwidth=200" class="img-extra" alt="<?php echo $extra ?>" title="<?php echo $extra ?>">
<?php } ?>
<?php } ?> 
<?php if ($sfile) { ?>
<a href="<?php echo $filepath ?>extras/files/<?php echo $extraid?>.<?php echo $sfile ?>" target="blank" class="color3"><span class="icon fa-file-text-o color3 margright10"></span> <?php echo $extra ?></a>
<?php }else{?>
<?php echo $extra ?>
<?php } ?>
</div>
<?php } ?>
</div>
<?php } ?>
<?php } ?>
</div>
<!--end specs -->
<div class="divvideo">
<?php echo $script ?>
</div>
<?php if ($rowsph>0) { ?>
<!--photos -->
<div class="divphotos">
<div class="colscontent margtop20 margbottom20">
<?php
$result20 = $mysqli->query("SELECT * FROM extras WHERE type=0 AND item_id=$id AND insert_id!='$photoid1' GROUP BY insert_id ORDER BY priority");
while($row = $result20->fetch_array()) {
$phcount++;
$photoid=$row['insert_id'];
$ppriority=$row['priority'];

$result = $mysqli->query("SELECT name FROM extras WHERE insert_id='$photoid' AND lang_id=$lang");
$row = $result->fetch_array(); 
$pname=$row['name'];
$photo=$row['name'];

if ($photo=='') { 
$photo=$name;
}
?>
<?php include 'photo.php';?>
<?php } ?>
</div><div class="cleared"></div>
</div>
<!--end photos -->
<?php } ?>
<!--price -->
<div class="divcart<?php if ($available==1) { echo " bordercolor3"; }?>">
<div class="floatleft<?php if ($price!='0.00' OR $offerprice!='0.00') { echo " padbottom10"; }?>">
<?php include 'itemcart.php';?>
</div>
<div class="floatright">
<?php if ($new==1) { ?>
<span class="strong color3"><?php echo $textnew ?></span>
<?php } ?>
<?php if ($file) { ?>
<a href="<?php echo $filepath ?>items/files/<?php echo $id?>.<?php echo $file ?>" target="blank"><span class="icon fa-file-text-o icstyle color3"></span> <?php echo $textfiles ?></a>
<?php } ?>
</div>
<div class="cleared"></div>
<?php include 'prices.php';?>
<!--request -->
<?php if ($available==0 OR ($type==2 AND $endprice!='0.00' AND $inquiry==0) OR ($type==2 AND $endprice=='0.00' AND $inquiry==1) OR ($type==4 AND $itemail=='')) {  ?>
<?php }else {?>
<?php if (!isset($_POST['submit'])) { ?><div class="trigger"> <div class="button"><?php echo $buttonname ?></div> </div><?php } ?>
<div class="<?php if (!isset($_POST['submit'])) { echo "toggle-container "; }?>margtop20">
<?php include $siteform.'form.php';?>
</div>
<?php } ?>
</div>
<div class="cleared"></div>
<?php if ($groupitem==1) { 
$resultgr = $mysqli->query("SELECT id FROM items WHERE insert_id!=$id AND (insert_id IN (SELECT item_id2 FROM groups WHERE item_id=$id) OR insert_id IN (SELECT item_id FROM groups WHERE item_id2=$id)) AND lang_id=$lang AND publish='yes'");
$nrrowsgr = mysqli_num_rows($resultgr);
?><?php if ($nrrowsgr>0) { ?>
<!--groups -->
<div class="titles4 margtop20 margbottom10"><span class="icon fa-bookmark-o color3"></span> <?php echo $textgroup ?></div>
<?php
$result3 = $mysqli->query("SELECT * FROM items WHERE insert_id!=$id AND (insert_id IN (SELECT item_id2 FROM groups WHERE item_id=$id) OR insert_id IN (SELECT item_id FROM groups WHERE item_id2=$id)) AND lang_id=$lang AND publish='yes' ORDER BY category_id, priority");
while($row = $result3->fetch_array()) {	
$grid=$row['insert_id'];
$category_id=$row['category_id'];
$section_id=$row['section_id'];
$pageid=$row['page_id'];
$pageitem=$row['page'];
if ($itempage==1) { $siteitem=$pageitem; }
$pagesiteitem=$siteitem.".".$pageid;
$name=$row['name'];
$details=$row['details'];
$price=$row['price'];
$price1=$row['price'];
$offerprice=$row['offerprice'];
$image=$row['image'];
$showpage=$row['showpage'];
$priority=$row['priority'];

$resultc = $mysqli->query("SELECT discount, type FROM categories WHERE insert_id=$category_id AND lang_id=$lang");
$row = $resultc->fetch_array();
$discount=$row['discount'];
$typec=$row['type'];
?>
<div class="boxgroup">
<?php if ($image==1) { ?>
<a href="<?php echo $pagesiteitem ?>"><img src="<?php echo $codepath ?>includes/image.php?image=<?php echo $imagepath ?>items/<?php echo $grid ?>.jpg&amp;nwidth=250" class="img-group" alt="<?php echo $name ?>" title="<?php echo $name ?>"></a>
<?php } ?>
<div class="margtop10 margbottom10"><a href="<?php echo $pagesiteitem ?>" class="links"><?php echo $name ?></a></div>
<?php include 'itemprice.php'; ?>
</div>
<?php } ?>
<?php } ?><?php } ?>

<div class="cleared"></div>
<?php 
if ($typei==1) {
$reviewit=$reviewsinfo;
}
if ($typei==2) {
$reviewit=$reviewsitem;
}

if ($reviewit==1) { 
$resultrev = $mysqli->query("SELECT id FROM members WHERE item_id=$id AND publish='yes'");
$nrrowsrev = mysqli_num_rows($resultrev);
?><?php if ($nrrowsrev>0) { ?>
<!--reviews -->
<div class="titles4 margtop20 margbottom10"><span class="icon fa-comments-o color3"></span> <?php echo $textreview ?></div>
<?php
$result4 = $mysqli->query("SELECT * FROM members WHERE item_id=$id AND publish='yes' ORDER BY id desc");
while($row = $result4->fetch_array()) {	
$rid=$row['id'];
$rname=$row['name'];
$rcity=$row['city'];
$rcountry=$row['country'];
$rcomments=$row['comments'];
$rate=$row['rate'];
$rimage=$row['image'];
$date=$row['date'];
?>
<div class="floatleft text2"><div class="number margright10"><?php if ($rate>6) { echo $rate; } else { echo '&nbsp;'; } ?></div> <span class="text"><?php echo $rname ?></span> &nbsp; &nbsp; <?php echo $rcity?> <?php echo $rcountry?></div>
<div class="floatright"><?php echo $date ?></div>
<div class="cleared text2 padtop10"><?php echo $rcomments ?></div>
<hr> 
<?php } ?>
<?php } ?>
<?php include 'review.php';?>
<?php } ?>