<?php include_once('header.php'); ?>

<h1><?= $h1 ?></h1>

<?php
	
	/*
	echo '<fieldset><legend>'.$words[4].'</legend>';
	echo 'Vysledku: '.$celkPocet;
	//*/
	//Cesta kategorii	
	if(!empty($nadkategorie) and count($nadkategorie)>0)
	{
		echo '<div class="navigace-kategorie"><a href="/';
		if(!empty($lokalita))echo $catcontroller.'/'.$lokalita[0]['cool_name'].'/';		
		echo '" title="'.$words[31].'">'.$words[21].'</a>';$i = 1;
		foreach($nadkategorie as $v)
		{
			if($i <= count($nadkategorie))echo '  &raquo; ';
			if($i < count($nadkategorie))
			{
				echo '<a href="/'.$catcontroller.'/';
				echo $v['cool_name'].'/';
				if(!empty($lokalita))echo $lokalita[0]['cool_name'].'/';
				echo '" title="'.$v['title'].'">'.$v['new_name'].'</a>';
			}else echo $v['new_name'];
			$i++;
		}
		echo '</div>';
	}
	//*/


if(!empty($podkategorie) and count($podkategorie)>0)
{
	echo '<div class="padding-left10"><table width="100%">';
	$i = 0;
	foreach($podkategorie as $k => $v)
	{
		if($i % 4 == 0)echo '<tr>';
		echo '<td><img src="/images/adresar.gif" alt="kategorie">&nbsp;<a href="/'.$catcontroller.'/'.$v['cool_name'].'/';
		if(!empty($lokalita))echo $lokalita[0]['cool_name'].'/';
		echo '" title="'.$v['title'].'">'.$v['new_name'].'</a></td>';
		if($i % 4 == 3)echo '</tr>';
		$i++;
	}
	echo '</table></div>';
}

	//echo '<fieldset><legend>'.$words[3].'</legend><table width="100%">';
	echo '<div class="navigace-lokality"><h2>';
	if(!empty($nadlokality) and count($nadlokality)>0)
	{
		echo '<a href="/';
		if(!empty($kategoria))echo $catcontroller.'/'.$kategoria[0]['cool_name'].'/';
		echo '" title="'.$words[27].'">'.$words[27].'</a>';$i = 1;
		foreach($nadlokality as $v)
		{
			if($i <= count($nadlokality))echo '  &raquo; ';
			if($i < count($nadlokality))
			{
				echo '<a href="/'.$catcontroller.'/';
				if(!empty($kategoria))echo $kategoria[0]['cool_name'].'/';
				if(!empty($v['cool_name']))echo $v['cool_name'].'/';
				echo '" title="'.$v['lokalita'].'">'.$v['lokalita'].'</a>';
			}else echo $v['lokalita'];
			$i++;
		}
	}else echo $words[82];
	
	echo '</h2>';
	
	if(!empty($podlokality) and count($podlokality)>0)
	{
		if(!empty($lokalita))$pocet_v_radku = 8;
		else $pocet_v_radku = 7;
		echo '<table width="100%">';
		$i = 0;
		foreach($podlokality as $k => $v)
		{
			if($i % $pocet_v_radku == 0)echo '<tr>';
			echo '<td><a href="/'.$catcontroller.'/';
			if(!empty($kategoria))echo $kategoria[0]['cool_name'].'/';
			echo $v['cool_name'].'/" title="'.$v['lokalita'].'">'.$v['lokalita'].'</a></td>';
			if($i % $pocet_v_radku == ($pocet_v_radku-1))echo '</tr>';
			$i++;
		}
		echo '</table>';
	}
	echo '</div>';


