{% if languages|length > 1 %}
	<div class="pull-right">
		<div id="form-language">
			<div class="btn-group">
				<button class="btn btn-link btnp dropdown-toggle" data-toggle="dropdown">
					{% for language in languages %}
						{% if (language['code'] == code) %}
							{% if (settings_widget['image_status'] is defined and settings_widget['image_status']) %}<img class="languages" src="catalog/language/{{ language['code'] }}/{{ language['code'] }}.png" width="16" height="11" alt="{{ language['name'] }}" title="{{ language['name'] }}">
							{% endif %}
							{{ language['name'] }}
						{% endif %}
					{% endfor %}
					<span class="hidden-xs hidden-sm hidden-md"></span>
					<i class="fa fa-caret-down"></i>
				</button>
				<ul class="dropdown-menu">
					{% for language in languages %}
						<li>
							{% if language.main %}
								<a class="language-call btn btn-link btn-block language-selectt" type="button" onclick="lm_deleteCookie('languageauto'); window.location = '{{ language.url }}'" name="{{ language['code'] }}">
									{% if (settings_widget['image_status'] is defined and settings_widget['image_status']) %}<img src="catalog/language/{{ language['code'] }}/{{ language['code'] }}.png" width="16" height="11" alt="{{ language['name'] }}" title="{{ language['name'] }}"/>
									{% endif %}
									{{ language['name'] }}</a>
							{% else %}
								<a class="language-call btn btn-link btn-block language-selectt" type="button" onclick="lm_setCookie('languageauto', '1', {expires: 180});  window.location = '{{ language.url }}'" name="{{ language['code'] }}">
									{% if (settings_widget['image_status'] is defined and settings_widget['image_status']) %}<img src="catalog/language/{{ language['code'] }}/{{ language['code'] }}.png" width="16" height="11" alt="{{ language['name'] }}" title="{{ language['name'] }}"/>
									{% endif %}
									{{ language['name'] }}</a>

							{% endif %}
						</li>
					{% endfor %}
				</ul>
			</div>
		</div>
	</div>
<script>
function lm_setCookie(name, value, options = {}) {
options = {
path: '/',
...options
};

	let date = new Date(Date.now() + (86400e3 * options.expires));
	date = date.toUTCString();
	options.expires = date;

	let updatedCookie = encodeURIComponent(name) + "=" + encodeURIComponent(value);

	for (let optionKey in options) {
		updatedCookie += "; " + optionKey;
		let optionValue = options[optionKey];
		if (optionValue !== true) {
			updatedCookie += "=" + optionValue;
		}
	}
	document.cookie = updatedCookie;
}

function lm_deleteCookie(name) {
	lm_setCookie(name, "", {'max-age': -1});
}
</script>
{% endif %}
