// source --> https://new.fylde.gov.uk/wp-content/plugins/interactive-3d-flipbook-powered-physics-engine/assets/js/client-locale-loader.js?ver=1.16.19 
function fb3dClientLocaleLoader() {
  if(window.jQuery && typeof jQuery.ajax==='function') {
    function fb3dNormalizeUrl(url) {
      return url.replace(/https{0,1}:/, location.protocol);
    }
    function fb3dFetch(url) {
      return new Promise(function(resolve, reject) {
        jQuery.ajax({url: fb3dNormalizeUrl(url), dataType: 'text'}).done(resolve).fail(reject);
      });
    }
    FB3D_CLIENT_LOCALE.render = function() {
      delete FB3D_CLIENT_LOCALE.render;
      var isStable = !Promise.withResolvers || /^((?!chrome|android).)*safari/i.test(navigator.userAgent),
        pdfJs = FB3D_CLIENT_LOCALE.pdfJS, assetsJs = FB3D_CLIENT_LOCALE.pluginurl+'assets/js/';
      window.FB3D_LOCALE = {
        dictionary: FB3D_CLIENT_LOCALE.dictionary
      };
      window.PDFJS_LOCALE = {
        pdfJsCMapUrl: fb3dNormalizeUrl(pdfJs.pdfJsCMapUrl),
        pdfJsWorker: fb3dNormalizeUrl(isStable? pdfJs.stablePdfJsWorker: pdfJs.pdfJsWorker)
      };
      Promise.all([
        fb3dFetch(FB3D_CLIENT_LOCALE.pluginurl+'assets/css/client.css?ver='+FB3D_CLIENT_LOCALE.version),
        fb3dFetch(FB3D_CLIENT_LOCALE.pluginurl+'assets/templates/iframe-init.html?ver='+FB3D_CLIENT_LOCALE.version),
        fb3dFetch(FB3D_CLIENT_LOCALE.cacheurl+'skins.js?ver='+FB3D_CLIENT_LOCALE.version),
        fb3dFetch(isStable? pdfJs.stablePdfJsLib: pdfJs.pdfJsLib),
        fb3dFetch(assetsJs+'three.min.js?ver=125'),
        fb3dFetch(assetsJs+'html2canvas.min.js?ver=0.5'),
        fb3dFetch(assetsJs+'client.min.js?ver='+FB3D_CLIENT_LOCALE.version),
      ]).then(function(fs) {
        jQuery('head').append(['<style type="text/css">', fs[0].replace(/url\('..\//gi, 'url(\''+fb3dNormalizeUrl(FB3D_CLIENT_LOCALE.pluginurl+'assets/')), '</style>'].join(''));
        for(var i = 2; i<fs.length; ++i) {
          eval(fs[i]);
        }
      });
    };
    if(jQuery('._'+FB3D_CLIENT_LOCALE.key).length) {
      FB3D_CLIENT_LOCALE.render();
    }
  }
  else {
    setTimeout(fb3dClientLocaleLoader, 100);
  }
}
fb3dClientLocaleLoader();
// source --> https://new.fylde.gov.uk/wp-content/themes/pe-public-institutions/js/theme.js?ver=1.2 
/*--------------------------------------------------------------
 Copyright (C) pixelemu.com
 License: http://www.pixelemu.com/license.html PixelEmu Proprietary Use License
 Website: http://www.pixelemu.com
 Support: info@pixelemu.com
---------------------------------------------------------------*/

(function($) {

	"use strict";

	/* -------------------------------------------------------- */
	/* FUNCTIONS                                                */
	/* -------------------------------------------------------- */

	// Animated Headlines
	//-------------------------------------------------------

	//set animation timing
	var animationDelay = 2500,
	//loading bar effect
	barAnimationDelay = 3800,
	barWaiting = barAnimationDelay - 3000, //3000 is the duration of the transition on the loading bar - set in the scss/css file
	//letters effect
	lettersDelay = 50,
	//type effect
	typeLettersDelay = 150,
	selectionDuration = 500,
	typeAnimationDelay = selectionDuration + 800,
	//clip effect
	revealDuration = 600,
	revealAnimationDelay = 1500;

	function initHeadline() {
		//insert <i> element for each letter of a changing word
		singleLetters($('.cd-headline.letters').find('b'));
		//initialise headline animation
		animateHeadline($('.cd-headline'));
	}

	function singleLetters($words) {
		$words.each(function(){
			var word = $(this),
				letters = word.text().split(''),
				selected = word.hasClass('is-visible');
			for (i in letters) {
				if(word.parents('.rotate-2').length > 0) letters[i] = '<em>' + letters[i] + '</em>';
				letters[i] = (selected) ? '<i class="in">' + letters[i] + '</i>': '<i>' + letters[i] + '</i>';
			}
				var newLetters = letters.join('');
				word.html(newLetters).css('opacity', 1);
		});
	}

	function animateHeadline($headlines) {
		var duration = animationDelay;
		$headlines.each(function(){
			var headline = $(this);

			if(headline.hasClass('loading-bar')) {
				duration = barAnimationDelay;
				setTimeout(function(){ headline.find('.cd-words-wrapper').addClass('is-loading') }, barWaiting);
			} else if (headline.hasClass('clip')){
				var spanWrapper = headline.find('.cd-words-wrapper'),
					newWidth = spanWrapper.width() + 10
				spanWrapper.css('width', newWidth);
			} else if (!headline.hasClass('type') ) {
				//assign to .cd-words-wrapper the width of its longest word
				var words = headline.find('.cd-words-wrapper b'),
					width = 0;
				words.each(function(){
					var wordWidth = $(this).width();
						if (wordWidth > width) width = wordWidth;
				});
				headline.find('.cd-words-wrapper').css('width', width);
			};

			//trigger animation
			setTimeout(function(){ hideWord( headline.find('.is-visible').eq(0) ) }, duration);
		});
	}

	function hideWord($word) {
		var nextWord = takeNext($word);

		if($word.parents('.cd-headline').hasClass('type')) {
			var parentSpan = $word.parent('.cd-words-wrapper');
			parentSpan.addClass('selected').removeClass('waiting');
			setTimeout(function(){
				parentSpan.removeClass('selected');
				$word.removeClass('is-visible').addClass('is-hidden').children('i').removeClass('in').addClass('out');
			}, selectionDuration);
			setTimeout(function(){ showWord(nextWord, typeLettersDelay) }, typeAnimationDelay);

		} else if($word.parents('.cd-headline').hasClass('letters')) {
			var bool = ($word.children('i').length >= nextWord.children('i').length) ? true : false;
			hideLetter($word.find('i').eq(0), $word, bool, lettersDelay);
			showLetter(nextWord.find('i').eq(0), nextWord, bool, lettersDelay);

		}  else if($word.parents('.cd-headline').hasClass('clip')) {
			$word.parents('.cd-words-wrapper').animate({ width : '2px' }, revealDuration, function(){
				switchWord($word, nextWord);
				showWord(nextWord);
			});

		} else if ($word.parents('.cd-headline').hasClass('loading-bar')){
			$word.parents('.cd-words-wrapper').removeClass('is-loading');
			switchWord($word, nextWord);
			setTimeout(function(){ hideWord(nextWord) }, barAnimationDelay);
			setTimeout(function(){ $word.parents('.cd-words-wrapper').addClass('is-loading') }, barWaiting);

		} else {
			switchWord($word, nextWord);
			setTimeout(function(){ hideWord(nextWord) }, animationDelay);
		}
	}

	function showWord($word, $duration) {
		if($word.parents('.cd-headline').hasClass('type')) {
			showLetter($word.find('i').eq(0), $word, false, $duration);
			$word.addClass('is-visible').removeClass('is-hidden');

		}  else if($word.parents('.cd-headline').hasClass('clip')) {
			$word.parents('.cd-words-wrapper').animate({ 'width' : $word.width() + 10 }, revealDuration, function(){
				setTimeout(function(){ hideWord($word) }, revealAnimationDelay);
			});
		}
	}

	function hideLetter($letter, $word, $bool, $duration) {
		$letter.removeClass('in').addClass('out');

		if(!$letter.is(':last-child')) {
			setTimeout(function(){ hideLetter($letter.next(), $word, $bool, $duration); }, $duration);
		} else if($bool) {
			setTimeout(function(){ hideWord(takeNext($word)) }, animationDelay);
		}

		if($letter.is(':last-child') && $('html').hasClass('no-csstransitions')) {
			var nextWord = takeNext($word);
			switchWord($word, nextWord);
		}
	}

	function showLetter($letter, $word, $bool, $duration) {
		$letter.addClass('in').removeClass('out');

		if(!$letter.is(':last-child')) {
			setTimeout(function(){ showLetter($letter.next(), $word, $bool, $duration); }, $duration);
		} else {
			if($word.parents('.cd-headline').hasClass('type')) { setTimeout(function(){ $word.parents('.cd-words-wrapper').addClass('waiting'); }, 200);}
			if(!$bool) { setTimeout(function(){ hideWord($word) }, animationDelay) }
		}
	}

	function takeNext($word) {
		return (!$word.is(':last-child')) ? $word.next() : $word.parent().children().eq(0);
	}

	function takePrev($word) {
		return (!$word.is(':first-child')) ? $word.prev() : $word.parent().children().last();
	}

	function switchWord($oldWord, $newWord) {
		$oldWord.removeClass('is-visible').addClass('is-hidden');
		$newWord.removeClass('is-hidden').addClass('is-visible');
	}

	//jQuery Off-Canvas
	//-------------------------------------------------------

	var PEoffcanvasScrollsize;

	function PEoffcanvasToggleNav() {
		var y = $(window).scrollTop();
		if ($('body').hasClass('off-canvas')) {
			// Do things on Nav Close
			$('body').removeClass('off-canvas');
			$('#pe-offcanvas').find('a').attr('tabindex', -1);
			setTimeout(function() {
				$('.sticky-bar #pe-bar').removeAttr('style');
				$('html').removeClass('no-scroll').removeAttr('style');
				$(window).scrollTop(PEoffcanvasScrollsize);
			}, 300);
		} else {
			// Do things on Nav Open
			$('body').addClass('off-canvas');
			$('.sticky-bar #pe-bar').css({'position':'absolute','top':y});
			$('#pe-offcanvas .toggle-nav.close').focus();
			$('#pe-offcanvas').find('a').attr('tabindex', 0);
			setTimeout(function() {
				$('html').addClass('no-scroll').css('top',-y);
			}, 300);
		}
	}

	// Megamenu Subtitle
	//-------------------------------------------------------

	/*function PEmenuSubtitleFromTitle() {
		var PEmenuItem = $('#pe-main-menu > div > ul > li > a[title]');
		if(PEmenuItem.length) {
			PEmenuItem.each(function (){
				var title = $(this).attr('title');
				$(this).append('<span aria-hidden="true">' + title + '</span>')
			});
		}
	}*/

	// Carousel
	//-------------------------------------------------------

	function SlickUpdateHeight(e) {
		var parentslider = $(e).closest('.pe-slick-content');
		if(parentslider.length) {
			parentslider.find('.slick-list').css('height','auto');
		}
	}

	function unFocusable(e) {
		$(e).find('.slick-slide a').attr('tabindex', '-1');
		$(e).find('.slick-slide.slick-active a').attr('tabindex', '0');
	}

	// Widget height suffix
	//-------------------------------------------------------

	function PEsetWidgetHeight() {
		var regexp = new RegExp("height([0-9]+)");
		var widgets = $(document).find('.pe-widget') || [];
		if (widgets.length) {
			widgets.each(function(index,element){
				var match = regexp.exec(element.className) || [];
				if (match.length > 1) {
					var widgetHeight = parseInt(match[1]);
					$(element).css('min-height', widgetHeight + 'px');
				}
			});
		}
	}

	// PE Stripe
	//-------------------------------------------------------

	function PEtabStripe() {
		var suffix = $('.pe_panels_widget.pe-stripes');
		suffix.each(function() {
			var container = suffix.closest('.pe-container').parent();
			//get tabs height
			var tabHeading = suffix.find('.pn-headings');
			var tabHeight = tabHeading.outerHeight();

			//set height
			if(!container.hasClass('show-stripes')) {
				container.addClass('show-stripes');
			}
			$('head').append('<style type="text/css">.show-stripes:before{height:' + tabHeight + 'px;}</style>');
		});
	}

	// Sticky Bar
	//-------------------------------------------------------

	var peTimerSticky;

	function resizeFunction() {
		var body = $('body');
		var allpage = $('#pe-main');

		if(body.hasClass('sticky-bar')) {
		var bar = allpage.find('#pe-bar-in');
			if (bar.length) {
				var offset = bar.outerHeight();
				allpage.css('padding-top', (offset) + 'px');
			}
		}
	};

	// on scroll animation
	//-------------------------------------------------------

	function onScrollInit( items, trigger ) {
		items.each( function() {
			var osElement = $(this),
				osAnimationClass = osElement.attr('data-animation'),
				osAnimationDelay = osElement.attr('data-animation-delay');

				osElement.css({
					'-webkit-animation-delay':  osAnimationDelay,
					'animation-delay':          osAnimationDelay
				});

				var osTrigger = ( trigger ) ? trigger : osElement;

				osTrigger.waypoint(function() {
					osElement.addClass('animated').addClass(osAnimationClass);
					},{
						triggerOnce: true,
						offset: 'bottom-in-view'
				});
		});
	}

	//hack for PE Panels
	function PEpanelsHack() {
		var PEpanelsWidget = $('.pe-panels.tabs');
		PEpanelsWidget.find('.pe-panels-heading a').on('click', function(e)  {
			setTimeout(function(){
				onScrollInit( $('.pe-animation') );
			}, 400);
		});

		var panels = $(this).find('.pe-panel');
		var panelsHeading = panels.find('.pe-panel-heading');
		panelsHeading.find('a').click(function(e) {
			setTimeout(function(){
				onScrollInit( $('.pe-animation') );
			}, 400);
		});
	}

	// PE Main Menu
	//-------------------------------------------------------

	function is_touch_device() {
		return 'ontouchstart' in window      // works on most browsers
			|| navigator.maxTouchPoints;       // works on IE10/11 and Surface
	};

	var peMenuTimer;

	function PEtopMenu() {
		var html = $('html, body');
		var navContainer = $('.pe-nav-container');
		var navToggle = $('.nav-toggle');
		var navDropdownToggle = $('.pe-nav-container .menu-item-has-children');

		var clicked = false;

		//position
		function setPositions() {
			//position
			var navTogglePosition = $('#pe-bar-in').outerHeight();
			if( navTogglePosition > 0 ) {
				if( $('body').hasClass('admin-bar') ) {
					var adminbar = $('#wpadminbar').height();
					navTogglePosition = navTogglePosition + adminbar;
				}
				navContainer.css({'top':navTogglePosition + 'px'});
			}
			//height
			var peScreenHeight = $(window).height();
			if( peScreenHeight > 0 && navTogglePosition > 0 ) {
				navContainer.css({'max-height': (peScreenHeight - navTogglePosition) + 'px'});
			}
			clicked = true;
		}

		function removePositions() {
			navContainer.css({'top': '', 'max-height': ''});
		}

		// Nav toggle
		navToggle.on('click', function(e) {
			e.preventDefault();

			if( clicked == false ) {
				setPositions();
			} else {
				removePositions();
				clicked = false;
			}

			$(this).toggleClass('is-active');
			navContainer.toggleClass('is-visible responsive');
			html.toggleClass('nav-open no-scroll');

		});

		// Nav dropdown toggle
		navDropdownToggle.on('click', function(e) {

			var $this = $(this);
			var link = $this.find('> a');
			var links = $this.siblings().find('> a');
			var hash = link.is('a[href^="#"]');
			var responsive = $this.closest('.pe-nav-container').hasClass('responsive');

			if( ! link.hasClass('clicked') ) {
				if( ! responsive ) {
					links.removeClass('clicked');
				}

				link.toggleClass('clicked');
				$this.toggleClass('is-active').children('.nav-dropdown').toggleClass('is-visible');

				if( hash || is_touch_device() || responsive ) {
					return false;
				}
			} else {
				link.toggleClass('clicked');
				$this.toggleClass('is-active').children('.nav-dropdown').toggleClass('is-visible');

				if ( hash ) {
					return false;
				}
				//go to url here
			}

		});

		// Prevent click events from firing on children of navDropdownToggle
		navDropdownToggle.find('.nav-dropdown a').click(function(e) {
			e.stopPropagation();
		});

	}

	// Change submenu position if it doesn't fit the screen (desktop view)
	function PEtopMenuDropdownDirection() {
		var navContainer = $('.pe-nav-container');
		var navDropdownToggle = $('.menu-item-has-children');
			//mouse over (parent)
			navDropdownToggle.mouseenter(function() {

				if ( navContainer.hasClass('responsive') ) {
					return;
				}

				var screenWidth = $(window).width();
				var dropDown = $(this).find('.nav-dropdown');
				dropDown.each( function(e) {
					var dropDownPosition = $(this).offset();
					var dropDownWidth = $(this).width();

					if((dropDownPosition.left + dropDownWidth) > screenWidth) {
						$(this).toggleClass('change-direction');
					}

				});
			});

		//remove class when mouse out of menu
		navContainer.mouseleave(function(){
			$(this).find('.nav-dropdown').removeClass('change-direction');
		});

	}

	// Max Megamenu helper class

	function PEmegamenuHelper() {
		var PEmegamenuBreakPoint = $('#mega-menu-main-menu').attr('data-breakpoint');
		var body = $('body');
		if( PEmegamenuBreakPoint ) {
			var swidth = (window.innerWidth-$(window).width());
			var PEscreenWidth = $('body').innerWidth() + swidth;
			if( PEscreenWidth <= PEmegamenuBreakPoint ) {
				$('#pe-logo-nav').addClass('responsive');
			} else {
				$('#pe-logo-nav').removeClass('responsive');
			}
		}
	}

	// WCAG MENU
	//-------------------------------------------------------

	function wcagSimpleMenu() {

		var menuContainer = $('.pe-nav-container');
		var menuLi = menuContainer.find('.menu-item');
		var totalElements = menuLi.length;

		menuLi.each(function(index) {

			var li = $(this);
			var anchor = li.find('> a');

			anchor.on('focus',function(){
				setTimeout(function(){
					li.trigger('mouseenter');
				}, 50);
			});

			anchor.on('focusout',function(){
				if(index === totalElements - 1) {
					setTimeout(function(){
						li.trigger('mouseleave');
					}, 50);
				}
			});

			li.on('mouseenter', function() {
				li.siblings().removeClass('hover');
				li.addClass('hover');
			});

			li.on('mouseleave', function() {
				li.removeClass('hover');
			});

		});

	}

	/*function wcagMaxMegaMenu() {

		$('.mega-menu-toggle').on('mousedown', function() {
			$(this).toggleClass('clicked');
		});

		$('.mega-menu-toggle').on('focus', function() {
			if( ! $(this).hasClass('clicked') ) {
				$(this).trigger('click');
			}
		});

		$('#mega-menu-main-menu .mega-menu-link').last().on('focusout', function(e) {
			if( !$(e.relatedTarget).hasClass('mega-menu-link') ) {
				$('.mega-menu-toggle').removeClass('mega-menu-open clicked');
			}
		});

	}*/

	// WCAG Rev Slider
	//-------------------------------------------------------

	function wcagRevSlider() {

		var navi = $('.rev_slider_wrapper .tp-bullets .tp-bullet, .rev_slider_wrapper .tp-leftarrow, .rev_slider_wrapper .tp-rightarrow');

		if( navi.length ) {
			navi.prop('tabindex', '0');
			navi.keypress(function( event ) {
				if ( event.which == 13 ) {
					$(this).trigger('click');
				}
			});
		}
	}

	// Refresh map
	//-------------------------------------------------------

	function refreshGoogleMap( element ) {
		var map = $(element).find('.pe_map_canvas');
		if( map.length ) {
			var maps = window.pemaps;
			map.each(function() {
				var self = maps[ $(this).attr('id') ];
				if( typeof self != 'undefined' ) {
					google.maps.event.trigger( self.map,'resize' );
					self.map.setCenter( self.marker.getPosition() );
					if( typeof self.infoWindow != 'undefined' ) {
						self.infoWindow.setContent( self.tooltip );
					}
				}
			});
		}
	}

	// Search Form
	//-------------------------------------------------------

	function searchForm() {
		var searchModule = $('#pe-bar #pe-search');

		var searchModuleInput = searchModule.find('.pe-search-input');
		var searchModuleInputField = searchModuleInput.find('.s');
		var searchModuleButton = searchModule.find('.button');

		var firstClick = true;

		function openSearch() {
			searchModuleInput.addClass('open');
			searchModuleInput.animate({width:'toggle'},400);
			searchModuleInputField.focus();
			firstClick = false;
		}

		function closeSearch() {
			searchModuleInput.removeClass('open');
			searchModuleInput.animate({width:'toggle'},400);
			firstClick = true;
		}

		if( searchModule.length ) {

			searchModuleInput.hide();

			searchModuleButton.click(function (e) {

				if( firstClick ) {
					openSearch();
					return false;
				} else {
					if( searchModuleInputField.val() ) {
						return;
					} else {
						closeSearch();
						return false;
					}
				}

			});

		}
	}

	/* -------------------------------------------------------- */
	/* READY state                                              */
	/* -------------------------------------------------------- */

	$(document).ready(function() {

		// PE Section space
		//-------------------------------------------------------

		$('.pe-section-space').closest('.container-fluid').parent().addClass('nospace');
		$('.pe-section-space-top').closest('.container-fluid').parent().addClass('nospace-top');
		$('.pe-section-space-bottom').closest('.container-fluid').parent().addClass('nospace-bottom');

		// First and Last class for widgets
		//-------------------------------------------------------

		var PEboxWidget = $('.row .pe-widget');
		PEboxWidget.first().addClass('first');
		PEboxWidget.last().addClass('last');

		// top menu
		//-------------------------------------------------------

		PEtopMenu();
		PEtopMenuDropdownDirection();

		// Animated Headlines
		//-------------------------------------------------------

		initHeadline();

		// Contact Form Handling - send-email.php
		//-------------------------------------------------------

		if($().validate && $().ajaxSubmit) {

			var submitButton = $( '#submit-button'),
					messageContainer = $( '.pe-success'),
					errorContainer = $( '.pe-alert' );

			var formOptions = {
				beforeSubmit: function() {
					submitButton.attr('disabled','disabled');
					messageContainer.fadeOut('fast');
					errorContainer.fadeOut('fast');
				},
				success: function( ajax_response, statusText, xhr, $form) {
					var response = $.parseJSON ( ajax_response );
					submitButton.removeAttr('disabled');
					if( response.success ) {
						$form.resetForm();
						messageContainer.html( response.message ).fadeIn('fast');
					} else {
						errorContainer.html( response.message ).fadeIn('fast');
					}
				}
			};

			// Contact page form

			$('#pe-contact-form').validate( {
				errorLabelContainer: errorContainer,
				submitHandler: function(form) {
					$(form).ajaxSubmit( formOptions );
				}
			});
		}

		//jQuery 'Back to Top' script
		//-------------------------------------------------------

		// hide #pe-back-top first
		$("#pe-back-top").hide();
		// fade in #pe-back-top
			$(window).scroll(function () {
				if ($(this).scrollTop() > 100) {
					$('#pe-back-top').fadeIn();
				} else {
					$('#pe-back-top').fadeOut();
				}
			});
			// scroll body to 0px on click
			$('#pe-back-top a').click(function () {
				$('body,html').animate({
					scrollTop: 0
				}, 800);
				return false;
			});

		// Off-Canvas sidebar
		//-------------------------------------------------------

		$('#pe-offcanvas').find('a').attr('tabindex', -1);

		// Toggle Nav on Click
		$('.toggle-nav').click(function(e) {
			e.preventDefault();
			$('.toggle-nav').toggleClass('active');
			// Get scroll size on offcanvas open
			if(!$('body').hasClass('off-canvas')) {
				PEoffcanvasScrollsize = $(window).scrollTop();
			}
			// Calling a function
			PEoffcanvasToggleNav();
		});

		// Modal
		//-------------------------------------------------------

		if (!!$.prototype.magnificPopup) {
			$('.pe-gallery').each(function() {
				$(this).find('.pe-gallery-modal').magnificPopup({
					type:'inline',
					midClick: true, // allow opening popup on middle mouse click. Always set it to true if you don't provide alternative source.
					gallery: {
						enabled: true
					}
				});
			});

			$('.pe-modal').magnificPopup({
				type:'inline',
				midClick: true, // allow opening popup on middle mouse click. Always set it to true if you don't provide alternative source.
			});

			$('.pe-modal, .pe-gallery-modal').keypress(function (e) {
				if (e.which == 13) {
					$(this).trigger('click');
				}
			});
		}

		// Tabs
		//-------------------------------------------------------

		$('.pe-tabs .pe-tab-links a').on('click', function(e)  {
			e.preventDefault();
			var currentAttrValue = $(this).attr('href');
			var tabContent = $('.pe-tabs .pe-tabs-content').find(currentAttrValue);
			// Show / hide tab content
			tabContent.slideDown(400).siblings().slideUp(400);

			// Change active state
			setTimeout(function() {
				tabContent.addClass('active').siblings().removeClass('active');
			}, 400);
			$(this).parent('li').addClass('active').siblings().removeClass('active');
			SlickUpdateHeight(this); //update slick height
			//refreshGoogleMap( tabContent );
		});

		// Accordion
		//-------------------------------------------------------

		$('.pe-accordion-container').each(function() {
			//check multiselect
			if($(this).attr('multiselectable')) {
				var multiSelect = true;
			} else {
				var multiSelect = false;
			}

				var allTitles = $(this).find('.pe-accordion-heading');
				var allContents = $(this).find('.pe-accordion-content');

				//hide content
				allContents.each(function() {
					if(!$(this).hasClass('active')) {
						$(this).hide();
					}
				});

				//on click
				allTitles.find('a').click(function(e) {
					e.preventDefault();
					SlickUpdateHeight(this); //update slick height

					var thisTitle = $(this).parent();
					var thisContent = $(this).parent().next();

					if(!thisContent.hasClass('active')) {
						//if item NOT active
						if(!multiSelect) {
							//hide all panels
							allContents.slideUp(400).removeClass('active');
							allContents.attr('aria-expanded', 'false');
							allTitles.removeClass('active');
						}
						//show current panel
						thisContent.slideDown(400).addClass('active');
						thisContent.attr('aria-expanded', 'true');
						thisTitle.addClass('active');
					} else {
						//if item ACTIVE
						if(!multiSelect) {
							//hide all panels
							allContents.slideUp(400).removeClass('active');
							allContents.attr('aria-expanded', 'false');
							allTitles.removeClass('active');
						} else {
							//hide current panel
							thisContent.slideUp(400).removeClass('active');
							thisContent.attr('aria-expanded', 'false');
							thisTitle.removeClass('active');
						}

					}
					//refreshGoogleMap( thisContent );
			});

		});

		// Carousel
		//-------------------------------------------------------

		$('.pe-carousel').each(function (){
			var slider = $(this).find('.pe-slick-content');
			var indicator = $(this).find('.pe-indicator');
			var anchor = slider.find('a');

			slider.slick({
				arrows: false,
				adaptiveHeight: true,
				pauseOnHover: true,
				accessibility: false
			});

			indicator.each(function (){
				$(this).on('keydown', function(event){
					if(event.which == 13) { // enter key
						$(this).click();
					}
				});
			});

			indicator.click(function(e){
				e.preventDefault();
				var slideIndex = $(this).attr('data-slick-goto');
				slider.slick('slickGoTo', slideIndex);
			});

			unFocusable(this);

			slider.on('afterChange', function(slick, currentSlide){
				unFocusable(this);
				indicator.each(function(){
					var $this = $(this);
					if ($this.attr('data-slick-goto') == currentSlide.currentSlide) {
						$this.addClass('active');
					} else {
						$this.removeClass('active');
					}
				});
			});
		});

		searchForm();

		// Megamenu Subtitle
		//-------------------------------------------------------

		//PEmenuSubtitleFromTitle();

		// Widget height suffix
		//-------------------------------------------------------

		PEsetWidgetHeight();

		// PE Stripe
		//-------------------------------------------------------

		PEtabStripe();

		//event calendar
		function pe_event_calendar() {
			$('.tribe-events-style-skeleton .tribe-events-calendar thead [title]').removeAttr('title');
			$('.tribe-events-style-skeleton .tribe-region').removeAttr('title');
			$('.tribe-events-style-skeleton .tribe-bar-views-inner label').attr('for', 'tribe-bar-view');
			$('.tribe-events-style-skeleton .tribe-bar-views-inner select').attr('id', 'tribe-bar-view');

			var venue = $('.tribe-events-style-skeleton .tribe-events-single .tribe-events-meta-group-venue').detach();
			$('.tribe-events-style-skeleton .tribe-events-single .tribe-events-event-meta.primary').append(venue);

			$('.tribe-events-style-skeleton .tribe-events-list .tribe-events-loop .tribe-event-featured').each(function() {
				var title = $(this).find('.tribe-events-list-event-title').detach();
				$(this).prepend(title);
			});

			var text = $('.tribe-events-style-skeleton h2.tribe-events-page-title').text();
			$('.tribe-events-style-skeleton h2.tribe-events-page-title').replaceWith('<h1 class="tribe-events-page-title">' + text + '</h1>');

			$('.tribe-events-list-widget h4.tribe-event-title').replaceWith(function(){
				return $("<h3 class='tribe-event-title' />").append($(this).contents());
			});

		}

		pe_event_calendar();

		/* -------------------------------------------------------- */
		/* end READY state                                          */
		/* -------------------------------------------------------- */

	});

	/* -------------------------------------------------------- */
	/* LOAD state                                               */
	/* -------------------------------------------------------- */

	$(window).load(function() {

		// Sticky Bar
		//-------------------------------------------------------

		resizeFunction();

		$('.pe-normal').click(function(event) {
			resizeFunction();
		});

		$(window).resize(function() {
			if(!!peTimerSticky){ clearTimeout(peTimerSticky); }
			peTimerSticky = setTimeout(resizeFunction, 30);
		});

		$(window).scroll(function() {
			var topbar = $('#pe-bar');
			if (topbar.length) {
				var scroll = $(window).scrollTop();
				if (scroll >= 20) {
					topbar.addClass("scrolled");
				} else {
					topbar.removeClass("scrolled");
				}
			}
		});

		// on scroll animation
		//-------------------------------------------------------

		setTimeout(function(){
			onScrollInit( $('.pe-animation') );
		}, 400);

		PEpanelsHack();

		// PE Main Menu
		//-------------------------------------------------------


		PEmegamenuHelper();

		$(window).resize(function(){
			if( !!peMenuTimer ){ clearTimeout(peMenuTimer); }
			peMenuTimer = setTimeout(PEmegamenuHelper, 50);
		});

		wcagSimpleMenu();
		//wcagMaxMegaMenu();

		// WCAG Rev Slider
		//-------------------------------------------------------

		setTimeout(function() {
			wcagRevSlider();
		}, 500);

	/* -------------------------------------------------------- */
	/* end LOAD state                                           */
	/* -------------------------------------------------------- */

	});

})(jQuery);