<?php
	// Settings
	$menu_type = StockieSettings::menu_type();

	
	$have_woocomerce = function_exists( 'WC' );
	$have_woocomerce_wl = function_exists( 'YITH_WCWL' );
	$have_wpml = function_exists( 'icl_get_languages' );
	$wpml_show_in_header = StockieSettings::get( 'wpml_show_in_header', 'global' );
	$wpml_show_in_header = ( $wpml_show_in_header === false ) ? false : true;
	$header_have_social = have_rows( 'global_header_menu_social_links', 'option' );
	$mobile_social_position = StockieSettings::get( 'header_mobile_social_position', 'global' );
	$dropdown_carets_visibility = StockieSettings::get( 'header_counters_visibility', 'global' );
	$mobile_menu_position = StockieSettings::get( 'mobile_menu_position', 'global' );

	$site_navigation_class = '';
	if ( $menu_type == 'hamburger' ) {
		$site_navigation_class .= ' hidden';
	}

	if ( $mobile_menu_position == 'right' ) {
		$site_navigation_class .= ' slide-right';
	}

	if ( $dropdown_carets_visibility == false ) {
		$site_navigation_class .= ' without-counters';
	}
?>

<nav id="site-navigation" class="main-nav<?php echo esc_attr( $site_navigation_class ); ?>">

	<!-- Mobile overlay -->
	<div class="mbl-overlay">
		<div class="mbl-overlay-bg"></div>

		<!-- Close bar -->
		<div class="close close-bar">
			<div class="close-bar-btn btn-round round-animation" tabindex="0">
				<i class="ion ion-md-close"></i>
			</div>
		</div>
		<div class="mbl-overlay-container">

			<!-- Navigation -->
			<div id="mega-menu-wrap" class="main-nav-container">

				<?php
					if ( StockieSettings::get('extended_menu', 'global') ) {
						wp_nav_menu( array( 'menu' => StockieSettings::get('extended_menu', 'global'), 'menu_id' => 'primary-menu' ) );
					} else {
                        if ( has_nav_menu( 'primary' ) ) {
                            wp_nav_menu( array( 'theme_location' => 'primary', 'menu_id' => 'secondary-menu' ) );
                        } else {
                            echo '<span class="menu-not-assigned">' . sprintf( esc_html__( 'Please, %1$s assign a menu %2$s', 'stockie' ), '<a target="_blank" href="' . esc_url( home_url( '/' ) ) . 'wp-admin/nav-menus.php">', '</a>' ) . '</span>';
                        }
					}
				?>
			</div>

			<!-- Lang switcher -->
			<?php get_template_part('parts/elements/language-dropdown'); ?>
		
			<!-- Copyright -->
			<div class="copyright">
				<?php echo wp_kses( StockieSettings::get( 'footer_copyright_left', 'global' ), 'post' ); ?><br>
				<?php echo wp_kses( StockieSettings::get( 'footer_copyright_right', 'global' ), 'post' ); ?>
			</div>

			<!-- Social links -->
			<?php if ( $header_have_social && $mobile_social_position == 'inside' ) : ?>
				<div class="socialbar small">
					<?php while( have_rows( 'global_header_menu_social_links', 'option' ) ): the_row(); ?>
						<?php switch ( get_sub_field( 'social_network' ) ) {
							case 'facebook':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="facebook"><i class="icon fa fa-facebook"></i></a>';
							break;
						case 'twitter':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="twitter"><i class="icon fa fa-twitter"></i></a>';
							break;
						case 'googleplus':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="googleplus"><i class="icon fa fa-google-plus"></i></a>';
							break;
						case 'instagram':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="instagram"><i class="icon fa fa-instagram"></i></a>';
							break;
						case 'dribbble':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="dribbble"><i class="icon fa fa-dribbble"></i></a>';
							break;
						case 'github':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="github"><i class="icon fa fa-github-alt"></i></a>';
							break;
						case 'linkedin':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="linkedin"><i class="icon fa fa-linkedin"></i></a>';
							break;
						case 'vimeo':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="vimeo"><i class="icon fa fa-vimeo"></i></a>';
							break;
						case 'youtube':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="youtube"><i class="icon fa fa-youtube"></i></a>';
							break;
						case 'vk':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="vk"><i class="icon fa fa-vk"></i></a>';
							break;
						case 'behance':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="behance"><i class="icon fa fa-behance"></i></a>';
							break;
						case 'flickr':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="flickr"><i class="icon fa fa-flickr"></i></a>';
							break;
						case 'reddit':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="reddit"><i class="icon fa fa-reddit-alien"></i></a>';
							break;
						case 'snapchat':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="snapchat"><i class="icon fa fa-snapchat"></i></a>';
							break;
						case 'whatsapp':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="whatsapp"><i class="icon fa fa-whatsapp"></i></a>';
							break;
						case 'quora':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="quora"><i class="icon fa fa-quora"></i></a>';
							break;
						case 'vine':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="vine"><i class="icon fa fa-vine"></i></a>';
							break;
						case 'digg':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="digg"><i class="icon fa fa-digg"></i></a>';
							break;
						case 'foursqure':
							echo '<a href="' . esc_url( get_sub_field( 'url' ) ) . '" class="foursquare"><i class="icon fa fa-foursquare"></i></a>';
							break;
						} ?>
					<?php endwhile; ?>
				</div>
			<?php endif; ?>
		</div>
	</div>
</nav>
