<?php
if(isset($_SESSION[$controller->defaultLangMenu]) && $_SESSION[$controller->defaultLangMenu] == 'show')
{
	if (isset($tpl['locale_arr']) && is_array($tpl['locale_arr']) && !empty($tpl['locale_arr']) && count($tpl['locale_arr']) > 1)
	{
		
		$locale_id = $_SESSION[$controller->defaultLocale];
		$selected_lang = '';
		$selected_flag = '';
		foreach ($tpl['locale_arr'] as $locale)
		{
			if($locale_id == $locale['id'])
			{
				$selected_lang = pjSanitize::html($locale['title']);
				$selected_flag = PJ_INSTALL_URL . PJ_FRAMEWORK_LIBS_PATH . 'pj/img/flags/'. $locale['file'];
			}
		}
		?>
		
		<div class="col-xs-12 pjErLocale">
			<button type="button" class="btn btn-default dropdown-toggle pjCpbBtn pjCpbBtnLanguage" data-toggle="dropdown" aria-expanded="false">
				<img src="<?php echo $selected_flag;?>" alt="" />
	
				<?php echo $selected_lang;?>
	
				<span class="caret"></span>
			</button>
			<ul class="dropdown-menu pjCpbLanguageOptions">
				<?php
				foreach ($tpl['locale_arr'] as $k => $locale)
				{
					$flag = PJ_INSTALL_URL . PJ_FRAMEWORK_LIBS_PATH . 'pj/img/flags/'. $locale['file'];
					?>
					<li>
						<a href="#" class="pjCpbBtn pjErSelectorLocale<?php echo $locale_id == $locale['id'] ? ' pjCpbBtnActive' : null;?>" data-id="<?php echo $locale['id'];?>" data-dir="<?php echo $locale['dir']; ?>">
							<img src="<?php echo $flag;?>" alt="" />
		
							<?php echo pjSanitize::html($locale['title']); ?>
						</a>
					</li>
					<?php
				}
				?>
			</ul>
		</div>
		<?php
	}
} 
?>