{% if languages|length > 1 %}
<div id="form-language">

	<div class="header__language">
		<button class="header__language-btn js-language-trigger">
			<mark>{{ text_language }}</mark>
			{% for language in languages %}
				{% if language.code == code %}
					{{ language.name }}
				{% endif %}
			{% endfor %}
			<svg class="icon-arrow-down">
				<use xlink:href="catalog/view/theme/prostore/sprites/sprite.svg#icon-arrow-down"></use>
			</svg>
		</button>

		<div class="header__language-offcanvas">

			<div class="header__language-offcanvas-overlay js-language-trigger"></div>

			<div class="header__language-offcanvas-content">
				<ul class="header__language-menu">
					{% for language in languages %}

						{% if language.main %}
							<li>
								<a data-lang="{{ language.code }}" class="header__language-link language-select" href="{{ language.url }}" onclick="lm_deleteCookie('languageauto'); window.location = '{{ language.url }}'">{{ language.name }}</a>
							</li>
						{% else %}
							<li>
								<a data-lang="{{ language.code }}" class="header__language-link language-select" href="{{ language.url }}" onclick="lm_setCookie('languageauto', '1', {expires: 180}); window.location = '{{ language.url }}'">{{ language.name }}</a>
							</li>
						{% endif %}

					{% endfor %}
					<li>
						<button class="header__language-link header__language-link--close js-language-trigger">{{ text_prostore_menu_close }}</button>
					</li>
				</ul>
			</div>

		</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 %}
