/*Navigation Menu*/(function ($) {
	'use strict';
	$(document).ready(function () {
		if($(".plus-navigation-wrap .plus-navigation-inner.menu-click").length>=1){
			theplus_ele_menu_clicking();
		}
		
		$(".plus-navigation-wrap .menu-item a").each(function(){
			var title = $(this).attr("title");
			$(this).attr("tmp_title", title);
			$(this).attr("title","");
		});
		
		if($(".mobile-plus-toggle-menu").length > 0){
			$(".mobile-plus-toggle-menu").on('click',function() {
				var target = $(this).data("target");
				$(this).toggleClass("plus-collapsed");
				if ($(target +'.collapse:not(".in")').length) {
				  
				  $(target +'.collapse:not(".in")').slideDown(400);
				  $(target +'.collapse:not(".in")').addClass('in');
				} else {
				  $(target + '.collapse.in').slideUp(400);
				  $(target +'.collapse.in').removeClass('in');
				}
			});
		}
		$(".plus-mobile-menu:not(.swiper-wrapper) .navbar-nav li.menu-item-has-children > a").on("click", function(a) {
            a.preventDefault(),
            a.stopPropagation();
            var b = $(this)
              , c = b.parent()
              , d = b.parent().parent()
              , e = c.find("> ul.dropdown-menu");
            c.hasClass("open-menu") ? (e.slideUp(400),
            c.removeClass("open-menu")) : (d.css("height", "auto"),
            d.find("li.dropdown.open-menu ul.dropdown-menu").slideUp(400),
            d.find("li.dropdown-submenu.open-menu ul.dropdown-menu").slideUp(400),
            d.find("li.dropdown,li.dropdown-submenu.open-menu").removeClass("open-menu"),
            e.slideDown(400),
            c.addClass("open-menu"));
			
			if(e.find('.list-isotope').length){
				setTimeout(function(){
					e.find('.list-isotope .post-inner-loop').isotope('layout');
				}, 420);
			}
			if(e.find('.list-isotope-metro .post-inner-loop').length > 0){
				theplus_setup_packery_portfolio('all');		
			}	
        });
		$(".plus-navigation-wrap .plus-dropdown-default").each(function(){
			var mwidth= $(this).data("dropdown-width");
			var id= $(this).attr("id");
			if(mwidth!='' && mwidth!=undefined){
				$('head').append('<style>#'+id+'.plus-dropdown-default.plus-fw > ul.dropdown-menu{max-width:'+mwidth+' !important;min-width:'+mwidth+' !important;right:auto;}#'+id+'.plus-dropdown-default:not(.plus-fw) > ul.dropdown-menu{max-width:'+mwidth+' !important;min-width:'+mwidth+' !important;width: 100%;}</style>');
			}
		});
		if($(".plus-navigation-menu.menu-vertical-side.toggle-type-click").length > 0){
			$(".menu-vertical-side.toggle-type-click .plus-vertical-side-toggle").on("click",function(a){
				a.preventDefault(),
				a.stopPropagation();
				$(this).closest(".toggle-type-click").toggleClass("tp-click");
			});
		}
		if($(".plus-navigation-menu.menu-vertical-side.toggle-type-hover").length > 0){
			$(".menu-vertical-side.toggle-type-hover").on('mouseenter',function() {
				$(this).addClass("tp-hover");
			}).on('mouseleave', function() {
				$(this).removeClass("tp-hover");
			});
		}
		
		var inner_width = window.innerWidth;
		if(inner_width <= 991 && $('.plus-mobile-menu-content').length){
			$(document).mouseup(function (e) {
				var container = $(".mobile-plus-toggle-menu");
				var mouse_click = $(e.target).closest(".plus-navigation-inner").data("mobile-menu-click");
				if(mouse_click=='yes'){					
					if (!container.is(e.target) && container.has(e.target).length === 0){
						var $menu = $('li.dropdown');
						if (!$menu.is(e.target) && $menu.has(e.target).length === 0){
							$menu.find('ul.dropdown-menu').slideUp(400);
							$menu.find('li.dropdown-submenu.open-menu ul.dropdown-menu').slideUp(400);
							$menu.removeClass('open-menu');
							$(e.target).closest(".plus-mobile-menu-content").slideUp(400);
							$(e.target).closest(".plus-mobile-menu-content").removeClass('in');
							$(e.target).closest(".plus-navigation-inner").find(".mobile-plus-toggle-menu").addClass("plus-collapsed");
						}
					}
				}
			});
			
		}
	});
	
	/*--Normal menu and Normal Bottom menu hover effect--*/
	var id;
	$(window).on("load resize",function(e){
		e.preventDefault();
		var inner_width = window.innerWidth;
		if(inner_width > 991){
			if($(".plus-navigation-wrap .plus-navigation-inner").hasClass("menu-hover")){
				theplus_navmenu_hover();
			}
		}
		
		//Mobile Menu Full Width
		if($('.plus-mobile-menu-content:not(.nav-cust-width)').length){
			$(".plus-mobile-menu-content").each(function(){
				var offeset=$(this).closest(".plus-navigation-wrap");
				var window_width = $(window).width();
				var menu_content=$(this);
				var offset_left = 0 - offeset.offset().left;
				
					if($('body').hasClass("rtl")){
						menu_content.css({
								right: offset_left,
								"box-sizing": "border-box",
								width: window_width
						});
					}else{
						menu_content.css({
								left: offset_left,
								"box-sizing": "border-box",
								width: window_width
						});
					}
					
			});
		}
		theplus_megamenu_fullwidth_container();
	});
} )(jQuery);
function theplus_navmenu_hover(){
	"use strict";
	var $= jQuery;	
	$(".plus-navigation-wrap .menu-hover .navbar-nav .dropdown").on('mouseenter',function() {
		var $container =$(this).closest(".plus-navigation-inner");
		var transition_style=$container.data("menu_transition");
		
		if(transition_style=='' || transition_style=='style-1'){
			$(this).find("> .dropdown-menu").stop().slideDown();
		}else if(transition_style=='style-2'){
			$(this).find("> .dropdown-menu").stop(true, true).delay(100).fadeIn(600);
		}else if(transition_style=='style-3' || transition_style=='style-4'){
			$(this).find("> .dropdown-menu").addClass("open-menu");			
		}
		
		if($('.list-isotope-metro .post-inner-loop',this).length > 0){
			theplus_setup_packery_portfolio('all');		
		}
		
	}).on('mouseleave', function() {
		var $container =$(this).closest(".plus-navigation-inner");
		var transition_style=$container.data("menu_transition");
		
		if(transition_style=='' || transition_style=='style-1'){
			$(this).find("> .dropdown-menu").stop().slideUp();
		}else if(transition_style=='style-2'){
			$(this).find("> .dropdown-menu").stop(true, true).delay(100).fadeOut(400);
		}else if(transition_style=='style-3' || transition_style=='style-4'){
			$(this).find("> .dropdown-menu").removeClass("open-menu");			
		}
		
	});
	$(".plus-navigation-wrap .menu-hover .navbar-nav .dropdown-submenu").on('mouseenter',function() {
		var $container =$(this).closest(".plus-navigation-inner");
		var transition_style=$container.data("menu_transition");
		
		if($('.list-isotope-metro .post-inner-loop',this).length > 0){
			theplus_setup_packery_portfolio('all');	
		}
		
		if(transition_style=='' || transition_style=='style-1'){
			$(this).find("> .dropdown-menu").stop().slideDown();
		}else if(transition_style=='style-2'){
		$(this).find("> .dropdown-menu").stop(true, true).delay(100).fadeIn(600);
		}else if(transition_style=='style-3' || transition_style=='style-4'){
			$(this).find("> .dropdown-menu").addClass("open-menu");
		}
		
	}).on('mouseleave', function() {
		var $container =$(this).closest(".plus-navigation-inner");
		var transition_style=$container.data("menu_transition");
		
		if(transition_style=='' || transition_style=='style-1'){
			$(this).find("> .dropdown-menu").stop().slideUp();
		}else if(transition_style=='style-2'){
			$(this).find("> .dropdown-menu").stop(true, true).delay(100).fadeOut(400);
		}else if(transition_style=='style-3' || transition_style=='style-4'){
			$(this).find("> .dropdown-menu").removeClass("open-menu");
		}
		
	});	
}
function theplus_megamenu_fullwidth_container(){
	"use strict";
	var $=jQuery;
	if($('.plus-navigation-menu .plus-dropdown-container').length > 0 || $('.plus-navigation-menu .plus-dropdown-full-width').length > 0){
	
		var left_offset=0;
	
		if( $('.plus-navigation-menu .plus-dropdown-container').length > 0 ) {
			$('.plus-navigation-menu .plus-dropdown-container').each(function(){
				var cthis =$(this);
				//Horizontal Menu
				var vertical_menu = cthis.closest('.menu-vertical-side');
				if(vertical_menu.length>0){
					var full_width=cthis.closest(".elementor-container").width();
					var menu_width = vertical_menu.find(".navbar-nav").width();
					var con_width = full_width - menu_width - 20;
					var container_megamenu=$(">.dropdown-menu",cthis);
					container_megamenu.css({
							"box-sizing": "border-box",
							width: con_width
					});
				}
				if(!vertical_menu.length){
					var cont_width=cthis.closest(".elementor-container").width();
					var window_width = window.innerWidth;
					window_width=window_width-cont_width;
					var left_offset=window_width/2;
					
					var offeset=cthis.closest(".plus-navigation-wrap");
					
					
					var container_megamenu=$(">.dropdown-menu",cthis);
					if($('body').hasClass("rtl")){
					var offset_right = 0 - offeset.offset().left+(left_offset);
						container_megamenu.css({
							right: offset_right,
							"box-sizing": "border-box",
							width: cont_width
						});
					}else{
					var offset_left = 0 - offeset.offset().left+(left_offset);
						container_megamenu.css({
							left: offset_left,
							"box-sizing": "border-box",
							width: cont_width
						});
					}
				}
			});
		}
		if( $('.plus-navigation-menu .plus-dropdown-full-width').length > 0 ) {
			$('.plus-navigation-menu .plus-dropdown-full-width').each(function(){
				var cthis =$(this);
				var vertical_menu = cthis.closest('.menu-vertical-side');
				if(vertical_menu.length>0){
					var full_width=cthis.closest(".elementor-container").width();
					var menu_width = vertical_menu.find(".navbar-nav").width();
					var con_width = full_width - menu_width - 20;
					var container_megamenu=$(">.dropdown-menu",cthis);
					container_megamenu.css({
							"box-sizing": "border-box",
							width: con_width
					});
				}
				if(!vertical_menu.length){
					var full_width=cthis.closest(".elementor-container").width();
					var window_width = $(window).width();
					//window_width=window_width-full_width;
					var offeset=cthis.closest(".plus-navigation-wrap");
					if(offeset.length > 0){
						var offset_left = 0 - offeset.offset().left-(left_offset);
					}else{
						var offset_left = 0 - 0+(left_offset);
					}
					if($('body').hasClass("rtl")){
						var offset_left = 0 - (window_width - (offeset.offset().left + offeset.width()));
					}
					var container_megamenu=$(">.dropdown-menu",cthis);
					
					if($('body').hasClass("rtl")){
						container_megamenu.css({
								right: offset_left,
								"box-sizing": "border-box",
								width: window_width
						});
					}else{
						container_megamenu.css({
								left: offset_left,
								"box-sizing": "border-box",
								width: window_width
						});
					}
				}
			});
		}
		
	}
}
function theplus_ele_menu_clicking(){
	"use strict";	
	var $=jQuery;
		$('.plus-navigation-wrap .menu-click .plus-navigation-menu .navbar-nav li.menu-item-has-children > a').on('click', function (event) {
			event.preventDefault(); 
			event.stopPropagation();
			if($(this).closest(".plus-navigation-inner.menu-click")){
				var navSideBut = $(this), 
				navSideItem = navSideBut.parent(),
				navSideUl = navSideBut.parent().parent(),
				navSideItemSub = navSideItem.find('> ul.dropdown-menu');

				if (navSideItem.hasClass('open-menu')) {
					navSideItemSub.slideUp(400);					
					navSideItem.removeClass('open-menu');
				} else {
					navSideUl.css("height","auto");
					navSideUl.find('li.dropdown.open-menu ul.dropdown-menu').slideUp(400);
					navSideUl.find('li.dropdown-submenu.open-menu ul.dropdown-menu').slideUp(400);
					navSideUl.find('li.dropdown,li.dropdown-submenu.open-menu').removeClass('open-menu');
					navSideItemSub.slideDown(400);					
					navSideItem.addClass('open-menu');
					if(navSideItem.find('.list-isotope-metro .post-inner-loop').length > 0){
						theplus_setup_packery_portfolio('all');		
					}	
				}
			}	
			
		});
		$(document).mouseup(function (e) {
			var $menu = $('li.dropdown');
			if (!$menu.is(e.target) && $menu.has(e.target).length === 0){
				$menu.find('ul.dropdown-menu').slideUp(400);
				$menu.find('li.dropdown-submenu.open-menu ul.dropdown-menu').slideUp(400);
				$menu.removeClass('open-menu');			
		   }
		});
}
(function ($) {
	'use strict';	
	var WidgetHeaderNavigation = function($scope, $) {

		var $plus_navigation = $scope.find('.plus-navigation-wrap');
		
		if($plus_navigation.find(".hover-inverse-effect").length >0){
			$(".plus-navigation-menu .nav > li > a").on({
			  mouseenter: function() {
				$( this ).closest(".hover-inverse-effect").addClass("is-hover-inverse");
				$( this ).addClass( "is-hover" );
			  }, mouseleave: function() {
				$( this ).closest(".hover-inverse-effect").removeClass("is-hover-inverse");
				$( this ).removeClass( "is-hover" );
			  }
			});
		}
		if($plus_navigation.find(".submenu-hover-inverse-effect").length >0){
			$(".plus-navigation-menu .nav li.dropdown .dropdown-menu > li > a").on({
			  mouseenter: function() {
				$( this ).closest(".submenu-hover-inverse-effect").addClass("is-submenu-hover-inverse");
				$( this ).addClass( "is-hover" );
			  }, mouseleave: function() {
				$( this ).closest(".submenu-hover-inverse-effect").removeClass("is-submenu-hover-inverse");
				$( this ).removeClass( "is-hover" );
			  }
			});
		}
		
		var inner_width = window.innerWidth;
		if(inner_width > 991){
			if($plus_navigation.find(".plus-navigation-inner").hasClass("menu-hover")){
				theplus_navmenu_hover();
			}
		}
		theplus_megamenu_fullwidth_container();
		//add class megamenu
		$plus_navigation.find(".nav>li .dropdown-menu").each(function(){
			var $this= $(this);
			var $megamenu_content=$this.find(".plus-megamenu-content");
			var $full_width_content=$this.closest(".plus-dropdown-full-width");
			var $container_content=$this.closest(".plus-dropdown-container");
			if($megamenu_content.length > 0 || $full_width_content.length || $container_content.length){
				var $closest_class=$this.closest(".dropdown");
				$closest_class.addClass("plus-fw");
			}
		});
		if($('.plus-mobile-menu-content.swiper-container').length > 0){
			new Swiper(".plus-mobile-menu-content.swiper-container",{
				slidesPerView: "auto",
				mousewheelControl: !0,
				freeMode: !0
			});
		}
		
		//navigation Sticky Opt
		if($plus_navigation.length > 0){
			var inner=$plus_navigation.find('.plus-navigation-inner'),
				nav_sticky=inner.data('nav-sticky'),
				nav_sticky_osup=inner.data('nav-sticky-osup'),
				nav_sticky_id=inner.data('wid');
			
			
			if (nav_sticky!=undefined && nav_sticky=='yes' && nav_sticky_id!='') {
				var sec_id = $plus_navigation.closest(".elementor-element.elementor-section:not(.elementor-inner-section)").addClass("plus-nav-sticky-sec").data("id");
				if(inner_width > 801 && $plus_navigation.closest(".elementor-element.elementor-section:not(.elementor-inner-section):not(.elementor-hidden-desktop)").length){				
					$plus_navigation.append('<div class="plus-nav-sticky ' + nav_sticky_id + "-" + sec_id + '"></div>');
				}
				if(inner_width < 800 && inner_width > 768 && $plus_navigation.closest(".elementor-element.elementor-section:not(.elementor-inner-section):not(.elementor-hidden-tablet)").length){
					$plus_navigation.append('<div class="plus-nav-sticky ' + nav_sticky_id + "-" + sec_id + '"></div>');
				}
				
				if(inner_width < 767 && $plus_navigation.closest(".elementor-element.elementor-section:not(.elementor-inner-section):not(.elementor-hidden-phone)").length){
					$plus_navigation.append('<div class="plus-nav-sticky ' + nav_sticky_id + "-" + sec_id + '"></div>');
				}				
                
                var sec_class = ".elementor-element-" + sec_id + ".elementor-section";
                $(".plus-nav-sticky." + nav_sticky_id + "-" + sec_id).insertBefore(sec_class), $(window).on("load scroll", function() {
                    var n = $(sec_class).outerHeight(),
                        o = $(".plus-nav-sticky." + nav_sticky_id + "-" + sec_id).length ? $(".plus-nav-sticky." + nav_sticky_id + "-" + sec_id).offset().top : 0,
                        i = $(".plus-nav-sticky." + nav_sticky_id + "-" + sec_id);
                    $(window).scrollTop() > o ? (i.css("min-height", n), $(sec_class).addClass("plus-fixed-sticky")) : (i.css("min-height", 0), $(sec_class).removeClass("plus-fixed-sticky"))
					/*On Mouse Scroll Up Sticky*/
					if(nav_sticky_osup!=undefined && nav_sticky_osup=='yes'){
						(function() {
							var header = new Headroom(document.querySelector(sec_class), {       
								tolerance: 5,
								classes: {
								  initial: "animated",
								  pinned: "slideDown",
								  unpinned: "slideUp"
								}
							});
							header.init();
							
						}());
					}
					/*On Mouse Scroll Up Sticky*/
                })
            }
		}
		
		/* AccessibilityMenu Code */
		document.addEventListener("click", accessibilitymenu );
		document.addEventListener('keyup', accessibilitymenu );

		function accessibilitymenu (event) {
			let $MenuType, $GetStyle, $Menulclick,
            	MainClass = $scope[0].querySelectorAll(".plus-navigation-wrap"),
            	innerClass = $scope[0].querySelectorAll(".plus-navigation-inner");

				if( $scope[0].querySelectorAll(".menu-horizontal").length > 0 ){
					$MenuType = "horizontal";
				}else if( $scope[0].querySelectorAll(".menu-vertical").length > 0 ){
					$MenuType = "vertical";
				}else if( $scope[0].querySelectorAll(".menu-vertical-side").length > 0 ){
					$MenuType = "vertical-side";
				}

				if( innerClass.length > 0 ){
					if( innerClass[0].classList.contains(" menu-hover") ){
						$Menulclick = 'hover';
					}else{
						$Menulclick = 'click';
					}

					$GetStyle = (innerClass[0] && innerClass[0].dataset && innerClass[0].dataset.menu_transition) ? innerClass[0].dataset.menu_transition : 'style-1';
				}

                if( MainClass.length > 0 ){
                    MainClass.forEach(function(Main) {
                        if( Number(event.which) == Number(9) ){
                            let GetSubdd = Main.querySelectorAll('.dropdown-toggle');
                            if( GetSubdd.length ){
                                GetSubdd.forEach(function(self) {
                                    if( self && self.classList.contains("focus-visible") ){
                                        /* Nothing */
                                    }else{
                                        if( self && self.nextElementSibling ){
                                            let Getsubfocus = self.nextElementSibling.querySelectorAll('.focus-visible');
										
                                                if( Getsubfocus.length == 0 ){
													if( $MenuType == "horizontal" || $MenuType == "vertical" || $MenuType == "vertical-side" ){
														self.nextElementSibling.style.display = "none";
													}
                                                }else{
                                                    if( self && self.classList.contains("dropdown-submenu") ){
                                                        /* Nothing */
                                                    }else{
                                                        Getsubfocus.forEach(function(self1) {
                                                            let GetSubUL = (self1 && self1.parentElement && self1.parentElement.parentElement) ? self1.parentElement.parentElement.querySelectorAll('li') : "";
                                                                if( GetSubUL.length > 0 ){
                                                                    GetSubUL.forEach(function(self2) {
                                                                        let GetSubLi = self2.querySelectorAll(".focus-visible");
                                                                        if( GetSubLi.length == 0 ){
                                                                            let GetSubclass = self2.querySelectorAll(".dropdown-menu");
                                                                                GetSubclass.forEach(function(self3) {
																					if( $MenuType == "horizontal" || $MenuType == "vertical" || $MenuType == "vertical-side" ){
																						self3.style.display = "none";
																					}
                                                                                });
                                                                        }
                                                                    });
                                                                }
                                                        });
                                                    }
                                                }
                                        }
                                    }
                                });
                            }	

							openmenu(Main, $MenuType, $GetStyle);
                        }else if( Number(event.which) == Number(27)){
							closemenu(Main, $MenuType);
                        }
                    });
                }
		}

		function openmenu (Main, $MenuType, $GetStyle) {
			/* Add OpenMenu */
			let GetAccessibility = Main.querySelectorAll('.focus-visible');
				if( GetAccessibility.length ){
					GetAccessibility.forEach(function(self) { 
						if(self && self.nextElementSibling){
							if($MenuType == "vertical-side" || $MenuType == "horizontal"){
								self.nextElementSibling.style.cssText = `display: block`;
							}else if($MenuType == "vertical"){
								jQuery(self.nextElementSibling).slideDown(); 				/* JQuery */
								if( self.parentElement.classList.contains('plus-fw') ){
									self.parentElement.classList.remove('plus-fw');
									relayoutmenu(self);
								}
							}
						}
					});
				}   
		}

		function closemenu (Main, $MenuType) {
			/* Close 27 Esc, 1 Mouse click */
			if($MenuType == "vertical" || $MenuType == "horizontal" || $MenuType == "vertical-side"){ 
				let GetMenuclass = Main.querySelectorAll("ul.dropdown-menu");
				if( GetMenuclass.length ){
					GetMenuclass.forEach(function(self) {
						self.style.display = "none";
					});
				}
			}
		}

		function relayoutmenu (self) {
			let Getlistisotope = self.parentElement.querySelectorAll('.list-isotope');
			if( Getlistisotope.length > 0 ){
				Getlistisotope.forEach(function(reload) {
					let GetpostLoop = reload.querySelectorAll('.post-inner-loop');
						if( GetpostLoop.length > 0 ){
							$(GetpostLoop).isotope('reloadItems').isotope();		/* JQuery */
						}
				});
			}else if( self.parentElement.querySelectorAll('.list-isotope-metro').length > 0 ){
				theplus_setup_packery_portfolio('all');	
			}
		}

	};
	
	$(window).on('elementor/frontend/init', function () {
		elementorFrontend.hooks.addAction('frontend/element_ready/tp-navigation-menu.default', WidgetHeaderNavigation);
	});

})(jQuery);