if(!empty($result) and count($result)>0)
{
	//Strankovanie
	if(!empty($itemsPerPage) and $pocetStranok > 1)
	{
		echo '<form method="post" action="'.base_url().'redirect/sort" class="info right">';
		echo '<input type="hidden" name="url" value="'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'">';
		if(($do - $itemsPerPage) > 0)
		{
			echo '<a href="/'.$catcontroller;
			if(!empty($kategoria))echo '/'.$kategoria[0]['cool_name'];
			if(!empty($lokalita))echo '/'.$lokalita[0]['cool_name'];
			if(!empty($s1) or !empty($s2))echo '/s/'.$s1.'/'.$s2;
			echo '/">'.$words[17].'</a>&nbsp;&nbsp;';	
		}
		for($i=$start;$i<$do;$i++)
		{
		  if($aktPage != $i)
		  {
  			echo '<a href="/'.$catcontroller;
  			if(!empty($kategoria))echo '/'.$kategoria[0]['cool_name'];
  			if(!empty($lokalita))echo '/'.$lokalita[0]['cool_name'];
  			if($i > 0)echo '/p/'.$i;
  			if(!empty($s1) or !empty($s2))echo '/s/'.$s1.'/'.$s2;
  			echo '/">'.($i+1).'</a>';
      }else echo '<b class="orange">['.($i+1).']</b>';
      echo '&nbsp;&nbsp;';
		}
		if(($start + $itemsPerPage) < $pocetStranok)
		{
			echo '<a href="/'.$catcontroller;
			if(!empty($kategoria))echo '/'.$kategoria[0]['cool_name'];
			if(!empty($lokalita))echo '/'.$lokalita[0]['cool_name'];
			echo '/p/'.($pocetStranok-1);
			if(!empty($s1) or !empty($s2))echo '/s/'.$s1.'/'.$s2;
			echo '/">'.$words[18].'</a>&nbsp;';
		}
		//Radenie
		echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$words[59].':';
		echo '<select name="s1" onchange="submit()"><option value="1">'.$words[78].'</option>
		<option value="0"';
		if(empty($s1) or $s1 == 0)echo ' selected=selected';
		echo '>'.$words[79].'</option>
		<option value="2"';
		if(!empty($s1) and $s1 == 2)echo ' selected=selected';
		echo '>'.$words[95].'</option>
		</select>&nbsp;';
		echo '<select name="s2" onchange="submit()"><option value="1">'.$words[93].'</option><option value="0"';
		if(empty($s2) or $s2 != 1)echo ' selected=selected';
		echo '>'.$words[92].'</option></select><noscript><input type="submit" value="'.$words[59].'"></noscript></form>';
	}
	?>
	
	<div id="ads"><?php include_once('ads_vypis_right.php'); ?></div>
	
	<?php
	
	include_once('vypis.php');
	
	//Strankovanie
	if(!empty($itemsPerPage) and $pocetStranok > 1)
	{
		echo '<form method="post" action="'.base_url().'redirect/sort" class="info right">';
		echo '<input type="hidden" name="url" value="'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'">';
		if(($do - $itemsPerPage) > 0)
		{
			echo '<a href="/'.$catcontroller;
			if(!empty($kategoria))echo '/'.$kategoria[0]['cool_name'];
			if(!empty($lokalita))echo '/'.$lokalita[0]['cool_name'];
			if(!empty($s1) or !empty($s2))echo '/s/'.$s1.'/'.$s2;
			echo '/">'.$words[17].'</a>&nbsp;&nbsp;';	
		}
		for($i=$start;$i<$do;$i++)
		{
			if($aktPage != $i)
		  {
  			echo '<a href="/'.$catcontroller;
  			if(!empty($kategoria))echo '/'.$kategoria[0]['cool_name'];
  			if(!empty($lokalita))echo '/'.$lokalita[0]['cool_name'];
  			if($i > 0)echo '/p/'.$i;
  			if(!empty($s1) or !empty($s2))echo '/s/'.$s1.'/'.$s2;
  			echo '/">'.($i+1).'</a>';
      }else echo '<b class="orange">['.($i+1).']</b>';
      echo '&nbsp;&nbsp;';
		}
		if(($start + $itemsPerPage) < $pocetStranok)
		{
			echo '<a href="/'.$catcontroller;
			if(!empty($kategoria))echo '/'.$kategoria[0]['cool_name'];
			if(!empty($lokalita))echo '/'.$lokalita[0]['cool_name'];
			echo '/p/'.($pocetStranok-1);
			if(!empty($s1) or !empty($s2))echo '/s/'.$s1.'/'.$s2;
			echo '/">'.$words[18].'</a>&nbsp;';
		}
		//Radenie
		echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$words[59].':';
		echo '<select name="s1" onchange="submit()"><option value="1">'.$words[78].'</option>
		<option value="0"';
		if(empty($s1) or $s1 == 0)echo ' selected=selected';
		echo '>'.$words[79].'</option>
		<option value="2"';
		if(!empty($s1) and $s1 == 2)echo ' selected=selected';
		echo '>'.$words[95].'</option>
		</select>&nbsp;';
		echo '<select name="s2" onchange="submit()"><option value="1">'.$words[93].'</option><option value="0"';
		if(empty($s2) or $s2 != 1)echo ' selected=selected';
		echo '>'.$words[92].'</option></select><noscript><input type="submit" value="'.$words[59].'"></noscript></form>';
	}
}else echo '<p class="info">'.$words[22].'</p>';

if(!empty($description) and 1 == 0)
{
	echo '<fieldset class="info"><legend>'.$words[16].'</legend>'.$description.'</fieldset>';
}
?>

<?php include_once('footer.php'); ?>
