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

<?php
		
	echo '<fieldset><legend>'.$words[4].'</legend>';
	echo 'Vysledku: '.$celkPocet;
	//Cesta kategorii	
	if(!empty($nadkategorie) and count($nadkategorie)>0)
	{
		echo '<div><a href="http://www.'.$domains[1].'.'.$domains[2].'/" 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="http://'.$v['cool_name'].'.'.$domains[1].'.'.$domains[2].'/';
				if(!empty($lokalita))echo 'katalog/'.$lokalita[0]['cool_name'].'/';
				echo '" title="'.$v['title'].'">'.$v['new_name'].'</a>';
			}else echo $v['new_name'];
			$i++;
		}
		echo '</div>';
	}
	if(!empty($nadlokality) and count($nadlokality)>0)
	{
		echo '<div><a href="http://'.$domains[0].'.'.$domains[1].'.'.$domains[2].'/" 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="http://'.$domains[0].'.'.$domains[1].'.'.$domains[2].'/';
				if(!empty($v['cool_name']))echo 'katalog/'.$v['cool_name'].'/';
				echo '" title="'.$v['lokalita'].'">'.$v['lokalita'].'</a>';
			}else echo $v['lokalita'];
			$i++;
		}
		echo '</div>';
	}
	echo '</fieldset>';


if(!empty($podkategorie) and count($podkategorie)>0)
{
	echo '<fieldset><legend>'.$words[2].'</legend><table width="100%">';
	$i = 0;
	foreach($podkategorie as $k => $v)
	{
		if($i % 3 == 0)echo '<tr>';
		echo '<td><a href="http://'.$v['cool_name'].'.'.$domains[1].'.'.$domains[2].'/';
		if(!empty($lokalita))echo 'katalog/'.$lokalita[0]['cool_name'].'/';
		echo '" title="'.$v['title'].'">'.$v['new_name'].'</a></td>';
		if($i % 3 == 2)echo '</tr>';
		$i++;
	}
	echo '</table></fieldset>';
}

if(!empty($podlokality) and count($podlokality)>0)
{
	echo '<fieldset><legend>'.$words[3].'</legend><table width="100%">';
	$i = 0;
	foreach($podlokality as $k => $v)
	{
		if($i % 5 == 0)echo '<tr>';
		echo '<td><a href="http://'.$domains[0].'.'.$domains[1].'.'.$domains[2].'/katalog/'.$v['cool_name'].'/" title="'.$v['lokalita'].'">'.$v['lokalita'].'</a></td>';
		if($i % 5 == 4)echo '</tr>';
		$i++;
	}
	echo '</table></fieldset>';
}

if(!empty($result) and count($result)>0)
{
	//Strankovanie
	if(!empty($itemsPerPage) and $pocetStranok > 1)
	{
		echo '<form method="post" class="info right">';
		if(($do - $itemsPerPage) > 0)
		{
			echo '<a href="/katalog';
			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++)
		{
			echo '<a href="/katalog';
			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 '/">';
			if($aktPage == $i)echo '<b>['.($i+1).']</b></a>&nbsp;&nbsp;';
			else echo ($i+1).'</a>&nbsp;&nbsp;';
		}
		if(($start + $itemsPerPage) < $pocetStranok)
		{
			echo '<a href="/katalog';
			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">Abecedne</option><option value="0"';
		if(empty($s1) or $s1 != 1)echo ' selected=selected';
		echo '>Dle hodnoceni</option></select>&nbsp;';
		echo '<select name="s2" onchange="submit()"><option value="1">Vzestupne</option><option value="0"';
		if(empty($s2) or $s2 != 1)echo ' selected=selected';
		echo '>Zestupne</option></select><noscript><input type="submit" value="'.$words[59].'"></noscript></form>';
	}
	echo '<p>Reklama 728x90px</p>';
	echo '<ul class="vypis">';
	foreach($result as $k => $row)
	{
		echo '<li class="hov"><h2><a href="'.base_url().'detail/'.$row->uri.'/" title="';
		echo htmlspecialchars($row->nazev);
		if(!empty($row->title))echo ' - '.htmlspecialchars($row->title);
		echo '">'.htmlspecialchars($row->nazev).'</a></h2>';
		if(substr($row->popis, 0, 2) == ' |')$row->popis = substr($row->popis, 2);
		if(strlen($row->popis) > 0)echo htmlspecialchars(substr(str_replace('|', ',', $row->popis), 0, 200));
		if(strlen($row->popis) > 200)echo '...';
		if(!empty($row->ulice) and !empty($row->obec) and !empty($row->psc))
		{
			echo '<div>'.$row->ulice.', '.$row->obec.', '.$row->psc.'</div>';
		}
		echo '</li>';
	}
	echo '</ul>';
	
	//Strankovanie
	if(!empty($itemsPerPage) and $pocetStranok > 1)
	{
		echo '<form method="post" class="info right">';
		if(($do - $itemsPerPage) > 0)
		{
			echo '<a href="/katalog';
			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++)
		{
			echo '<a href="/katalog';
			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 '/">';
			if($aktPage == $i)echo '<b>['.($i+1).']</b></a>&nbsp;&nbsp;';
			else echo ($i+1).'</a>&nbsp;&nbsp;';
		}
		if(($start + $itemsPerPage) < $pocetStranok)
		{
			echo '<a href="/katalog';
			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">Abecedne</option><option value="2"';
		if(empty($s1) or $s1 != 1)echo ' selected=selected';
		echo '>Dle hodnoceni</option></select>&nbsp;';
		echo '<select name="s2" onchange="submit()"><option value="1">Vzestupne</option><option value="2"';
		if(empty($s2) or $s2 != 1)echo ' selected=selected';
		echo '>Zestupne</option></select><noscript><input type="submit" value="'.$words[59].'"></noscript></form>';
	}
}else echo '<p class="info">'.$words[22].'</p>';

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

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