<?php
$params = $controller->getParams();

$menu = !isset($params['menu']) || $params['menu'] !== false || isset($params['search_installation']);
$lang = !isset($params['lang']) || $params['lang'] !== false;

if ($menu || $lang)
{ 
	$listingPage = $_SERVER['SCRIPT_NAME'];
	?>
	<div class="container-fluid pjVrContainer">
		<nav class="navbar navbar-default pjVrHeader">
			<?php
			if($menu)
			{ 
				?>
				<ul class="nav navbar-nav navbar-left pjVrNav">
					<?php
					if (@$_GET['controller'] == 'pjListings' && @$_GET['action'] == 'pjActionView')
					{ 
						$listing_url = $_SERVER['SCRIPT_NAME'] .'?controller=pjListings&amp;action=pjActionListings'. $QS_LANG. (isset($_GET['iframe']) ? '&amp;iframe' : NULL);
						$back = isset($_SESSION[$controller->defaultBackUrl]) ? (!empty($_SESSION[$controller->defaultBackUrl]) ? $_SESSION[$controller->defaultBackUrl] : $listing_url) :  $listing_url;
						?>
						<li>
							<a href="<?php echo htmlspecialchars($back); ?>"><?php __('front_menu_back'); ?></a>
						</li><!-- /.active pjVrNavCurrent -->
						<?php
					}
					?>
					<li<?php echo $_GET['action'] == 'pjActionListings' ? ' class="active pjVrNavCurrent"' : null;?>>
						<a href="<?php echo $listingPage; ?>?controller=pjListings&amp;action=pjActionListings<?php echo $QS_LANG; ?><?php echo isset($_GET['iframe']) ? '&amp;iframe' : NULL; ?>"><?php __('front_all_properties'); ?></a>
					</li><!-- /.active pjVrNavCurrent -->
					<li<?php echo $_GET['action'] == 'pjActionSearch' ? ' class="active pjVrNavCurrent"' : null;?>>
						<a href="<?php echo $listingPage; ?>?controller=pjListings&amp;action=pjActionSearch<?php echo $QS_LANG; ?><?php echo isset($_GET['iframe']) ? '&amp;iframe' : NULL; ?>"><?php __('front_menu_map'); ?></a>
					</li>
				</ul><!-- /.nav navbar-nav navbar-left pjVrNav -->
				<?php
			}
			?>
			<ul class="nav navbar-nav navbar-right pjVrNavAccess">
				<?php
				if ($tpl['option_arr']['o_allow_add_property'] == 'No') 
				{ 
					if($menu)
					{
						?>
						<li class="pjVrNavLogin<?php echo $_GET['action'] == 'pjActionAdd' || $_GET['action'] == 'pjActionForgot' ? ' active pjVrNavCurrent' : null;?>">
							<a href="<?php echo $listingPage; ?>?controller=pjListings&amp;action=pjActionAdd<?php echo $QS_LANG; ?><?php echo isset($_GET['iframe']) ? '&amp;iframe' : NULL; ?>"><?php __('front_login_signup'); ?></a>
						</li>
						<?php
					}
				}
				if ($lang)
				{ 
					if (isset($tpl['locale_arr']))
					{
						$cnt = count($tpl['locale_arr']);
						if ($cnt > 1)
						{
							$locale_id = $controller->getLocaleId();
							$selected_lang = '';
							foreach ($tpl['locale_arr'] as $k => $locale)
							{
								if($locale_id == $locale['id'])
								{
									$selected_lang = pjSanitize::html($locale['title']);
								}
							}
							?>
							<li>
								<div class="btn-group pjVrLanduage">
									<button type="button" class="btn btn-default dropdown-toggle pjVrLanduageToggle" data-toggle="dropdown" aria-expanded="false">
										<?php echo $selected_lang;?>
										<i class="fa fa-caret-down"></i>
									</button>
				
									<ul class="dropdown-menu pjVrLanduageDropdown">
										<?php
										foreach ($tpl['locale_arr'] as $locale)
										{ 
											?><li<?php echo $controller->getLocaleId() == $locale['id'] ? ' class="pjVrLanduageCurrent"' : null;?>><a href="<?php echo $_SERVER['SCRIPT_NAME']; ?>?controller=pjListings&amp;action=pjActionSetLocale&amp;locale=<?php echo $locale['id']; ?><?php echo isset($_GET['iframe']) ? '&amp;iframe' : NULL; ?>"><?php echo pjSanitize::html($locale['title']);?></a></li><?php
										} 
										?>
									</ul><!-- /.dropdown-menu pjVrLanduageDropdown -->
								</div><!-- /.btn-group pjVrLanduage -->
							</li>
							<?php
						}
					}
				} 
				?>
			</ul><!-- /.nav navbar-nav navbar-right pjVrNavAccess -->
		</nav><!-- /.navbar navbar-default pjVrHeader -->
	</div><!-- /.container-fluid pjVrContainer -->
	<?php
} 
?>