<?php require_once 'includes/protect.php'; ?>
<div class="navbar hidden-print"><div class="navbarin">
<div class="nav-collapse collapse navbar-main">
<ul class="nav">
<?php
$result50 = $mysqli->query("SELECT insert_id, page, name, type FROM categories WHERE level=1 AND type<3 AND lang_id=$lang AND publish='yes' ORDER BY priority");
while($row = $result50->fetch_array()) {
$ncatid1=$row['insert_id'];
$npage1=$row['page'];
$ncategory1=$row['name'];
$type1=$row['type'];

$result51 = $mysqli->query("SELECT id, insert_id FROM categories WHERE parent=$ncatid1 AND type<3 AND lang_id=$lang AND publish='yes'");
$nrrows51 = mysqli_num_rows($result51);
$row = $result51->fetch_array();
$ncatid12=$row['insert_id'];
	
$result52 = $mysqli->query("SELECT id FROM items WHERE category_id=$ncatid1 AND section_id=0 AND lang_id=$lang AND publish='yes'");
$nrrows52 = mysqli_num_rows($result52);

$result52b = $mysqli->query("SELECT id FROM items WHERE (category_id=$ncatid1 OR category_id IN (SELECT insert_id FROM categories WHERE parent=$ncatid1)) AND section_id>0 AND lang_id=$lang AND publish='yes'");
$nrrows52b = mysqli_num_rows($result52b);
?><?php if ($nrrows52b==0) {?><?php if ($nrrows51>0) {?><li class="dropdown"><?php if ($nrrows52>0) {?><a href="<?php echo $npage1 ?>" <?php if ($catid==$ncatid1 OR $parent==$ncatid1) { echo 'class="dropdown-toggle navactive"'; } else { echo 'class="dropdown-toggle"'; }?> ><?php echo $ncategory1 ?> <span class="caret"></span></a><?php }else{?><a href="#" <?php if ($catid==$ncatid1 OR $parent==$ncatid1) { echo 'class="dropdown-toggle navactive"'; } else { echo 'class="dropdown-toggle"'; }?> ><?php echo $ncategory1 ?> <span class="caret"></span></a><?php } ?><ul class="dropdown-menu"><?php if ($type1==2) { ?><li class="licat"><a href="<?php echo $npage1 ?>"><?php echo $ncategory1 ?><?php echo $textall ?></a></li><?php } ?><?php
$result53 = $mysqli->query("SELECT insert_id, page, name, image FROM categories WHERE parent=$ncatid1 AND lang_id=$lang AND publish='yes' ORDER BY priority");
while($row = $result53->fetch_array()) {
$ncatid2=$row['insert_id'];
$npage2=$row['page'];
$ncategory2=$row['name'];
$nimage2=$row['image'];
?><li><?php if ($imgcat==1 AND $nimage2==2) { ?><img src="<?php echo $codepath ?>includes/image.php?image=<?php echo $imagepath ?>categories/<?php echo $ncatid2 ?>.jpg&amp;nwidth=60" class="img-cat" alt="<?php echo $ncategory2 ?>"><?php } ?><a href="<?php echo $npage2 ?>"<?php if ($catid==$ncatid2) { echo ' class="navactive-submenu"'; }?>><?php echo $ncategory2 ?></a></li><?php } ?></ul></li><?php }else{?><?php if ($ncatid1==1) {?><li><a href="."<?php if ($pagename=='index.php') { echo ' class="navactive"'; }?>><?php echo $ncategory1 ?></a></li><?php }else{?><li><a href="<?php echo $npage1 ?>"<?php if ($catid==$ncatid1) { echo ' class="navactive"'; }?>><?php echo $ncategory1 ?></a></li><?php } ?><?php } ?><?php } ?><?php } ?>
<?php
$resections = $mysqli->query("SELECT COUNT(id) FROM sections WHERE lang_id=$lang AND publish='yes'");
$rows = $resections->fetch_row();
$nrsections = $rows[0];
?><?php if ($nrsections==0) {?>
<?php if ($reviews==1) { ?><li class="navlinks2 navreviews"><a href="reviews"<?php if ($pagename=='reviews.php') { echo ' class="navactive"'; }?>><?php echo $pagereviews ?></a></li><?php } ?><?php if ($siteform!="contact") { ?><?php
$result70 = $mysqli->query("SELECT id FROM prices");
$nrrows70 = mysqli_num_rows($result70);
?><?php if ($type!=4 AND $type!=5 AND $nrrows70>0) {?><li class="navlinks2 navrates"><a href="rates"<?php if ($pagename=='rates.php') { echo ' class="navactive"'; }?>><?php echo $pagerates ?></a></li><?php } ?><li class="navlinks2 navrequest"><a href="request"<?php if ($pagename=='request.php') { echo ' class="navactive"'; }?>><?php echo $pagerequest ?></a></li><?php } ?><?php echo $navigationlinks ?><li class="navlinks2 navcontact"><a href="contact"<?php if ($pagename=='contact.php') { echo ' class="navactive"'; }?>><?php echo $pagecontact ?></a></li>
<?php } ?>
</ul>
</div>
<?php if ($nrsections>0) {?><!--sections -->
<div class="nav-collapse collapse navbar-container">
<ul class="nav">
<?php 
$result60 = $mysqli->query("SELECT insert_id, page, name, title, image FROM sections WHERE level=1 AND lang_id=$lang AND publish='yes' ORDER BY priority");
while($row = $result60->fetch_array()) {
$secid1=$row['insert_id'];
$pagesection1=$row['page'];
$section1=$row['name'];
$sectiont1=$row['title'];
$simage=$row['image'];
$photopath="sections/";
?><li class="dropdown"><a href="#" <?php if ($secid==$secid1 OR $separent==$secid1) { echo 'class="dropdown-toggle navactive"'; } else { echo 'class="dropdown-toggle"';	}?> ><?php echo $section1 ?> <span class="caret"></span></a><ul class="dropdown-menu dropdown-sections"><li class="dropdown-container">
<div class="colorlight divsection"><a href="<?php echo $pagesection1 ?>." title="<?php echo $sectiont1 ?>" class="asection"><span class="icon fa-search-plus"></span> <?php echo $section1 ?></a>
<?php if ($simage!=0 AND (file_exists("./files/".$photopath.$secid1.".jpg"))) { ?>
<img src="<?php echo $codepath ?>includes/image.php?image=<?php echo $imagepath.$photopath ?><?php echo $secid1 ?>.jpg&amp;nwidth=400" class="bordercolor1 img-sec" alt="<?php echo $sectiont1 ?>" title="<?php echo $section1 ?>">
<?php } ?></div>
<?php
$result61 = $mysqli->query("SELECT insert_id, page, name, type FROM categories WHERE level=1 AND insert_id>1 AND type<3 AND lang_id=$lang AND publish='yes' ORDER BY priority");
while($row = $result61->fetch_array()) {
$mcatid1=$row['insert_id'];
$mpage1=$row['page'];
$mcategory1=$row['name'];
$mtype1=$row['type'];

$result62 = $mysqli->query("SELECT COUNT(id) FROM items WHERE category_id='$mcatid1' AND section_id='$secid1' AND lang_id=$lang AND publish='yes'");
$rows = $result62->fetch_row();
$nrrows62 = $rows[0];

$result63 = $mysqli->query("SELECT COUNT(id) FROM items WHERE category_id IN (SELECT insert_id FROM categories WHERE insert_id='$mcatid1' OR parent='$mcatid1') AND section_id>0 AND lang_id=$lang AND publish='yes'");
$rows = $result63->fetch_row();
$nrrows63 = $rows[0];
?><?php if ($nrrows63>0) {?><div class="divsnav"><?php if ($mtype1==2) {?><div class="titlesnav"><a href="<?php echo $pagesection1 ?>.<?php echo $mpage1 ?>"><?php echo $mcategory1 ?></a></div><?php }else{?><div class="titlesnav"><?php echo $mcategory1 ?></div><?php } ?><?php 
$result64 = $mysqli->query("SELECT insert_id, page, name FROM sections WHERE parent='$secid1' AND lang_id=$lang AND publish='yes' ORDER BY priority");
while($row = $result64->fetch_array()) {
$secid2=$row['insert_id'];
$pagesection2=$row['page'];
$section2=$row['name'];

$result65 = $mysqli->query("SELECT COUNT(id) FROM items WHERE category_id='$mcatid1' AND section_id='$secid2' AND lang_id=$lang AND publish='yes'");
$rows = $result65->fetch_row();
$nrrows65 = $rows[0];
?><?php if ($nrrows65>0) {?><a href="<?php echo $pagesection1 ?>-<?php echo $pagesection2 ?>.<?php echo $mpage1 ?>" class="color1">&raquo; <?php echo $section2 ?></a> <?php } ?><?php } ?><?php 
$result66 = $mysqli->query("SELECT insert_id, page, name FROM categories WHERE parent='$mcatid1' AND lang_id=$lang AND publish='yes' ORDER BY priority");
while($row = $result66->fetch_array()) {
$mcatid2=$row['insert_id'];
$mpage2=$row['page'];
$mcategory2=$row['name'];

$result67 = $mysqli->query("SELECT COUNT(id) FROM items WHERE category_id='$mcatid2' AND section_id='$secid1' AND lang_id=$lang AND publish='yes'");
$rows = $result67->fetch_row();
$nrrows67 = $rows[0];
?><?php if ($nrrows67>0) {?><div><a href="<?php echo $pagesection1 ?>.<?php echo $mpage2 ?>" class="colorn"><?php echo $mcategory2 ?></a></div><?php } ?><?php
$resulti67 = $mysqli->query("SELECT COUNT(id) FROM items WHERE section_id IN (SELECT insert_id FROM sections WHERE parent='$secid1' AND lang_id=$lang AND publish='yes') AND category_id='$mcatid2' AND lang_id=$lang AND publish='yes'");
$rows = $resulti67->fetch_row();
$nrrowsi67 = $rows[0];
?><?php if ($nrrowsi67>0 && $nrrows67==0) {?><div class="textnav"><?php echo $mcategory2 ?></div><?php } ?><?php 
$result68 = $mysqli->query("SELECT insert_id, page, name FROM sections WHERE parent='$secid1' AND lang_id=$lang AND publish='yes' ORDER BY priority");
while($row = $result68->fetch_array()) {
$secid2=$row['insert_id'];
$pagesection2=$row['page'];
$section2=$row['name'];

$result69 = $mysqli->query("SELECT COUNT(id) FROM items WHERE category_id='$mcatid2' AND section_id='$secid2' AND lang_id=$lang AND publish='yes'");
$rows = $result69->fetch_row();
$nrrows69 = $rows[0];
?><?php if ($nrrows69>0) {?><a href="<?php echo $pagesection1 ?>-<?php echo $pagesection2 ?>.<?php echo $mpage2 ?>" class="color1">&raquo; <?php echo $section2 ?></a> <?php } ?><?php } ?><?php } ?></div><?php } ?><?php } ?><div class="cleared"></div></li></ul></li><?php } ?><!--end sections -->

<?php if ($reviews==1) { ?><li class="navlinks2 navreviews"><a href="reviews"<?php if ($pagename=='reviews.php') { echo ' class="navactive"'; }?>><?php echo $pagereviews ?></a></li><?php } ?><?php if ($siteform!="contact") { ?><?php
$result70 = $mysqli->query("SELECT id FROM prices");
$nrrows70 = mysqli_num_rows($result70);
?><?php if ($type!=4 AND $type!=5 AND $nrrows70>0) {?><li class="navlinks2 navrates"><a href="rates"<?php if ($pagename=='rates.php') { echo ' class="navactive"'; }?>><?php echo $pagerates ?></a></li><?php } ?><li class="navlinks2 navrequest"><a href="request"<?php if ($pagename=='request.php') { echo ' class="navactive"'; }?>><?php echo $pagerequest ?></a></li><?php } ?><?php echo $navigationlinks ?><li class="navlinks2 navcontact"><a href="contact"<?php if ($pagename=='contact.php') { echo ' class="navactive"'; }?>><?php echo $pagecontact ?></a></li>
</ul>
</div>
<?php } ?>
</div></div>