PageSourceSearch

https://www.swissdrums.com/wp-content/themes/atelier/js/functions.js

js swissdrums.com collected 2026-10-09 05:23:49 UTC 211,431 bytes, 6,448 lines download raw bytes

1/* global jQuery,google,TweenLite,Circ,Cookies */
2
3var SWIFT = SWIFT || {};
4
5(function(){
6
7	// USE STRICT
8	"use strict";
9
10	/////////////////////////////////////////////
11	// PAGE FUNCTIONS
12	/////////////////////////////////////////////
13
14 	SWIFT.page = {
15		init: function () {
16
17			// BROWSER CHECK
18			SWIFT.page.browserCheck();
19
20			// FITTEXT
21			//SWIFT.page.resizeHeadings();
22
23			// HEADER SLIDER
24			if (body.hasClass('header-below-slider') && jQuery('.home-slider-wrap').length > 0) {
25				SWIFT.page.headerSlider();
26			}
27
28			// ONE PAGE NAV
29			if (jQuery('#one-page-nav').length > 0) {
30				SWIFT.page.onePageNav();
31			}
32
33			// BACK TO TOP
34			if (jQuery('#back-to-top').length > 0) {
35				$window.scroll(function() {
36					SWIFT.page.backToTop();
37				});
38			}
39
40			// HERO/CONTENT SPLIT STYLE
41			if (body.hasClass('hero-content-split')) {
42				SWIFT.page.heroContentSplit();
43			}
44
45			// FOOTER NEWSLETTER SUB BAR
46			if (jQuery('#sf-newsletter-bar').length > 0) {
47				SWIFT.page.newsletterSubBar();
48			}
49
50			// ADMIN BAR CHECK
51			if (jQuery('#wpadminbar').length > 0) {
52				body.addClass('has-wpadminbar');
53			}
54
55			// RECENT POSTS
56			if (jQuery('.recent-posts').length > 0) {
57				SWIFT.recentPosts.init();
58			}
59
60//			if (jQuery('.sf-share-counts').length > 0) {
61//				SWIFT.page.shareCounts();
62//			}
63
64			// MOVE MODALS TO BOTTOM OF PAGE
65			SWIFT.page.moveModals();
66
67			// LOAD MAP ASSET ON MODAL CLICK
68			jQuery('a[data-toggle="modal"]').on('click', function() {
69				setTimeout(function() {
70					SWIFT.map.init();
71				}, 300);
72
73				return true;
74			});
75
76			// REFRESH MODAL IFRAME ON CLOSE (FOR VIDEOS)
77			SWIFT.page.modalClose();
78
79			// REPLACE COMMENTS REPLY TITLE HTML
80			if (body.hasClass('single-post')) {
81				var replyTitle = jQuery('#respond').find('h3');
82				var originalText = jQuery('#respond').find('h3').html();
83
84				replyTitle.addClass('spb-heading');
85				replyTitle.html('<span>'+originalText+'</span>');
86			}
87
88			// SMOOTH SCROLL LINKS
89			SWIFT.page.smoothScrollLinks();
90
91			// EXPANDING ASSETS
92			SWIFT.page.expandingAssets();
93
94			// PORTFOLIO STICKY SIDEBAR
95			if (!isMobileAlt && jQuery('article.type-portfolio').hasClass('single-portfolio-split')) {
96				//SWIFT.portfolio.stickyDetails();
97			}
98
99			// BUDDYPRESS ACTIVITY LINK CLICK
100			jQuery('.activity-time-since,.bp-secondary-action').on('click', function(e) {
101				e.preventDefault();
102				jQuery('.viewer').css('display', 'none');
103				window.location = jQuery(this).attr('href');
104			});
105
106			// LOVE IT CLICK
107			jQuery('.love-it').on('click', function() {
108				SWIFT.page.loveIt(jQuery(this));
109				return false;
110			});
111
112			// ARTICLE NAVIGATION
113			if (body.hasClass('article-swipe') && body.hasClass('single-post') && jQuery('.post-pagination-wrap').length > 0) {
114				SWIFT.page.articleNavigation();
115			}
116
117			// ARTICLE WITH FULL WIDTH MEDIA TITLE
118			if (jQuery('article').hasClass('single-post-fw-media-title')) {
119				SWIFT.page.postMediaTitle();
120			}
121
122			// RELATED POSTS
123			if (jQuery('.related-items').length > 0) {
124				SWIFT.relatedPosts.init();
125			}
126
127			// LIGHTBOX
128			SWIFT.page.lightbox();
129
130			// MOBILE 2 CLICK IMAGES
131			if (isMobileAlt && body.hasClass('mobile-two-click')) {
132				SWIFT.page.mobileThumbLinkClick();
133			}
134
135			// PAGE FADE OUT
136			if (body.hasClass('page-transitions')) {
137				SWIFT.page.pageTransitions();
138			}
139
140			// DIRECTORY SUBMIT
141			SWIFT.page.directorySubmit();
142
143			// REVIEW POST
144			if (jQuery('.article-review-wrap').length > 0) {
145				jQuery('.article-review-wrap').find('.review-bar > .bar').each(function() {
146					var bar = jQuery(this);
147					bar.css('width', bar.data('width') + '%');
148				});
149			}
150
151			jQuery('.mobile-search-trigger').on('click', function(e) {
152				e.preventDefault();
153				jQuery( ".mobile-search-form" ).submit();
154			});
155		},
156		homePreloader: function() {
157			// Site loaded, fade out preloader
158			body.addClass('sf-preloader-done');
159			setTimeout(function() {
160				jQuery('#sf-home-preloader').fadeOut(300);
161			}, 300);
162		},
163		load: function() {
164			// PAGE BUILDER ROW CONTENT HEIGHT
165			if ($window.width() > 767) {
166				SWIFT.page.fwRowContent();
167			}
168			$window.smartresize( function() {
169				if ($window.width() > 767) {
170					SWIFT.page.fwRowContent();
171				}
172			});
173
174			// Hero HEADING
175			if (jQuery('.fancy-heading').length > 0) {
176				SWIFT.page.fancyHeading();
177			}
178			
179			// RECENT POSTS RESIZE
180			if (jQuery('.recent-posts').length > 0) {
181				SWIFT.recentPosts.load();
182			}
183
184			// FS NEXT/PREV
185			if (jQuery('#prev-article-pagination') || jQuery('#next-article-pagination')) {
186
187				if ((body.hasClass('single-portfolio') && jQuery('article.portfolio').hasClass('single-portfolio-fw-media')) || (body.hasClass('single-post') && (jQuery('article.type-post').hasClass('single-post-fw-media-title') || jQuery('article.type-post').hasClass('single-post-fw-media') ))) {
188
189					setTimeout(function() {
190						SWIFT.page.fwMediaNextPrevAdjust();
191					}, 500);
192					$window.smartresize( function() {
193						SWIFT.page.fwMediaNextPrevAdjust();
194					});
195				}
196
197				SWIFT.page.fsNextPrev();
198				$window.scroll(function() {
199					SWIFT.page.fsNextPrev();
200				});
201			}
202			
203			// HASH CHECK
204			setTimeout(function() {
205		        var urlHash = document.location.toString();
206				if (urlHash.match('#')) {
207				    var hash = urlHash.split('#')[1];
208				    if ( jQuery('#' + hash).length > 0 ) {
209				        SWIFT.page.onePageNavGoTo('#' + hash);
210				    }
211				}
212		   }, 1000);
213		},
214		browserCheck: function() {
215			// BODY CLASSES
216			if (isMobileAlt) {
217				body.addClass("mobile-browser");
218			} else {
219				body.addClass("standard-browser");
220			}
221			if (isIEMobile) {
222				body.addClass("ie-mobile");
223			}
224			if (isAppleDevice) {
225				body.addClass("apple-mobile-browser");
226			}
227			if (body.hasClass("woocommerce-page") && !body.hasClass("woocommerce")) {
228				body.addClass("woocommerce");
229			}
230
231			// ADD IE CLASS
232			if (IEVersion && IEVersion < 9) {
233				body.addClass('browser-ie');
234			}
235
236			// ADD IE10 CLASS
237			var pattern = /MSIE\s([\d]+)/,
238				ua = navigator.userAgent,
239				matched = ua.match(pattern);
240			if (matched) {
241				body.addClass('browser-ie10');
242			}
243
244			// ADD SAFARI CLASS
245			if (navigator.userAgent.search("Safari") >= 0 && navigator.userAgent.search("Chrome") < 0) {
246				body.addClass('browser-safari');
247			}
248		},
249		resizeHeadings: function() {
250			var h1FontSize = jQuery('h1:not(.logo-h1)').css('font-size'),
251				h2FontSize = jQuery('h2:not(.caption-title)').css('font-size');
252
253			SWIFT.page.resizeHeadingsResize(h1FontSize, h2FontSize);
254			$window.smartresize( function() {
255				SWIFT.page.resizeHeadingsResize(h1FontSize, h2FontSize);
256			});
257		},
258		resizeHeadingsResize: function(h1FontSize, h2FontSize) {
259			if ($window.width() <= 768) {
260				if (h1FontSize) {
261					h1FontSize = h1FontSize.replace("px", "");
262					var h1FontSizeMin = Math.floor(h1FontSize * 0.6);
263					jQuery('h1:not(.logo-h1)').fitText(1, { minFontSize: h1FontSizeMin + 'px', maxFontSize: h1FontSize +'px' }).css('line-height', '120%');
264				}
265
266				if (h2FontSize) {
267					h2FontSize = h2FontSize.replace("px", "");
268					var h2FontSizeMin = Math.floor(h2FontSize * 0.6);
269					jQuery('h2:not(.caption-title)').fitText(1, { minFontSize: h2FontSizeMin + 'px', maxFontSize: h2FontSize +'px' }).css('line-height', '120%');
270				}
271			} else {
272				jQuery('h1:not(.logo-h1)').css('font-size', '').css('line-height', '');
273				jQuery('h2:not(.caption-title)').css('font-size', '').css('line-height', '');
274			}
275		},
276		loveIt: function($this) {
277			var locale = jQuery('#loveit-locale'),
278				post_id = $this.data('post-id'),
279				user_id = $this.data('user-id'),
280				action = 'love_it';
281
282			if ($this.hasClass('loved')) {
283				action = 'unlove_it';
284			}
285			if (locale.data('loggedin') == 'false' && Cookies.get('loved-' + post_id)) {
286				action = 'unlove_it';
287			}
288
289			var data = {
290				action: action,
291				item_id: post_id,
292				user_id: user_id,
293				love_it_nonce: locale.data('nonce')
294			};
295
296			jQuery.post(locale.data('ajaxurl'), data, function(response) {
297				var ajaxResponse = jQuery.trim(response),
298					count_wrap,
299					count;
300
301				if (ajaxResponse == 'loved') {
302					$this.addClass('loved');
303					count_wrap = $this.find('data.count');
304					count = count_wrap.text();
305					count_wrap.text(parseInt(count) + 1);
306					if(locale.data('loggedin') == 'false') {
307						Cookies.set('loved-' + post_id, 'yes', { expires: 1 });
308					}
309				} else if (ajaxResponse == 'unloved') {
310					$this.removeClass('loved');
311					count_wrap = $this.find('data.count');
312					count = count_wrap.text();
313					count_wrap.text(parseInt(count) - 1);
314					if (locale.data('loggedin') == 'false') {
315						Cookies.set('loved-' + post_id, 'no', { expires: 1 });
316					}
317				} else {
318					alert(locale.data('error'));
319				}
320			});
321		},
322		stickyWidget: function() {
323
324			var stickyWidget = jQuery('.sticky-widget'),
325				sidebar = stickyWidget.parent(),
326				offset = 24;
327
328			if (jQuery('.sticky-header').length > 0) {
329				offset = offset + jQuery('.sticky-header').height() > 0 ? jQuery('.sticky-header').height() : jQuery('#header-section').height();
330			}
331			if (jQuery('#wpadminbar').length > 0) {
332				offset = offset + 32;
333			}
334			if (jQuery('.sticky-top-bar').length > 0) {
335				offset = offset + jQuery('.sticky-top-bar').height() > 0 ? jQuery('.sticky-top-bar').height() : jQuery('#top-bar').height();
336			}
337
338			SWIFT.page.initStickyWidget(stickyWidget, sidebar, offset);
339
340			$window.smartresize( function() {
341				jQuery('.inner-page-wrap').stickem().destroy();
342				SWIFT.page.resizeStickyWidget(stickyWidget, sidebar);
343				SWIFT.page.initStickyWidget(stickyWidget, sidebar, offset);
344			});
345
346		},
347		initStickyWidget: function(stickyWidget, sidebar, offset) {
348			
349			var parent = ".page-content";
350			
351			if ( body.hasClass('page') || body.hasClass('archive') || body.hasClass('home') || body.hasClass('search-results') ) {
352				parent = ".inner-page-wrap";
353			}		
354			
355			jQuery('.inner-page-wrap').stickem({
356				item: '.sticky-widget',
357				container: parent,
358				offset: offset + 24,
359				onStick: function() {
360					SWIFT.page.resizeStickyWidget(stickyWidget, sidebar);
361				}
362			});
363		},
364		resizeStickyWidget: function(stickyWidget, sidebar) {
365			var headerHeight = 0,
366				content = jQuery('.content-wrap'),
367				sidebarHeight = sidebar.find('.sidebar-widget-wrap').height();
368									
369			if ( body.hasClass('page') ) {
370				content = jQuery('.page-content');
371			}	
372
373			if (jQuery('.sticky-header').length > 0) {
374				headerHeight = jQuery('.sticky-header').height() > 0 ? jQuery('.sticky-header').height() : jQuery('#header-section').height();
375			}
376			if (jQuery('#wpadminbar').length > 0) {
377				headerHeight = headerHeight + 32;
378			}
379			if (jQuery('.sticky-top-bar').length > 0) {
380				headerHeight = headerHeight + jQuery('.sticky-top-bar').height() > 0 ? jQuery('.sticky-top-bar').height() : jQuery('#top-bar').height();
381			}
382			stickyWidget.css('width', sidebar.width()).css('top', headerHeight + 30);
383			
384			var contentHeight = content.height();
385			if (contentHeight > sidebarHeight) {
386				sidebar.css('height', contentHeight);
387			} else {
388				sidebar.css('height', sidebarHeight);
389			}
390		},
391		expandingAssets: function() {
392			jQuery('.spb-row-expand-text').on('click', '', function(e) {
393				e.preventDefault();
394				var expand = jQuery(this),
395					expandRow = expand.next();
396
397				if (expandRow.hasClass('spb-row-expanding-open') && !expandRow.hasClass('spb-row-expanding-active')) {
398					expandRow.addClass('spb-row-expanding-open').addClass('spb-row-expanding-active').slideUp(800);
399					setTimeout(function() {
400						expand.removeClass('row-open').find('span').text(expand.data('closed-text'));
401						expandRow.css('display', 'block').removeClass('spb-row-expanding-open').removeClass('spb-row-expanding-active');
402					}, 800);
403				} else if (!expandRow.hasClass('spb-row-expanding-active')) {
404					expand.addClass('row-open').find('span').text(expand.data('open-text'));
405					expandRow.css('display', 'none').addClass('spb-row-expanding-open').addClass('spb-row-expanding-active').slideDown(800);
406					setTimeout(function() {
407						expandRow.removeClass('spb-row-expanding-active');
408					}, 800);
409				}
410
411			});
412		},
413		fwRowContent: function() {
414			jQuery('.spb-row-container[data-v-center="true"]').each(function() {
415
416				if (jQuery(this).find('.row').length > 0) {
417
418					jQuery(this).find('.row').each(function() {
419						var contentHeight = 0,
420							parentContainer = jQuery(this).parents('.spb-row-container');
421
422						if (parentContainer.hasClass('parallax-window-height')) {
423							parentContainer.find('> .spb_content_element').vCenterTop();
424						}
425
426						if (jQuery(this).find('> div').length > 1) {
427
428							jQuery(this).addClass('multi-column-row');
429
430							jQuery(this).find('> div').each(function() {
431								var assetPadding = parseInt(jQuery(this).css('padding-top')) + parseInt(jQuery(this).css('padding-bottom')),
432									itemHeight = jQuery(this).find('.spb-asset-content').first().innerHeight() + assetPadding;
433								if (itemHeight > contentHeight) {
434									contentHeight = itemHeight;
435								}
436							});
437
438							// SET THE ROW & INNER ASSET MIN HEIGHT
439							jQuery(this).css('min-height', contentHeight);
440							jQuery(this).find('> div').css('min-height', contentHeight);
441
442							// VERTICAL ALIGN THE INNER ASSET CONTENT
443							jQuery(this).find('> div').each(function() {
444								var assetContent = jQuery(this).find('.spb-asset-content').first(),
445									assetPadding = parseInt(jQuery(this).css('padding-top')) + parseInt(jQuery(this).css('padding-bottom')) + parseInt(assetContent.css('padding-top')) + parseInt(assetContent.css('padding-bottom')),
446									innerHeight = assetContent.height() + assetPadding,
447									margins = Math.floor((contentHeight / 2) - (innerHeight /2));
448
449								if (margins > 0) {
450									assetContent.css('margin-top', margins).css('margin-bottom', margins);
451								} else {
452									assetContent.css('margin-top', '').css('margin-bottom', '');
453								}
454							});
455
456						}
457
458					});
459
460				}
461			});
462		},
463		headerSlider: function() {
464
465			// SET LOADING INDICATOR
466			jQuery('#site-loading').css('display', 'block');
467
468			// SET SLIDER POSITION & HEIGHT
469			jQuery('.home-slider-wrap').css('position', 'fixed');
470			jQuery('#main-container').css('position', 'relative');
471			jQuery('#container').css('top', jQuery('.home-slider-wrap').height());
472			setTimeout(function() {
473				jQuery('#site-loading').fadeOut(1000);
474			}, 250);
475
476			// RESIZE SLIDER HEIGHT
477			$window.smartresize( function() {
478				jQuery('#container').css('top', jQuery('.home-slider-wrap').height());
479			});
480
481			// CONTINUE LINK
482			jQuery('a#slider-continue').on('click', function(e) {
483
484				// Prevent default anchor action
485				e.preventDefault();
486
487				// Animate scroll to main content
488				jQuery('html, body').stop().animate({
489					scrollTop: jQuery('#container').css('top')
490				}, 1500, 'easeInOutExpo');
491
492			});
493		},
494		fancyHeading: function() {
495			var fancyHeading = jQuery('.fancy-heading'),
496				fancyHeadingText = fancyHeading.find('.heading-text'),
497				fancyHeadingTextHeight = fancyHeadingText.height(),
498				fancyHeadingDivider = jQuery('.content-divider-wrap'),
499				fancyHeadingHeight = parseInt(fancyHeading.data('height'), 10),
500				header = jQuery('.header-wrap'),
501				headerHeight = 0;
502
503			if (body.hasClass('header-naked-light') || body.hasClass('header-naked-dark')) {
504				headerHeight = header.height();
505			}
506
507			if (!fancyHeadingHeight) {
508				fancyHeadingHeight = 400;
509			}
510
511			if (fancyHeadingTextHeight > fancyHeadingHeight) {
512				fancyHeadingHeight = fancyHeadingTextHeight + 80;
513			}
514
515			fancyHeadingHeight = fancyHeadingHeight + headerHeight;
516			phc_height = fancyHeadingHeight;
517
518			// Vertically center the heading text
519			fancyHeadingText.vCenterTop();
520
521			if (fancyHeading.hasClass('page-heading-breadcrumbs')) {
522				fancyHeading.find('#breadcrumbs').vCenter();
523			}
524
525			var fancyHeadingAnimDelay = 400;
526
527			// Animate in the heading text and title
528			if ( !fancyHeading.hasClass('fixed-height') ) {
529				fancyHeading.transition({
530					height: fancyHeadingHeight
531				}, 600, 'easeOutCirc');
532			}
533			
534			setTimeout(function() {
535				fancyHeadingText.css('opacity', 1);
536			}, fancyHeadingAnimDelay + 600);
537			setTimeout(function() {
538				fancyHeading.addClass('animated');
539			}, fancyHeadingAnimDelay + 1000);
540
541			// Canvas Effects
542			if (fancyHeading.find('canvas').length > 0 && !isMobileAlt) {
543
544				if ( body.hasClass( 'hero-content-split' ) ) {
545					fancyHeadingHeight = jQuery('#main-container').height();
546				}
547
548				SWIFT.canvasEffects.init(fancyHeadingHeight);
549			}
550			
551			// Adjust stickyWidget
552			if (sfIncluded.hasClass('stickysidebars') && jQuery('.sticky-widget').length > 0) {
553				SWIFT.page.stickyWidget();
554			}
555
556			// Check if parallax scroll is possible
557			if ( parallaxScroll && !isMobileAlt && fancyHeading.find('canvas').length <= 0 && !body.hasClass('hero-content-split') ) {
558				$window.scroll(function(){
559
560					var scrollTop = $window.scrollTop(),
561						realScrollTop = scrollTop,
562						headingOffset = 0,
563						opacityScale = 420;
564
565					if ( fancyHeading.parent().hasClass('fancy-tabbed-style') ) {
566						opacityScale = 180;
567					}
568
569					if (jQuery('.sticky-header').length > 0) {
570						headingOffset = jQuery('.sticky-header').height();
571					}
572					if (jQuery('#top-bar').length > 0) {
573						headingOffset = headingOffset + jQuery('#top-bar').height();
574					}
575					if (jQuery('#wpadminbar').length > 0) {
576						headingOffset = headingOffset + 32;
577					}
578					if (jQuery('#sf-header-banner').length > 0) {
579						headingOffset = headingOffset + jQuery('#sf-header-banner').outerHeight();
580					}
581					
582					scrollTop = scrollTop - headingOffset;
583
584					// Only scroll if the heading is makes sense to do so
585					if (scrollTop < jQuery(document).height() - $window.height()) {
586
587						if (scrollTop < 0) {
588							scrollTop = 0;
589						}
590
591						// Reduce the heading height
592						fancyHeading.stop(true,true).transition({
593							y: scrollTop * 0.4
594						}, 0);
595
596						if ( fancyHeading.parent().hasClass('fancy-tabbed-style') ) {
597							fancyHeadingText.stop(true,true).transition({
598								opacity: 1 - scrollTop / opacityScale
599							}, 0);
600							fancyHeadingDivider.stop(true,true).transition({
601								opacity: 1 - scrollTop / opacityScale
602							}, 0);
603						} else {
604							fancyHeadingText.stop(true,true).transition({
605								y: realScrollTop * 0.4,
606								opacity: 1 - realScrollTop / opacityScale
607							}, 0);
608						}
609					}
610
611				});
612			}
613		},
614		moveModals: function() {
615			jQuery(".modal").each(function(){
616				jQuery(this).appendTo("body");
617			});
618		},
619		modalClose: function() {
620			jQuery(".modal-backdrop, .modal .close, .modal .btn").on("click", function() {
621				jQuery(".modal iframe").each(function() {
622					var thisModal = jQuery(this);
623					thisModal.attr("src", thisModal.attr("src"));
624				});
625			});
626		},
627		smoothScrollLinks: function() {
628			jQuery('a.smooth-scroll-link').on('click', function(e) {
629
630				var linkHref = jQuery(this).attr('href'),
631					linkOffset = jQuery(this).data('offset') ? jQuery(this).data('offset') : 0;
632					
633				if (linkHref && linkHref.indexOf('#') === 0) {
634					var headerHeight = 0;
635
636					if (jQuery('.sticky-header').length > 0) {
637						headerHeight = jQuery('.sticky-header').height() > 0 ? jQuery('.sticky-header').height() : jQuery('#header-section').height();
638					}
639					if (jQuery('#wpadminbar').length > 0) {
640						headerHeight = headerHeight + 32;
641					}
642					if (jQuery('.sticky-top-bar').length > 0) {
643						headerHeight = headerHeight + jQuery('.sticky-top-bar').height() > 0 ? jQuery('.sticky-top-bar').height() : jQuery('#top-bar').height();
644					}
645
646					SWIFT.isScrolling = true;
647
648					if (body.hasClass('hero-content-split')) {
649						jQuery('.hero-content-split #main-container > .container').stop().animate({
650							scrollTop: jQuery(linkHref).offset().top - headerHeight + linkOffset
651						}, 1000, 'easeInOutExpo', function() {
652							SWIFT.isScrolling = false;
653						});
654					} else {
655						jQuery('html, body').stop().animate({
656							scrollTop: jQuery(linkHref).offset().top - headerHeight + linkOffset
657						}, 1000, 'easeInOutExpo', function() {
658							SWIFT.isScrolling = false;
659						});
660					}
661
662					e.preventDefault();
663
664				} else {
665					return e;
666				}
667
668			});
669		},
670		onePageNav: function() {
671
672			var onePageNav = jQuery('#one-page-nav'),
673				onePageNavType = onePageNav.hasClass('opn-arrows') ? "arrows" : "standard",
674				onePageNavItems = "",
675				pageSectionCount = 0,
676				mainContent = jQuery('.page-content');
677
678			mainContent.find('section.row').each(function() {
679				var linkID = jQuery(this).attr('id'),
680					linkName = jQuery(this).data('rowname');
681
682				if (linkID && linkName.length > 0 && jQuery(this).height() > 0) {
683					onePageNavItems += '<li><a href="#'+linkID+'" data-title="'+linkName+'"><i></i></a><div class="hover-caption">'+linkName+'</div></li>';
684					pageSectionCount++;
685				}
686			});
687
688			if (pageSectionCount > 0) {
689				if (onePageNav.find('ul').length === 0) {
690					onePageNav.append('<ul>'+onePageNavItems+'</ul>');
691
692					if (onePageNavType === "arrows") {
693						onePageNav.find('ul').css('display', 'none');
694						onePageNav.append('<a href="#" class="opn-up"><i class="sf-icon-chevron-up"></i></a>');
695						onePageNav.append('<div class="opn-status"><span class="current">1</span>/<span class="total">'+pageSectionCount+'</span></div>');
696						onePageNav.append('<a href="#" class="opn-down"><i class="sf-icon-chevron-down"></i></a>');
697					}
698				}
699
700				onePageNav.vCenter();
701				setTimeout(function() {
702
703					SWIFT.page.onePageNavScroll(onePageNav);
704
705					onePageNav.css('display', 'block').stop().animate({
706						'right': '0',
707						'opacity': 1
708					}, 1000, "easeOutQuart");
709
710					// Nav Dots
711					jQuery('#one-page-nav ul li a').on('click', function(e) {
712						SWIFT.page.onePageNavGoTo(jQuery(this).attr('href'));
713						e.preventDefault();
714					});
715
716					// Up Arrow
717					jQuery('#one-page-nav a.opn-up').on('click', function(e) {
718						var currentSection = parseInt(jQuery('.opn-status .current').text(), 10),
719							prevSection = currentSection - 1,
720							prevSectionHref = jQuery('#one-page-nav ul li:nth-child('+ prevSection +') > a').attr('href');
721
722						if (prevSection > 0) {
723							SWIFT.page.onePageNavGoTo(prevSectionHref);
724						}
725						e.preventDefault();
726					});
727
728					// Down Arrow
729					jQuery('#one-page-nav a.opn-down').on('click', function(e) {
730						var currentSection = parseInt(jQuery('.opn-status .current').text(), 10),
731							nextSection = currentSection + 1,
732							nextSectionHref = jQuery('#one-page-nav ul li:nth-child('+ nextSection +') > a').attr('href');
733
734						if (nextSection <= pageSectionCount) {
735							SWIFT.page.onePageNavGoTo(nextSectionHref);
736						}
737						e.preventDefault();
738					});
739
740					// Assign current on init and scroll
741					SWIFT.page.onePageNavScroll(onePageNav);
742					$window.on('scroll', function() {
743						SWIFT.page.onePageNavScroll(onePageNav);
744					});
745
746				}, 1000);
747			}
748		},
749		onePageNavGoTo: function(anchor) {
750
751			var adjustment = 0;
752
753			if (jQuery('#wpadminbar').length > 0) {
754				adjustment = jQuery('#wpadminbar').height();
755			}
756
757			if (body.hasClass('sticky-header-enabled')) {
758				adjustment += jQuery('.sticky-header').height() > 0 ? jQuery('.sticky-header').height() : jQuery('#header-section').height();
759			}
760
761			if (jQuery('.sticky-top-bar').length > 0) {
762				adjustment += jQuery('.sticky-top-bar').height() > 0 ? jQuery('.sticky-top-bar').height() : jQuery('#top-bar').height();
763			}
764
765			SWIFT.isScrolling = true;
766
767			jQuery('html, body').stop().animate({
768				scrollTop: jQuery(anchor).offset().top - adjustment + 1
769			}, 1000, 'easeInOutExpo', function() {
770				SWIFT.isScrolling = false;
771			});
772		},
773		onePageNavScroll: function(onePageNav) {
774
775			var adjustment = 0;
776
777			if (body.hasClass('sticky-header-enabled')) {
778				adjustment = jQuery('.sticky-header').height() > 0 ? adjustment + jQuery('.sticky-header').height() : adjustment + jQuery('#header-section').height();
779			}
780
781			if (jQuery('#wpadminbar').length > 0) {
782				adjustment = adjustment + jQuery('#wpadminbar').height();
783			}
784
785			if ( jQuery('.sticky-top-bar')) {
786				adjustment = adjustment + jQuery('.sticky-top-bar').height() > 0 ? adjustment + jQuery('.sticky-top-bar').height() : adjustment + jQuery('#top-bar').height();
787			}
788
789			var currentSection = jQuery('section.row:in-viewport('+adjustment+')').data('rowname'),
790				currentSectionIndex = 0;
791
792			if (!currentSection) {
793				onePageNav.find('li').removeClass('selected');
794			}
795
796			if (onePageNav.is(':visible') && currentSection) {
797				onePageNav.find('li').removeClass('selected');
798				onePageNav.find('li a[data-title="'+currentSection+'"]').parent().addClass('selected');
799				currentSectionIndex = onePageNav.find('li a[data-title="'+currentSection+'"]').parent().index() + 1;
800			}
801
802			if (currentSectionIndex > 0) {
803				jQuery('.opn-status .current').text(currentSectionIndex);
804			}
805
806			if (onePageNav.hasClass('opn-arrows')) {
807				var current = onePageNav.find('.current').text(),
808					total = onePageNav.find('.total').text();
809
810				if (current === "1") {
811					onePageNav.find('.opn-up').addClass('disabled');
812				} else {
813					onePageNav.find('.opn-up').removeClass('disabled');
814				}
815
816				if (current === total) {
817					onePageNav.find('.opn-down').addClass('disabled');
818				} else {
819					onePageNav.find('.opn-down').removeClass('disabled');
820				}
821			}
822		},
823		heroContentSplit: function() {
824
825			var mainContainer = jQuery('#main-container');
826
827			// RESIZE
828			SWIFT.page.heroContentSplitResize();
829			$window.smartresize( function() {
830				SWIFT.page.heroContentSplitResize();
831			});
832
833			// ANIMATE IN
834			mainContainer.animate({
835				'opacity': 1
836			}, 600, "easeOutExpo");
837
838		},
839		heroContentSplitResize: function() {
840			var mainContainer = jQuery('#main-container'),
841				windowHeight = $window.height(),
842				headerHeight = 0;
843
844			if (jQuery('.sticky-header').length > 0) {
845				headerHeight = jQuery('.sticky-header').height() > 0 ? jQuery('.sticky-header').height() : jQuery('#header-section').height();
846			}
847			if (jQuery('#wpadminbar').length > 0) {
848				headerHeight = headerHeight + jQuery('#wpadminbar').height();
849			}
850			if (jQuery('#top-bar').length > 0) {
851				headerHeight = headerHeight + jQuery('#top-bar').height();
852			}
853
854			if ($window.width() > 991) {
855				mainContainer.css('height', windowHeight - headerHeight);
856			}
857		},
858		shareCounts: function() {
859
860			var shareCounts = jQuery('.sf-share-counts'),
861				facebookCount = shareCounts.find('a.sf-share-fb'),
862				twitterCount = shareCounts.find('a.sf-share-twit'),
863				pinterestCount = shareCounts.find('a.sf-share-pin'),
864				linkedInCount = shareCounts.find('a.sf-share-linked'),
865				pageHref = window.location.href.replace(window.location.hash, '');
866
867			// Facebook
868			if (facebookCount.length > 0) {
869				jQuery.getJSON('https://graph.facebook.com/?id='+ pageHref +'&c
869allback=?', function(data) {
870					if (data.shares !== undefined && data.shares !== null) {
871						facebookCount.find('.count').html(data.shares);
872					}
873					facebookCount.find('.count').addClass('animate');
874				});
875			}
876
877			// Twitter
878			if (twitterCount.length > 0) {
879				var twitterAPIURL = 'http://urls.api.twitter.com/1/urls/count.json?url='+pageHref+'&callback=?';	
880				if (document.location.protocol == "https:") {
881					twitterAPIURL = 'https://urls.api.twitter.com/1/urls/count.json?url='+pageHref+'&callback=?';
882				}
883				
884				jQuery.getJSON(twitterAPIURL, function(data) {
885					if (data.count !== undefined && data.count !== null) {
886						twitterCount.find('.count').html(data.count);
887					}
888					twitterCount.find('.count').addClass('animate');
889				});
890			}
891
892			// LinkedIn
893			if (linkedInCount.length > 0) {
894				jQuery.getJSON('https://www.linkedin.com/countserv/count/share?url='+pageHref+'&callback=?', function(data) {
895					if (data.count !== undefined && data.count !== null) {
896						linkedInCount.find('.count').html(data.count);
897					}
898					linkedInCount.find('.count').addClass('animate');
899				});
900			}
901
902			// Pinterest
903			if (pinterestCount.length > 0) {
904				jQuery.getJSON('https://api.pinterest.com/v1/urls/count.json?url='+pageHref+'&callback=?', function(data) {
905					if (data.count !== undefined && data.count !== null) {
906						pinterestCount.find('.count').html(data.count);
907					}
908					pinterestCount.find('.count').addClass('animate');
909				});
910			}
911			
912		},
913		articleNavigation: function() {
914			var postPagination = jQuery('.post-pagination-wrap'),
915				postNext = postPagination.find('.next-article > h2 > a').attr('href'),
916				postPrev = postPagination.find('.prev-article > h2 > a').attr('href');
917
918			jQuery('article.type-post').hammer().on("swipeleft", function(event) {
919			    if (postPrev) {
920			    	window.location = postPrev;
921			    }
922			});
923
924			jQuery('article.type-post').hammer().on("swiperight", function(event) {
925			    if (postNext) {
926			    	window.location = postNext;
927			    }
928			});
929
930		},
931		postMediaTitle: function() {
932			var detailsOverlay = jQuery('.details-overlay'),
933				detailFeature = jQuery('.detail-feature'),
934				featureHeight = detailsOverlay.height() + 80;
935
936			if (body.hasClass('header-naked-light') || body.hasClass('header-naked-dark')) {
937				detailFeature.css('padding-top', jQuery('.header-wrap').height() * 2);
938			}
939
940			detailFeature.css('height', featureHeight);
941			setTimeout(function() {
942				jQuery('.details-overlay').vCenter().stop().animate({
943					'bottom': '50%',
944					'opacity': 1
945				}, 1500, "easeOutExpo");
946			}, 500);
947
948			$window.smartresize( function() {
949				detailFeature.css('height', detailsOverlay.height() + 80);
950				jQuery('.details-overlay').vCenter();
951			});
952
953		},
954		lightbox: function() {
955		
956			if ( !lightboxEnabled ) {
957				return;
958			}
959			
960			// Lightbox Social
961			var lightboxSocial = {};
962			if (lightboxSharing) {
963				lightboxSocial = {
964					facebook: {
965						source: 'https://www.facebook.com/sharer/sharer.php?u={URL}',
966						text: 'Share on Facebook'
967					},
968					twitter: true,
969					googleplus: true,
970					pinterest: {
971						source: "https://pinterest.com/pin/create/button/?url={URL}&media={URL}",
972						text: "Share on Pinterest"
973					}
974				};
975			}
976
977			// Lightbox Galleries
978			var galleryArr = [];
979			jQuery('[data-rel^="ilightbox["]').each(function () {
980				var attr = this.getAttribute("data-rel");
981				if ( jQuery(this).hasClass( 'ilightbox-enabled' ) ) {
982					return;
983				}
984				if (jQuery.inArray(attr, galleryArr) == -1 ) {
985					galleryArr.push(attr);
986				}
987			});
988			jQuery.each(galleryArr, function (b, c) {
989				jQuery('[data-rel="' + c + '"]').iLightBox({
990					skin: lightboxSkin,
991					social: {
992						buttons: lightboxSocial
993					},
994					path: 'horizontal',
995					thumbnails: {
996						maxWidth: 120,
997						maxHeight: 120
998					},
999					controls: {
1000						arrows: lightboxControlArrows,
1001						thumbnail: lightboxThumbs
1002					}
1003				});
1004				jQuery('[data-rel="' + c + '"]').addClass( 'ilightbox-enabled' );
1005			});
1006		},
1007		backToTop: function() {
1008			var scrollPosition = $window.scrollTop();
1009
1010			if (scrollPosition > 300) {
1011				jQuery('#back-to-top').stop().animate({
1012					'bottom': '10px',
1013					'opacity': 1
1014				}, 300, "easeOutQuart");
1015			} else if (scrollPosition < 300) {
1016				jQuery('#back-to-top').stop().animate({
1017					'bottom': '-60px',
1018					'opacity': 0
1019				}, 300, "easeInQuart");
1020			}
1021		},
1022		newsletterSubBar: function() {
1023			var subBar = jQuery('#sf-newsletter-bar'),
1024				closedCookieName = 'newsletter-sub-bar-hidden';
1025
1026			setTimeout(function() {
1027				if (Cookies.get(closedCookieName) != '1') {
1028					subBar.fadeIn(600);
1029				}
1030			}, 3000);
1031
1032			jQuery('a.sub-close').on('click', '', function(e) {
1033				e.preventDefault();
1034				Cookies.set(closedCookieName, '1', { expires: 7 });
1035				subBar.fadeOut(600);
1036			});
1037		},
1038		fwMediaNextPrevAdjust: function() {
1039
1040			var navTop = 0;
1041
1042			if (body.hasClass('single-portfolio')) {
1043				navTop = jQuery('article.portfolio').offset().top + jQuery('figure.fw-media-wrap').height() + 80;
1044			} else if (body.hasClass('single-post')) {
1045				if (jQuery('.detail-feature').length > 0) {
1046					navTop = jQuery('article.post').offset().top + jQuery('.detail-feature').height() + 80;
1047				} else {
1048					navTop = jQuery('article.post').offset().top + jQuery('figure.fw-media-wrap').height() + 80;
1049				}
1050			}
1051
1052			jQuery('#prev-article-pagination').addClass('has-fw-media').css('top', navTop);
1053			jQuery('#next-article-pagination').addClass('has-fw-media').css('top', navTop);
1054		},
1055		fsNextPrev: function() {
1056			var scrollPosition = $window.scrollTop(),
1057				absTop = 0,
1058				showArrowX = body.hasClass('single-product') ? 60 : 100;
1059
1060			if ((body.hasClass('single-portfolio') && jQuery('article.portfolio').hasClass('single-portfolio-fw-media')) || (body.hasClass('single-post') && (jQuery('article.type-post').hasClass('single-post-fw-media-title') || jQuery('article.type-post').hasClass('single-post-fw-media') ))) {
1061
1062				if (body.hasClass('single-portfolio')) {
1063					absTop = jQuery('article.portfolio').offset().top + jQuery('figure.fw-media-wrap').height() + 200;
1064				} else if (body.hasClass('single-post')) {
1065					if (jQuery('.detail-feature').length > 0) {
1066						absTop = jQuery('article.post').offset().top + jQuery('.detail-feature').height() + 200;
1067					} else {
1068						absTop = jQuery('article.post').offset().top + jQuery('figure.fw-media-wrap').height() + 200;
1069					}
1070				}
1071
1072				if ((scrollPosition + $window.height() / 2) > absTop) {
1073					jQuery('#prev-article-pagination').addClass('fs-nav-fixed');
1074					jQuery('#next-article-pagination').addClass('fs-nav-fixed');
1075				} else if (scrollPosition < absTop) {
1076					jQuery('#prev-article-pagination').removeClass('fs-nav-fixed');
1077					jQuery('#next-article-pagination').removeClass('fs-nav-fixed');
1078				}
1079			} else {
1080				if (scrollPosition > showArrowX) {
1081					jQuery('#prev-article-pagination').stop().animate({
1082						'left': '0',
1083						'opacity': 1
1084					}, 300, "easeOutQuart");
1085					jQuery('#next-article-pagination').stop().animate({
1086						'right': '0',
1087						'opacity': 1
1088					}, 300, "easeOutQuart");
1089				} else if (scrollPosition < showArrowX) {
1090					jQuery('#prev-article-pagination').stop().animate({
1091						'left': '-200px',
1092						'opacity': 1
1093					}, 300, "easeOutQuart");
1094					jQuery('#next-article-pagination').stop().animate({
1095						'right': '-200px',
1096						'opacity': 1
1097					}, 300, "easeOutQuart");
1098				}
1099			}
1100		},
1101		getViewportHeight: function() {
1102			var height = "innerHeight" in window ? window.innerHeight: document.documentElement.offsetHeight;
1103			return height;
1104		},
1105		checkIE: function() {
1106			var undef,
1107				v = 3,
1108				div = document.createElement('div'),
1109				all = div.getElementsByTagName('i');
1110
1111			while (
1112				div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
1113				all[0]
1114			);
1115
1116			return v > 4 ? v : undef;
1117		},
1118		pageTransitions: function() {
1119			jQuery('a').on('click', function(e) {
1120				var linkElement = jQuery(this),
1121					link = linkElement.attr('href'),
1122					linkTarget = linkElement.attr('target');
1123
1124				// Return if is tab click
1125				if (linkElement.data('toggle') === "tab" || linkElement.parent().parent().hasClass('tabs') || linkElement.parent('.ui-accordion-header').length > 0) {
1126					return e;
1127				}
1128
1129				if (link.indexOf('#') === 0 && link.length > 1) {
1130					SWIFT.isScrolling = true;
1131					SWIFT.page.onePageNavGoTo(link);
1132					setTimeout(function() {
1133						SWIFT.isScrolling = false;
1134					}, 1000);
1135					e.preventDefault();
1136				} else if (link.indexOf('#') === 0 && link.length === 1) {
1137					return;
1138				} else if (linkTarget === '_blank') {
1139					return;
1140				} else if (link.indexOf('?') >= 0 || link.indexOf('.jpg') >= 0 || link.indexOf('.png') >= 0 || link.indexOf('mailto') >= 0 || e.ctrlKey || e.metaKey || link.indexOf('javascript') === 0 || link.indexOf('tel:') === 0) {
1141					return e;
1142				} else {
1143					if (body.hasClass('mobile-menu-open') || body.hasClass('mh-overlay-show') || body.hasClass('side-slideout-open') || linkElement.hasClass('cart-contents') || body.hasClass('overlay-menu-open') ) {
1144						return;
1145					} else {
1146						SWIFT.page.fadePageOut(link);
1147						e.preventDefault();
1148					}
1149				}
1150			});
1151		},
1152		fadePageIn: function() {
1153			var preloadTime = 1000;
1154
1155			if (jQuery('.parallax-window-height').length > 0) {
1156				preloadTime = 1200;
1157			}
1158
1159			body.addClass('page-fading-in');
1160			jQuery('#site-loading').css('opacity', '0');
1161
1162			setTimeout(function() {
1163				jQuery('#site-loading').css('display', 'none');
1164				body.removeClass('page-fading-in');
1165			}, preloadTime);
1166		},
1167		fadePageOut: function(link) {
1168			jQuery('#site-loading').css('display', 'block').transition({
1169				opacity: 1,
1170				delay: 200
1171			}, 600, "ease" );
1172			setTimeout(function() {
1173				window.location = link;
1174			}, 600);
1175		},
1176		mobileThumbLinkClick: function() {
1177			jQuery(document).on('click', '.animated-overlay > a, .box-link', function(e) {
1178				var thisLink = jQuery(this);
1179
1180				if (thisLink.hasClass('hovered')) {
1181					return e;
1182				} else {
1183					e.preventDefault();
1184					thisLink.addClass('hovered');
1185				}
1186			});
1187		},
1188		directorySubmit: function() {
1189			jQuery(document).on('click', '#sf_directory_calculate_coordinates', function(e) {
1190				e.preventDefault();
1191				var geocoder = new google.maps.Geocoder();
1192
1193				geocoder.geocode( { 'address': jQuery('#sf_directory_address').val()}, function(results, status) {
1194					jQuery('#sf_directory_lat_coord').val(results[0].geometry.location.lat());
1195					jQuery('#sf_directory_lng_coord').val(results[0].geometry.location.lng());
1196				});
1197
1198			});
1199
1200			jQuery('#directory-submit').on('click', function(e) {
1201
1202			if (jQuery('#sf_directory_address').val() === '' || jQuery('#sf_directory_lat_coord').val() === '' || jQuery('atelier_directory_lng_coord').val() === '' || jQuery('#directory_title').val() === '' || jQuery('#directory_description').val() === '' || jQuery('#directory-cat').val() <= 0 || jQuery('#directory-loc').val() <= 0) {
1203					e.preventDefault();
1204					jQuery('.directory-error').show();
1205					jQuery('html, body').animate({ scrollTop: jQuery('.directory-error').offset().top-100}, 700);
1206					return false;
1207				}
1208				jQuery('#add-directory-entry').submit();
1209			});
1210		}
1211	};
1212
1213
1214	/////////////////////////////////////////////
1215	// SUPER SEARCH
1216	/////////////////////////////////////////////
1217
1218	SWIFT.superSearch = {
1219		init: function() {
1220
1221			jQuery('.search-options .ss-dropdown').on('click', function(e) {
1222				e.preventDefault();
1223
1224				var option = jQuery(this),
1225					dropdown = option.find( 'ul' );
1226
1227				if (isMobileAlt) {
1228					if (dropdown.hasClass('show-dropdown')) {
1229						setTimeout(function() {
1230							dropdown.removeClass('show-dropdown');
1231						}, 100);
1232					} else {
1233						dropdown.addClass('show-dropdown');
1234					}
1235				} else {
1236					if (dropdown.hasClass('show-dropdown')) {
1237						setTimeout(function() {
1238							dropdown.removeClass('show-dropdown');
1239						}, 100);
1240					} else {
1241						dropdown.addClass('show-dropdown');
1242					}
1243				}
1244			});
1245
1246			jQuery('.ss-option').on('click', function(e) {
1247				e.preventDefault();
1248
1249				var thisOption = jQuery(this),
1250					selectedOption = thisOption.attr('data-attr_value'),
1251					parentOption = thisOption.parent().parent().parent();
1252
1253				parentOption.find('li').removeClass('selected');
1254				thisOption.parent().addClass('selected');
1255
1256				parentOption.attr('data-attr_value', selectedOption);
1257				parentOption.find('span').text(thisOption.text());
1258
1259				setTimeout(function() {
1260					thisOption.parents('ul').first().removeClass('show-dropdown');
1261				}, 100);
1262			});
1263
1264			jQuery('.super-search-go').on('click', function(e) {
1265				e.preventDefault();
1266				var parentSearch = jQuery(this).parents('.sf-super-search'),
1267					filterURL = SWIFT.superSearch.urlBuilder(parentSearch),
1268					homeURL = jQuery(this).attr('data-home_url'),
1269					shopURL = jQuery(this).attr('data-shop_url');
1270
1271				if (filterURL.indexOf("product_cat") >= 0) {
1272				location.href = homeURL + filterURL;
1273				} else {
1274				location.href = shopURL + filterURL;
1275				}
1276
1277			});
1278		},
1279		urlBuilder: function(searchInstance) {
1280
1281			var queryString = "";
1282
1283			jQuery(searchInstance).find('.search-options .ss-dropdown').each(function() {
1284
1285				var attr = jQuery(this).attr('id');
1286				var attrValue = jQuery(this).attr('data-attr_value');
1287				if (attrValue !== "") {
1288					if (attr === "product_cat") {
1289						if (queryString === "") {
1290							queryString += "?product_cat=" + attrValue;
1291						} else {
1292							queryString += "&product_cat=" + attrValue;
1293						}
1294					} else {
1295						if (queryString === "") {
1296						queryString += "?filter_" + attr + "=" + attrValue;
1297						} else {
1298						queryString += "&filter_" + attr + "=" + attrValue;
1299						}
1300					}
1301				}
1302			});
1303
1304			jQuery('.search-options input').each(function() {
1305				var attr = jQuery(this).attr('name');
1306				var attrValue = jQuery(this).attr('value');
1307				if (queryString === "") {
1308					queryString += "?"+ attr + "=" + attrValue;
1309				} else {
1310					queryString += "&" + attr + "=" + attrValue;
1311				}
1312			});
1313
1314			return queryString;
1315		}
1316	};
1317
1318
1319	/////////////////////////////////////////////
1320	// HEADER
1321	/////////////////////////////////////////////
1322
1323	SWIFT.header = {
1324		init: function() {
1325
1326			// INIT VARIABLES
1327			var lastAjaxSearchValue = "",
1328				searchTimer = false;
1329
1330
1331			// STICKY HEADER
1332			if (body.hasClass('sticky-header-enabled') && !body.hasClass('vertical-header')) {
1333				SWIFT.header.stickyHeaderInit();
1334			}
1335
1336			// STICKY TOP BAR
1337			if ( jQuery('.sticky-top-bar').length > 0 ) {
1338				SWIFT.header.stickyTopBarInit();
1339			}
1340
1341			// SPLIT HEADER
1342			if (jQuery('#header-section').hasClass('header-split')) {
1343				SWIFT.header.splitHeader(true);
1344				$window.smartresize( function() {
1345					SWIFT.header.splitHeader();
1346				});
1347			}
1348
1349			// FULLSCREEN SEARCH
1350			if (jQuery('#fullscreen-search').length > 0) {
1351				SWIFT.header.fsSearch();
1352			}
1353
1354			jQuery('a.fs-overlay-close').on('click', function(e) {
1355				e.preventDefault();
1356
1357				if (body.hasClass('overlay-menu-open')) {
1358					SWIFT.header.overlayMenuToggle();
1359				}
1360				if (body.hasClass('fs-supersearch-open')) {
1361					SWIFT.header.fsSuperSearchToggle();
1362				}
1363				if (body.hasClass('fs-search-open')) {
1364					SWIFT.header.fsSearchToggle();
1365				}
1366			});
1367
1368
1369			jQuery('a.fs-header-search-link').on('click', function(e) {
1370				e.preventDefault();
1371
1372				if (body.hasClass('overlay-menu-open')) {
1373					SWIFT.header.overlayMenuToggle();
1374				}
1375				if (body.hasClass('fs-supersearch-open')) {
1376					SWIFT.header.fsSuperSearchToggle();
1377				}
1378				SWIFT.header.fsSearchToggle();
1379			});
1380
1381			// FULLSCREEN SUPERSEARCH
1382			jQuery('a.fs-supersearch-link').on('click', function(e) {
1383				e.preventDefault();
1384
1385				if (body.hasClass('overlay-menu-open')) {
1386					SWIFT.header.overlayMenuToggle();
1387				}
1388				if (body.hasClass('fs-search-open')) {
1389					SWIFT.header.fsSearchToggle();
1390				}
1391
1392				SWIFT.header.fsSuperSearchToggle();
1393			});
1394
1395
1396			// OVERLAY MENU
1397			jQuery('a.overlay-menu-link').on('click', function(e) {
1398				e.preventDefault();
1399				SWIFT.header.overlayMenuToggle();
1400
1401				if (body.hasClass('fs-search-open')) {
1402					SWIFT.header.fsSearchToggle();
1403				}
1404				if (body.hasClass('fs-supersearch-open')) {
1405					SWIFT.header.fsSuperSearchToggle();
1406				}
1407			});
1408			
1409			// Overlay Menu parent click
1410			jQuery('#overlay-menu li.menu-item > a').on('click', function(e) {
1411				var parentMenuItem = jQuery(this).parent(),
1412					linkHref = jQuery(this).attr('href'),
1413					linkTarget = jQuery(this).attr('target'),
1414					subMenu = parentMenuItem.find('ul.sub-menu').first();
1415
1416				if (!parentMenuItem.hasClass('parent')) {
1417					SWIFT.header.overlayMenuToggle();
1418
1419					if (linkHref.indexOf('#') === 0 && linkHref.length > 1) {
1420						SWIFT.isScrolling = true;
1421						SWIFT.page.onePageNavGoTo(linkHref);
1422						setTimeout(function() {
1423							SWIFT.isScrolling = false;
1424						}, 1000);
1425						e.preventDefault();
1426					} else if (body.hasClass('page-transitions')) {
1427						if ( linkTarget === "_blank" ) {
1428							return e;
1429						} else {
1430							SWIFT.page.fadePageOut(linkHref);
1431						}
1432					}
1433
1434					return e;
1435				}
1436
1437				if (parentMenuItem.hasClass('sub-menu-open')) {
1438					if (linkHref.indexOf('http') === 0 || linkHref.indexOf('/') === 0) {
1439						return e;
1440					} else {
1441						parentMenuItem.removeClass('sub-menu-open');
1442						subMenu.slideUp();
1443						e.preventDefault();
1444					}
1445				} else {
1446					parentMenuItem.addClass('sub-menu-open');
1447					subMenu.slideDown();
1448					e.preventDefault();
1449				}
1450			});
1451
1452
1453
1454			// SIDE SLIDEOUT MENU
1455			jQuery('a.side-slideout-link').on('click', function(e) {
1456				e.preventDefault();
1457				SWIFT.nav.showSideSlideout(jQuery(this).data('side'));
1458			});
1459			$window.smartresize( function() {
1460				var windowWidth = $window.width();
1461
1462				if (windowWidth < 1024 && body.hasClass('mhs-tablet-land') && body.hasClass('side-slideout-open')) {
1463					SWIFT.nav.sideSlideoutHideTrigger();
1464				} else if (windowWidth < 991 && body.hasClass('mhs-tablet-port') && body.hasClass('side-slideout-open')) {
1465					SWIFT.nav.sideSlideoutHideTrigger();
1466				} else if (windowWidth < 767 && body.hasClass('mhs-mobile') && body.hasClass('side-slideout-open')) {
1467					SWIFT.nav.sideSlideoutHideTrigger();
1468				}
1469
1470			});
1471
1472
1473			// AJAX SEARCH
1474			jQuery('.header-search-link-alt').on('click', function(e) {
1475				e.preventDefault();
1476
1477				var searchLink = jQuery(this),
1478					ajaxSearchWrap = searchLink.parent().find('.ajax-search-wrap');
1479
1480				if (ajaxSearchWrap.is(':visible')) {
1481					ajaxSearchWrap.fadeOut(300);
1482					searchLink.removeClass('search-open');
1483					setTimeout(function() {
1484						jQuery('.ajax-search-results').slideUp(100).empty();
1485						jQuery('.ajax-search-form input[name=s]').val('');
1486					}, 300);
1487				} else {
1488					ajaxSearchWrap.fadeIn(300);
1489					searchLink.addClass('search-open');
1490					setTimeout(function() {
1491						jQuery('.ajax-search-form input[name=s]').focus();
1492						jQuery("#container").on("click", function(e) {
1493							var ajaxSearchWrap = jQuery('.ajax-search-wrap');
1494							if (!ajaxSearchWrap.is(e.target) && ajaxSearchWrap.has(e.target).length === 0) {
1495								searchLink.removeClass('search-open');
1496							}
1497							if (!jQuery(e.target).closest('.ajax-search-wrap').length) {
1498								ajaxSearchWrap.fadeOut(300);
1499								setTimeout(function() {
1500									jQuery('.ajax-search-results').slideUp(100).empty();
1501									jQuery('.ajax-search-form input[name=s]').val('');
1502								}, 300);
1503								jQuery("#container").off("click");
1504							}
1505						});
1506					}, 300);
1507				}
1508
1509			});
1510
1511
1512			// AJAX SEARCH INPUT FUNCTION
1513			jQuery('.ajax-search-form input[name=s],#fs-search-input').on('keyup', function(e) {
1514				var searchvalue = e.currentTarget.value,
1515					homeURL = jQuery('.ajax-search-form').attr('action');
1516
1517				if ( jQuery(this).hasClass('noajax') ) {
1518					return e;
1519				} 
1520
1521				clearTimeout(searchTimer);
1522				if (lastAjaxSearchValue != jQuery.trim(searchvalue) && searchvalue.length >= 3) {
1523					searchTimer = setTimeout( function() {
1524						if (jQuery('#fullscreen-search').length > 0 && history.pushState) {
1525							jQuery('#fullscreen-search').find('.search-wrap').animate({
1526								'margin-top': '10%'
1527							}, 200);
1528						    var urlWithSearchParam = homeURL + '?s=' + searchvalue;
1529						    window.history.pushState({path:urlWithSearchParam}, '', urlWithSearchParam);
1530						}
1531						SWIFT.header.ajaxSearch(e);
1532					}, 400);
1533				} else if (searchvalue.length < 3) {
1534					jQuery('.ajax-search-results').slideUp(800, 'easeInOutExpo');
1535				}
1536			});
1537
1538
1539			// CONTACT SLIDEOUT
1540			jQuery('a.contact-menu-link').on('click', function(e) {
1541				e.preventDefault();
1542				var contactSlideout = jQuery('#contact-slideout'),
1543					thisLink = jQuery(this);
1544				
1545				if ( body.scrollTop() > 0 ) {
1546					jQuery('body,html').animate({scrollTop: 0}, 600, 'easeOutCubic');
1547					setTimeout(function() {
1548						contactSlideout.slideToggle(800, 'easeInOutExpo');
1549						if (thisLink.hasClass('slide-open')) {
1550							thisLink.removeClass('slide-open');
1551						} else {
1552							SWIFT.map.init();
1553							thisLink.addClass('slide-open');
1554						}
1555					}, 800);
1556				} else {
1557					contactSlideout.slideToggle(800, 'easeInOutExpo');
1558					if (thisLink.hasClass('slide-open')) {
1559						thisLink.removeClass('slide-open');
1560					} else {
1561						SWIFT.map.init();
1562						thisLink.addClass('slide-open');
1563					}
1564				}
1565			});
1566
1567			// MOBILE STICKY HEADER
1568			if (body.hasClass('mh-sticky')) {
1569
1570				if (isMobileAlt) {
1571					jQuery('html').addClass('has-mh-sticky');
1572				}
1573
1574				var mobileHeader = jQuery('#mobile-header'),
1575					spacing = 0;
1576
1577				mobileHeader.sticky({
1578					topSpacing: spacing
1579				});
1580
1581				jQuery('#mobile-header-sticky-wrapper').css('height', mobileHeader.outerHeight(true));
1582
1583				$window.smartresize( function() {
1584					mobileHeader.sticky('update');
1585					jQuery('#mobile-header-sticky-wrapper').css('height', mobileHeader.outerHeight(true));
1586				});
1587			}
1588
1589
1590			// VERTICAL HEADER RIGHT POSITIONING
1591			if (body.hasClass('layout-boxed') && body.hasClass('vertical-header-right')) {
1592
1593				var rightOffset = ($window.width() - jQuery('#container').width()) / 2;
1594				jQuery('.header-wrap').css('right', rightOffset);
1595
1596				$window.smartresize( function() {
1597					var rightOffset = ($window.width() - jQuery('#container').width()) / 2;
1598					jQuery('.header-wrap').css('right', rightOffset);
1599				});
1600			}
1601		},
1602		stickyHeaderInit: function() {
1603			var spacing = 0,
1604				stickyHeader = jQuery('.sticky-header'),
1605				headerWrap = jQuery('.header-wrap');
1606
1607			if (jQuery('#wpadminbar').length > 0) {
1608				spacing = 32;
1609			}
1610
1611			if ( jQuery('.sticky-top-bar').length > 0 ) {
1612				spacing += jQuery('.sticky-top-bar').outerHeight();
1613			}
1614
1615			stickyHeader.sticky({
1616				topSpacing: spacing
1617			});
1618
1619			$window.smartresize( function() {
1620				stickyHeader.sticky('update');
1621			});
1622
1623			if (body.hasClass('layout-boxed')) {
1624				jQuery('.sticky-header').css('max-width', headerWrap.width());
1625				$window.smartresize( function() {
1626					jQuery('.sticky-header').css('max-width', headerWrap.width());
1627				});
1628			}
1629
1630			// Sticky Header Resizing
1631			if (body.hasClass('sh-dynamic')) {
1632				var defaultHeaderPos = headerWrap.offset().top;
1633				$window.scroll(function () {
1634					defaultHeaderPos = headerWrap.offset().top - $window.scrollTop();
1635					if (jQuery('.sticky-wrapper').hasClass('is-sticky') && defaultHeaderPos < -160) {
1636						headerWrap.addClass('resized-header');
1637					} else if (headerWrap.hasClass('resized-header')) {
1638						headerWrap.removeClass('resized-header');
1639					}
1640
1641				});
1642			}
1643
1644			// Sticky Header Hiding
1645			if (body.hasClass('sh-show-hide')) {
1646				var lastTop = 0;
1647
1648				$window.scroll(function(event){
1649					var currentTop = jQuery(this).scrollTop();
1650					var headerHide = 800;
1651				   	var sliderHeight = 0;
1652				   	
1653					if ( jQuery('#container > .swift-slider-outer').length > 0 ) {
1654						var slider = jQuery('#container > .swift-slider-outer'),
1655							sliderTop = slider.offset().top;
1656						sliderHeight = slider.height();
1657							
1658						headerHide = sliderTop + sliderHeight + 100;
1659					} else if ( jQuery('#container > .home-slider-wrap').length > 0 ) {
1660						var contentTop = jQuery('#main-container').offset().top;
1661						sliderHeight = jQuery('#container > .home-slider-wrap').height();
1662							
1663						headerHide = contentTop + sliderHeight + 100;
1664					}
1665										
1666					if (currentTop > lastTop && currentTop > headerHide) {
1667						
1668						if ( body.hasClass('fs-supersearch-open') || body.hasClass('overlay-menu-open') || body.hasClass('fs-search-open') ) {
1669							return;
1670						}
1671						
1672						jQuery('.sticky-header').addClass('sticky-header-hide');
1673					} else if (jQuery('.sticky-header').hasClass('sticky-header-hide')) {
1674					   jQuery('.sticky-header').removeClass('sticky-header-hide');
1675					}
1676					lastTop = currentTop;
1677				});
1678			}
1679		},
1680		stickyTopBarInit: function() {
1681			var spacing = 0,
1682				stickyTB = jQuery('.sticky-top-bar'),
1683				headerWrap = jQuery('.header-wrap');
1684
1685			if (jQuery('#wpadminbar').length > 0) {
1686				spacing = 32;
1687			}
1688
1689			stickyTB.sticky({
1690				topSpacing: spacing
1691			});
1692
1693			$window.smartresize( function() {
1694				stickyTB.sticky('update');
1695			});
1696
1697			if (body.hasClass('layout-boxed')) {
1698				stickyTB.css('max-width', headerWrap.width());
1699				$window.smartresize( function() {
1700					stickyTB.css('max-width', headerWrap.width());
1701				});
1702			}
1703		},
1704		splitHeader: function($init) {
1705
1706			var mainNav = jQuery('#main-navigation'),
1707				mainNavUl = mainNav.find('> div > ul');
1708			
1709			// prepare for split header
1710			mainNavUl.find('> li').each(function() {
1711				if ( body.hasClass('logged-in') && jQuery(this).hasClass('sf-menu-item-loggedout') ) {
1712					jQuery(this).remove();
1713				} else if ( body.hasClass('logged-out') && jQuery(this).hasClass('sf-menu-item-loggedin') ) {
1714					jQuery(this).remove();
1715				}
1716			});
1717			
1718			// continue with layout
1719			var navChildCount = mainNavUl.find('> li').length,
1720				logo = jQuery('#logo');
1721
1722			if (navChildCount <= 0) {
1723				if ($init) {
1724					logo.imagesLoaded(function () {
1725						logoWidth = logo.width();
1726						logo.css('margin-left', - (logoWidth/2));
1727					});
1728					jQuery('.header-split').addClass('header-split-loaded');
1729				}
1730				return;
1731			} else {
1732				var halfwayCount = Math.floor(navChildCount / 2),
1733					halfwayMenuItem = mainNavUl.find('> li:nth-child('+halfwayCount+')'),
1734					logoWidth = 0,
1735					extraSpacing = 62,
1736					leftHalfWidth = 0,
1737					rightHalfWidth = 0;
1738
1739				if (logo.find('img').length > 0) {
1740					logo.imagesLoaded(function () {
1741						logoWidth = logo.width();
1742
1743						logo.css('margin-left', - (logoWidth/2));
1744
1745						mainNavUl.find('> li').each(function() {
1746
1747							var thisMenuItem = jQuery(this),
1748								index = thisMenuItem.index();
1749
1750							if (index < halfwayCount) {
1751								thisMenuItem.addClass('left-side-item');
1752								leftHalfWidth += thisMenuItem.outerWidth();
1753							} else {
1754								thisMenuItem.addClass('right-side-item');
1755								rightHalfWidth += thisMenuItem.outerWidth();
1756							}
1757						});
1758
1759						if (leftHalfWidth > rightHalfWidth) {
1760							var leftAdjustment = Math.floor( (leftHalfWidth - rightHalfWidth) / 2 );
1761							mainNavUl.css('margin-left', -leftAdjustment + 'px');
1762						} else {
1763							var rightAdjustment = Math.floor( (rightHalfWidth - leftHalfWidth) / 2 );
1764							mainNavUl.css('margin-left', rightAdjustment + 'px');
1765						}
1766
1767						if (isRTL) {
1768						halfwayMenuItem.css('margin-left', logoWidth + extraSpacing + 'px');
1769						} else {
1770						halfwayMenuItem.css('margin-right', logoWidth + extraSpacing + 'px');
1771						}
1772
1773						if ($init) {
1774							jQuery('.header-split').addClass('header-split-loaded');
1775						}
1776					});
1777				} else {
1778					logoWidth = logo.width();
1779					logo.css('margin-left', - (logoWidth/2));
1780					mainNavUl.find('> li').each(function() {
1781
1782						var thisMenuItem = jQuery(this),
1783							index = thisMenuItem.index();
1784
1785						if (index < halfwayCount) {
1786							leftHalfWidth += thisMenuItem.width();
1787						} else {
1788							rightHalfWidth += thisMenuItem.width();
1789						}
1790					});
1791
1792					if (leftHalfWidth > rightHalfWidth) {
1793						var leftAdjustment = Math.floor( (leftHalfWidth - rightHalfWidth) / 2 );
1794						mainNavUl.css('margin-left', -leftAdjustment + 'px');
1795					} else {
1796						var rightAdjustment = Math.floor( (rightHalfWidth - leftHalfWidth) / 2 );
1797						mainNavUl.css('margin-right', -rightAdjustment + 'px');
1798					}
1799
1800					halfwayMenuItem.css('margin-right', logoWidth + extraSpacing + 'px');
1801
1802					if ($init) {
1803						jQuery('.header-split').addClass('header-split-loaded');
1804					}
1805				}
1806			}
1807		},
1808		ajaxSearch: function(e) {
1809			var searchInput = jQuery(e.currentTarget),
1810				searchValues = searchInput.parents('form').serialize() + '&action=atelier_ajaxsearch',
1811				results = jQuery('.ajax-search-results'),
1812				loadingIndicator = jQuery('.search-wrap .ajax-loading'),
1813				ajaxurl = jQuery('.search-wrap').data('ajaxurl');
1814
1815			jQuery.ajax({
1816				url: ajaxurl,
1817				type: "POST",
1818				data: searchValues,
1819				beforeSend: function() {
1820					jQuery('.ajax-search-results').slideUp(200);
1821					setTimeout(function() {
1822						loadingIndicator.fadeIn(50);
1823					}, 150);
1824				},
1825				success: function(response) {
1826					if (response === 0 || response == "0") {
1827						response = "";
1828					} else {
1829						results.html(response);
1830					}
1831				},
1832				complete: function() {
1833					loadingIndicator.fadeOut(200);
1834					setTimeout(function() {
1835						results.slideDown(400);
1836						if (jQuery('#fullscreen-search').length > 0) {
1837							results.find('.search-result').each(function(i) {
1838								var result = jQuery(this);
1839								setTimeout(function() {
1840									result.addClass('load-in');
1841								}, 200*i);
1842							});
1843						}
1844					}, 200);
1845				}
1846			});
1847		},
1848		fsSearch: function() {
1849			var fsSearch = jQuery('#fullscreen-search'),
1850				searchInput = fsSearch.find('#fs-search-input');
1851
1852			searchInput.autoGrowInput();
1853		},
1854		fsSearchToggle: function() {
1855			var fsSearch = jQuery('#fullscreen-search'),
1856				searchInput = fsSearch.find('#fs-search-input');
1857
1858			if (body.hasClass('fs-search-open')) {
1859				body.removeClass('fs-aux-open');
1860				body.removeClass('fs-search-open');
1861				body.addClass('fs-search-closing');
1862				setTimeout(function() {
1863					if (!body.hasClass('overlay-menu-open')) {
1864						jQuery('#main-nav,#main-navigation').fadeIn(400);
1865					}
1866				}, 200);
1867			} else {
1868				setTimeout(function() {
1869					body.removeClass('fs-search-closing');
1870					body.addClass('fs-search-open');
1871					body.addClass('fs-aux-open');
1872					searchInput.focus();
1873					jQuery('#main-nav,#main-navigation').fadeOut(300);
1874				}, 30);
1875			}
1876		},
1877		fsSuperSearchToggle: function() {
1878			if (body.hasClass('fs-supersearch-open')) {
1879				body.removeClass('fs-supersearch-open');
1880				body.removeClass('fs-aux-open');
1881				body.addClass('fs-supersearch-closing');
1882				setTimeout(function() {
1883					jQuery('#main-nav,#main-navigation').fadeIn(400);
1884				}, 200);
1885			} else {
1886				setTimeout(function() {
1887					body.removeClass('fs-supersearch-closing');
1888					body.addClass('fs-supersearch-open');
1889					body.addClass('fs-aux-open');
1890					jQuery('#main-nav,#main-navigation').fadeOut(300);
1891				}, 30);
1892			}
1893		},
1894		overlayMenuToggle: function() {
1895			var overlayMenu = jQuery('#overlay-menu'),
1896				overlayMenuItemHeight = Math.floor(overlayMenu.find('nav ul.menu').height() / overlayMenu.find('ul.menu > li.menu-item').length) - 5,
1897				overlayMenuItemFS = Math.floor(overlayMenuItemHeight * 0.5);
1898
1899			if (overlayMenuItemFS > 60) {
1900				overlayMenuItemFS = 60;
1901			}
1902
1903			//overlayMenu.find('ul.menu > li.menu-item').css('height', overlayMenuItemHeight + 'px').css('font-size', overlayMenuItemFS + 'px').css('line-height', overlayMenuItemHeight - 20 + 'px');
1904			overlayMenu.find('ul.menu > li.menu-item > a').css('font-size', overlayMenuItemFS + 'px').css('line-height', overlayMenuItemHeight - 20 + 'px');
1905
1906			if (body.hasClass('overlay-menu-open')) {
1907				body.removeClass('overlay-menu-open');
1908				body.removeClass('fs-aux-open');
1909				body.addClass('overlay-menu-closing');
1910				setTimeout(function() {
1911					if (!body.hasClass('fs-search-open')) {
1912						jQuery('#main-nav,#main-navigation').fadeIn(400);
1913					}
1914					body.removeClass('overlay-menu-closing');
1915				}, 200);
1916			} else {
1917				setTimeout(function() {
1918					body.removeClass('overlay-menu-closing');
1919					body.addClass('overlay-menu-open');
1920					body.addClass('fs-aux-open');
1921					jQuery('#main-nav,#main-navigation').fadeOut(300);
1922				}, 30);
1923			}
1924		}
1925	};
1926
1927
1928	/////////////////////////////////////////////
1929	// NAVIGATION
1930	/////////////////////////////////////////////
1931
1932	SWIFT.nav = {
1933		init: function() {
1934
1935			// Set up Mega Menu
1936			if (!isMobile || $window.width() > 768) {
1937				SWIFT.nav.mainMenu();
1938			}
1939
1940			// Set up Mobile Menu
1941			SWIFT.nav.mobileMenuInit();
1942
1943			// Add main menu actions
1944			SWIFT.nav.mainMenuActions();
1945
1946			SWIFT.nav.cartHover();
1947
1948			if ( jQuery('.sf-side-slideout').length > 0 ) {
1949				SWIFT.nav.sideSlideoutInit();
1950			}
1951
1952		},
1953		mainMenu: function() {
1954
1955			var mainNav = jQuery("#main-navigation");
1956
1957			if (jQuery('.header-wrap').hasClass('full-center')) {
1958				mainNav.find('li.sf-mega-menu > ul.sub-menu').each(function() {
1959					var thisSubMenu = jQuery(this);
1960
1961					if (!thisSubMenu.children().first().hasClass('container')) {
1962						jQuery(this).wrapInner('<div class="container"></div>');
1963					}
1964				});
1965			}
1966
1967			mainNav.find(".menu li.menu-item").hoverIntent({
1968				over: function() {
1969					if (jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) {
1970						jQuery(this).find('ul.sub-menu,.mega-menu-sub').first().fadeIn(200);
1971					}
1972				},
1973				out:function() {
1974					if (jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) {
1975						jQuery(this).find('ul.sub-menu,.mega-menu-sub').first().fadeOut(150);
1976					}
1977				},
1978				timeout: 0
1979			});
1980
1981			// Set sub-menu position based on menu height
1982			var mainNavHeight = mainNav.height(),
1983				subMenu = mainNav.find('.sub-menu');
1984
1985			subMenu.each(function() {
1986				jQuery(this).css('top', mainNavHeight);
1987			});
1988		},
1989		mainMenuActions: function() {
1990			// Add parent class to items with sub-menus
1991			jQuery("ul.sub-menu").parents('li').addClass('parent');
1992
1993			// Menu parent click function
1994			jQuery('.menu li.parent > a').on('click', function(e) {
1995
1996				if (jQuery('#container').width() < 1024 || body.hasClass('standard-browser')) {
1997					return e;
1998				}
1999
2000				var directDropdown = jQuery(this).parent().find('ul.sub-menu').first();
2001				if ( (directDropdown.css('opacity') === '1' || directDropdown.css('opacity') === 1) && directDropdown.css('display') == 'block') {
2002					if (isMobile) {
2003						directDropdown.fadeOut(200);
2004					}
2005					return e;
2006				} else {
2007					if (isMobile) {
2008						directDropdown.fadeIn(200);
2009					}
2010					e.preventDefault();
2011				}
2012			});
2013
2014			// Set Standard Sub Menu Top Position
2015			jQuery("nav.std-menu").find(".menu li").each(function() {
2016				var top = jQuery(this).outerHeight();
2017				jQuery(this).find('ul.sub-menu').first().css('top', top);
2018			});
2019
2020			// Enable hover dropdowns for window size above tablet width
2021			jQuery("nav.std-menu").find(".menu li.parent").hoverIntent({
2022				over: function() {
2023					var isSideSlideout = jQuery(this).parents('.sf-side-slideout').length > 0;
2024					if ((jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) && !isSideSlideout && !body.hasClass('custom-menu-hover')) {
2025						jQuery(this).find('ul.sub-menu').first().stop( true, true ).fadeIn(200);
2026					}
2027				},
2028				out:function() {
2029					var isSideSlideout = jQuery(this).parents('.sf-side-slideout').length > 0;
2030					if ((jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) && !isSideSlideout && !body.hasClass('custom-menu-hover')) {
2031						jQuery(this).find('.sub-menu').first().stop( true, true ).fadeOut(150);
2032					}
2033				},
2034				timeout: 100
2035			});
2036
2037			// Menu item click function
2038			jQuery('.menu-item').on('click', 'a', function(e) {
2039
2040				var menuItem = jQuery(this),
2041					linkHref = menuItem.attr('href'),
2042					isMobileMenuItem = false,
2043					isSlideoutItem = false,
2044					isOverlayItem = false,
2045					youtubeURL = linkHref.match(/watch\?v=([a-zA-Z0-9\-_]+)/),
2046					vimeoURL = linkHref.match(/^http:\/\/(www\.)?vimeo\.com\/(clip\:)?(\d+).*$/);
2047
2048
2049				if (jQuery(this).parents('nav').attr('id') === "mobile-menu") {
2050					isMobileMenuItem = true;
2051				}
2052
2053				if ( jQuery(this).parents('.sf-side-slideout').length > 0 ) {
2054					isSlideoutItem = true;
2055				}
2056				
2057				if ( jQuery(this).parents('#overlay-menu').length > 0 ) {
2058					isOverlayItem = true;
2059				}
2060
2061				// Link to full width video overlay if link is YouTube/Vimeo
2062				if (youtubeURL || vimeoURL) {
2063
2064					var videoURL = "";
2065
2066					if (youtubeURL) {
2067						videoURL = 'https://www.youtube.com/embed/'+ youtubeURL[1] +'?autoplay=1&amp;wmode=transparent';
2068					} else if (vimeoURL) {
2069						videoURL = 'https://player.vimeo.com/video/'+ vimeoURL[3] +'?title=0&amp;byline=0&amp;portrait=0&amp;autoplay=1&amp;wmode=transparent';
2070					}
2071
2072					if (videoURL !== "") {
2073						jQuery(this).data('video', videoURL);
2074						SWIFT.widgets.openFullWidthVideo(jQuery(this));
2075					}
2076					e.preventDefault();
2077				// Smooth Scroll
2078				} else if (linkHref.indexOf('#') === 0 && linkHref.length > 1) {
2079					var headerHeight = 0;
2080					
2081					if ( isOverlayItem ) {
2082						return;
2083					} else if (isMobileMenuItem) {
2084						SWIFT.nav.mobileMenuHideTrigger();
2085						setTimeout(function() {
2086							if (body.hasClass('mh-sticky')) {
2087								headerHeight = jQuery('#mobile-header').height();
2088							}
2089							if (jQuery('#wpadminbar').length > 0) {
2090								headerHeight = headerHeight + jQuery('#wpadminbar').height();
2091							}
2092
2093							if (jQuery(linkHref).length > 0) {
2094								jQuery('html, body').stop().animate({
2095									scrollTop: jQuery(linkHref).offset().top - headerHeight + 2
2096								}, 1000, 'easeInOutExpo');
2097							}
2098						}, 400);
2099					} else {
2100						SWIFT.page.onePageNavGoTo(linkHref);
2101					}
2102					e.preventDefault();
2103				} else {
2104					if (isMobileMenuItem || isOverlayItem) {
2105						return;
2106					} else {
2107						return e;
2108					}
2109				}
2110
2111			});
2112
2113
2114			// Set current language to top bar item
2115			var currentLanguage = jQuery('li.aux-languages').find('.current-language').html();
2116			if (currentLanguage !== "") {
2117				jQuery('li.aux-languages > a').html(currentLanguage);
2118			}
2119			jQuery('li.aux-languages > a').animate({
2120				'opacity': 1
2121			}, 400, 'easeOutQuart');
2122
2123			// Set menu state on resize
2124			$window.smartresize( function() {
2125				if (jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) {
2126					var menus = jQuery('nav').find('ul.menu');
2127					menus.each(function() {
2128						jQuery(this).css("display", "");
2129					});
2130				}
2131			});
2132
2133			// Change menu active when scroll through sections
2134			if ( jQuery('section.row.row-has-id').length > 0 ) {
2135				SWIFT.nav.currentScrollIndication();
2136				$window.on('scroll', SWIFT.nav.throttle( SWIFT.nav.currentScrollIndication, 300 ));
2137			}
2138		},
2139		throttle: function(fn, threshhold, scope) {
2140			var last,
2141			  deferTimer;
2142			return function () {
2143			var context = scope || this;
2144
2145			var now = new Date(),
2146			    args = arguments;
2147			if (last && now < last + threshhold) {
2148			  // hold on to it
2149			  clearTimeout(deferTimer);
2150			  deferTimer = setTimeout(function () {
2151			    last = now;
2152			    fn.apply(context, args);
2153			  }, threshhold);
2154			} else {
2155			  last = now;
2156			  fn.apply(context, args);
2157			}
2158			};
2159		},
2160		cartHover: function() {
2161
2162			// Shopping bag hover function
2163			jQuery(document).on("mouseenter", "li.shopping-bag-item", function() {
2164
2165				if ( jQuery(this).parents('#mobile-menu-wrap').length > 0 || jQuery(this).parents('#mobile-cart-wrap').length > 0 && !body.hasClass('custom-menu-hover') ) {
2166					return;
2167				}
2168
2169				if (jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) {
2170					jQuery(this).find('ul.sub-menu').first().stop( true, true ).fadeIn(200);
2171					shopBagHovered = true;
2172				}
2173			}).on("mouseleave", "li.shopping-bag-item", function() {
2174
2175				if ( jQuery(this).parents('#mobile-menu-wrap').length > 0 || jQuery(this).parents('#mobile-cart-wrap').length > 0 && !body.hasClass('custom-menu-hover') ) {
2176					return;
2177				}
2178
2179				if (jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) {
2180					jQuery(this).find('ul.sub-menu').first().stop( true, true ).fadeOut(150);
2181					shopBagHovered = false;
2182				}
2183			});
2184		},
2185		currentScrollIndication: function() {
2186			var adjustment = 0,
2187				link;
2188			
2189			if (body.hasClass('sticky-header-enabled')) {
2190				adjustment = jQuery('.header-wrap').height();
2191			}
2192
2193			if ( jQuery('.sticky-top-bar').length > 0 ) {
2194				adjustment += jQuery('.sticky-top-bar').outerHeight();
2195			}
2196
2197			var inview = jQuery('section.row:in-viewport('+adjustment+')').attr('id'),
2198				menuItems = jQuery('#main-navigation .menu li a');
2199			
2200			if ( typeof inview === 'undefined' ) {
2201				return;
2202			}
2203							
2204			link = menuItems.filter('[href="#' + inview + '"]');
2205			jQuery('#main-navigation').find('.current-scroll-item').removeClass('current-scroll-item');
2206			if (link.length > 0 && !link.hasClass('.current-scroll-item')) {
2207				link.parent().addClass('current-scroll-item');
2208			}
2209			
2210		},
2211		mobileMenuInit: function() {
2212
2213			// Mobile Logo click
2214			jQuery('#mobile-logo > a').on('click touchstart', function(e) {
2215				if (body.hasClass('mobile-menu-open') || body.hasClass('mobile-cart-open') || body.hasClass('mobile-menu-closing')) {
2216					return false;
2217				} else {
2218					return e;
2219				}
2220			});
2221
2222			// Mobile Nav show
2223			jQuery('.mobile-menu-link').on('click', function(e) {
2224				e.preventDefault();
2225
2226				if (body.hasClass('mh-overlay')) {
2227					SWIFT.nav.mobileHeaderOverlay('menu');
2228				} else {
2229					if (body.hasClass('mobile-menu-open')) {
2230						SWIFT.nav.mobileMenuHideTrigger();
2231					} else {
2232						SWIFT.nav.showMobileMenu();
2233					}
2234				}
2235			});
2236
2237			// Mobile Cart show
2238			jQuery(document).on('click', '.cart-contents', function(e) {
2239
2240				if ( jQuery(this).parents('.mobile-header-opts').length > 0 ) {
2241					e.preventDefault();
2242					if (body.hasClass('mh-overlay')) {
2243						SWIFT.nav.mobileHeaderOverlay('cart');
2244					} else {
2245						if (body.hasClass('mobile-menu-open')) {
2246							SWIFT.nav.mobileMenuHideTrigger();
2247						} else {
2248							SWIFT.nav.showMobileCart();
2249						}
2250					}
2251				} else {
2252					return e;
2253				}
2254			});
2255
2256			// Mobile Overlay Close
2257			jQuery('.mobile-overlay-close').on('click', function(e) {
2258				e.preventDefault();
2259				if (body.hasClass('mh-cart-show')) {
2260					jQuery('#mobile-cart-wrap').animate({
2261						'opacity': 0
2262					}, 500, 'easeOutQuart');
2263					setTimeout(function() {
2264						body.removeClass('mh-overlay-show');
2265						body.removeClass('mh-cart-show');
2266						jQuery('#mobile-cart-wrap').css('display', 'none');
2267					}, 500);
2268				} else if (body.hasClass('mh-menu-show')) {
2269					jQuery('#mobile-menu-wrap').animate({
2270						'opacity': 0
2271					}, 500, 'easeOutQuart');
2272					setTimeout(function() {
2273						body.removeClass('mh-overlay-show');
2274						body.removeClass('mh-menu-show');
2275						jQuery('#mobile-menu-wrap').css('display', 'none');
2276					}, 500);
2277				}
2278			});
2279
2280			// Mobile Menu parent click
2281			jQuery('#mobile-menu li > a').on('click', function(e) {
2282				var parentMenuItem = jQuery(this).parent(),
2283					linkHref = jQuery(this).attr('href'),
2284					subMenu = parentMenuItem.find('ul.sub-menu').first();
2285
2286				if (!parentMenuItem.hasClass('parent')) {
2287					SWIFT.nav.mobileMenuHideTrigger();
2288
2289					if (linkHref.indexOf('#') === 0 && linkHref.length > 1) {
2290						SWIFT.isScrolling = true;
2291						SWIFT.page.onePageNavGoTo(linkHref);
2292						setTimeout(function() {
2293							SWIFT.isScrolling = false;
2294						}, 1000);
2295						e.preventDefault();
2296					} else if (body.hasClass('page-transitions')) {
2297						SWIFT.page.fadePageOut(linkHref);
2298					}
2299
2300					return e;
2301				}
2302
2303				if (parentMenuItem.hasClass('sub-menu-open')) {
2304					if (linkHref.indexOf('http') === 0 || linkHref.indexOf('/') === 0) {
2305						return e;
2306					} else {
2307						parentMenuItem.removeClass('sub-menu-open');
2308						subMenu.slideUp();
2309						e.preventDefault();
2310					}
2311				} else {
2312					parentMenuItem.addClass('sub-menu-open');
2313					subMenu.slideDown();
2314					e.preventDefault();
2315				}
2316			});
2317
2318
2319			// Swipe to hide mobile menu
2320			jQuery("#mobile-menu-wrap").swipe({
2321				swipeLeft:function() {
2322					if (!body.hasClass('mobile-header-center-logo-alt') && !body.hasClass('mobile-header-left-logo')) {
2323						SWIFT.nav.mobileMenuHideTrigger();
2324					}
2325				},
2326				swipeRight:function() {
2327					if (body.hasClass('mobile-header-center-logo-alt') || body.hasClass('mobile-header-left-logo')) {
2328						SWIFT.nav.mobileMenuHideTrigger();
2329					}
2330				},
2331			});
2332
2333			// Swipe to hide mobile cart
2334			jQuery("#mobile-cart-wrap").swipe( {
2335				swipeLeft:function() {
2336					if (body.hasClass('mobile-header-center-logo-alt') || body.hasClass('mobile-header-right-logo') || body.hasClass('mobile-header-center-logo')) {
2337						SWIFT.nav.mobileMenuHideTrigger();
2338					}
2339				},
2340				swipeRight:function() {
2341					if (!body.hasClass('mobile-header-center-logo-alt') && !body.hasClass('mobile-header-right-logo')) {
2342						SWIFT.nav.mobileMenuHideTrigger();
2343					}
2344				},
2345			});
2346
2347			// Hide on resize
2348			$window.smartresize( function() {
2349			
2350				if ( !body.hasClass('mobile-menu-open') ) {
2351					return;
2352				}
2353
2354				var windowWidth = $window.width();
2355
2356				if (windowWidth > 1024 && body.hasClass('mhs-tablet-land')) {
2357					SWIFT.nav.mobileMenuHideTrigger();
2358				} else if (windowWidth > 991 && body.hasClass('mhs-tablet-port')) {
2359					SWIFT.nav.mobileMenuHideTrigger();
2360				} else if (windowWidth > 767 && body.hasClass('mhs-mobile')) {
2361					SWIFT.nav.mobileMenuHideTrigger();
2362				}
2363
2364			});
2365
2366		},
2367		showMobileMenu: function() {
2368			body.addClass('mobile-menu-open');
2369			setTimeout(function() {
2370				jQuery('#container').on('click touchstart', SWIFT.nav.mobileMenuHideTrigger);
2371			}, 400);
2372		},
2373		hideMobileMenu: function() {
2374			body.removeClass('mobile-menu-open');
2375			if ( body.hasClass('mh-overlay-show') ) {
2376				jQuery('#mobile-menu-wrap').animate({
2377					'opacity': 0
2378				}, 300, 'easeOutQuart');
2379			}
2380			setTimeout(function() {
2381				body.removeClass('mh-menu-show');
2382				if ( body.hasClass('mh-overlay-show') ) {
2383					body.removeClass('mh-overlay-show');
2384					jQuery('#mobile-menu-wrap').css('display', 'none');
2385				}
2386				jQuery('#container').off('click touchstart', SWIFT.nav.mobileMenuHideTrigger);
2387			}, 300);
2388			setTimeout(function() {
2389				body.removeClass('mobile-menu-closing');
2390			}, 1000);
2391		},
2392		showMobileCart: function() {
2393			body.addClass('mobile-cart-open');
2394			setTimeout(function() {
2395				jQuery('#container').on('click touchstart', SWIFT.nav.mobileMenuHideTrigger);
2396			}, 400);
2397		},
2398		hideMobileCart: function() {
2399			body.removeClass('mobile-cart-open');
2400			if ( body.hasClass('mh-overlay-show') ) {
2401				jQuery('#mobile-cart-wrap').animate({
2402					'opacity': 0
2403				}, 300, 'easeOutQuart');
2404			}
2405			setTimeout(function() {
2406				if ( body.hasClass('mh-overlay-show') ) {
2407					body.removeClass('mh-overlay-show');
2408					jQuery('#mobile-cart-wrap').css('display', 'none');
2409				}
2410				body.removeClass('mh-cart-show');
2411				jQuery('#container').off('click touchstart', SWIFT.nav.mobileMenuHideTrigger);
2412			}, 400);
2413			setTimeout(function() {
2414				body.removeClass('mobile-menu-closing');
2415			}, 1000);
2416		},
2417		mobileMenuHideTrigger: function(e) {
2418			if (e) {
2419			    e.preventDefault();
2420			}
2421			body.addClass('mobile-menu-closing');
2422			SWIFT.nav.hideMobileMenu();
2423			SWIFT.nav.hideMobileCart();
2424		},
2425		mobileHeaderOverlay: function(type) {
2426
2427			if (type === "menu") {
2428				jQuery('#mobile-menu-wrap').css('display', 'block');
2429				body.addClass('mh-overlay-show');
2430				body.addClass('mh-menu-show');
2431				jQuery('#mobile-menu-wrap').animate({
2432					'opacity': 1
2433				}, 500, 'easeOutQuart');
2434			} else if (type === "cart") {
2435				jQuery('#mobile-cart-wrap').css('display', 'block');
2436				body.addClass('mh-overlay-show');
2437				body.addClass('mh-cart-show');
2438				jQuery('#mobile-cart-wrap').animate({
2439					'opacity': 1
2440				}, 500, 'easeOutQuart');
2441			}
2442
2443		},
2444		showSideSlideout: function(side) {
2445
2446			var windowTop = $window.scrollTop();
2447
2448			if (side === "left") {
2449				jQuery('#side-slideout-left-wrap').css('display', 'block');
2450				body.addClass('side-slideout-open');
2451				body.addClass('side-slideout-left-open');
2452			} else {
2453				jQuery('#side-slideout-right-wrap').css('display', 'block');
2454				body.addClass('side-slideout-open');
2455				body.addClass('side-slideout-right-open');
2456			}
2457
2458			if (windowTop > 0 && body.hasClass('sticky-header-enabled') && jQuery('.sticky-wrapper').hasClass('is-sticky')) {
2459				stickyHeaderTop = jQuery('.sticky-header').css('top');
2460				jQuery('.sticky-header').css('position', 'absolute').css('top', windowTop);
2461				if ( jQuery('.sticky-top-bar').length > 0 ) {
2462				jQuery('.sticky-top-bar').css('position', 'absolute').css('top', windowTop);
2463				}
2464			}
2465
2466			setTimeout(function() {
2467				jQuery('#container').on('click touchstart', SWIFT.nav.sideSlideoutHideTrigger);
2468			}, 400);
2469		},
2470		hideSideSlideout: function() {
2471			body.removeClass('side-slideout-open side-slideout-left-open side-slideout-right-open');
2472			setTimeout(function() {
2473				jQuery('#container').off('click touchstart', SWIFT.nav.sideSlideoutHideTrigger);
2474			}, 400);
2475			setTimeout(function() {
2476				body.removeClass('side-slideout-closing');
2477				if (body.hasClass('sticky-header-enabled') && jQuery('.sticky-wrapper').hasClass('is-sticky')) {
2478					jQuery('.sticky-header').css('position', 'fixed').css('top', stickyHeaderTop);
2479					jQuery('.sticky-top-bar').css('position', 'fixed').css('top', stickyHeaderTop);
2480				}
2481			}, 1000);
2482		},
2483		sideSlideoutHideTrigger: function() {
2484			body.addClass('side-slideout-closing');
2485			SWIFT.nav.hideSideSlideout();
2486		},
2487		sideSlideoutInit: function() {
2488
2489			// Slideout Menu parent click
2490			jQuery('.sf-side-slideout li.menu-item > a').on('click', function(e) {
2491				var parentMenuItem = jQuery(this).parent(),
2492					linkHref = jQuery(this).attr('href'),
2493					subMenu = parentMenuItem.find('ul.sub-menu').first(),
2494					subParent = subMenu.parent();
2495
2496				if (!parentMenuItem.hasClass('parent')) {
2497					SWIFT.nav.sideSlideoutHideTrigger();
2498
2499					if (body.hasClass('page-transitions')) {
2500						SWIFT.page.fadePageOut(linkHref);
2501					}
2502
2503					return e;
2504				}
2505
2506				if (subParent.hasClass('sub-menu-open')) {
2507					if (linkHref.indexOf('http') === 0 || linkHref.indexOf('/') === 0) {
2508						return e;
2509					} else {
2510						subParent.removeClass('sub-menu-open');
2511						subMenu.slideUp();
2512						e.preventDefault();
2513					}
2514				} else {
2515					subParent.addClass('sub-menu-open');
2516					subMenu.slideDown();
2517					e.preventDefault();
2518				}
2519			});
2520		}
2521	};
2522
2523
2524	/////////////////////////////////////////////
2525	// WOOCOMMERCE FUNCTIONS
2526	/////////////////////////////////////////////
2527
2528	SWIFT.woocommerce = {
2529		init: function() {
2530
2531			// SHOP LAYOUT SWITCH
2532			SWIFT.woocommerce.shopLayoutSwitch();
2533			
2534			// SHOP PAGINATION
2535			if ( body.hasClass('archive') && body.hasClass('woocommerce') ) {
2536				SWIFT.woocommerce.infiniteScroll();
2537			}
2538			
2539			// REMOVE MAIN NAV CART IF STICKY HEADER DISABLED
2540			if ( body.hasClass('sticky-header-disabled') && jQuery('#main-nav .shopping-bag-item').length > 0 ) {
2541				jQuery('#main-nav .shopping-bag-item').remove();
2542			}
2543
2544			// MOBILE SHOP FILTERS
2545			SWIFT.woocommerce.mobileShopFilters();
2546
2547			// QUANTITY FUNCTIONS
2548			if ( !jQuery('.quantity').hasClass('mnm-quantity') ) {
2549				SWIFT.woocommerce.productQuantityAdjust();
2550			}
2551			
2552			// SMALL PRODUCT CHECK
2553			SWIFT.woocommerce.smallProductCheck();
2554			$window.smartresize( function() {
2555				SWIFT.woocommerce.smallProductCheck();
2556			});
2557			
2558			// PREVIEW SLIDER LAYOUT
2559			if ( jQuery('.product-type-preview-slider').length > 0 ) {
2560				SWIFT.woocommerce.previewSliderLayout();
2561			}
2562
2563			// QUICKVIEW TOOLTIP
2564			jQuery('.jckqvBtn').attr('data-toggle', 'tooltip').attr('data-original-title', sfOptionParams.data('quickview-text'));
2565
2566			// UPDATE QUANTITY DATA VALUE
2567			jQuery(document).on("change", "form.cart input.qty", function() {
2568			    jQuery(this.form).find("button[data-quantity]").attr("data-quantity", this.value);
2569			});
2570
2571			jQuery(".add_to_cart_button.product_type_simple").on('click', function() {
2572				var $button = jQuery(this);
2573				$button.data('quantity', $button.parent().find('input.qty').val());
2574			});
2575
2576			// ADD TO CART LOADING
2577			jQuery(document).on('click', '.add-to-cart-wrap .add_to_cart_button', function() {
2578				var button = jQuery(this),
2579					buttonWrap = button.parent(),
2580					loadingText = button.attr("data-loading_text"),
2581					
2582					addedTitle = buttonWrap.data('tooltip-added-text');
2583				
2584				if ( button.hasClass('disabled') || button.hasClass('product_type_variable') ) {
2585					return;
2586				}
2587				
2588				button.addClass("added-spinner");
2589				button.find('span').text(loadingText);
2590				button.find('i').attr('class', 'sf-icon-loader');
2591
2592				if ( !buttonWrap.hasClass('cart') && !buttonWrap.hasClass('add-to-cart-shortcode') ) {
2593					setTimeout(function() {
2594						buttonWrap.tooltip('hide').attr('title', addedTitle).tooltip('fixTitle');
2595					}, 500);
2596					setTimeout(function() {
2597						buttonWrap.tooltip('show');
2598					}, 700);
2599				}
2600			});
2601
2602			jQuery("body").on("adding_to_cart", function() {
2603				var addToCartBtn,
2604					defaultText = "",
2605					defaultIcon = "",
2606					addedTitle = "",
2607					loadingText = "";
2608
2609				if (body.hasClass('single-product')) {
2610					addToCartBtn = jQuery('.add_to_cart_button, .single_add_to_cart_button');
2611					defaultText = addToCartBtn.data('default_text');
2612					defaultIcon = addToCartBtn.data('default_icon');
2613				 	addedTitle = addToCartBtn.data('tooltip-added-text');
2614				 	loadingText = addToCartBtn.data("loading_text");
2615				} else {
2616					return;
2617				}
2618
2619				addToCartBtn.addClass("added-spinner");
2620				addToCartBtn.find('span').text(loadingText);
2621				addToCartBtn.find('i').attr('class', 'sf-icon-loader');
2622			});
2623
2624			// ADD TO CART NOTIFICATION
2625			jQuery("body").on("added_to_cart", function() {
2626				var currentProduct = jQuery('.added-spinner'),
2627					addToCartBtn,
2628					addedText,
2629					buttonWrap,
2630					defaultText = "",
2631					defaultIcon = "";
2632
2633				currentProduct.addClass('product-added');
2634
2635				if (body.hasClass('single-product') || currentProduct.parents('#jckqv').length > 0) {
2636					addToCartBtn = jQuery('.add_to_cart_button, .single_add_to_cart_button');
2637					addedText = addToCartBtn.data('added_text');
2638					addToCartBtn.find('span').text(addedText);
2639				}
2640				
2641				if ( currentProduct.parents('li.product').length > 0 ) {
2642				 	addToCartBtn = currentProduct;
2643					addedText = addToCartBtn.data('added_short');						
2644					addToCartBtn.find('span').text(addedText);
2645				}
2646				
2647				if ( currentProduct.parents('.add-to-cart-shortcode').length > 0 ) {
2648					addToCartBtn = currentProduct;
2649					addedText = addToCartBtn.data('added_text');
2650					addToCartBtn.find('span').text(addedText);
2651				}
2652
2653				currentProduct.find('i').attr('class', 'sf-icon-tick');
2654				currentProduct.removeClass('added-spinner');
2655				
2656				// Animate icon
2657				setTimeout(function() {
2658					jQuery(document).find('.shopping-bag-item:visible:last').addClass('added-notification');
2659					jQuery(document).find('.shopping-bag-item:visible:last .cart-contents').addClass('sf-animate ' + cartNotification);
2660				}, 100);
2661				
2662				// Show cart dropdown
2663				setTimeout(function() {
2664					jQuery(document).find('.shopping-bag-item:visible:last').find('ul.sub-menu').fadeIn(200);
2665				}, 800);
2666
2667				// Reset button on single product
2668				setTimeout(function() {
2669					if (body.hasClass('single-product') || currentProduct.parents('#jckqv').length > 0) {
2670						addToCartBtn = jQuery('.add_to_cart_button, .single_add_to_cart_button');
2671						defaultText = addToCartBtn.data('default_text');
2672						defaultIcon = addToCartBtn.data('default_icon');
2673					 	buttonWrap = addToCartBtn.parent();
2674
2675						currentProduct.find('i').attr('class', defaultIcon);
2676						addToCartBtn.find('span').text(defaultText);
2677						addToCartBtn.removeClass('added product-added');
2678					}
2679					
2680					if ( currentProduct.parents('.add-to-cart-shortcode').length > 0 ) {
2681						addToCartBtn = currentProduct;
2682						buttonWrap = addToCartBtn.parent();
2683						defaultText = addToCartBtn.data('default_text');
2684						defaultIcon = addToCartBtn.data('default_icon');
2685
2686						currentProduct.find('i').attr('class', defaultIcon);
2687						addToCartBtn.find('span').text(defaultText);
2688						addToCartBtn.removeClass('added product-added');
2689					}
2690					
2691				}, 3000);
2692
2693				// Hide cart dropdown
2694				setTimeout(function() {
2695					jQuery(document).find('.shopping-bag-item:visible:last').removeClass('added-notification');
2696					jQuery(document).find('.shopping-bag-item:visible:last .cart-contents').removeClass('sf-animate ' + cartNotification);
2697					if (!shopBagHovered) {
2698						jQuery(document).find('.shopping-bag-item:visible:last').find('ul.sub-menu').fadeOut(150);
2699					}
2700				}, 4000);
2701			});
2702
2703			// WISHLIST UPDATE
2704			jQuery(document).on('click', '.add_to_wishlist', function(){
2705
2706				var data = {action: 'atelier_add_to_wishlist', product_id: jQuery(this).attr('data-product-id')};
2707				var ajaxURL = jQuery(this).attr('data-ajaxurl');
2708
2709				jQuery.post(ajaxURL, data, function(response) {
2710					var json = jQuery.parseJSON(response);
2711					jQuery('.cart-wishlist .wishlist-item .bag-contents').prepend(json.wishlist_output);
2712					jQuery('.wishlist-empty').remove();
2713					jQuery('.bag-buttons').removeClass('no-items');
2714					var navWishlist = jQuery('.wishlist-item:visible:last'),
2715						wishlistIcon = navWishlist.find('.wishlist-link');
2716
2717					navWishlist.addClass('added-notification');
2718					wishlistIcon.addClass('sf-animate ' + cartNotification);
2719					setTimeout(function() {
2720						navWishlist.find('ul.sub-menu').fadeIn(200);
2721					}, 800);
2722					setTimeout(function() {
2723						navWishlist.removeClass('added-notification');
2724						wishlistIcon.removeClass('sf-animate ' + cartNotification);
2725						if (!wishlistHovered) {
2726							navWishlist.find('ul.sub-menu').fadeOut(150);
2727						}
2728					}, 4000);
2729				});
2730
2731        	});
2732
2733			// SHOW PRODUCTS
2734			jQuery('.show-products-link').on('click', function(e) {
2735				e.preventDefault();
2736				var linkHref = jQuery(this).attr('href').replace('?', ''),
2737					currentURL = document.location.href.replace(/\/page\/\d+/, ''),
2738					currentQuery = document.location.search;
2739
2740				if (currentQuery.indexOf('?show') >= 0) {
2741					window.location = jQuery(this).attr('href');
2742				} else if (currentQuery.indexOf('?') >= 0) {
2743					window.location = currentURL + '&' + linkHref;
2744				} else {
2745					window.location = currentURL + '?' + linkHref;
2746				}
2747			});
2748
2749
2750			// SHOPPING CALCULATOR
2751			jQuery('.shipping-calculator-form input').keypress(function(e) {
2752				if(e.which == 10 || e.which == 13) {
2753					jQuery(".update-totals-button button").trigger( "click" );
2754				}
2755			});
2756
2757			// PRODUCT GRID
2758			if (jQuery('.product-grid').length > 0) {
2759
2760				if (!jQuery('.inner-page-wrap').hasClass('full-width-shop')) {
2761					var productGrid = jQuery('.product-grid');
2762					productGrid.each(function() {
2763						if ( productGrid.parent('.upsells').length > 0 ) {
2764							return;
2765						}
2766						SWIFT.woocommerce.productGridSetup(jQuery(this));
2767					});
2768				}
2769			}
2770
2771			// Multi-Masonry Product
2772			if (jQuery('.products.multi-masonry-items').length > 0) {
2773
2774				jQuery('.products.multi-masonry-items').each(function() {
2775					SWIFT.woocommerce.multiMasonrySetup(jQuery(this));
2776				});
2777
2778				$window.smartresize( function() {
2779					SWIFT.woocommerce.windowResized();
2780				});
2781
2782			}
2783
2784			// EDIT PRODUCT CATEGORY COUNT DISPLAY
2785			jQuery('.product-categories li span.count, .widget_layered_nav li span.count').each(function() {
2786				var thisCategory = jQuery(this),
2787					thisText = thisCategory.text();
2788				thisCategory.text(thisText.replace('(', '').replace(')', ''));
2789				thisCategory.addClass('show-count');
2790			});
2791
2792			jQuery('.upsell-heading-link').on('click', '', function(e) {
2793
2794				var upsellToggle = jQuery(this);
2795
2796				jQuery('.upsells > .products').slideToggle();
2797
2798				if (upsellToggle.hasClass('upsell-open')) {
2799					upsellToggle.find('i').removeClass('sf-icon-minus').addClass('sf-icon-plus');
2800					upsellToggle.removeClass('upsell-open');
2801				} else {
2802					upsellToggle.find('i').removeClass('sf-icon-plus').addClass('sf-icon-minus');
2803					upsellToggle.addClass('upsell-open');
2804				}
2805
2806				e.preventDefault();
2807
2808			});
2809			
2810			// Currency Switcher
2811			if ( jQuery('.wcml_currency_switcher').length > 0 ) {
2812				jQuery('.wcml_currency_switcher > ul').addClass('sub-menu');
2813			}
2814		},
2815		load: function() {
2816
2817			if (jQuery('.woocommerce-shop-page').hasClass('full-width-shop') && !(IEVersion && IEVersion < 9) && !jQuery('#products').hasClass('multi-masonry-items')) {
2818				SWIFT.woocommerce.fullWidthShop();
2819			}
2820			
2821			if ( jQuery('#product-img-slider').length > 0 ) {
2822				SWIFT.woocommerce.variations();
2823				SWIFT.woocommerce.swatches();
2824			}
2825			
2826		},
2827		cartWishlist: function() {
2828			// Cart remove product
2829			jQuery(document).on('click', '.shopping-bag .remove-product', function(e) {
2830
2831				e.preventDefault();
2832				e.stopPropagation();
2833												
2834				var prod_id = jQuery(this).attr('data-product-id'),
2835				    variation_id = jQuery(this).attr('data-variation-id'),
2836					prod_quantity = jQuery(this).attr('data-product-qty'),
2837					empty_bag_txt = jQuery('.shopping-bag').attr('data-empty-bag-txt'),
2838					singular_item_txt = jQuery('.shopping-bag').attr('data-singular-item-txt'),
2839					multiple_item_txt = jQuery('.shopping-bag').attr('data-multiple-item-txt'),
2840					data = {action: 'atelier_cart_product_remove', product_id: prod_id, variation_id: variation_id},
2841					ajaxURL = jQuery(this).attr('data-ajaxurl'),
2842					cartURL = jQuery('.shopping-bag').find(".bag-button").attr('href');
2843
2844					jQuery('.shopping-bag .loading-overlay').fadeIn(200);
2845
2846					jQuery.post(ajaxURL, data, function(response) {
2847
2848						var cartTotal = response;
2849						var cartcounter = 0;
2850						
2851						if ( body.hasClass('woocommerce-checkout') ) {
2852							window.location.href = cartURL;
2853						}
2854						
2855						if ( body.hasClass('woocommerce-cart') ) {
2856							location.reload();
2857						}
2858
2859						jQuery('.shopping-bag .loading-overlay').fadeOut(100);
2860
2861						cartcounter = parseInt(jQuery('.cart-contents .num-items').first().text()) - prod_quantity;
2862						jQuery('.cart-contents .amount').replaceWith(cartTotal);
2863						jQuery('.bag-total .amount').replaceWith(cartTotal);
2864						jQuery('.cart-contents .num-items').text(cartcounter);
2865
2866						jQuery('.cart-contents .num-items').each(function( index ) {
2867							jQuery(this).text(cartcounter);
2868						});
2869						
2870						if ( variation_id > 0 ){
2871							jQuery('.product-var-id-'+variation_id).remove();
2872						}else{
2873							jQuery('.product-id-'+prod_id).remove();	
2874						}
2875						
2876
2877						if ( cartcounter <= 0 ) {
2878							jQuery('.sub-menu .shopping-bag').append('<div class="bag-empty">' + empty_bag_txt + '</div>');
2879							jQuery('.sub-menu .shopping-bag .bag-buttons').remove();
2880							jQuery('.sub-menu .shopping-bag .bag-header').remove();
2881							jQuery('.sub-menu .shopping-bag .bag-total').remove();
2882							jQuery('.sub-menu .shopping-bag .bag-contents').remove();
2883						} else {
2884							if ( cartcounter == 1 ) {
2885								jQuery('.sub-menu .shopping-bag .bag-header').text('1 ' + singular_item_txt);
2886							} else {
2887								jQuery('.sub-menu .shopping-bag .bag-header').text(cartcounter + ' ' + multiple_item_txt);
2888							}
2889						}
2890
2891					});
2892				
2893				return false;
2894
2895			});
2896
2897			// WISHLIST REMOVE PRODUCT
2898			jQuery(document).on('click', '.wishlist_table .remove', function(){
2899				jQuery(".prod-"+jQuery(this).attr('data-product-id')).remove();
2900				if (jQuery('.wishlist-bag').find('.bag-product').length === 0) {
2901					jQuery('.bag-buttons').addClass('no-items');
2902				}
2903			});
2904		},
2905		variations: function() {
2906			jQuery('.single_variation_wrap').on("show_variation", function() {
2907
2908				if (hasProductZoom) {
2909					jQuery('.zoomContainer').remove();
2910					setTimeout(function() {
2911						if (SWIFT.productSlider) {
2912							jQuery('.product-slider-image').each(function() {
2913								jQuery(this).data('zoom-image', jQuery(this).parent().find('a.zoom').attr('href'));
2914							});
2915							var firstImage = jQuery('#product-img-slider li:first').find('.product-slider-image');
2916							SWIFT.woocommerce.productZoom(firstImage);
2917							SWIFT.productSlider.goToSlide(0);
2918						}
2919					}, 500);
2920				} else {
2921					setTimeout(function() {
2922						if (SWIFT.productSlider) {
2923							SWIFT.productSlider.goToSlide(0);
2924						}
2925					}, 500);
2926				}
2927				setTimeout(function() {
2928
2929					// Update lightbox image
2930					jQuery('.product-slider-image').each(function() {
2931						var zoomImage = jQuery(this).attr('src');
2932						jQuery(this).parent().find('a.zoom').attr('href', zoomImage).attr('data-o_href', '').attr('data-o_href', zoomImage);
2933						jQuery('[data-rel="ilightbox[product]"]').removeClass('ilightbox-enabled').iLightBox().destroy();
2934						SWIFT.page.lightbox();
2935					});
2936				}, 600);
2937
2938			});			
2939
2940			// Support for additional variations images plugin
2941			jQuery( 'form.variations_form' ).on( 'wc_additional_variation_images_frontend_image_swap_callback wc_additional_variation_images_frontend_ajax_default_image_swap_callback wc_additional_variation_images_frontend_on_reset', function( e, response, gallery_images_class, main_images_class, o_gallery_images, o_main_images ) {
2942			
2943				switch( e.type ) {
2944					case 'wc_additional_variation_images_frontend_image_swap_callback':
2945						jQuery('#product-img-slider .slides').html( response.gallery_images );
2946									
2947						jQuery( '#product-img-nav ul.slides a.zoom.lightbox' ).each( function() {
2948							var link = jQuery( this ).parent().find( 'img' ).attr('data-zoom-image');
2949							jQuery( this ).attr('href', link);
2950						});
2951			
2952						break;						
2953					case 'wc_additional_variation_images_frontend_ajax_default_image_swap_callback':
2954						jQuery('#product-img-slider .slides').html( o_gallery_images );
2955									
2956						break;	
2957					case 'wc_additional_variation_images_frontend_on_reset':
2958						jQuery('#product-img-slider .slides').html( o_gallery_images );
2959						break;	
2960				}
2961				
2962				SWIFT.productSlider.destroy();
2963				SWIFT.sliders.productSlider();
2964				
2965				setTimeout(function() {
2966					jQuery('[data-rel="ilightbox[product]"]').removeClass('ilightbox-enabled').iLightBox().destroy();
2967					SWIFT.page.lightbox();
2968				}, 500);
2969								
2970			});
2971			jQuery( 'form.variations_form' ).on( 'wc_additional_variation_images_frontend_lightbox_done', function() {
2972				setTimeout(function() {
2973					jQuery('[data-rel="ilightbox[product]"]').removeClass('ilightbox-enabled').iLightBox().destroy();
2974					SWIFT.page.lightbox();
2975				}, 500);
2976			});
2977			
2978			
2979			// Reset on variation reset
2980			jQuery(document).on( 'reset_image', function() {
2981								
2982				setTimeout(function() {
2983					if (hasProductZoom) {
2984						jQuery('.zoomContainer').remove();
2985						if (SWIFT.productSlider) {
2986							SWIFT.productSlider.goToSlide(0);			
2987							var firstImage = jQuery('#product-img-slider li:first').find('.product-slider-image');
2988							firstImage.attr('data-zoom-image', firstImage.parent().attr('data-thumb'));
2989							firstImage.data('zoom-image', firstImage.parent().attr('data-thumb'));
2990							setTimeout(function() {
2991								SWIFT.woocommerce.productZoom(firstImage);
2992							}, 200);
2993						}
2994					} else {
2995						if (SWIFT.productSlider) {
2996							SWIFT.productSlider.goToSlide(0);
2997						}
2998					}
2999				}, 500);
3000								
3001			});
3002		},
3003		swatches: function() {
3004			jQuery(document).on("change", "div.select", function(){
3005								
3006				if (hasProductZoom) {
3007					jQuery('.zoomContainer').remove();
3008					setTimeout(function() {
3009						if (SWIFT.productSlider) {
3010							jQuery('.product-slider-image').each(function() {
3011								jQuery(this).data('zoom-image', jQuery(this).parent().find('a.zoom').attr('href'));
3012							});
3013							var firstImage = jQuery('#product-img-slider li:first').find('.product-slider-image');
3014							SWIFT.woocommerce.productZoom(firstImage);
3015							SWIFT.productSlider.goToSlide(0);
3016						}
3017					}, 500);
3018				} else {
3019					setTimeout(function() {
3020						if (SWIFT.productSlider) {
3021							SWIFT.productSlider.goToSlide(0);
3022						}
3023					}, 500);
3024				}
3025			});
3026		},
3027		productZoom: function(zoomObject) {
3028			jQuery('#product-img-slider li a.zoom').css('display', 'none');
3029			jQuery('.zoomContainer').remove();
3030			zoomObject.elevateZoom({
3031				zoomType: productZoomType,
3032				cursor: "crosshair",
3033				zoomParent: '#product-img-slider .lSSlideWrapper',
3034				responsive: true,
3035				zoomWindowFadeIn: 400,
3036				zoomWindowFadeOut: 500,
3037				lensSize: 350
3038			});
3039
3040			$window.smartresize( function() {
3041				jQuery('.zoomContainer').remove();
3042				zoomObject.elevateZoom({
3043					zoomType: productZoomType,
3044					cursor: "crosshair",
3045					zoomParent: '#product-img-slider .lSSlideWrapper',
3046					responsive: true,
3047					zoomWindowFadeIn: 400,
3048					zoomWindowFadeOut: 500,
3049					lensSize: 350
3050				});
3051			});
3052		},
3053		shopLayoutSwitch: function() {
3054			var isSwitchingLayout = false;
3055
3056			jQuery(document).on('click', 'a.layout-opt', function(e) {
3057
3058				var products = jQuery('#products'),
3059					selectedLayout = jQuery(this).data('layout'),
3060					defaultWidth = products.find('.product').first().data('width') == 'col-sm-sf-5' ? 'col-sm-3' : products.find('.product').first().data('width'),
3061					gridWidth = jQuery('.inner-page-wrap').hasClass('has-no-sidebar') ? 'col-sm-sf-5' : 'col-sm-3',
3062					standardSidebarWidth = 'col-sm-4';
3063
3064				console.log(defaultWidth);
3065
3066				if ( jQuery(this).parent().data('display-type') == "gallery" || jQuery(this).parent().data('display-type') == "gallery-bordered" ) {
3067					gridWidth = "col-sm-2";
3068				}
3069
3070				if (isSwitchingLayout) {
3071					return;
3072				}
3073
3074				isSwitchingLayout = true;
3075				var timeout = 0,
3076					timeoutEnd = 0;
3077
3078				if ( !SWIFT.isInfScrolling ) {
3079					timeout = 400;
3080					timeoutEnd = 500;
3081					products.animate({
3082						'opacity': 0
3083					}, timeout);
3084				}
3085				setTimeout(function() {
3086
3087					products.find('.product').removeClass('product-layout-standard product-layout-list product-layout-grid product-layout-solo');
3088					products.find('.product').addClass('product-layout-' + selectedLayout);
3089
3090					if ( jQuery('.product-grid').length > 0 ) {
3091						jQuery('.product-grid').children().css('min-height','0');
3092
3093						if (selectedLayout === "grid") {
3094							products.find('.product').removeClass(defaultWidth).removeClass(standardSidebarWidth).addClass(gridWidth);
3095						}
3096
3097						if (selectedLayout === "standard" || selectedLayout === "solo") {
3098							products.find('.product').removeClass(gridWidth).addClass(defaultWidth);
3099							// if (jQuery('.inner-page-wrap').hasClass('has-no-sidebar')) {
3100							// 	products.find('.product').removeClass(gridWidth).addClass(defaultWidth);	
3101							// } else {
3102							// 	products.find('.product').removeClass(gridWidth).addClass(standardSidebarWidth);	
3103							// }
3104						}
3105
3106						if (selectedLayout !== "list" && selectedLayout !== "solo" && jQuery('.product-grid').find('.sidebar').length < 0) {
3107							jQuery('.product-grid').equalHeights();
3108						}
3109					}
3110
3111					setTimeout(function() {
3112						products.isotope( 'layout' );
3113					}, 500);
3114
3115					products.animate({
3116						'opacity': 1
3117					}, timeout);
3118
3119					isSwitchingLayout = false;
3120
3121				}, timeoutEnd);
3122
3123				e.preventDefault();
3124
3125			});
3126		},
3127		mobileShopFilters: function() {
3128
3129			jQuery(document).on('click', '.sf-mobile-shop-filters-link', function(e) {
3130
3131				e.preventDefault();
3132
3133				var thisLink = jQuery(this);
3134
3135				if ( thisLink.hasClass('filters-open') ) {
3136
3137					jQuery('.sf-mobile-shop-filters').slideUp(400);
3138					thisLink.removeClass('filters-open');
3139
3140				} else {
3141
3142					jQuery('.sf-mobile-shop-filters').slideDown(600);
3143					thisLink.addClass('filters-open');
3144
3145				}
3146
3147
3148			});
3149		},
3150		fullWidthShop: function() {
3151			var shopItems = jQuery('.full-width-shop').find('.products'),
3152				itemWidth = shopItems.find('li.product').first().data('width'),
3153				shopSidebar = shopItems.find('.sidebar');
3154
3155			if (shopSidebar.length > 0) {
3156
3157				// Full Width Shop Sidebar
3158				SWIFT.woocommerce.fullWidthShopSetSidebarHeight();
3159				$window.smartresize( function() {
3160					SWIFT.woocommerce.fullWidthShopSetSidebarHeight();
3161				});
3162				
3163				shopItems.isotope({
3164					itemSelector: '.product',
3165					layoutMode: 'masonry',
3166					masonry: {
3167						columnWidth: '.'+itemWidth
3168					},
3169					isOriginLeft: !isRTL
3170				});
3171				
3172				shopItems.isotope( 'stamp', shopItems.find('.sidebar') );
3173				shopItems.isotope( 'layout' );
3174				
3175				SWIFT.woocommerce.animateItems(shopItems);
3176				
3177				setTimeout(function() {
3178					shopItems.isotope( 'layout' );
3179				}, 500);
3180
3181			} else {
3182
3183				shopItems.isotope({
3184					itemSelector: '.product',
3185					layoutMode: 'fitRows',
3186					isOriginLeft: !isRTL
3187				});
3188
3189				setTimeout(function() {
3190					shopItems.isotope('layout');
3191				}, 500);
3192
3193				SWIFT.woocommerce.animateItems(shopItems);
3194
3195			}
3196		},
3197		fullWidthShopSetSidebarHeight: function() {
3198			var shopItems = jQuery('.full-width-shop').find('.products'),
3199				shopSidebar = shopItems.find('div.sidebar'),
3200				defaultSidebarHeight = shopSidebar.css('height', '').outerHeight(),
3201				newSidebarHeight = 0,
3202				sidebarHeightMultiply = 2,
3203				firstProductHeight = shopItems.find('li.product').first().outerHeight(true);
3204
3205			sidebarHeightMultiply = Math.ceil(defaultSidebarHeight / firstProductHeight);
3206			newSidebarHeight = firstProductHeight * sidebarHeightMultiply;
3207			shopSidebar.css('height', newSidebarHeight);
3208		},
3209		productGridSetup: function(productsInstance) {
3210			productsInstance.isotope({
3211				resizable: false,
3212				itemSelector : '.product',
3213				layoutMode: 'fitRows',
3214				isOriginLeft: !isRTL
3215			});
3216			productsInstance.imagesLoaded().progress( function() {
3217			  productsInstance.isotope('layout');
3218			});
3219			productsInstance.appear(function() {
3220				setTimeout(function() {
3221					productsInstance.isotope('layout');
3222					SWIFT.woocommerce.animateItems(productsInstance);
3223				}, 1000);
3224			});
3225		},
3226		multiMasonrySetup: function(productsInstance) {
3227			if (isMobile) {
3228				productsInstance.appear(function() {
3229					SWIFT.woocommerce.animateItems(productsInstance);
3230				});
3231				return;
3232			}
3233			productsInstance.imagesLoaded(function () {
3234				SWIFT.woocommerce.multiMasonrySizeFix(productsInstance, false);
3235				productsInstance.isotope({
3236					resizable: false,
3237					itemSelector : '.product',
3238					layoutMode: 'packery',
3239					packery: {
3240						columnWidth: '.grid-sizer'
3241					},
3242					isOriginLeft: !isRTL
3243				});
3244				if (isMobile) {
3245					setTimeout(function() {
3246						productsInstance.isotope('layout');
3247					}, 500);
3248				}
3249			});
3250			productsInstance.appear(function() {
3251				SWIFT.woocommerce.animateItems(productsInstance);
3252			});
3253		},
3254		multiMasonrySizeFix: function(productsInstance, $init) {
3255			var baseItem = productsInstance.find('.product.size-standard').first(),
3256				standardHeight = baseItem.height(),
3257				largeHeight = 0;
3258			
3259			if ( standardHeight > 0 ) {
3260				largeHeight = (standardHeight * 2) + parseInt(baseItem.css('margin-bottom'), 10);
3261			} else {
3262				var firstProduct = productsInstance.find('.product.size-large,.product.size-tall').first();
3263				largeHeight = firstProduct.height();				
3264			}
3265			
3266			if (largeHeight > 0) {
3267				productsInstance.find('.product.size-large .multi-masonry-img-wrap').css('height', largeHeight);
3268				productsInstance.find('.product.size-tall .multi-masonry-img-wrap').css('height', largeHeight);
3269			}
3270			if ( $init && productsInstance.data('isotope') ) {
3271				productsInstance.isotope('layout');
3272			}
3273		},
3274		windowResized: function() {
3275			jQuery('.products.multi-masonry-items').each(function() {
3276				SWIFT.woocommerce.multiMasonrySizeFix(jQuery(this), true);
3277			});
3278		},
3279		animateItems: function(shopItems) {
3280			shopItems.find('.product').each(function(i) {
3281				jQuery(this).delay(i*200).animate({
3282					'opacity' : 1
3283				}, 800, 'easeOutExpo', function() {
3284					jQuery(this).addClass('item-animated');
3285				});
3286			});
3287		},
3288		productQuantityAdjust: function() {
3289			// Increase
3290			jQuery(document).on('click', '.qty-plus', function(e) {
3291				e.preventDefault();
3292				var quantityInput = jQuery(this).parents('.quantity').find('input.qty'),
3293					step = parseInt(quantityInput.attr('step'), 10),
3294					newValue = parseInt(quantityInput.val(), 10) + step,
3295					maxValue = parseInt(quantityInput.attr('max'), 10);
3296
3297				if (!maxValue) {
3298					maxValue = 9999999999;
3299				}
3300
3301				if ( newValue <= maxValue ) {
3302					quantityInput.val(newValue);
3303					quantityInput.change();
3304				}
3305			});
3306
3307			// Decrease
3308			jQuery(document).on('click', '.qty-minus', function(e) {
3309				e.preventDefault();
3310				var quantityInput = jQuery(this).parents('.quantity').find('input.qty'),
3311					step = parseInt(quantityInput.attr('step'), 10),
3312					newValue = parseInt(quantityInput.val(), 10) - step,
3313					minValue = parseInt(quantityInput.attr('min'), 10);
3314
3315				if (!minValue) {
3316					minValue = 0;
3317				}
3318
3319				if ( newValue >= minValue ) {
3320					quantityInput.val(newValue);
3321					quantityInput.change();
3322				}
3323			});
3324		},
3325		smallProductCheck: function() {
3326			jQuery('.product').each(function() {
3327				var thisProduct = jQuery(this);
3328
3329				if (thisProduct.width() < 220) {
3330					thisProduct.addClass('mini-view');
3331				}
3332			});
3333		},
3334		previewSliderLayout: function() {
3335			var previewSliderItems = jQuery('.product-type-preview-slider > .products, .products.product-type-preview-slider').children('.product');
3336		
3337			previewSliderItems.each(function(){
3338				var container = jQuery(this),
3339					sliderDots = SWIFT.woocommerce.pslCreateDots(container);
3340				
3341				if ( !container.find('.variable-image-wrapper').hasClass('is-variable') ) {
3342					return;	
3343				}
3344				
3345				SWIFT.woocommerce.pslUpdatePrice(container, 0);
3346		
3347				// update slider when user clicks one of the dots
3348				if (sliderDots) {
3349					sliderDots.on('click', function() {
3350						var selectedDot = jQuery(this);
3351						if ( !selectedDot.hasClass('selected') ) {
3352							var selectedPosition = selectedDot.index(),
3353								activePosition = container.find('.variable-image-wrapper .selected').index();
3354							if ( activePosition < selectedPosition ) {
3355								SWIFT.woocommerce.pslNextSlide(container, sliderDots, selectedPosition);
3356							} else {
3357								SWIFT.woocommerce.pslPrevSlide(container, sliderDots, selectedPosition);
3358							}
3359							SWIFT.woocommerce.pslUpdatePrice(container, selectedPosition);
3360						}
3361					});
3362				}
3363				
3364				// update slider on swipeleft
3365				container.find('.variable-image-wrapper').swipe({
3366					swipeLeft:function() {
3367						var wrapper = jQuery(this),
3368							selectedPosition = 0;
3369						if ( !wrapper.find('.selected').is(':last-child') ) {
3370							selectedPosition = container.find('.variable-image-wrapper .selected').index() + 1;
3371							SWIFT.woocommerce.pslNextSlide(container, sliderDots);
3372							SWIFT.woocommerce.pslUpdatePrice(container, selectedPosition);
3373						}
3374					},
3375					swipeRight:function() {
3376						var wrapper = jQuery(this),
3377							selectedPosition = 0;
3378						if ( !wrapper.find('.selected').is(':first-child') ) {
3379							selectedPosition = container.find('.variable-image-wrapper .selected').index() - 1;
3380							SWIFT.woocommerce.pslPrevSlide(container, sliderDots);
3381							SWIFT.woocommerce.pslUpdatePrice(container, selectedPosition);
3382						}
3383					},
3384				});
3385		
3386				// preview image hover effect - desktop only
3387				container.on('mouseover', '.move-right, .move-left', function(e) {
3388					SWIFT.woocommerce.pslHoverItem(jQuery(this), true);
3389				});
3390				container.on('mouseleave', '.move-right, .move-left', function(e) {
3391					SWIFT.woocommerce.pslHoverItem(jQuery(this), false);
3392				});
3393				
3394				// View product
3395				container.on('click', '.img-wrap.selected', function(e) {
3396					e.preventDefault();
3397					window.location = container.find('.preview-slider-item-wrapper').data('permalink');
3398				});
3399		
3400				// update slider when user clicks on the preview images
3401				container.on('click', '.move-right, .move-left', function(e) {
3402					e.preventDefault();
3403					var selectedPosition = 0;
3404					if ( jQuery(this).hasClass('move-right') ) {
3405						selectedPosition = container.find('.variable-image-wrapper .selected').index() + 1;
3406						SWIFT.woocommerce.pslNextSlide(container, sliderDots);
3407					} else {
3408						selectedPosition = container.find('.variable-image-wrapper .selected').index() - 1;
3409						SWIFT.woocommerce.pslPrevSlide(container, sliderDots);
3410					}
3411					SWIFT.woocommerce.pslUpdatePrice(container, selectedPosition);
3412				});
3413			});
3414		},
3415		pslCreateDots: function(container) {
3416			
3417			if ( container.find('.variable-image-wrapper .img-wrap').length <= 1) {
3418				return false;
3419			}
3420			
3421			var dotsWrapper = jQuery('<ol class="preview-slider-dots"></ol>').insertAfter(container.find('.variable-image-wrapper'));
3422			container.find('.variable-image-wrapper .img-wrap').each(function(index){
3423				var dotWrapper = (index === 0) ? jQuery('<li class="selected"></li>') : jQuery('<li></li>'),
3424					dot = jQuery('<a href="#0"></a>').appendTo(dotWrapper);
3425				dotWrapper.appendTo(dotsWrapper);
3426				dot.text(index+1);
3427			});
3428			return dotsWrapper.children('li');
3429		},
3430		pslHoverItem: function(item, bool) {
3431			if ( item.hasClass('move-right') ) {
3432				item.toggleClass('hover', bool).siblings('.selected, .move-left').toggleClass('focus-on-right', bool);
3433			} else {
3434				item.toggleClass('hover', bool).siblings('.selected, .move-right').toggleClass('focus-on-left', bool);
3435			}
3436		},
3437		pslNextSlide: function(container, dots, n) {
3438			var visibleSlide = container.find('.variable-image-wrapper .selected'),
3439				navigationDot = container.find('.preview-slider-dots .selected');
3440			if(typeof n === 'undefined') n = visibleSlide.index() + 1;
3441			visibleSlide.removeClass('selected');
3442			container.find('.variable-image-wrapper .img-wrap').eq(n).addClass('selected').removeClass('move-right hover').prevAll().removeClass('move-right move-left focus-on-right').addClass('hide-left').end().prev().removeClass('hide-left').addClass('move-left').end().next().addClass('move-right');
3443			navigationDot.removeClass('selected');
3444			dots.eq(n).addClass('selected');
3445		},
3446		pslPrevSlide: function(container, dots, n) {
3447			var visibleSlide = container.find('.variable-image-wrapper .selected'),
3448				navigationDot = container.find('.preview-slider-dots .selected');
3449			if(typeof n === 'undefined') n = visibleSlide.index() - 1;
3450			visibleSlide.removeClass('selected focus-on-left');
3451			container.find('.variable-image-wrapper .img-wrap').eq(n).addClass('selected').removeClass('move-left hide-left hover').nextAll().removeClass('hide-left move-right move-left focus-on-left').end().next().addClass('move-right').end().prev().removeClass('hide-left').addClass('move-left');
3452			navigationDot.removeClass('selected');
3453			dots.eq(n).addClass('selected');
3454		},
3455		pslUpdatePrice: function(container, n) {
3456			var productDetails = container.find('.product-details'),
3457				priceTag = productDetails.find('span.price'),
3458				selectedItem = container.find('.variable-image-wrapper .img-wrap').eq(n),
3459				variationPriceHTML = selectedItem.find('.variation-price').html(),
3460				isOnSale = selectedItem.data('sale');
3461			
3462			if ( !variationPriceHTML || priceTag.html() === selectedItem.find('.variation-price span.price').html() ) {
3463				return;
3464			}
3465			
3466			if ( isOnSale ) { 
3467				// if item is on sale
3468				productDetails.addClass('on-sale');
3469				priceTag.replaceWith(variationPriceHTML);
3470				setTimeout(function(){ productDetails.addClass('is-visible'); }, 100);
3471			} else {
3472				// if item is not on sale - remove cross on old price and sale price
3473				productDetails.removeClass('on-sale is-visible');
3474				priceTag.fadeOut(function() {
3475				  priceTag.replaceWith(variationPriceHTML);
3476				}).fadeIn();
3477			}	
3478		},
3479		infiniteScroll: function() {
3480			if (!(IEVersion && IEVersion < 9)) {
3481				var infScrollData = jQuery('#inf-scroll-params'),
3482					products = jQuery('.products'),
3483					isLoadMore = products.parents('.page-content').find('.pagination-wrap').hasClass('load-more') ? true : false;
3484				
3485				if ( !products.parents('.page-content').find('.pagination-wrap').hasClass('infinite-scroll-enabled') ) {
3486					return;
3487				}
3488				
3489				var infiniteScroll = {
3490					loading: {
3491						img: infScrollData.data('loadingimage'),
3492						msgText: isLoadMore ? infScrollData.data('msgtext') : '',
3493						finishedMsg: isLoadMore ? infScrollData.data('finishedmsg') : '',
3494						selector: '.woocommerce-shop-page .page-content',
3495						loaderHTML: jQuery('body > .sf-svg-loader').html()
3496					},
3497					"nextSelector":".pagenavi li:last-child a",
3498					"navSelector":".pagination-wrap",
3499					"itemSelector":".product",
3500					"contentSelector":"#products",
3501					errorCallback: function () {
3502						setTimeout(function() {
3503							jQuery( '#infscr-loading' ).animate({
3504								'opacity' : 0
3505							}, 500);
3506						}, 1000);
3507					},
3508				};
3509				jQuery( infiniteScroll.contentSelector ).infinitescroll(
3510					infiniteScroll, function(elements) {
3511						products.imagesLoaded(function () {
3512							products.isotope( 'appended', elements );
3513
3514							var firstProduct = jQuery('.products > .product').first(),
3515								type = '';
3516
3517							if ( firstProduct.hasClass('product-layout-list') ) {
3518								type = 'list';
3519							} else if ( firstProduct.hasClass('product-layout-grid') ) {
3520								type = 'grid';
3521							} else {
3522								type = 'standard';
3523							}
3524
3525							SWIFT.isInfScrolling = true;
3526
3527							jQuery('a.layout-opt[data-layout="' + type + '"]').trigger('click');
3528						
3529							jQuery.each(elements, function(i, element) {
3530								jQuery(element).addClass('item-animated');
3531							});
3532
3533							setTimeout(function() {
3534								SWIFT.isInfScrolling = false;
3535							}, 200);
3536						});
3537						if (isLoadMore) {
3538							setTimeout(function() {
3539								jQuery('.load-more-btn').css('display', 'block');							
3540							}, 200);
3541						}
3542					}
3543				);
3544				if (isLoadMore) {
3545					products.parent().addClass('products-load-more-pagination');
3546					$window.off('.infscr');
3547					jQuery('.load-more-btn').on('click', function(e) {
3548						e.preventDefault();
3549						jQuery( infiniteScroll.contentSelector ).infinitescroll('retrieve');
3550						jQuery('.load-more-btn').css('display', 'none');
3551						$window.trigger('resize');
3552					});
3553				}
3554			} else {
3555				jQuery('.pagination-wrap').removeClass('hidden');
3556			}
3557		}
3558	};
3559	
3560	
3561	/////////////////////////////////////////////
3562	// EDD FUNCTIONS
3563	/////////////////////////////////////////////
3564
3565	SWIFT.edd = {
3566		init: function() {
3567			/**
3568			 * EDD cart information in the header
3569			 */
3570			var header_cart_total = jQuery('.edd-cart-contents .cart-total'),
3571				header_cart_count = jQuery('.edd-cart-contents .num-items');
3572				
3573			body.on('edd_cart_item_added',function(event, response) {
3574				header_cart_total.html(response.subtotal);
3575				header_cart_count.html(response.cart_quantity);
3576				
3577				jQuery('.edd-cart').find('.empty').removeClass('force-hide force-show');
3578				
3579				var navBag = jQuery('.edd-shopping-bag-item:visible:last'),
3580					bagIcon = navBag.find('.edd-cart-contents');
3581				
3582				navBag.addClass('added-notification');
3583				bagIcon.addClass('sf-animate ' + cartNotification);
3584
3585				// Show cart dropdown
3586				setTimeout(function() {
3587					navBag.find('ul.sub-menu').fadeIn(200);
3588				}, 800);
3589
3590				// Hide cart dropdown
3591				setTimeout(function() {
3592					navBag.removeClass('added-notification');
3593					bagIcon.removeClass('sf-animate ' + cartNotification);
3594					if (!shopBagHovered) {
3595						navBag.find('ul.sub-menu').fadeOut(150);
3596					}
3597				}, 4000);
3598								
3599			});
3600			body.on('edd_cart_item_removed',function(event, response) {
3601				header_cart_total.html(response.subtotal);
3602				header_cart_count.html(response.cart_quantity);
3603				if ( response.cart_quantity === "0" ) {
3604					jQuery('.edd-cart').find('.empty').first().addClass('force-show');
3605					jQuery('.edd-cart').find('.empty').last().addClass('force-hide');
3606				}
3607			});
3608
3609			// Fade in 'Cart' button - stops blinking of nojs/hasjs buttons
3610			if(body.hasClass('single-download')) {
3611				var addToCart = jQuery('.single-download .edd_purchase_submit_wrapper');
3612				addToCart.animate({opacity: 1}, 400);
3613			}
3614		}
3615	};
3616
3617
3618	/////////////////////////////////////////////
3619	// SLIDER FUNCTIONS
3620	/////////////////////////////////////////////
3621
3622	SWIFT.sliders = {
3623		init: function() {
3624
3625			if ( jQuery('#product-img-slider').length > 0 ) {
3626				SWIFT.sliders.productSlider();
3627			}
3628
3629			if ( jQuery('.item-slider').length > 0 ) {
3630				SWIFT.sliders.itemSlider();
3631			}
3632
3633			if ( jQuery('.content-slider').length > 0 ) {
3634				SWIFT.sliders.contentSlider();
3635			}
3636		},
3637		itemSlider: function()  {
3638			jQuery('.item-slider > ul').lightSlider({
3639				item: 1,
3640	            pager: true,
3641	            controls: true,
3642	            slideMargin: 0,
3643	            adaptiveHeight: true,
3644	            loop: true,
3645	            rtl: isRTL,
3646	            auto: sliderAuto,
3647	            pause: sliderSlideSpeed,
3648	            speed: sliderAnimSpeed
3649			});
3650		},
3651		contentSlider: function() {
3652			jQuery('.content-slider > ul').each(function() {
3653				var slider = jQuery(this),
3654					autoplay = ((slider.parent().attr('data-autoplay') === "yes") ? true : false),
3655					timeout;
3656
3657				var contentSlider = slider.lightSlider({
3658					mode: "fade",
3659					item: 1,
3660		            pager: true,
3661		            controls: false,
3662		            slideMargin: 0,
3663		            adaptiveHeight: true,
3664		            loop: true,
3665		            rtl: isRTL,
3666		            auto: autoplay,
3667		            pause: sliderSlideSpeed,
3668		            speed: sliderAnimSpeed,
3669		            onSliderLoad: function() {
3670			            contentSlider.removeClass('cS-hidden');
3671			        }
3672				});
3673
3674				slider.parent().on('mouseenter',function() {
3675					if (autoplay) {
3676				    	contentSlider.pause();
3677				    	clearTimeout(timeout);
3678					}
3679				});
3680				slider.parent().on('mouseleave',function(){
3681					if (autoplay) {
3682				    	timeout = setTimeout(function () {
3683			    	        contentSlider.play();
3684			    	    }, sliderSlideSpeed);
3685				    }
3686				});
3687			});
3688		},
3689		productSlider: function() {
3690
3691			var galleryMode = jQuery('#product-img-slider > ul > li').length > 1 ? true : false,
3692				galleryVertical = false,
3693				sliderVertHeight = parseInt(productSliderVertHeight, 10),
3694				thumbItems = 4,
3695				thumbItemsResponsive = 3;
3696				
3697			if ( isMobileAlt || $window.width() <= 768 ) {
3698				productSliderThumbsPos = "bottom";
3699			}
3700			
3701			if ( productSliderThumbsPos === "left" ) {
3702				galleryVertical = true;
3703				thumbItems = Math.floor(sliderVertHeight / 120);
3704				thumbItemsResponsive = 3;
3705			}
3706
3707			SWIFT.productSlider = jQuery('#product-img-slider > ul').lightSlider({
3708	            item: 1,
3709	            gallery: galleryMode,
3710	            autoWidth: false,
3711	            slideMargin: 0,
3712	            speed: 400, //ms'
3713	            auto: false,
3714	            loop: false,
3715	            vThumbWidth: 70,
3716	            vertical: galleryVertical,
3717	            verticalHeight: sliderVertHeight,
3718	            pause: 2000,
3719	            keyPress: true,
3720	            controls: true,
3721	            rtl: isRTL,
3722	            adaptiveHeight: true,
3723	            thumbItem: thumbItems,
3724	            thumbMargin: 30,
3725	            freeMove: false,
3726	            currentPagerPosition: 'middle',
3727	            swipeThreshold: 40,
3728	            responsive : [
3729		            {
3730		                breakpoint: 768,
3731		                settings: {
3732		                	verticalHeight: (sliderVertHeight / 2),
3733		                    thumbItem: thumbItemsResponsive,
3734		                }
3735		            }
3736		        ],
3737	            onSliderLoad: function (el) {
3738		            el.addClass('slider-loaded');
3739		            el.parents('#product-img-slider').find('.lSPager').addClass('thumbnails');
3740		            if (hasProductZoom) {
3741						var currentImage = jQuery('#product-img-slider').find('.lslide.active > .product-slider-image');
3742						SWIFT.woocommerce.productZoom(currentImage);
3743					}
3744					el.find('.product-slider-image').each(function(){
3745						var imgClass = (this.width/this.height >= 1) ? 'wide' : 'tall';
3746						jQuery(this).addClass(imgClass);
3747					});
3748					$window.trigger('resize');
3749	            },
3750	            onBeforeSlide: function (el) {
3751		            if (hasProductZoom) {
3752						jQuery('.zoomContainer').remove();
3753					}
3754	            },
3755	            onAfterSlide: function (el) {
3756	            	if (hasProductZoom) {
3757						if (SWIFT.variationsReset) {
3758							return;
3759						}						
3760						var currentImage = jQuery('#product-img-slider').find('.lslide.active > .product-slider-image');
3761						SWIFT.woocommerce.productZoom(currentImage);
3762					}
3763	            }
3764	        });
3765		},
3766		thumb: function() {
3767			jQuery('.thumb-slider > ul').lightSlider({
3768	            item: 1,
3769	            pager: false,
3770	            controls: true,
3771	            slideMargin: 0,
3772	            loop: true,
3773	            adaptiveHeight: true,
3774	            rtl: isRTL,
3775	            auto: sliderAuto,
3776	            pause: sliderSlideSpeed,
3777	            speed: sliderAnimSpeed
3778			});
3779		}
3780	};
3781
3782	/////////////////////////////////////////////
3783	// PORTFOLIO
3784	/////////////////////////////////////////////
3785
3786	var portfolioContainer = jQuery('.portfolio-wrap').find('.filterable-items');
3787
3788	SWIFT.portfolio = {
3789		init: function() {
3790			portfolioContainer.each(function() {
3791				var portfolioInstance = jQuery(this);
3792				if (portfolioInstance.hasClass('masonry-items') && !(IEVersion && IEVersion < 9)) {
3793					SWIFT.portfolio.masonrySetup(portfolioInstance);
3794				} else if (portfolioInstance.hasClass('multi-masonry-items') && !(IEVersion && IEVersion < 9)) {
3795					SWIFT.portfolio.multiMasonrySetup(portfolioInstance);
3796				} else {
3797					SWIFT.portfolio.standardSetup(portfolioInstance);
3798				}
3799			});
3800
3801			// PORTFOLIO WINDOW RESIZE
3802			$window.smartresize( function() {
3803				SWIFT.portfolio.windowResized();
3804			});
3805
3806			// Enable filter options on when there are items from that skill
3807			jQuery('.portfolio-wrap .filtering li').each( function() {
3808				var filter = jQuery(this),
3809					filterName = jQuery(this).find('a').attr('class'),
3810					portfolioItems = jQuery(this).parents('.portfolio-wrap').find('.filterable-items'),
3811					itemCount = 0;
3812
3813				portfolioItems.find('.portfolio-item').each( function() {
3814					if ( jQuery(this).hasClass(filterName) ) {
3815						filter.addClass('has-items');
3816						itemCount++;
3817					}
3818				});
3819				if ( filter.find('sup.count').length > 0 ) {
3820					filter.find('sup.count').text(itemCount);
3821				} else {
3822					filter.find('a').append('<sup class="count">'+itemCount+'</sup>');
3823				}
3824			}).parents('.filtering').animate({
3825				opacity: 1
3826			}, 400);
3827
3828			// filter items when filter link is clicked
3829			jQuery('.portfolio-wrap .filtering li').on('click', 'a', function(e) {
3830				e.preventDefault();
3831				jQuery(this).parent().parent().find('li').removeClass('selected');
3832				jQuery(this).parent().addClass('selected');
3833				var selector = jQuery(this).data('filter');
3834				var portfolioItems = jQuery(this).parents('.portfolio-wrap').find('.filterable-items');
3835				portfolioItems.isotope({ filter: selector });
3836			});
3837
3838			jQuery('.filter-wrap > a').on('click', function(e) {
3839				e.preventDefault();
3840				jQuery(this).parent().find('.filter-slide-wrap').slideToggle();
3841			});
3842		},
3843		standardSetup: function(portfolioInstance) {
3844			portfolioInstance.imagesLoaded(function () {
3845				SWIFT.sliders.thumb();
3846				portfolioInstance.animate({opacity: 1}, 800);
3847				portfolioInstance.isotope({
3848					resizable: true,
3849					layoutMode: 'fitRows',
3850					isOriginLeft: !isRTL
3851				});
3852				setTimeout(function() {
3853					SWIFT.portfolio.setItemHeight();
3854					$window.trigger('resize');
3855					portfolioInstance.isotope('layout');
3856				}, 500);
3857			});
3858			portfolioInstance.appear(function() {
3859				SWIFT.portfolio.animateItems(portfolioInstance);
3860			});
3861		},
3862		masonrySetup: function(portfolioInstance) {
3863			portfolioInstance.imagesLoaded(function () {
3864				SWIFT.sliders.thumb();
3865				portfolioInstance.isotope({
3866					resizable: false,
3867					itemSelector : '.portfolio-item',
3868					layoutMode: 'masonry',
3869					isOriginLeft: !isRTL
3870				});
3871				setTimeout(function() {
3872					portfolioInstance.isotope('layout');
3873				}, 500);
3874			});
3875			portfolioInstance.appear(function() {
3876				SWIFT.portfolio.animateItems(portfolioInstance);
3877			});
3878		},
3879		multiMasonrySetup: function(portfolioInstance) {
3880			portfolioInstance.imagesLoaded(function () {
3881				SWIFT.sliders.thumb();
3882				SWIFT.portfolio.multiMasonrySizeFix(false);
3883				portfolioInstance.isotope({
3884					resizable: false,
3885					itemSelector : '.portfolio-item',
3886					layoutMode: 'packery',
3887					packery: {
3888						columnWidth: '.grid-sizer'
3889					},
3890					isOriginLeft: !isRTL
3891				});
3892				setTimeout(function() {
3893					portfolioInstance.isotope('layout');
3894				}, 500);
3895			});
3896			portfolioInstance.appear(function() {
3897				SWIFT.portfolio.animateItems(portfolioInstance);
3898			});
3899		},
3900		animateItems: function(portfolioInstance) {
3901			portfolioInstance.find('.portfolio-item').each(function(i) {
3902				jQuery(this).delay(i*200).animate({
3903					'opacity' : 1
3904				}, 800, 'easeOutExpo', function() {
3905					jQuery(this).addClass('item-animated');
3906				});
3907			});
3908		},
3909		setItemHeight: function() {
3910			if (!portfolioContainer.hasClass('col-1') && !portfolioContainer.hasClass('masonry-items') && !portfolioContainer.hasClass('multi-masonry-items')) {
3911				portfolioContainer.children().css('min-height','0');
3912				portfolioContainer.equalHeights();
3913			}
3914		},
3915		multiMasonrySizeFix: function($init) {
3916			var baseItem = portfolioContainer.find('.portfolio-item.size-standard').first(),
3917				standardHeight = baseItem.height(),
3918				largeHeight = 0;
3919			
3920			if ( standardHeight > 0 ) {
3921				largeHeight = (standardHeight * 2) + parseInt(baseItem.css('margin-bottom'), 10);
3922			} else {
3923				var firstItem = portfolioContainer.find('.portfolio-item.size-tall,.portfolio-item.size-wide-tall').first();
3924				largeHeight = firstItem.height();
3925				standardHeight = (largeHeight / 2) - parseInt(baseItem.css('margin-bottom'), 10);			
3926			}
3927			
3928			if (largeHeight > 0) {
3929				portfolioContainer.find('.portfolio-item.size-wide .multi-masonry-img-wrap').css('height', standardHeight);
3930				portfolioContainer.find('.portfolio-item.size-wide-tall .multi-masonry-img-wrap').css('height', largeHeight);
3931				portfolioContainer.find('.portfolio-item.size-tall .multi-masonry-img-wrap').css('height', largeHeight);
3932				
3933				// Wide tall sliders
3934				var heightDiff = (portfolioContainer.find('.portfolio-item.size-wide-tall ul.slides > li').first().height() - largeHeight) / 2;
3935				portfolioContainer.find('.portfolio-item.size-wide-tall ul.slides').css('max-height', largeHeight);
3936				portfolioContainer.find('.portfolio-item.size-wide-tall ul.slides > li').css('margin-top', -heightDiff);
3937				
3938				// Wide sliders
3939				var wideHeightDiff = (portfolioContainer.find('.portfolio-item.size-wide ul.slides > li').first().height() - standardHeight) / 2;
3940				portfolioContainer.find('.portfolio-item.size-wide ul.slides').css('max-height', standardHeight);
3941				portfolioContainer.find('.portfolio-item.size-wide ul.slides > li').css('margin-top', -wideHeightDiff);
3942			}
3943			if ($init && portfolioContainer.data('isotope') ) {
3944				portfolioContainer.isotope('layout');
3945			}
3946		},
3947		windowResized: function() {
3948			if (!portfolioContainer.hasClass('col-1') && !portfolioContainer.hasClass('masonry-items') && !portfolioContainer.hasClass('multi-masonry-items')) {
3949				SWIFT.portfolio.setItemHeight();
3950			}
3951
3952			if (portfolioContainer.hasClass('multi-masonry-items')) {
3953				SWIFT.portfolio.multiMasonrySizeFix(true);
3954			}
3955		},
3956		portfolioShowcaseInit: function() {
3957			SWIFT.sliders.thumb();
3958			SWIFT.portfolio.portfolioShowcaseWrap();
3959			SWIFT.portfolio.portfolioShowcaseItems();
3960			$window.smartresize( function() {
3961				SWIFT.portfolio.portfolioShowcaseWrap();
3962				SWIFT.portfolio.portfolioShowcaseItems();
3963			});
3964		},
3965		portfolioShowcaseWrap: function() {
3966			var portfolioShowcaseWrap = jQuery('.portfolio-showcase-wrap');
3967			portfolioShowcaseWrap.animate({opacity: 1}, 600);
3968		},
3969		portfolioShowcaseItems: function() {
3970			jQuery('.portfolio-showcase-wrap').each(function() {
3971
3972				var contWidth = jQuery('#main-container').width();
3973
3974				if (jQuery('#container').hasClass('boxed-layout')) {
3975					contWidth = jQuery('#container').width();
3976				}
3977
3978				var thisShowcase = jQuery(this),
3979					columns = thisShowcase.find('.portfolio-showcase-items').data('columns'),
3980					windowWidth = contWidth + 2,
3981					itemWidth = Math.floor(windowWidth / columns),
3982					maximisedWidth = Math.floor(windowWidth * 40 / 100),
3983					reducedWidth = Math.floor(windowWidth / 5),
3984					deselectedLeft = (itemWidth / 2 - maximisedWidth / 2) / 0.75,
3985					resetLeft = (reducedWidth / 2 - maximisedWidth / 2) / 1.3,
3986					isAnimating = !1,
3987					speed = 300;
3988
3989				var showcaseItem = thisShowcase.find('li.portfolio-item');
3990
3991				if (columns === 5) {
3992					maximisedWidth = Math.floor(windowWidth * 25 / 100);
3993					reducedWidth = Math.floor(windowWidth / 5.33);
3994					deselectedLeft = (itemWidth / 2 - maximisedWidth / 2) / 0.75;
3995					resetLeft = (reducedWidth / 2 - maximisedWidth / 2) / 1.3;
3996					showcaseItem.css("width", itemWidth);
3997					showcaseItem.css("height", maximisedWidth / 1.5);
3998					showcaseItem.find('.main-image').css("width", maximisedWidth);
3999					showcaseItem.find('.main-image').css("left", resetLeft);
4000					showcaseItem.find('.main-image').css("top", - maximisedWidth / 6);
4001					speed = 200;
4002				} else {
4003					showcaseItem.css("width", itemWidth);
4004					showcaseItem.css("height", maximisedWidth / 2);
4005					showcaseItem.find('.main-image').css("width", maximisedWidth);
4006					showcaseItem.find('.main-image').css("left", resetLeft);
4007				}
4008
4009				showcaseItem.each(function () {
4010					if (windowWidth > 768) {
4011						jQuery(this).mouseenter(function () {
4012							if (!isAnimating) {
4013								isAnimating = !0;
4014								jQuery(this).removeClass("deselected-item");
4015								thisShowcase.find(".deselected-item").stop().animate({
4016									width: reducedWidth
4017								}, speed);
4018								thisShowcase.find(".deselected-item").find(".main-image").stop().animate({
4019									left: deselectedLeft
4020								}, speed);
4021								jQuery(this).find(".main-image").stop().animate({
4022									left: 0
4023								}, speed);
4024								jQuery(this).stop().animate({
4025									width: maximisedWidth
4026								}, speed + 1, function () {
4027									jQuery(this).find(".item-info").stop().show();
4028									jQuery(this).find(".item-info").stop().animate({
4029										bottom: 0
4030									}, speed, "easeInOutQuart");
4031								});
4032							}
4033						});
4034						jQuery(this).mouseleave(function () {
4035							if (isAnimating) {
4036								isAnimating = !1;
4037								jQuery(this).addClass("deselected-item");
4038								thisShowcase.find(".portfolio-item").stop().animate({
4039									width: itemWidth
4040								}, speed);
4041								thisShowcase.find(".portfolio-item .main-image").stop().animate({
4042									left: resetLeft
4043								}, speed);
4044								jQuery(this).find(".item-info").stop().animate({
4045									bottom: -85
4046								}, speed, function () {
4047									jQuery(this).find(".item-info").stop().hide();
4048								});
4049							}
4050						});
4051					}
4052				});
4053			});
4054		},
4055		stickyDetails: function() {
4056
4057			var offset = 0;
4058
4059			if (jQuery('.sticky-header').length > 0) {
4060				offset = jQuery('.sticky-header').height() > 0 ? jQuery('.sticky-header').height() : jQuery('#header-section').height();
4061			}
4062			if (jQuery('#wpadminbar').length > 0) {
4063				offset = offset + jQuery('#wpadminbar').height();
4064			}
4065			if (jQuery('.sticky-top-bar').length > 0) {
4066				offset = offset + jQuery('.sticky-top-bar').height() > 0 ? jQuery('.sticky-top-bar').height() : jQuery('#top-bar').height();
4067			}
4068
4069			jQuery(".page-content").stick_in_parent({
4070				offset_top: offset + 30
4071			});
4072
4073		}
4074	};
4075
4076
4077	/////////////////////////////////////////////
4078	// BLOG
4079	/////////////////////////////////////////////
4080
4081	var blogItems = jQuery('.blog-wrap').find('.blog-items');
4082
4083	SWIFT.blog = {
4084		init: function() {
4085
4086			// BLOG ITEM SETUP
4087			blogItems.each(function() {
4088				var blogInstance = jQuery(this);
4089				if (blogInstance.hasClass('blog-grid-items')) {
4090					SWIFT.blog.blogGrid(blogInstance.find('.grid-items'));
4091				} else {
4092					SWIFT.blog.blogLayout(blogInstance);
4093				}
4094			});
4095
4096			// Blog Filtering
4097			SWIFT.blog.blogFiltersInit();
4098
4099			// BLOG AUX SLIDEOUT
4100			jQuery('.blog-slideout-trigger').on('click', function(e) {
4101				e.preventDefault();
4102
4103				// VARIABLES
4104				var blogWrap = jQuery(this).parent().parent().parent().parent();
4105				var filterPanel = blogWrap.find('.blog-filter-wrap .filter-slide-wrap');
4106				var auxType = jQuery(this).attr('data-aux');
4107
4108				// ADD COLUMN SIZE AND REMOVE BRACKETS FROM COUNT
4109				blogWrap.find('.aux-list li').addClass('col-sm-2');
4110				blogWrap.find('.aux-list li a span').each(function() {
4111					jQuery(this).html(jQuery(this).html().replace("(","").replace(")",""));
4112				});
4113
4114				// IF SELECTING AN OPTION THAT IS OPEN, CLOSE THE PANEL
4115				if (jQuery(this).parent().hasClass('selected') && !filterPanel.is(':animated')) {
4116					blogWrap.find('.blog-aux-options li').removeClass('selected');
4117					filterPanel.slideUp(400);
4118					return;
4119				}
4120
4121				// AUX BUTTON SELECTED STATE
4122				blogWrap.find('.blog-aux-options li').removeClass('selected');
4123				jQuery(this).parent().addClass('selected');
4124
4125				// IF SLIDEOUT IS OPEN
4126				if (filterPanel.is(':visible')) {
4127
4128					filterPanel.slideUp(400);
4129					setTimeout(function() {
4130						blogWrap.find('.aux-list').css('display', 'none');
4131						blogWrap.find('.aux-'+auxType).css('display', 'block');
4132						filterPanel.slideDown();
4133					}, 600);
4134
4135				// IF SLIDEOUT IS CLOSED
4136				} else {
4137
4138					blogWrap.find('.aux-list').css('display', 'none');
4139					blogWrap.find('.aux-'+auxType).css('display', 'block');
4140					filterPanel.slideDown();
4141
4142				}
4143			});
4144
4145		},
4146		blogFiltersInit: function() {
4147
4148			SWIFT.blog.blogShowFilters();
4149			jQuery('.filtering').animate({
4150				opacity: 1
4151			}, 400);
4152
4153			// filter items when filter link is clicked
4154			jQuery('.blog-wrap .filtering li').on('click', 'a', function(e) {
4155				e.preventDefault();
4156				jQuery(this).parent().parent().find('li').removeClass('selected');
4157				jQuery(this).parent().addClass('selected');
4158				var selector = jQuery(this).data('filter');
4159				var blogItems = jQuery(this).parents('.blog-wrap').find('.blog-items');
4160				blogItems.isotope({ filter: selector });
4161			});
4162
4163			jQuery('.filter-wrap > a').on('click', function(e) {
4164				e.preventDefault();
4165				jQuery(this).parent().find('.filter-slide-wrap').slideToggle();
4166			});
4167		},
4168		blogShowFilters: function() {
4169			// Enable filter options on when there are items from that skill
4170			jQuery('.blog-wrap .filtering li').each( function() {
4171				var filter = jQuery(this),
4172					filterName = jQuery(this).find('a').attr('class'),
4173					blogItems = jQuery(this).parents('.blog-wrap').find('.blog-items'),
4174					itemCount = 0;
4175
4176				blogItems.find('.blog-item').each( function() {
4177					if ( jQuery(this).hasClass(filterName) ) {
4178						filter.addClass('has-items');
4179						itemCount++;
4180					}
4181				});
4182				if ( filter.find('sup.count').length > 0 ) {
4183					filter.find('sup.count').text(itemCount);
4184				} else {
4185					filter.find('a').append('<sup class="count">
4185'+itemCount+'</sup>');
4186				}
4187			});
4188		},
4189		blogLayout: function(blogInstance) {
4190
4191			var blogType = blogInstance.data('blog-type'),
4192				layoutMode = 'fitRows';
4193
4194			if (blogType === "masonry") {
4195				layoutMode = 'masonry';
4196			}
4197
4198			if (blogType === "masonry" && blogInstance.hasClass('social-blog')) {
4199				var tweets = blogInstance.parent().find('.blog-tweets').html(),
4200					instagrams = blogInstance.parent().find('.blog-instagrams');
4201
4202				blogInstance.imagesLoaded(function () {
4203					SWIFT.sliders.thumb();
4204					blogInstance.isotope({
4205						resizable: false,
4206						itemSelector : '.blog-item',
4207						layoutMode: 'masonry',
4208						getSortData : {
4209							date : function ( elem ) {
4210								return jQuery(elem).data('date');
4211							}
4212						},
4213						sortBy: 'date',
4214						sortAscending: false,
4215						isOriginLeft: !isRTL
4216					});
4217					if (tweets !== "") {
4218					blogInstance.isotope('insert', jQuery(tweets));
4219					}
4220					if (instagrams.length > 0) {
4221					SWIFT.blog.masonryInstagram(instagrams, blogInstance);
4222					}
4223					blogInstance.isotope('updateSortData').isotope();
4224					setTimeout(function() {
4225						blogInstance.isotope('layout');
4226					}, 500);
4227				});
4228
4229			} else {
4230				blogInstance.imagesLoaded(function () {
4231					SWIFT.sliders.thumb();
4232					blogInstance.isotope({
4233						resizable: true,
4234						layoutMode: layoutMode,
4235						isOriginLeft: !isRTL
4236					});
4237					setTimeout(function() {
4238						blogInstance.isotope('layout');
4239					}, 500);
4240				});
4241				blogInstance.appear(function() {
4242					SWIFT.blog.animateItems(blogInstance);
4243				});
4244			}
4245		},
4246		masonryInstagram: function(instagrams, blogItems) {
4247			var userID = instagrams.data('userid'),
4248				token = instagrams.data('token'),
4249				count = instagrams.data('count'),
4250				itemClass = instagrams.data('itemclass'),
4251				clientid = '641129180090039';
4252			    
4253			jQuery.ajax({
4254				url: 'https://graph.instagram.com/' + userID + '/media?fields=media_url,thumbnail_url,caption,id,media_type,timestamp,username,comments_count,like_count,permalink,children{media_url,id,media_type,timestamp,permalink,thumbnail_url}
4254&limit=' + count + '&access_token=' + token,
4255				dataType: 'jsonp',
4256				type: 'GET',
4257				data: {client_id: clientid, count: count},
4258				success: function(data) {
4259					for (var i = 0; i < count; i++) {
4260						var item = data.data[i];
4261						if (typeof item !== 'undefined') {
4262							var caption = "",
4263							imageURL = item.media_url;
4264							if (item.caption) {
4265								caption = item.caption;
4266							}
4267							var date = new Date(item.timestamp);
4268							instagrams.append("<li class='blog-item instagram-item "+itemClass+"' data-date='"+item.timestamp+"'><a class='timestamp inst-icon' target='_blank' href='" + item.permalink +"'><i class='fab fa-instagram'></i></a><div class='inst-overlay'><a target='_blank' href='" + item.permalink +"'></a><h6>"+instagrams.data('title')+"</h6><h2>"+caption+"</h2><div class='name-divide'></div><time class='date timeago' datetime='"+date+"'>"+date+"</time></div><img class='instagram-image' src='" + imageURL +"' width='306px' height='306px' /></li>");
4269						}
4270					}
4271					jQuery( "time.timeago" ).timeago();
4272					instagrams.imagesLoaded(function(){
4273						blogItems.isotope( 'insert', jQuery(instagrams.html()) );
4274					});
4275					blogItems.isotope('updateSortData').isotope();
4276				}
4277			});			
4278		},
4279		animateItems: function(blogInstance) {
4280			blogInstance.find('.blog-item').each(function(i) {
4281				jQuery(this).delay(i*200).animate({
4282					'opacity' : 1,
4283				}, 800, 'easeOutExpo', function() {
4284					jQuery(this).addClass('item-animated');
4285				});
4286			});
4287		},
4288		blogGrid: function(gridItems) {
4289			var tweets = gridItems.parent().find('.blog-tweets').html(),
4290				instagrams = gridItems.parent().find('.blog-instagrams');
4291
4292			gridItems.imagesLoaded(function () {
4293				SWIFT.sliders.thumb();
4294				gridItems.isotope({
4295					resizable: false,
4296					itemSelector : '.blog-item',
4297					layoutMode: 'fitRows',
4298					getSortData : {
4299						id : function ( elem ) {
4300							return jQuery(elem).data('sortid');
4301						}
4302					},
4303					sortBy: 'id',
4304					sortAscending: true,
4305					isOriginLeft: !isRTL
4306				});
4307				setTimeout(function() {
4308					gridItems.isotope('layout');
4309				}, 500);
4310				if (tweets !== "") {
4311				gridItems.isotope('insert', jQuery(tweets));
4312				}
4313				if (instagrams.length > 0) {
4314				SWIFT.blog.blogGridInstagram(instagrams, gridItems);
4315				}
4316				gridItems.isotope('updateSortData').isotope();
4317				SWIFT.blog.blogGridResize();
4318			}).animate({
4319				'opacity' : 1
4320			}, 800, 'easeOutExpo');
4321
4322			$window.smartresize( function() {
4323				SWIFT.blog.blogGridResize();
4324			});
4325
4326		},
4327		blogGridResize: function() {
4328			blogItems.find('.grid-items').each(function() {
4329				var gridItem = jQuery(this).find('.blog-item'),
4330					itemWidth = gridItem.first().width();
4331				if (gridItem.first().hasClass('col-sm-sf-25')) {
4332					itemWidth = itemWidth / 2;
4333				}
4334				gridItem.css('height', itemWidth);
4335			});
4336			setTimeout(function() {
4337				jQuery(".tweet-text,.quote-excerpt").dotdotdot();
4338				blogItems.find('.grid-items').isotope('layout');
4339			}, 500);
4340		},
4341		blogGridInstagram: function(instagrams, gridItems) {
4342			var userID = instagrams.data('userid'),
4343				token = instagrams.data('token'),
4344				count = instagrams.data('count'),
4345				itemClass = instagrams.data('itemclass'),
4346				clientid = '641129180090039',
4347				isFullwidthRow = false;
4348
4349				// Items contained within a fullwidth stretched Row?
4350		        if (instagrams.closest('.spb-row').attr('data-wrap') == 'full-width-stretch') {
4351		          isFullwidthRow = true;
4352		        }
4353			
4354			jQuery.ajax({
4355				url: 'https://graph.instagram.com/' + userID + '/media?fields=media_url,thumbnail_url,caption,id,media_type,timestamp,username,comments_count,like_count,permalink,children{media_url,id,media_type,timestamp,permalink,thumbnail_url}
4355&limit=' + count + '&access_token=' + token,
4356				dataType: 'jsonp',
4357				type: 'GET',
4358				data: {client_id: clientid, count: count},
4359				success: function(data) {
4360					for (var i = 0; i < count; i++) {
4361						var item = data.data[i];
4362						if (typeof item !== 'undefined') {
4363							var caption = "",
4364              				imageURL = item.media_url;
4365							if (item.caption) {
4366								caption = item.caption;
4367							}
4368							var date = new Date(item.timestamp);
4369							instagrams.append("<li class='blog-item "+itemClass+" instagram-item' data-date='"+item.timestamp+"' data-sortid='"+i*2+"'><a class='timestamp inst-icon' target='_blank' href='" + item.permalink +"'><i class='fab fa-instagram'></i></a><div class='inst-img-wrap'><div class='inst-overlay'><a target='_blank' href='" + item.permalink +"'></a><h6>"+instagrams.data('title')+"</h6><h2>"+caption+"</h2><div class='name-divide'></div><time class='date timeago' datetime='"+date+"'></time></div><img class='instagram-image' src='" + imageURL +"' /></div></li>");
4370						}
4371					}
4372					jQuery("time.timeago").timeago();
4373					SWIFT.blog.blogGridResize();
4374					instagrams.imagesLoaded(function(){
4375						gridItems.isotope('insert', jQuery(instagrams.html()));
4376						SWIFT.blog.blogGridResize();
4377					});
4378					gridItems.isotope('updateSortData').isotope();
4379				}
4380			});
4381		},
4382		infiniteScroll: function() {
4383			if (!(IEVersion && IEVersion < 9)) {
4384				var infScrollData = jQuery('#inf-scroll-params');
4385				var blogInfiniteScroll = {
4386					loading: {
4387						img: infScrollData.data('loadingimage'),
4388						msgText: infScrollData.data('msgtext'),
4389						finishedMsg: infScrollData.data('finishedmsg')
4390					},
4391					"nextSelector":".blog-items-wrap .pagenavi li.next a",
4392					"navSelector":".blog-items-wrap .pagenavi",
4393					"itemSelector":".blog-items-wrap .blog-item",
4394					"contentSelector":".blog-items-wrap .blog-items"
4395				};
4396				jQuery( blogInfiniteScroll.contentSelector ).infinitescroll(
4397					blogInfiniteScroll, function(elements) {
4398						SWIFT.sliders.thumb();
4399						blogItems.imagesLoaded(function () {
4400							blogItems.isotope( 'appended', elements );
4401							jQuery.each(elements, function(i, element) {
4402								jQuery(element).addClass('item-animated');
4403							});
4404						});
4405						jQuery('[data-rel="ilightbox[posts]"]').removeClass('ilightbox-enabled').iLightBox().destroy();
4406						SWIFT.page.lightbox();
4407						SWIFT.blog.blogShowFilters();
4408						if (blogItems.parent().find('.pagination-wrap').hasClass('load-more')) {
4409							jQuery('.load-more-btn').animate({
4410								'opacity': 1
4411							}, 400);
4412						}
4413						$window.trigger('resize');
4414					}
4415				);
4416				if (blogItems.parent().find('.pagination-wrap').hasClass('load-more')) {
4417					$window.off('.infscr');
4418					jQuery('.load-more-btn').on('click', function(e) {
4419						e.preventDefault();
4420						jQuery( blogInfiniteScroll.contentSelector ).infinitescroll('retrieve');
4421						jQuery('.load-more-btn').animate({
4422							'opacity': 0
4423						}, 400);
4424						$window.trigger('resize');
4425					});
4426				}
4427			} else {
4428				jQuery('.pagination-wrap').removeClass('hidden');
4429			}
4430		}
4431	};
4432
4433	/////////////////////////////////////////////
4434	// GALLERIES
4435	/////////////////////////////////////////////
4436
4437	var galleriesContainer = jQuery('.galleries-wrap').find('.filterable-items');
4438
4439	SWIFT.galleries = {
4440		init: function() {
4441			galleriesContainer.each(function() {
4442				var galleriesInstance = jQuery(this);
4443				if (galleriesInstance.hasClass('masonry-items')) {
4444					SWIFT.galleries.masonrySetup(galleriesInstance);
4445				} else {
4446					SWIFT.galleries.standardSetup(galleriesInstance);
4447				}
4448			});
4449
4450			// PORTFOLIO WINDOW RESIZE
4451			$window.smartresize( function() {
4452				SWIFT.galleries.windowResized();
4453			});
4454
4455			// Enable filter options on when there are items from that skill
4456			jQuery('.galleries-wrap .filtering li').each( function() {
4457				var filter = jQuery(this),
4458					filterName = jQuery(this).find('a').attr('class'),
4459					galleryItems = jQuery(this).parents('.galleries-wrap').find('.filterable-items'),
4460					itemCount = 0;
4461
4462				galleryItems.find('.gallery-item').each( function() {
4463					if ( jQuery(this).hasClass(filterName) ) {
4464						filter.addClass('has-items');
4465						itemCount++;
4466					}
4467				});
4468				if ( filter.find('sup.count').length > 0 ) {
4469					filter.find('sup.count').text(itemCount);
4470				} else {
4471					filter.find('a').append('<sup class="count">
4471'+itemCount+'</sup>');
4472				}
4473			}).parents('.filtering').animate({
4474				opacity: 1
4475			}, 400);
4476
4477			// filter items when filter link is clicked
4478			jQuery('.galleries-wrap .filtering li').on('click', 'a', function(e) {
4479				e.preventDefault();
4480				jQuery(this).parent().parent().find('li').removeClass('selected');
4481				jQuery(this).parent().addClass('selected');
4482				var selector = jQuery(this).data('filter');
4483				var galleryItems = jQuery(this).parents('.galleries-wrap').find('.filterable-items');
4484				galleryItems.isotope({ filter: selector });
4485			});
4486		},
4487		standardSetup: function(galleryInstance) {
4488			galleryInstance.imagesLoaded(function () {
4489				SWIFT.galleries.setItemHeight();
4490				galleryInstance.animate({opacity: 1}, 800);
4491				galleryInstance.isotope({
4492					resizable: true,
4493					layoutMode: 'fitRows',
4494					isOriginLeft: !isRTL
4495				});
4496				setTimeout(function() {
4497					galleryInstance.isotope('layout');
4498				}, 500);
4499			});
4500			galleryInstance.appear(function() {
4501				SWIFT.galleries.animateItems(galleryInstance);
4502			});
4503		},
4504		masonrySetup: function(galleryInstance) {
4505			galleryInstance.imagesLoaded(function () {
4506				galleryInstance.isotope({
4507					resizable: false,
4508					itemSelector : '.gallery-item',
4509					layoutMode: 'masonry',
4510					isOriginLeft: !isRTL
4511				});
4512				setTimeout(function() {
4513					galleryInstance.isotope('layout');
4514				}, 500);
4515			});
4516			galleryInstance.appear(function() {
4517				SWIFT.galleries.animateItems(galleryInstance);
4518			});
4519		},
4520		animateItems: function(galleryInstance) {
4521			galleryInstance.find('.gallery-item').each(function(i) {
4522				jQuery(this).delay(i*200).animate({
4523					'opacity' : 1
4524				}, 800, 'easeOutExpo', function() {
4525					jQuery(this).addClass('item-animated');
4526				});
4527			});
4528		},
4529		setItemHeight: function() {
4530			if (!galleriesContainer.hasClass('col-1') && !galleriesContainer.hasClass('masonry-items')) {
4531				galleriesContainer.children().css('min-height','0');
4532				galleriesContainer.equalHeights();
4533			}
4534		},
4535		windowResized: function() {
4536			if (!galleriesContainer.hasClass('col-1') && !galleriesContainer.hasClass('masonry-items')) {
4537				SWIFT.galleries.setItemHeight();
4538			}
4539		},
4540	};
4541
4542
4543	/////////////////////////////////////////////
4544	// GALLERY
4545	/////////////////////////////////////////////
4546
4547	SWIFT.gallery = {
4548		init: function() {
4549
4550			jQuery('.spb_gallery_widget').each(function() {
4551				if (jQuery(this).hasClass('gallery-masonry')) {
4552					SWIFT.gallery.galleryMasonry(jQuery(this).find('.filterable-items'));
4553				} else if (jQuery(this).hasClass('gallery-slider')) {
4554					SWIFT.gallery.gallerySlider(jQuery(this));
4555				}
4556			});
4557		},
4558		galleryMasonry: function(element) {
4559			element.imagesLoaded(function () {
4560				element.isotope({
4561					resizable: false,
4562					itemSelector : '.gallery-image',
4563					layoutMode: 'masonry',
4564					isOriginLeft: !isRTL
4565				});
4566				setTimeout(function() {
4567					element.isotope('layout');
4568				}, 500);
4569			});
4570			element.appear(function() {
4571				SWIFT.gallery.animateItems(element);
4572			});
4573		},
4574		animateItems: function(element) {
4575			element.find('.gallery-image').each(function(i) {
4576				jQuery(this).delay(i*200).animate({
4577					'opacity' : 1
4578				}, 800, 'easeOutExpo', function() {
4579					jQuery(this).addClass('item-animated');
4580				});
4581			});
4582		},
4583		gallerySlider: function(element) {
4584
4585			var gallerySlider = element.find('.gallery-slider > ul'),
4586				galleryAuto = gallerySlider.parent().data('autoplay') === "yes" ? true : false,
4587				galleryThumbs = gallerySlider.parent().data('thumbs') === "yes" ? true : false;
4588
4589			gallerySlider.lightSlider({
4590				mode: gallerySlider.parent().data('transition'),
4591	            item: 1,
4592	            gallery: galleryThumbs,
4593	            autoWidth: false,
4594	            slideMargin: 0,
4595	            speed: sliderAnimSpeed, //ms'
4596	            auto: galleryAuto,
4597	            loop: true,
4598	            pause: sliderSlideSpeed,
4599	            keyPress: true,
4600	            controls: true,
4601	            rtl: isRTL,
4602	            adaptiveHeight: true,
4603	            thumbMargin: 30,
4604	            galleryMargin: 30,
4605	            currentPagerPosition: 'middle',
4606	            swipeThreshold: 40,
4607	            responsive : [
4608		            {
4609		                breakpoint: 1024,
4610		                settings: {
4611		                    thumbItem: 3,
4612		                }
4613		            }
4614		        ],
4615		        onSliderLoad: function (el) {
4616		            el.addClass('slider-loaded');
4617		        }
4618	        });
4619
4620
4621		}
4622	};
4623
4624
4625	/////////////////////////////////////////////
4626	// RECENT POSTS
4627	/////////////////////////////////////////////
4628
4629	SWIFT.recentPosts = {
4630		init: function() {
4631
4632			// TEAM EQUAL HEIGHTS
4633			var recentPostAsset = jQuery('.recent-posts:not(.carousel-items,.posts-type-list)');
4634			recentPostAsset.imagesLoaded(function () {
4635				SWIFT.sliders.thumb();
4636			});
4637
4638			// TEAM ASSETS
4639			$window.smartresize( function() {
4640				jQuery('.recent-posts:not(.carousel-items,.posts-type-list)').children().css('min-height','0');
4641				jQuery('.recent-posts:not(.carousel-items,.posts-type-list)').equalHeights();
4642			});
4643		},
4644		load: function() {
4645			setTimeout(function() {
4646				jQuery('.recent-posts:not(.carousel-items,.posts-type-list)').children().css('min-height','0');
4647				jQuery('.recent-posts:not(.carousel-items,.posts-type-list)').equalHeights();
4648			}, 400);
4649		}
4650	};
4651
4652
4653	/////////////////////////////////////////////
4654	// CAROUSEL FUNCTIONS
4655	/////////////////////////////////////////////
4656
4657	SWIFT.carouselWidgets = {
4658		init: function() {
4659
4660			// CAROUSELS
4661			var carousel = jQuery('.carousel-items'),
4662				carouselAuto = sfOptionParams.data('carousel-autoplay'),
4663				carouselPSpeed = sfOptionParams.data('carousel-pagespeed'),
4664				carouselSSpeed = sfOptionParams.data('carousel-slidespeed'),
4665				carouselPagination = sfOptionParams.data('carousel-pagination'),
4666				carouselPDirection = 'ltr',
4667				desktopWidth = 1199;
4668
4669			if (body.hasClass('vertical-header')) {
4670				desktopWidth = desktopWidth + jQuery('#header-section').width();
4671			}
4672
4673			if (carouselAuto) {
4674				carouselAuto = true;
4675			} else {
4676				carouselAuto = false;
4677			}
4678			if (carouselPagination) {
4679				carouselPagination = true;
4680			} else {
4681				carouselPagination = false;
4682			}
4683			if (isRTL) {
4684				carouselPDirection = 'rtl';
4685			}
4686
4687			carousel.each(function() {
4688				var carouselInstance = jQuery('#'+jQuery(this).attr('id')),
4689					carouselColumns = parseInt(carouselInstance.attr("data-columns"), 10),
4690					desktopCarouselItems = 4 > carouselColumns ? carouselColumns : 4,
4691					desktopSmallCarouselItems = 3 > carouselColumns ? carouselColumns : 3,
4692					mobileCarouselItems = 1;
4693
4694				if (carouselInstance.hasClass('clients-items')) {
4695					mobileCarouselItems = 2;
4696				}
4697				
4698				if (carouselInstance.hasClass('testimonials')) {
4699					desktopCarouselItems = 1;
4700					desktopSmallCarouselItems = 1;
4701					mobileCarouselItems = 1;
4702				}
4703
4704				if (carouselInstance.hasClass('products')) {
4705					mobileCarouselItems = 1;
4706				}
4707
4708				carouselInstance.imagesLoaded(function () {
4709
4710					if (!carouselInstance.hasClass('no-gutters')) {
4711						var carouselWidth = carouselInstance.parent().width();
4712						if (isRTL) {
4713						carouselInstance.css('margin-right', '-15px').css('width', carouselWidth + 30);
4714						} else {
4715						carouselInstance.css('margin-left', '-15px').css('width', carouselWidth + 30);
4716						}
4717					}
4718
4719					carouselInstance.owlCarousel({
4720						items : carouselColumns,
4721						itemsDesktop: [desktopWidth,desktopCarouselItems],
4722						itemsDesktopSmall: [desktopWidth-220,desktopSmallCarouselItems],
4723						itemsTablet: mobileCarouselItems,
4724						itemsMobile: [479,mobileCarouselItems],
4725						paginationSpeed: carouselPSpeed,
4726						slideSpeed: carouselSSpeed,
4727						autoPlay: carouselAuto,
4728						autoPlayDirection : carouselPDirection,
4729						pagination: carouselPagination,
4730						autoHeight : false,
4731						beforeUpdate: function() {
4732							if (!carouselInstance.hasClass('no-gutters')) {
4733								var carouselWidth = carouselInstance.parent().width();
4734								if (isRTL) {
4735								carouselInstance.css('margin-right', '-15px').css('width', carouselWidth + 30);
4736								} else {
4737								carouselInstance.css('margin-left', '-15px').css('width', carouselWidth + 30);
4738								}
4739							}
4740						},
4741						afterUpdate: function () {
4742							setTimeout(function() {
4743								SWIFT.sliders.thumb();
4744							}, 200);
4745						},
4746						afterInit: function() {
4747							SWIFT.sliders.thumb();
4748							$window.trigger('resize');
4749							setTimeout(function() {
4750								SWIFT.parallax.init(true);
4751							}, 200);
4752						},
4753						afterAction: function(){
4754							var carouselNext = carouselInstance.parents('.carousel-wrap').find('.carousel-next'),
4755								carouselPrev = carouselInstance.parents('.carousel-wrap').find('.carousel-prev');
4756							
4757							if (carouselNext.length < 1) {
4758								carouselNext = carouselInstance.parents('.spb-asset-content').find('.carousel-next');
4759								carouselPrev = carouselInstance.parents('.spb-asset-content').find('.carousel-prev');
4760							}
4761							
4762						    if ( this.itemsAmount > this.visibleItems.length ) {
4763						        carouselNext.show();
4764						        carouselPrev.show();
4765						
4766						        carouselNext.removeClass('disabled');
4767						        carouselPrev.removeClass('disabled');
4768						        if ( this.currentItem === 0 ) {
4769						            carouselPrev.addClass('disabled');
4770						        }
4771						        if ( this.currentItem == this.maximumItem ) {
4772						            carouselNext.addClass('disabled');
4773						        }
4774						
4775						    } else {
4776						        carouselNext.hide();
4777						        carouselPrev.hide();
4778						    }
4779						}
4780					}).animate({
4781						'opacity': 1
4782					},800);
4783				});
4784			});
4785
4786			// Previous
4787			jQuery('.carousel-next').on('click', function(e) {
4788				e.preventDefault();
4789				var carousel = jQuery(this).closest('.spb_content_element').find('.owl-carousel');
4790
4791				if (!carousel.data( 'owlCarousel' )) {
4792					return;
4793				}
4794
4795				if (isRTL) {
4796					carousel.data( 'owlCarousel' ).prev();
4797				} else {
4798					carousel.data( 'owlCarousel' ).next();
4799				}
4800			});
4801
4802			// Next
4803			jQuery('.carousel-prev').on('click', function(e) {
4804				e.preventDefault();
4805				var carousel = jQuery(this).closest('.spb_content_element').find('.owl-carousel');
4806
4807				if (!carousel.data( 'owlCarousel' )) {
4808					return;
4809				}
4810
4811				if (isRTL) {
4812					carousel.data( 'owlCarousel' ).next();
4813				} else {
4814					carousel.data( 'owlCarousel' ).prev();
4815				}
4816			});
4817		},
4818		carouselSwipeIndicator: function(carousel) {
4819			carousel.appear(function() {
4820				var swipeIndicator = jQuery(this).parents('.carousel-wrap').find('.sf-swipe-indicator');
4821				setTimeout(function() {
4822					swipeIndicator.fadeIn(500);
4823				}, 400);
4824				setTimeout(function() {
4825					swipeIndicator.addClass('animate');
4826				}, 1000);
4827				setTimeout(function() {
4828					swipeIndicator.fadeOut(400);
4829				}, 3000);
4830			});
4831		},
4832		carouselMinHeight: function(carousel) {
4833			var minHeight = parseInt(carousel.find('.carousel-item:not(.no-thumb)').eq(0).css('height'));
4834			carousel.find('.owl-item').each(function () {
4835				jQuery(this).css('min-height',minHeight+'px');
4836			});
4837		}
4838	};
4839
4840
4841	/////////////////////////////////////////////
4842	// WIDGET FUNCTIONS
4843	/////////////////////////////////////////////
4844
4845	SWIFT.widgets = {
4846		init: function() {
4847
4848			// LOAD WIDGETS
4849			SWIFT.widgets.accordion();
4850			SWIFT.widgets.toggle();
4851			SWIFT.widgets.fullWidthVideo();
4852			SWIFT.widgets.introAnimations();
4853			SWIFT.widgets.iconBoxes();
4854
4855			// DYNAMIC TABS
4856			jQuery('.tabs-type-dynamic .menu-icon').on({
4857    			mouseenter: function () {
4858					jQuery(this).parents('.nav-tabs').addClass('show-tabs');
4859				}
4860			});
4861
4862			jQuery('.tabs-type-dynamic').on({
4863				mouseleave: function () {
4864					jQuery(this).find('.nav-tabs').removeClass('show-tabs');
4865				}
4866			});
4867
4868			// CATEGORY COUNT DISPLAY
4869			jQuery('.widget_categories li span').each(function() {
4870				var thisCategory = jQuery(this),
4871					thisText = thisCategory.text();
4872				thisCategory.text(thisText.replace('(', '').replace(')', ''));
4873				thisCategory.addClass('show-count');
4874			});
4875
4876		},
4877		load: function() {
4878
4879			SWIFT.widgets.tabs();
4880
4881			if (sfIncluded.hasClass('has-progress-bar')) {
4882			SWIFT.widgets.initSkillBars();
4883			}
4884
4885			// SF TOOLTIPS
4886			if (jQuery('[data-toggle="tooltip"]').length > 0 && !isMobileAlt) {
4887				SWIFT.widgets.initTooltips();
4888			}
4889
4890		},
4891		accordion: function() {
4892			jQuery('.spb_accordion').each(function() {
4893				var spb_tabs,
4894					active_tab = false,
4895					active_attr = parseInt(jQuery(this).attr('data-active'), 10);
4896
4897				if (jQuery.type( active_attr ) === "number") { active_tab = active_attr; }
4898
4899				spb_tabs = jQuery(this).find('.spb_accordion_wrapper').accordion({
4900					header: "> div > h4",
4901					autoHeight: true,
4902					collapsible: true,
4903					active: active_tab,
4904					heightStyle: "content"
4905				});
4906			}).css('opacity', 1);
4907		},
4908		tabs: function() {
4909			// SET ACTIVE TABS PANE
4910			setTimeout(function() {
4911				jQuery('.spb_tabs').each(function() {
4912					jQuery(this).find('.tab-pane').first().addClass('active');
4913					jQuery(this).find('.tab-pane').removeClass('load');
4914				});
4915			}, 200);
4916
4917			// SET ACTIVE TOUR PANE
4918			setTimeout(function() {
4919				jQuery('.spb_tour').each(function() {
4920					jQuery(this).find('.tab-pane').first().addClass('active');
4921					jQuery(this).find('.tab-pane').removeClass('load');
4922				});
4923			}, 200);
4924
4925			// RESET MAPS ON TAB CLICK
4926			jQuery('ul.nav-tabs li a, .spb_accordion_section > h4 a').on('click', '', function(){
4927				var thisTab = jQuery(this),
4928					asset = thisTab.parents('.spb_content_element').first();
4929
4930				if (asset.find('.map-canvas,.product-grid,.filterable-items').length > 0) {
4931					setTimeout(function() {
4932						jQuery(window).trigger('resize');
4933						SWIFT.map.init();
4934					}, 100);
4935				}
4936			});
4937
4938			// Reset isotope layout on tab shown
4939			jQuery('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
4940		        var target = jQuery(e.target).attr("href");
4941		        if ( jQuery(target).find('.filterable-items').length > 0 ) {
4942		            jQuery(target).find('.filterable-items').isotope('layout');
4943		        }
4944		        if ( jQuery(target).find('.product-grid').length > 0 ) {
4945		            jQuery(target).find('.product-grid').isotope('layout');
4946		            jQuery(window).trigger('resize');
4947		        }
4948		    }); 
4949
4950			// SET DESIRED TAB ON LOAD
4951			setTimeout(function() {
4952				if (jQuery('.spb_tabs').length > 0) {
4953				
4954					$window.trigger('resize');
4955
4956					// Show correct tab on page load
4957					var tabUrl = document.location.toString();
4958					if (tabUrl.match('#') && jQuery('.nav-tabs a[href="#'+tabUrl.split('#')[1]+'"]').length > 0) {
4959					    var tabHash = tabUrl.split('#')[1];
4960					    jQuery('.nav-tabs a[href="#'+tabHash+'"]').tab('show');
4961					}
4962
4963					// Change hash on tab click
4964					jQuery('.nav-tabs a').on('click', function (e) {
4965						var hash = e.target.hash;
4966
4967						if (history.pushState) {
4968						    history.pushState(null, null, hash);
4969						} else {
4970						    location.hash = hash;
4971						}
4972					});
4973				}
4974				if (jQuery('.spb_accordion').length > 0) {
4975
4976					// Show correct accordion section on page load
4977					var accordionUrl = document.location.toString();
4978					if (accordionUrl.match('#') && jQuery('.spb_accordion a[href="#'+accordionUrl.split('#')[1]+'"]').length > 0) {
4979					    var accordionHash = accordionUrl.split('#')[1];
4980					    jQuery('.spb_accordion a[href="#'+accordionHash+'"]').trigger( "click" );
4981					}
4982
4983					// Change hash on tab click
4984					jQuery('.spb_accordion a').on('click', function (e) {
4985						var hash = e.target.hash;
4986
4987						if (history.pushState) {
4988						    history.pushState(null, null, hash);
4989						} else {
4990						    location.hash = hash;
4991						}
4992					});
4993				}
4994
4995				if (jQuery('.spb_tour').length > 0) {
4996
4997					// Show correct accordion section on page load
4998					var tourUrl = document.location.toString();
4999					if (tourUrl.match('#') && jQuery('.spb_tour a[href="#'+tourUrl.split('#')[1]+'"]').length > 0) {
5000					    var tourHash = tourUrl.split('#')[1];
5001					    jQuery('.spb_tour a[href="#'+tourHash+'"]').trigger( "click" );
5002					}
5003
5004					// Change hash on tab click
5005					jQuery('.spb_tour a').on('click', function (e) {
5006						var hash = e.target.hash;
5007
5008						if ( history.pushState ) {
5009						    history.pushState(null, null, hash);
5010						} else {
5011						    location.hash = hash;
5012						}
5013					});
5014				}
5015
5016			}, 200);
5017		},
5018		toggle: function() {
5019			jQuery('.spb_toggle').on('click', function() {
5020				if ( jQuery(this).hasClass('spb_toggle_title_active') ) {
5021					jQuery(this).removeClass('spb_toggle_title_active').next().slideUp(500);
5022				} else {
5023					jQuery(this).addClass('spb_toggle_title_active').next().slideDown(500);
5024				}
5025			});
5026			jQuery('.spb_toggle_content').each(function() {
5027				if ( jQuery(this).next().is('h4.spb_toggle') === false ) {
5028					jQuery('<div class="last_toggle_el_margin"></div>').insertAfter(this);
5029				}
5030			});
5031		},
5032		initSkillBars: function() {
5033			// SKILL BARS
5034			SWIFT.widgets.animateSkillBars(); 
5035			jQuery('a.ui-tabs-anchor').on('click', function(){
5036				SWIFT.widgets.animateSkillBars();
5037			});
5038		},
5039		animateSkillBars: function() {
5040			jQuery('.progress:not(.animated)').each(function(){
5041				var progress = jQuery(this);
5042
5043				progress.appear(function() {
5044					var progressBar = jQuery(this),
5045					progressValue = progressBar.find('.bar').data('value');
5046					progressBar.addClass('animated');
5047					progressBar.find('.bar').animate({
5048						width: progressValue + "%"
5049					}, 800, function() {
5050						progressBar.parent().find('.bar-text').css('width', progressValue + "%");
5051						progressBar.parent().find('.bar-text .progress-value').fadeIn(600);
5052					});
5053				});
5054			});
5055		},
5056		fullWidthVideo: function() {
5057			body.on('click', '.fw-video-link', function(){
5058				if (jQuery(this).data('video') !== "") {
5059				SWIFT.widgets.openFullWidthVideo(jQuery(this));
5060				}
5061				return false;
5062			});
5063
5064			body.on('click', '.fw-video-close', function(){
5065				SWIFT.widgets.closeFullWidthVideo();
5066			});
5067		},
5068		openFullWidthVideo: function(element) {
5069			jQuery('.fw-video-close').addClass('is-open');
5070			jQuery('.fw-video-spacer').animate({
5071				height: windowheight
5072			}, 1000, 'easeInOutExpo');
5073
5074			jQuery('.fw-video-area').css('display', 'block').animate({
5075				top: 0,
5076				height: '100%'
5077			}, 1000, 'easeInOutExpo', function() {
5078				// load video here
5079				jQuery('.fw-video-area > .fw-video-wrap').append('<iframe class="fw-video" src="'+element.data('video')+'" width="100%" height="100%" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>');
5080			});
5081		},
5082		closeFullWidthVideo: function() {
5083			jQuery('.fw-video-close').removeClass('is-open');
5084			jQuery('.fw-video-spacer').animate({
5085				height: 0
5086			}, 1000, 'easeInOutExpo', function(){
5087			});
5088			jQuery('.fw-video-area').animate({
5089				top:'-100%'
5090			}, 1000, 'easeInOutExpo', function() {
5091				jQuery('.fw-video-area').css('display', 'none');
5092				jQuery('.fw-video-area .fw-video').remove();
5093			});
5094
5095			// pause videos
5096			jQuery('.fw-video-area video').each(function(){
5097				this.pause();
5098			});
5099			setTimeout(function() {
5100				jQuery('.fw-video-area').find('iframe').remove();
5101			}, 1500);
5102
5103			return false;
5104		},
5105		introAnimations: function() {		
5106			if ( !(isMobileAlt && body.hasClass('disable-mobile-animations')) ) {
5107				jQuery('.sf-animation').each(function() {
5108					var animatedItem = jQuery(this);
5109					animatedItem.waypoint(function(direction) {
5110						var itemAnimation = animatedItem.data('animation'),
5111						itemDelay = animatedItem.data('delay');
5112						
5113						setTimeout(function() {
5114							window.requestAnimationFrame( function() {
5115								animatedItem.addClass(itemAnimation);
5116								setTimeout(function() {
5117									animatedItem.addClass('sf-animate');
5118								}, 100);
5119							});
5120						}, itemDelay);
5121					}, {
5122					    offset: '90%',
5123					    triggerOnce: true
5124					});
5125				});
5126			}
5127		},
5128		iconBoxes: function() {
5129			if (isMobileAlt) {
5130				jQuery('.sf-icon-box').on('click', function() {
5131					jQuery(this).addClass('sf-mobile-hover');
5132				});
5133			} else {
5134				jQuery('.sf-icon-box').on({
5135    				mouseenter: function () {
5136						jQuery(this).addClass('sf-hover');
5137					},
5138					mouseleave: function () {
5139						jQuery(this).removeClass('sf-hover');
5140					}
5141				});
5142			}
5143		},
5144		initTooltips: function() {
5145			jQuery('[data-toggle="tooltip"]').tooltip({
5146				trigger: 'hover'
5147			});
5148		}
5149	};
5150
5151
5152	/////////////////////////////////////////////
5153	// TEAM MEMBERS FUNCTION
5154	/////////////////////////////////////////////
5155
5156	SWIFT.teamMembers = {
5157		init: function() {
5158			// TEAM EQUAL HEIGHTS
5159			var team = jQuery('.team-members:not(.carousel-items)');
5160			team.imagesLoaded(function () {
5161				if ($window.width() > 767) {
5162					team.equalHeights();
5163				}
5164			});
5165
5166			// TEAM ASSETS
5167			$window.smartresize( function() {
5168				jQuery('.team-members:not(.carousel-items)').children().css('min-height','0');
5169				if ($window.width() > 767) {
5170					jQuery('.team-members:not(.carousel-items)').equalHeights();
5171				}
5172			});
5173		}
5174	};
5175
5176
5177	/////////////////////////////////////////////
5178	// RELATED POSTS FUNCTION
5179	/////////////////////////////////////////////
5180
5181	SWIFT.relatedPosts = {
5182		init: function() {
5183			// TEAM EQUAL HEIGHTS
5184			var relatedItems = jQuery('.related-items');
5185			relatedItems.imagesLoaded(function () {
5186				if ($window.width() > 767) {
5187					relatedItems.equalHeights();
5188				}
5189			});
5190
5191			// TEAM ASSETS
5192			$window.smartresize( function() {
5193				jQuery('.related-items').children().css('min-height','0');
5194				if ($window.width() > 767) {
5195					jQuery('.related-items').equalHeights();
5196				}
5197			});
5198		}
5199	};
5200	
5201
5202	/////////////////////////////////////////////
5203	// PARALLAX FUNCTION
5204	/////////////////////////////////////////////
5205
5206	SWIFT.parallax = {
5207		init: function(reset) {
5208
5209			jQuery('.spb_parallax_asset').each(function(reset) {
5210
5211				var parallaxAsset = jQuery(this);
5212
5213				if (parallaxAsset.hasClass('sf-parallax-video')) {
5214
5215					if (!isMobileAlt) {
5216						SWIFT.parallax.parallaxVideoInit();
5217					} else {
5218						parallaxAsset.find('video').remove();
5219
5220						// Fade in
5221						parallaxAsset.transition({
5222							opacity: 1
5223						}, 300);
5224					}
5225
5226					// Add resize handler
5227					$window.smartresize( function() {
5228						SWIFT.parallax.parallaxVideoResize(parallaxAsset);
5229					});
5230
5231				} else if (parallaxAsset.hasClass('parallax-window-height')) {
5232
5233					parallaxAsset.css('height', '');
5234					var assetHeight = $window.height();
5235
5236					if (parallaxAsset.height() > assetHeight && !reset) {
5237						assetHeight = parallaxAsset.height();
5238					}
5239
5240					parallaxAsset.height(assetHeight - (parseInt(parallaxAsset.css('padding-top'), 10) * 2));
5241					if (parallaxAsset.data('v-center') === "true") {
5242						parallaxAsset.find('div:first').vCenterTop();
5243					}
5244
5245					// Fade in
5246					parallaxAsset.transition({
5247						opacity: 1
5248					}, 300);
5249
5250					// Add resize handler
5251					setTimeout(function() {
5252						SWIFT.parallax.windowImageResize(parallaxAsset);
5253					}, 500);
5254					$window.smartresize( function() {
5255						SWIFT.parallax.windowImageResize(parallaxAsset);
5256					});
5257				}
5258			});
5259		},
5260		load: function() {
5261			jQuery.stellar({
5262				horizontalScrolling: false,
5263				verticalOffset: 0,
5264			});
5265		},
5266		videoScroll: function(asset) {
5267
5268			var offsetTop = asset.offset().top,
5269				windowTop = $window.scrollTop(),
5270				defaultHeight = parseInt(asset.data('height-default'), 10),
5271				diff = windowTop - offsetTop,
5272				currentTop = asset.find('.spb_content_wrapper').css('top'),
5273				heightDifference = defaultHeight - diff * 1.5;
5274
5275			if (windowTop > offsetTop) {
5276				asset.css('height', heightDifference);
5277				asset.find('.spb_content_wrapper').css('opacity', 1 - (diff / 300));
5278				if (asset.hasClass('parallax-window-height') && asset.data('v-center') === "true") {
5279				asset.find('.spb_content_wrapper').css('top', currentTop + (diff / 4));
5280				} else if (asset.data('v-center') === "true") {
5281				asset.find('.spb_content_wrapper').css('top', (diff / 3));
5282				}
5283			} else {
5284				asset.css('height', defaultHeight);
5285				asset.find('.spb_content_wrapper').css('opacity', 1);
5286				if (asset.hasClass('parallax-video-height') && asset.data('v-center') === "true") {
5287				asset.find('.spb_content_wrapper').css('top', '50%');
5288				} else {
5289				asset.find('.spb_content_wrapper').css('top', 0);
5290				}
5291			}
5292
5293		},
5294		windowImageResize: function(asset) {
5295
5296			if (asset.hasClass('spb-row-container')) {
5297
5298				var rowContentHeight = asset.find('> .spb_content_element').height();
5299
5300				if (asset.hasClass('parallax-window-height')) {
5301
5302					if (rowContentHeight < $window.height()) {
5303						rowContentHeight = $window.height();
5304					}
5305				}
5306
5307				asset.height(rowContentHeight);
5308
5309				if (asset.data('v-center')) {
5310				asset.find('> .spb_content_element').vCenterTop();
5311				}
5312
5313			} else {
5314
5315				var assetHeight = asset.height();
5316
5317				if (asset.hasClass('parallax-window-height')) {
5318
5319					if (assetHeight < $window.height()) {
5320						assetHeight = $window.height();
5321					}
5322				}
5323
5324				asset.height(assetHeight - asset.css('padding-top') / 2);
5325				asset.find('.spb_content_wrapper').vCenterTop();
5326			}
5327
5328		},
5329		parallaxVideoInit: function() {
5330			jQuery('.spb_parallax_asset.sf-parallax-video').each(function() {
5331				var parallaxAsset = jQuery(this),
5332					parallaxVideo = parallaxAsset.find('video'),
5333					parallaxVideoWidth = parallaxVideo.width(),
5334					parallaxContent = parallaxAsset.find('div:first'),
5335					parallaxAssetHeight = 0;
5336
5337				if (parallaxAsset.hasClass('parallax-window-height')) {
5338
5339					if (parallaxContent.height() > $window.height()) {
5340						parallaxAssetHeight = parallaxContent.height();
5341					} else {
5342						parallaxAssetHeight = $window.height();
5343					}
5344
5345					parallaxAsset.animate({
5346						'height': parallaxAssetHeight
5347					}, 400);
5348
5349					setTimeout(function() {
5350
5351						// Scale video
5352						SWIFT.parallax.parallaxVideoResize(parallaxAsset);
5353
5354						// Fade in
5355						parallaxAsset.transition({
5356							opacity: 1
5357						}, 300);
5358
5359					}, 500);
5360
5361					setTimeout(function() {
5362						parallaxAsset.find('.video-overlay').animate({
5363							'opacity': 0.8
5364						}, 200);
5365					}, 100);
5366
5367					if (parallaxAsset.data('v-center') === "true") {
5368					parallaxContent.vCenterTop();
5369					}
5370
5371					setTimeout(function() {
5372						parallaxContent.animate({
5373							'opacity': 1,
5374							'top': '50%'
5375						}, 600, 'easeOutExpo');
5376					}, 600);
5377
5378					parallaxAsset.attr('data-height-default', parallaxVideo.height());
5379
5380				} else {
5381					SWIFT.parallax.scaleVideo(parallaxAsset);
5382				}
5383
5384				if ($window.width() < parallaxVideoWidth) {
5385					parallaxVideo.css('left', - (parallaxVideoWidth - $window.width()) /2);
5386				}
5387				
5388                var videoInstance = parallaxVideo.get( 0 );
5389                videoInstance.load();
5390                videoInstance.addEventListener( 'loadeddata' , function() {
5391                        SWIFT.parallax.parallaxVideoResize(parallaxAsset);
5392                    }
5393                );
5394
5395			});
5396		},
5397		parallaxVideoResize: function(parallaxAsset) {
5398			var parallaxContent = parallaxAsset.find('div:first'),
5399				parallaxAssetHeight = 0;
5400
5401			if (parallaxAsset.hasClass('parallax-window-height')) {
5402				if (parallaxContent.height() > $window.height()) {
5403					parallaxAssetHeight = parallaxContent.height();
5404				} else {
5405					parallaxAssetHeight = $window.height();
5406				}
5407
5408				parallaxAsset.animate({
5409					'height': parallaxAssetHeight
5410				}, 400);
5411
5412				if (parallaxAsset.data('v-center') === "true") {
5413				parallaxContent.vCenterTop();
5414				}
5415			}
5416
5417			SWIFT.parallax.scaleVideo(parallaxAsset);
5418		},
5419		scaleVideo: function(parallaxAsset) {
5420
5421			var video = parallaxAsset.find('video'),
5422				assetHeight = parallaxAsset.outerHeight(),
5423				assetWidth = parallaxAsset.outerWidth(),
5424				videoWidth = video[0].videoWidth,
5425				videoHeight = video[0].videoHeight;
5426
5427			// Use the largest scale factor of horizontal/vertical
5428			var scale_h = assetWidth / videoWidth;
5429			var scale_v = assetHeight / videoHeight;
5430			var scale = scale_h > scale_v ? scale_h : scale_v;
5431
5432			// Update minium width to never allow excess space
5433			var min_w = videoWidth/videoHeight * (assetHeight+20);
5434
5435			// Don't allow scaled width < minimum video width
5436			if (scale * videoWidth < min_w) {scale = min_w / videoWidth;}
5437
5438			// Scale the video
5439			video.width(Math.ceil(scale * videoWidth +2));
5440			video.height(Math.ceil(scale * videoHeight +50));
5441			video.css('margin-top', - (video.height() - assetHeight) /2);
5442			video.css('margin-left', - (video.width() - assetWidth) /2);
5443		},
5444
5445	};
5446
5447
5448
5449	/////////////////////////////////////////////
5450	// MAP FUNCTIONS
5451	/////////////////////////////////////////////
5452
5453	var boundsArray = [], infowindow, bounds, directory_bounds, mapTypeIdentifier = "", mapType, mapColor, mapSaturation, mapCenterLat, mapCenterLng, companyPos = "", isDraggable = true, latitude, longitude, mapCoordinates, markersArray = [], pinTitle, pinContent, pinLink, address, pinButtonText = "";
5454
5455	SWIFT.map = {
5456		init:function() {
5457
5458			var maps = jQuery('.map-canvas');
5459			var mapContainer;
5460
5461			if (typeof google !== 'undefined') {
5462				bounds = new google.maps.LatLngBounds();
5463			}
5464
5465			maps.each(function(i, element) {
5466				mapContainer = element;
5467				var mapZoom = mapContainer.getAttribute('data-zoom'),
5468					mapControls = mapContainer.getAttribute('data-controls') == "yes" ? true : false;
5469
5470				mapType = mapContainer.getAttribute('data-maptype');
5471				mapColor = mapContainer.getAttribute('data-mapcolor');
5472				mapCenterLat = mapContainer.getAttribute('data-center-lat');
5473				mapCenterLng = mapContainer.getAttribute('data-center-lng');
5474				mapSaturation = mapContainer.getAttribute('data-mapsaturation');
5475
5476				SWIFT.map.createMap( mapContainer, mapZoom, mapControls, mapType, mapColor, mapSaturation, jQuery(this));
5477			});
5478
5479		},
5480		getLatLong: function(address, pintit, pinimage, fn) {
5481			var geocoder;
5482			geocoder = new google.maps.Geocoder();
5483			geocoder.geocode( { 'address': address}, function(results, status) {
5484				fn(results[0].geometry.location, results[0].geometry.location.lat(), results[0].geometry.location.lng() , pintit, pinimage);
5485			});
5486		},
5487		addWinContent: function(marker, html, map) {
5488			google.maps.event.addListener(marker, 'click', function() {
5489				infowindow.setContent(html);
5490				infowindow.open(map, marker);
5491			});
5492		},
5493		addMarker: function(mapInstance, pinLogoURL, pinTitle, pinContent, pinLink, address, pinButtonText) {
5494			var companyMarker;
5495
5496			mapCoordinates = new google.maps.LatLng(latitude, longitude);
5497
5498			if (pinLogoURL) {
5499				companyPos = new google.maps.LatLng(latitude, longitude);
5500				companyMarker = new google.maps.Marker({
5501					position: mapCoordinates,
5502					map: mapInstance,
5503					icon: pinLogoURL,
5504					animation: google.maps.Animation.DROP });
5505			} else {
5506				companyPos = new google.maps.LatLng(latitude, longitude);
5507				companyMarker = new google.maps.Marker({
5508					position: mapCoordinates,
5509					map: mapInstance,
5510					animation: google.maps.Animation.DROP });
5511			}
5512
5513			var html = '<div class="pinmarker">';
5514			if (pinTitle !== "") {
5515			html += '<h3>'+pinTitle+'</h3>';
5516			}
5517			if (pinContent !== "") {
5518			html += '<p>'+pinContent+' </p>';
5519			}
5520			if (pinLink !== "" && pinButtonText !== "") {
5521			html += '<div><a href="' + pinLink + '" target="_blank">'+pinButtonText+'</a></div>';
5522			}
5523			html += '</div>';
5524
5525			infowindow = new google.maps.InfoWindow();
5526			SWIFT.map.addWinContent(companyMarker, html, mapInstance);
5527			bounds.extend(mapCoordinates);
5528		},
5529		createMap: function(mapContainer, mapZoom, mapControls, mapType, mapColor, mapSaturation, targetMap) {
5530
5531			if (typeof google == 'undefined') {
5532				return;
5533			}
5534			
5535			directory_bounds = new google.maps.LatLngBounds();
5536			
5537			var pinLogoURL = "", mapLightness = false;
5538
5539			// MAP STYLES
5540			var stylesArray = [],
5541				isStyled = false;
5542
5543			if (jQuery(mapContainer).parent().find('.map-styles-array').length > 0) {
5544				isStyled = true;
5545				stylesArray = JSON.parse(jQuery(mapContainer).parent().find('.map-styles-array').text());
5546			} else {
5547				if (mapSaturation == "mono-light") {
5548					if (mapColor === "") {
5549						mapColor = "#ffffff";
5550					}
5551					mapSaturation = -100;
5552				} else if (mapSaturation == "mono-dark") {
5553					if (mapColor === "") {
5554						mapColor = "#222222";
5555					}
5556					mapSaturation = -100;
5557					mapLightness = true;
5558				} else {
5559					mapSaturation = -20;
5560				}
5561				stylesArray = [
5562					{
5563						stylers: [
5564							{hue: mapColor},
5565							{"invert_lightness": mapLightness},
5566							{saturation: mapSaturation}
5567						]
5568					}
5569				];
5570			}
5571
5572			if (isMobileAlt) {
5573			isDraggable = false;
5574			}
5575
5576			if (mapType === "satellite") {
5577			mapTypeIdentifier = google.maps.MapTypeId.SATELLITE;
5578			} else if (mapType === "terrain") {
5579			mapTypeIdentifier = google.maps.MapTypeId.TERRAIN;
5580			} else if (mapType === "hybrid") {
5581			mapTypeIdentifier = google.maps.MapTypeId.HYBRID;
5582			} else {
5583			mapTypeIdentifier = google.maps.MapTypeId.ROADMAP;
5584			}
5585
5586			var options = {
5587				zoom: parseInt(mapZoom, 10),
5588				scrollwheel: false,
5589				draggable: isDraggable,
5590				mapTypeControl: true,
5591				disableDefaultUI: !mapControls,
5592				mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
5593				navigationControl: true,
5594				navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
5595				mapTypeId: mapTypeIdentifier,
5596				styles: stylesArray
5597			};
5598
5599			var mapInstance = new google.maps.Map(mapContainer, options);
5600			var pincount = targetMap.parent().find('.pin_location').length;
5601            
5602   //          mapsArray.push( mapInstance );
5603
5604			// // Resize Window Responsiveness
5605			// google.maps.event.addDomListener(window, 'resize', function() {
5606			// 	jQuery.each( mapsArray, function( i, val ) {
5607	  //               val.fitBounds(boundsArray[i]);
5608	  //               val.setZoom(parseInt(mapZoom, 10));
5609			// 	});
5610			// });
5611
5612			//Resize Window Responsiveness
5613			google.maps.event.addDomListener(window, 'resize', function() {
5614				var center = mapInstance.getCenter();
5615					google.maps.event.trigger(mapInstance, "resize");
5616					mapInstance.setCenter(center);
5617			});
5618
5619			bounds = new google.maps.LatLngBounds();
5620			boundsArray.push( bounds );
5621
5622			targetMap.parent().find('.pin_location').each(function(i, element) {
5623
5624				pinLogoURL = element.getAttribute('data-pinimage');
5625				pinTitle = element.getAttribute('data-title');
5626				pinContent = element.getAttribute('data-content');
5627				address = element.getAttribute('data-address');
5628				pinLink = element.getAttribute('data-pinlink');
5629				latitude = element.getAttribute('data-lat');
5630				longitude = element.getAttribute('data-lng');
5631				pinButtonText = element.getAttribute('data-button-text');
5632
5633
5634				if (latitude === '' && longitude === '') {
5635
5636					SWIFT.map.getLatLong(address, pinTitle, pinLogoURL ,function(location, lati,longi, pintit, pinimage ){
5637
5638						latitude = lati;
5639						longitude = longi;
5640						pinTitle = pintit;
5641						pinLogoURL = pinimage;
5642
5643						SWIFT.map.addMarker(mapInstance, pinLogoURL, pinTitle, pinContent, pinLink, address, pinButtonText);
5644
5645						if ( pincount > 1 ) {
5646							if (mapCenterLat !== '' && mapCenterLng !== ''){
5647								mapInstance.setZoom(parseInt(mapZoom, 10));
5648								mapInstance.setCenter(new google.maps.LatLng(mapCenterLat, mapCenterLng));
5649							} else {
5650								mapInstance.fitBounds(bounds);
5651							}
5652						} else {
5653							mapInstance.setZoom(parseInt(mapZoom, 10));
5654							mapInstance.setCenter(new google.maps.LatLng(latitude, longitude));
5655						}
5656
5657					});
5658
5659				} else {
5660
5661					SWIFT.map.addMarker(mapInstance, pinLogoURL, pinTitle, pinContent, pinLink, address, pinButtonText);
5662
5663					if ( pincount > 1 ) {
5664						if (mapCenterLat !== '' && mapCenterLng !== '') {
5665								mapInstance.setZoom(parseInt(mapZoom, 10));
5666								mapInstance.setCenter(new google.maps.LatLng(mapCenterLat, mapCenterLng));
5667							} else {
5668								mapInstance.fitBounds(bounds);
5669						}
5670					} else {
5671						mapInstance.setZoom(parseInt(mapZoom, 10));
5672						mapInstance.setCenter(new google.maps.LatLng(latitude, longitude));
5673					}
5674
5675				}
5676
5677			});
5678		}
5679	};
5680
5681
5682	/////////////////////////////////////////////
5683	// MAP DIRECTORY FUNCTIONS
5684	/////////////////////////////////////////////
5685
5686	SWIFT.mapDirectory = {
5687		init : function(searchTerm, locationFilter, categoryFilter) {
5688
5689			searchTerm = jQuery('#dir-search-value').val();
5690			locationFilter = jQuery('.directory-location-option').val();
5691			categoryFilter = jQuery('.directory-category-option').val();
5692
5693			var mapsDirectory = jQuery('.map-directory-canvas');
5694
5695			mapsDirectory.each(function(i, element) {
5696
5697				var mapDirContainer = element,
5698					mapZoom = mapDirContainer.getAttribute('data-zoom'),
5699					mapType = mapDirContainer.getAttribute('data-maptype'),
5700					mapColor = mapDirContainer.getAttribute('data-mapcolor'),
5701					mapSaturation = mapDirContainer.getAttribute('data-mapsaturation');
5702
5703					if ( categoryFilter === null || categoryFilter == 'All' ){
5704						categoryFilter = mapDirContainer.getAttribute('data-directory-category');
5705					}
5706
5707				SWIFT.mapDirectory.directoryMap( mapDirContainer, mapZoom, mapType, mapColor, mapSaturation, jQuery(this), searchTerm, locationFilter, categoryFilter);
5708
5709			});
5710		},
5711		searchDirectory: function(){
5712			SWIFT.mapDirectory.init(jQuery('#dir-search-value').val(), jQuery('.directory-location-option').val(), jQuery('.directory-category-option').val());
5713		},
5714		getLatLong: function(address, fn){
5715			var geocoder;
5716			geocoder = new google.maps.Geocoder();
5717			geocoder.geocode( { 'address': address}, function(results, status) {
5718				fn(results[0].geometry.location, results[0].geometry.location.lat(), results[0].geometry.location.lng());
5719			});
5720		},
5721		addWinContent: function(marker, html, map){
5722				markersArray.push(marker);
5723				google.maps.event.addListener(marker, 'click', function() {
5724				infowindow.setContent(html);
5725				infowindow.open(map, marker);
5726			});
5727		},
5728		addMarkerDir: function(mapInstance, pinLogoURL, pinTitle, pinContent, pinLink, address, pinButtonText,pinFeaturedImage, lat, lng){
5729			var companyMarker, pinImgContainer;
5730
5731			mapCoordinates = new google.maps.LatLng(lat, lng);
5732
5733			if (pinLogoURL) {
5734				companyPos = new google.maps.LatLng(lat, lng);
5735				companyMarker = new google.maps.Marker({
5736					position: mapCoordinates,
5737					map: mapInstance,
5738					icon: pinLogoURL,
5739					optimized: true,
5740					animation: google.maps.Animation.DROP });
5741			} else {
5742				companyPos = new google.maps.LatLng(lat, lng);
5743				companyMarker = new google.maps.Marker({
5744					position: mapCoordinates,
5745					map: mapInstance,
5746					animation: google.maps.Animation.DROP });
5747			}
5748			if (pinFeaturedImage === null) {
5749				pinImgContainer = '';
5750			} else {
5751				pinImgContainer = '<img class="info-window-img" alt="" src="'+pinFeaturedImage
5751+'" height="140" width="140"/>';
5752			}
5753
5754			var html = '';
5755			if (pinLink === '' || pinButtonText === '') {
5756				html = '<div class="pinmarker">'+pinImgContainer+'<div class="pinmarker-container"><h3>'+pinTitle+'</h3><div class="excerpt">'+pinContent+'</div></div></div>';
5757			} else {
5758				html = '<div class="pinmarker">'+pinImgContainer+'<div class="pinmarker-container"><h3>'+pinTitle+'</h3><div class="excerpt">'+pinContent+'</div><a class="pin-button" href="' + pinLink + '" target="_blank">'+pinButtonText+'</a></div></div>';
5759			}
5760
5761
5762			infowindow = new google.maps.InfoWindow();
5763			SWIFT.mapDirectory.addWinContent(companyMarker, html, mapInstance);
5764			directory_bounds.extend(mapCoordinates);
5765		},
5766		directoryMap: function(mapContainer, mapZoom, mapType, mapColor, mapSaturation, targetMap, searchTerm, locationFilter, categoryFilter, otherExcerpt) {
5767
5768			var mapLightness = false;
5769			var mapResults =  mapContainer.getAttribute('data-directory-map-results');
5770			var excerpt =  mapContainer.getAttribute('data-excerpt');
5771
5772			//Only if we want to display the map
5773			if (mapResults !== 'list') {
5774
5775				if (mapSaturation == "mono-light") {
5776					if (mapColor === "") {
5777						mapColor = "#ffffff";
5778					}
5779					mapSaturation = -100;
5780				} else if (mapSaturation == "mono-dark") {
5781					if (mapColor === "") {
5782						mapColor = "#222222";
5783					}
5784					mapSaturation = -100;
5785					mapLightness = true;
5786				} else {
5787					mapSaturation = -20;
5788				}
5789
5790				var styles = [
5791					{
5792						stylers: [
5793							{hue: mapColor},
5794							{"invert_lightness": mapLightness},
5795							{saturation: mapSaturation}
5796						]
5797					}
5798				];
5799
5800				var styledMap = new google.maps.StyledMapType(styles,{name: "Styled Map"});
5801
5802				if (isMobileAlt) {
5803					isDraggable = false;
5804				}
5805
5806				if (mapType === "satellite") {
5807				mapTypeIdentifier = google.maps.MapTypeId.SATELLITE;
5808				} else if (mapType === "terrain") {
5809				mapTypeIdentifier = google.maps.MapTypeId.TERRAIN;
5810				} else if (mapType === "hybrid") {
5811				mapTypeIdentifier = google.maps.MapTypeImapDirContainerd.HYBRID;
5812				} else {
5813				mapTypeIdentifier = google.maps.MapTypeId.ROADMAP;
5814				}
5815
5816
5817			} else {
5818				jQuery(mapContainer).hide();
5819			}
5820
5821			directory_bounds = new google.maps.LatLngBounds();
5822
5823			if (categoryFilter === "") {
5824				categoryFilter = mapContainer.getAttribute('data-directory-category');
5825			}
5826
5827			//Ajax call to get the Directory Itens
5828			var data = {
5829				action: 'atelier_directory',
5830				search_term: searchTerm,
5831				location_term: locationFilter,
5832				category_term: categoryFilter,
5833				item_excerpt: excerpt
5834
5835			};
5836
5837			jQuery.post(mapContainer.getAttribute('data-ajaxurl'), data, function(response) {
5838				var json = jQuery.parseJSON(response);
5839				var pincount = json.results;
5840
5841				jQuery('.directory-results').hide();
5842
5843				var settings = {
5844					scrollwheel: false,
5845					draggable: isDraggable,
5846					mapTypeControl: true,
5847					mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
5848					navigationControl: true,
5849					navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
5850					mapTypeId: mapTypeIdentifier
5851				};
5852
5853				if (pincount > 0) {
5854
5855					var mapInstance = new google.maps.Map(mapContainer, settings);
5856					markersArray = [];
5857
5858					// MAP COLOURIZE
5859					if (mapColor !== "" && mapResults != 'list') {
5860						mapInstance.mapTypes.set('map_style', styledMap);
5861						mapInstance.setMapTypeId('map_style');
5862					}
5863
5864					//Resize Window Responsiveness
5865					google.maps.event.addDomListener(window, 'resize', function() {
5866						var center = mapInstance.getCenter();
5867						google.maps.event.trigger(mapInstance, "resize");
5868						mapInstance.setCenter(center);
5869					});
5870
5871					var resultText = "";
5872
5873					if ( pincount > 1 ) {
5874					resultText = json.results_text_1 + ' '+pincount+' '+json.results_text_2plural;
5875					} else {
5876					resultText = json.results_text_1 + ' '+pincount+' '+json.results_text_2;
5877					}
5878					jQuery(mapContainer).parent().parent().parent().find('.directory-results').prepend('<div class="results-title"><h2>'+resultText+'</h2>');
5879
5880				} else {
5881
5882					for (var i=0; i < markersArray.length; i++) {
5883						markersArray[i].setMap(null);
5884					}
5885
5886					jQuery(mapContainer).parent().parent().parent().find('.directory-results').append('<div class="results-title"><h2>
5886'+json.errormsg+'</h2>');
5887
5888				}
5889
5890				if (pincount > 0 && mapResults != 'list') {
5891
5892					jQuery(mapContainer).show();
5893					jQuery('.directory-results').append(json.pagination);
5894
5895					jQuery.each(json.items, function(i, item) {
5896
5897						//Get the directory itens details
5898						var pinTitle = item.pin_title,
5899							pinLogoURL = item.pin_logo_url,
5900							pinContent = item.pin_content,
5901							pinShortContent = item.pin_short_content,
5902							address = item.pin_address,
5903							pinLink = item.pin_link,
5904							pinButtonText = item.pin_button_text,
5905							latitude = item.pin_lat,
5906							longitude = item.pin_lng,
5907							pinThumbnail = item.pin_thumbnail,
5908							// categories = item.categories,
5909							// location = item.location,
5910							thumbnail_image	= '',
5911							// result_header = true,
5912							hasThumb = false,
5913							extra_class = '';
5914							if ( excerpt !== '' ){
5915								pinContent = pinShortContent;
5916							}
5917
5918						if (pinThumbnail && pinLink) {
5919							hasThumb = true;
5920							thumbnail_image = '<figure class="animated-overlay overlay-alt"><img itemprop="image" src="'+pinThumbnail+'" alt="'+pinTitle+'"><a href="'+pinLink+'" target="_blank" class="link-to-post"></a><div class="figcaption-wrap"></div><figcaption><div class="thumb-info"><h4>'+pinTitle+'</h4></div></figcaption></figure>';
5921						} else if (pinThumbnail) {
5922							hasThumb = true;
5923							thumbnail_image = '<figure><img itemprop="image" src="'+pinThumbnail+'" alt="'+pinTitle+'"></figure>';
5924						}
5925
5926						//Add the Directory List Results
5927						if (!hasThumb) {
5928							extra_class = 'no-thumb';
5929						}
5930
5931						if ( mapResults != 'list') {
5932
5933							//Add directory item to the map
5934							SWIFT.mapDirectory.addMarkerDir(mapInstance, pinLogoURL, pinTitle, pinContent, pinLink, address, pinButtonText,pinThumbnail, latitude, longitude);
5935
5936							if ( pincount > 1 ) {
5937								mapInstance.fitBounds(directory_bounds);
5938							} else {
5939								mapInstance.setZoom(parseInt(mapZoom, 10));
5940								mapInstance.setCenter(new google.maps.LatLng(latitude, longitude));
5941							}
5942
5943							google.maps.event.addDomListener(window, 'resize', function() {
5944								mapInstance.fitBounds(directory_bounds);
5945								mapInstance.setCenter(new google.maps.LatLng(latitude, longitude));
5946      						});
5947      						
5948						}
5949					});
5950				}else{
5951					jQuery(mapContainer).hide();
5952				}
5953				jQuery('.directory-results').show();
5954			});
5955		}
5956	};
5957
5958
5959	/////////////////////////////////////////////
5960	// CROWDFUNDING FUNCTIONS
5961	/////////////////////////////////////////////
5962
5963	SWIFT.crowdfunding = {
5964		init:function() {
5965
5966			if (jQuery('#back-this-project').find('.edd_price_options').length <= 0) {
5967				jQuery('#back-this-project > h2').css('display', 'none');
5968			}
5969
5970			if (jQuery('#back-this-project').hasClass('project-donate-only')) {
5971				jQuery('.edd_price_options').find('li').first().addClass('atcf-selected');
5972				jQuery('.edd_price_options').find('li').first().find('input[type="radio"]').prop('checked', true);
5973			}
5974
5975			jQuery('.atcf-price-option').on('click', function() {
5976
5977				var selectedOption = jQuery(this),
5978					selectedPrice = selectedOption.data('price').substr(0, selectedOption.data('price').indexOf('-'));
5979
5980				if (selectedOption.hasClass('inactive')) {
5981					return false;
5982				}
5983
5984				if (selectedPrice && jQuery('#atcf_custom_price').val().length <= 0) {
5985				jQuery('#atcf_custom_price').val(selectedPrice);
5986				}
5987				jQuery('.atcf-price-option').find('input[type="radio"]').prop('checked', false);
5988				jQuery('.atcf-price-option').removeClass('atcf-selected');
5989				selectedOption.find('input[type="radio"]').prop('checked', true);
5990				selectedOption.addClass('atcf-selected');
5991			});
5992
5993			var campaignItems = jQuery('.campaign-items:not(.carousel-items)');
5994			campaignItems.imagesLoaded(function () {
5995				campaignItems.equalHeights();
5996			});
5997
5998			$window.smartresize( function() {
5999				jQuery('.campaign-items:not(.carousel-items)').children().css('min-height','0');
6000				jQuery('.campaign-items:not(.carousel-items)').equalHeights();
6001			});
6002
6003		}
6004	};
6005
6006	/////////////////////////////////////////////
6007	// CANVAS EFFECTS
6008	/////////////////////////////////////////////
6009
6010	var phc_width, phc_height, phc_ctx, phc_points, phc_circles, phc_target = true;
6011
6012	SWIFT.canvasEffects = {
6013		init: function(heightOverride) {
6014
6015			var canvasAsset = jQuery('.sf-canvas-effect');
6016
6017			if (canvasAsset.data('type') === "circles") {
6018				SWIFT.canvasEffects.initCircles(canvasAsset, heightOverride);
6019			} else if (canvasAsset.data('type') === "geometric") {
6020				SWIFT.canvasEffects.initGeometry(canvasAsset, heightOverride);
6021			}
6022
6023		},
6024		initCircles: function(canvas, heightOverride) {
6025			phc_width = canvas.parent().width();
6026	        phc_height = heightOverride > 0 ? heightOverride : canvas.parent().height();
6027	        phc_target = {x: 0, y: phc_height};
6028
6029	        var canvasID = canvas.find('canvas').data('canvas_id');
6030		    canvas.find('canvas').attr('width', phc_width).attr('height', phc_height);
6031	        phc_ctx = document.getElementById(canvasID).getContext('2d');
6032
6033	        // create particles
6034	        phc_circles = [];
6035	        for (var x = 0; x < phc_width*2; x++) {
6036	            var c = new SWIFT.canvasEffects.circleInstance();
6037	            phc_circles.push(c);
6038	        }
6039	        SWIFT.canvasEffects.animateCircles();
6040		},
6041		animateCircles: function() {
6042		    //if (animateHeader) {
6043		        phc_ctx.clearRect(0,0,phc_width,phc_height);
6044		        for (var i = 0; i < phc_circles.length; i++) {
6045		            phc_circles[i].draw();
6046		        }
6047		    //}
6048		    window.requestAnimationFrame(SWIFT.canvasEffects.animateCircles);
6049		},
6050		circleInstance: function() {
6051			var _this = this;
6052
6053	        // constructor
6054	        (function() {
6055	            _this.pos = {};
6056	            init();
6057	        })();
6058
6059	        function init() {
6060	            _this.pos.x = Math.random()*phc_width;
6061	            _this.pos.y = -30 - Math.random()*100;
6062	            _this.alpha = 0.1+Math.random()*0.3;
6063	            _this.scale = 0.1+Math.random()*0.3;
6064	            _this.velocity = -Math.random();
6065	        }
6066
6067	        this.draw = function() {
6068	            if (_this.alpha <= 0) {
6069	                init();
6070	            }
6071	            _this.pos.y -= _this.velocity;
6072	            _this.alpha -= 0.0005;
6073	            phc_ctx.beginPath();
6074	            phc_ctx.arc(_this.pos.x, _this.pos.y, _this.scale*10, 0, 2 * Math.PI, false);
6075	            phc_ctx.fillStyle = 'rgba(255,255,255,'+ _this.alpha+')';
6076	            phc_ctx.fill();
6077	        };
6078		},
6079		initGeometry: function(canvas, heightOverride) {
6080            phc_width = canvas.parent().width();
6081            phc_height = heightOverride > 0 ? heightOverride : canvas.parent().height();
6082            phc_target = {x: phc_width/2, y: phc_height/2};
6083
6084            var canvasID = canvas.find('canvas').data('canvas_id');
6085            canvas.find('canvas').attr('width', phc_width).attr('height', phc_height);
6086            phc_ctx = document.getElementById(canvasID).getContext('2d');
6087
6088            // create points
6089            phc_points = [];
6090            for(var x = 0; x < phc_width; x = x + phc_width/20) {
6091                for(var y = 0; y < phc_height; y = y + phc_height/20) {
6092                    var px = x + Math.random()*phc_width/40;
6093                    var py = y + Math.random()*phc_height/20;
6094                    var p = {x: px, originX: px, y: py, originY: py };
6095                    phc_points.push(p);
6096                }
6097            }
6098
6099            // for each point find the 5 closest points
6100            for(var i = 0; i < phc_points.length; i++) {
6101                var closest = [];
6102                var p1 = phc_points[i];
6103                for(var j = 0; j < phc_points.length; j++) {
6104                    var p2 = phc_points[j];
6105                    if (p1 != p2) {
6106                        var placed = false;
6107                        for(var k = 0; k < 3; k++) {
6108                            if(!placed) {
6109                                if (closest[k] === undefined) {
6110                                    closest[k] = p2;
6111                                    placed = true;
6112                                }
6113                            }
6114                        }
6115
6116                        for(var k2 = 0; k2 < 3; k2++) {
6117                            if(!placed) {
6118                                if (SWIFT.canvasEffects.getDistance(p1, p2) < SWIFT.canvasEffects.getDistance(p1, closest[k2])) {
6119                                    closest[k2] = p2;
6120                                    placed = true;
6121                                }
6122                            }
6123                        }
6124                    }
6125                }
6126                p1.closest = closest;
6127            }
6128
6129            // assign a circle to each point
6130            for(var i2 = 0; i2 < phc_points.length; i2++) {
6131                var c = new SWIFT.canvasEffects.geoCircleInstance(phc_points[i2], 2+Math.random(), 'rgba(255,255,255,0.3)');
6132                phc_points[i2].circle = c;
6133            }
6134
6135	        // Init Animation
6136	        SWIFT.canvasEffects.animateGeometry();
6137	        for (var i3 = 0; i3 < phc_points.length; i3++) {
6138	            SWIFT.canvasEffects.shiftPoint(phc_points[i3]);
6139	        }
6140
6141	        // Init Mouse Movement
6142	        if (!('ontouchstart' in window)) {
6143	            window.addEventListener('mousemove', SWIFT.canvasEffects.mouseMove);
6144	        }
6145		},
6146		mouseMove: function(e) {
6147		    var posx = 0;
6148		    var posy = 0;
6149		    if (e.pageX || e.pageY) {
6150		        posx = e.pageX;
6151		        posy = e.pageY;
6152		    }
6153		    else if (e.clientX || e.clientY)    {
6154		        posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
6155		        posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
6156		    }
6157		    phc_target.x = posx;
6158		    phc_target.y = posy / 2;
6159		},
6160	    animateGeometry: function() {
6161            phc_ctx.clearRect(0,0,phc_width,phc_height);
6162            for (var i = 0; i < phc_points.length; i++) {
6163                // detect points in range
6164                if(Math.abs(SWIFT.canvasEffects.getDistance(phc_target, phc_points[i])) < 20000) {
6165                    phc_points[i].active = 0.2;
6166                    phc_points[i].circle.active = 0.3;
6167                } else if(Math.abs(SWIFT.canvasEffects.getDistance(phc_target, phc_points[i])) < 300000) {
6168                    phc_points[i].active = 0.1;
6169                    phc_points[i].circle.active = 0.2;
6170                } else if(Math.abs(SWIFT.canvasEffects.getDistance(phc_target, phc_points[i])) < 2000000) {
6171                    phc_points[i].active = 0.02;
6172                    phc_points[i].circle.active = 0.1;
6173                } else {
6174                    phc_points[i].active = 0;
6175                    phc_points[i].circle.active = 0;
6176                }
6177
6178                SWIFT.canvasEffects.drawLines(phc_points[i]);
6179                phc_points[i].circle.draw();
6180            }
6181	        window.requestAnimationFrame(SWIFT.canvasEffects.animateGeometry);
6182	    },
6183	    shiftPoint: function(p) {
6184	        TweenLite.to(p, 1+1*Math.random(), {x:p.originX-50+Math.random()*100,
6185	            y: p.originY-50+Math.random()*100, ease:Circ.easeInOut,
6186	            onComplete: function() {
6187	                SWIFT.canvasEffects.shiftPoint(p);
6188	            }});
6189	    },
6190	    drawLines: function(p) {
6191	        if(!p.active) return;
6192	        for (var i = 0; i < p.closest.length; i++) {
6193	            phc_ctx.beginPath();
6194	            phc_ctx.moveTo(p.x, p.y);
6195	            phc_ctx.lineTo(p.closest[i].x, p.closest[i].y);
6196	            phc_ctx.strokeStyle = 'rgba(255,255,255,'+ p.active+')';
6197	            phc_ctx.stroke();
6198	        }
6199	    },
6200		geoCircleInstance: function(pos,rad,color) {
6201			var _this = this;
6202
6203	        // constructor
6204	        (function() {
6205	            _this.pos = pos || null;
6206	            _this.radius = rad || null;
6207	            _this.color = color || null;
6208	        })();
6209
6210	        this.draw = function() {
6211	            if(!_this.active) return;
6212	            phc_ctx.beginPath();
6213	            phc_ctx.arc(_this.pos.x, _this.pos.y, _this.radius, 0, 2 * Math.PI, false);
6214	            phc_ctx.fillStyle = 'rgba(255,255,255,'+ _this.active+')';
6215	            phc_ctx.fill();
6216	        };
6217		},
6218		getDistance: function(p1, p2) {
6219		    return Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2);
6220		}
6221	};
6222
6223	/////////////////////////////////////////////
6224	// RELOAD FUNCTIONS
6225	/////////////////////////////////////////////
6226
6227	SWIFT.reloadFunctions = {
6228		init:function() {
6229
6230			// Remove title attributes from images to avoid showing on hover
6231			jQuery('img[title]').each(function() {
6232				jQuery(this).removeAttr('title');
6233			});
6234
6235			if (!isAppleDevice) {
6236				jQuery('embed').show();
6237			}
6238
6239			// Animate Top Links
6240			jQuery('.animate-top').on('click', function(e) {
6241				e.preventDefault();
6242				jQuery('body,html').animate({scrollTop: 0}, 800, 'easeOutCubic');
6243			});
6244		},
6245		load:function() {
6246			if (!isMobileAlt) {
6247
6248				// Button hover tooltips
6249				jQuery('.tooltip').each( function() {
6250					jQuery(this).css( 'marginLeft', '-' + Math.round( (jQuery(this).outerWidth(true) / 2) ) + 'px' );
6251				});
6252
6253				jQuery('.comment-avatar').on({
6254    				mouseenter: function () {
6255						jQuery(this).find('.tooltip' ).stop().animate({
6256							bottom: '44px',
6257							opacity: 1
6258						}, 500, 'easeInOutExpo');
6259					},
6260    				mouseleave: function () {
6261						jQuery(this).find('.tooltip').stop().animate({
6262							bottom: '25px',
6263							opacity: 0
6264						}, 400, 'easeInOutExpo');
6265					}
6266				});
6267
6268				jQuery('.grid-image').on({
6269    				mouseenter: function () {
6270						jQuery(this).find('.tooltip' ).stop().animate({
6271							bottom: '85px',
6272							opacity: 1
6273						}, 500, 'easeInOutExpo');
6274					},
6275    				mouseleave: function () {
6276						jQuery(this).find('.tooltip').stop().animate({
6277							bottom: '65px',
6278							opacity: 0
6279						}, 400, 'easeInOutExpo');
6280					}
6281				});
6282
6283			}
6284		}
6285	};
6286
6287
6288	/////////////////////////////////////////////
6289	// GLOBAL VARIABLES
6290	/////////////////////////////////////////////
6291
6292	var $window = jQuery(window),
6293		body = jQuery('body'),
6294		sfIncluded = jQuery('#sf-included'),
6295		sfOptionParams = jQuery('#sf-option-params'),
6296		windowheight = SWIFT.page.getViewportHeight(),
6297		deviceAgent = navigator.userAgent.toLowerCase(),
6298		isMobile = deviceAgent.match(/(iphone|ipod|android|iemobile)/),
6299		isMobileAlt = deviceAgent.match(/(iphone|ipod|ipad|android|iemobile)/),
6300		isAppleDevice = deviceAgent.match(/(iphone|ipod|ipad)/),
6301		isIEMobile = deviceAgent.match(/(iemobile)/),
6302		parallaxScroll = navigator.userAgent.indexOf('Safari') != -1 || navigator.userAgent.indexOf('Chrome') == -1,
6303		IEVersion = SWIFT.page.checkIE(),
6304		isRTL = body.hasClass('rtl') ? true : false,
6305		shopBagHovered = false,
6306		wishlistHovered = false,
6307		stickyHeaderTop = 0,
6308		sliderAuto = sfOptionParams.data('slider-autoplay') ? true : false,
6309		sliderSlideSpeed = sfOptionParams.data('slider-slidespeed'),
6310		sliderAnimSpeed = sfOptionParams.data('slider-animspeed'),
6311		lightboxEnabled = sfOptionParams.data('lightbox-enabled') ? true : false,
6312		lightboxControlArrows = sfOptionParams.data('lightbox-nav') === "arrows" ? true : false,
6313		lightboxThumbs = sfOptionParams.data('lightbox-thumbs') ? true : false,
6314		lightboxSkin = sfOptionParams.data('lightbox-skin') === "dark" ? "metro-black" : "metro-white",
6315		lightboxSharing = sfOptionParams.data('lightbox-sharing') ? true : false,
6316		hasProductZoom = jQuery('#sf-included').hasClass('has-productzoom') && !isMobileAlt ? true : false,
6317		productZoomType = sfOptionParams.data('product-zoom-type') === "lens" ? "lens" : "inner",
6318		productSliderThumbsPos = sfOptionParams.data('product-slider-thumbs-pos') === "left" ? "left" : "bottom",
6319		productSliderVertHeight = sfOptionParams.data('product-slider-vert-height'),
6320		cartNotification = sfOptionParams.data('cart-notification');
6321
6322	SWIFT.isScrolling = false;
6323	SWIFT.productSlider = false;
6324	SWIFT.isInfScrolling = false;
6325
6326	/////////////////////////////////////////////
6327	// LOAD + READY FUNCTION
6328	/////////////////////////////////////////////
6329
6330	SWIFT.onReady = {
6331		init: function(){
6332			SWIFT.page.init();
6333			SWIFT.sliders.init();
6334			if (sfIncluded.hasClass('has-gallery')) {
6335			SWIFT.gallery.init();
6336			}
6337			if (jQuery('.sf-super-search').length > 0) {
6338			SWIFT.superSearch.init();
6339			}
6340			if (jQuery('#header-section').length > 0) {
6341			SWIFT.header.init();
6342			}
6343			SWIFT.nav.init();
6344			SWIFT.woocommerce.init();
6345			SWIFT.woocommerce.cartWishlist();
6346			
6347			SWIFT.edd.init();
6348			
6349			if (sfIncluded.hasClass('has-portfolio')) {
6350			SWIFT.portfolio.init();
6351			}
6352			if (sfIncluded.hasClass('has-portfolio-showcase')) {
6353			SWIFT.portfolio.portfolioShowcaseInit();
6354			}
6355			if (sfIncluded.hasClass('has-blog')) {
6356			SWIFT.blog.init();
6357			}
6358			if (sfIncluded.hasClass('has-infscroll')) {
6359			SWIFT.blog.infiniteScroll();
6360			}
6361			if (sfIncluded.hasClass('has-galleries')) {
6362			SWIFT.galleries.init();
6363			}
6364			SWIFT.widgets.init();
6365			if (sfIncluded.hasClass('has-team')) {
6366			SWIFT.teamMembers.init();
6367			}
6368			if (sfIncluded.hasClass('has-carousel')) {
6369			SWIFT.carouselWidgets.init();
6370			}
6371			if (sfIncluded.hasClass('has-parallax')) {
6372			SWIFT.parallax.init();
6373			}
6374			SWIFT.crowdfunding.init();
6375			SWIFT.reloadFunctions.init();
6376		}
6377	};
6378	SWIFT.onLoad = {
6379		init: function(){
6380			if (body.hasClass('sf-preloader')) {
6381			SWIFT.page.homePreloader();
6382			}
6383			if (sfIncluded.hasClass('has-parallax')) {
6384			SWIFT.parallax.load();
6385			}
6386			if (sfIncluded.hasClass('has-products') || body.hasClass('woocommerce-cart') || body.hasClass('woocommerce-account')) {
6387			SWIFT.woocommerce.load();
6388			}
6389			SWIFT.page.load();
6390			if (body.hasClass('page-transitions')) {
6391			SWIFT.page.fadePageIn();
6392			}
6393			SWIFT.widgets.load();
6394			if (sfIncluded.hasClass('has-map')) {
6395				SWIFT.map.init();
6396				SWIFT.mapDirectory.init('', '', '');
6397
6398				jQuery(document).on('click', '#directory-search-button', function(e) {
6399					e.preventDefault();
6400					jQuery('.directory-search-form').submit();
6401				});
6402				jQuery('ul.nav-tabs li a').on('click', function(){
6403					var thisTabHref = jQuery(this).attr('href');
6404					if (jQuery(thisTabHref).find('.spb_gmaps_widget').length > 0) {
6405						SWIFT.map.init();
6406						SWIFT.mapDirectory.init('', '', '');
6407					}
6408				});
6409			}
6410			SWIFT.reloadFunctions.load();
6411
6412			if (sfIncluded.hasClass('stickysidebars') && jQuery('.sticky-widget').length > 0) {
6413				SWIFT.page.stickyWidget();
6414			}
6415
6416		}
6417	};
6418
6419	jQuery(document).ready(SWIFT.onReady.init);
6420	jQuery(window).on('load', SWIFT.onLoad.init);
6421
6422	jQuery.fn.vCenter = function() {return this.each(function(){var height = jQuery(this).outerHeight();jQuery(this).css('margin-bottom',- Math.floor(height/2));});};
6423	jQuery.fn.vCenterTop = function() {return this.each(function(){var height = jQuery(this).outerHeight();jQuery(this).css('margin-top',- Math.ceil(height/2));});};
6424
6425})(jQuery);
6426
6427window.onpageshow = function(event) {
6428    if ( event.persisted && jQuery('body').hasClass("page-transitions") ) {
6429        window.location.reload();
6430    }
6431};
6432window.onunload = function(){
6433	if (jQuery('body').hasClass("page-transitions") ) {
6434	    var preloadTime = 1000;
6435
6436		if (jQuery('.parallax-window-height').length > 0) {
6437			preloadTime = 1200;
6438		}
6439
6440		jQuery('body').addClass('page-fading-in');
6441		jQuery('#site-loading').css('opacity', '0');
6442
6443		setTimeout(function() {
6444			jQuery('#site-loading').css('display', 'none');
6445			jQuery('body').removeClass('page-fading-in');
6446		}, preloadTime);
6447	}
6448};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.