{% import _self as self %}
{% macro childNodes(nodes) %}
	{% import _self as self %}
	<ul>
		{% for node in nodes %}
			{% if not node.Conditionally_Hidden %}
				<li class="{{node.Class}}">
					<span class="menu_image">{{node.Image}}</span>
					{% if node.Inactive_Open_Tag %}
						{{node.Inactive_Open_Tag}}
					{% endif %}
					
					{{node.Hyperlink}}
					
					{% if node.Inactive_Close_Tag %}
						{{node.Inactive_Close_Tag}}
					{% endif %}
					
					{% if node.children %}
						{{ self.childNodes(node.children) }}
					{% endif %}
				</li>
			{% endif %}
		{% endfor %}
	</ul>
{% endmacro %}

{% set hasChildren = false %}

<div class="wrap_menu {% if limit_initial_level_1_menu_nodes %} menu_with_more_button {% endif %}">
<div class="wrap_menu_outer">
<div class="wrap_menu_inner">
	{% set currentNode = 0 %}
	{% for node in nodes %}
		{% if not node.Conditionally_Hidden %}
			
			{% if limit_initial_level_1_menu_nodes %}
				{% set currentNode = currentNode + 1 %}
				{% if currentNode - limit_initial_level_1_menu_nodes == 1 %}
					<ul>
						<li class="zenario_menu_node_more">
							<span class="menu_more_text">{{text_for_more_button|trans}}</span>
							<div class="menu_more_div">
				{% endif %}
			{% endif %}

			<ul>
				<li class="{{node.Class}}">
					<span class="menu_image">{{node.Image}}</span>
					{% if node.Inactive_Open_Tag %}
						{{node.Inactive_Open_Tag}}
					{% endif %}
					
					{{node.Hyperlink}}
					
					{% if node.Inactive_Close_Tag %}
						{{node.Inactive_Close_Tag}}
					{% endif %}
					
					{% if node.children and not node.All_Children_Are_Hidden %}
						{% if not limit_initial_level_1_menu_nodes or (limit_initial_level_1_menu_nodes and (currentNode - limit_initial_level_1_menu_nodes <= 0 and node.depth <= menu_max_number_of_levels)) %}
							{{ self.childNodes(node.children) }}
							{% set hasChildren = true %}
						{% endif %}
					{% endif %}
				</li>
			</ul>
		{% endif %}
	{% endfor %}

	{% if limit_initial_level_1_menu_nodes and (currentNode > limit_initial_level_1_menu_nodes) %}
		</div></li></ul>
	{% endif %}
</div>
</div>
</div>

{% if hasChildren %}
	{% do this.requireJsLib('zenario/libs/yarn/jquery-doubletaptogo/dist/jquery.dcd.doubletaptogo.min.js') %}
	{% do this.jQuery('#' ~ containerId ~ ' .level1.has_child > a', 'doubleTapToGo') %}
{% endif %}