PageSourceSearch

https://greysignal.com/wp-content/themes/dante/js/functions.js

js greysignal.com collected 2026-10-04 16:22:22 UTC 99,757 bytes, 3,174 lines download raw bytes

1/*global jQuery,google,AnimOnScroll,ajaxurl */
2(function(){
3	
4	// USE STRICT
5	"use strict";
6	
7	/////////////////////////////////////////////
8	// PAGE FUNCTIONS
9	/////////////////////////////////////////////
10	
11	var page = {
12		init: function () {
13			
14			// BROWSER CHECK
15			jQuery.browser = {};
16			jQuery.browser.mozilla = /mozilla/.test(navigator.userAgent.toLowerCase()) && !/webkit/.test(navigator.userAgent.toLowerCase());
17			jQuery.browser.webkit = /webkit/.test(navigator.userAgent.toLowerCase());
18			jQuery.browser.opera = /opera/.test(navigator.userAgent.toLowerCase());
19			jQuery.browser.msie = /msie/.test(navigator.userAgent.toLowerCase());
20			jQuery.browser.msieMobile10 = /iemobile\/10\.0/.test(navigator.userAgent.toLowerCase());
21					
22			// BODY CLASSES
23			if (isMobileAlt) {
24				body.addClass("mobile-browser");
25			} else {
26				body.addClass("standard-browser");
27			}
28			if (isIEMobile) {
29				body.addClass("ie-mobile");
30			}
31			if (isAppleDevice) {
32				body.addClass("apple-mobile-browser");
33			}
34			if (body.hasClass("woocommerce-page") && !body.hasClass("woocommerce")) {
35				body.addClass("woocommerce");
36			}
37			// ADD IE CLASS
38			if (IEVersion && IEVersion < 10) {
39				body.addClass('browser-ie');
40			}
41			
42			// ADD IE10 CLASS
43			var pattern = /MSIE\s([\d]+)/,
44				ua = navigator.userAgent,
45				matched = ua.match(pattern);
46			if (matched) {
47				body.addClass('browser-ie10');
48			}
49			
50			if (jQuery.browser.mozilla) {
51				body.addClass('browser-ff');
52			}
53			
54			// ADD IE11 CLASS
55			var isIE11 = !!navigator.userAgent.match(/Trident.*rv\:11\./);
56			if (isIE11) {
57				body.addClass('browser-ie11');
58			}
59			
60			
61			// ONE PAGE NAV
62			if (jQuery('#one-page-nav').length > 0) {
63				page.onePageNav();
64			}
65			
66			// BACK TO TOP
67			if (jQuery('#back-to-top').length > 0) {
68				$window.scroll(function() {
69					page.backToTop();
70				});
71			}
72			
73			// CAROUSEL GRAB POINTER FUNCTIONALITY
74			if (!isMobileAlt) {
75				body.on('mousedown', '.caroufredsel_wrapper', function() {
76					jQuery(this).addClass('isSwiping');
77				});
78				body.on('mouseup', '.caroufredsel_wrapper', function() {
79					jQuery(this).removeClass('isSwiping');
80				});
81			}
82			
83			// FANCY HEADING
84			if (jQuery('.fancy-heading').length > 0) {
85				page.fancyHeading();
86			}
87									
88			// FITVIDS
89			//page.fitVids();
90			
91			// SMOOTH SCROLL
92			if (isMobile && !jQuery.browser.msieMobile10 && !isIEMobile) {
93				page.niceScroll();
94			}
95			
96			if (jQuery('#page-wrap').has('.full-width-display-wrap')) {
97				page.fullscreenMedia();
98				$window.smartresize( function() {
99					page.fullscreenMedia();
100				});			
101			}
102			
103			// MOVE MODALS TO BOTTOM OF PAGE
104			jQuery(".modal").each(function(){
105				jQuery(this).appendTo("body");
106			});
107			
108			// LOAD MAP ASSET ON MODAL CLICK
109			jQuery('a[data-toggle="modal"]').on('click', function() {
110				setTimeout(function() {
111					map.init();						
112				}, 300);
113				
114				return true;
115			});
116			
117			// REFRESH MODAL IFRAME ON CLOSE (FOR VIDEOS)
118			jQuery(".modal-backdrop, .modal .close, .modal .btn").on("click", function() {
119				jQuery(".modal iframe").each(function() {
120					var thisModal = jQuery(this);
121					thisModal.attr("src", thisModal.attr("src"));
122				});
123			});
124			
125			// REPLACE COMMENTS REPLY TITLE HTML
126			if (body.hasClass('single-post')) {
127				var replyTitle = jQuery('#respond').find('h3');
128				var originalText = jQuery('#respond').find('h3').html();
129				
130				replyTitle.addClass('spb-heading');
131				replyTitle.html('<span>'+originalText+'</span>');
132			}
133			
134			// SMOOTH SCROLL LINKS
135			jQuery('a.smooth-scroll-link').on('click', function(e) {
136				
137				var linkHref = jQuery(this).attr('href');
138								
139				if (linkHref.indexOf('#') === 0) {
140					var spacerHeight = jQuery(linkHref).height(),
141						headerHeight = 0;
142						
143					if (jQuery('.sticky-header').length > 0) {
144						headerHeight = jQuery('.sticky-header').height();
145					}
146					if (jQuery('#wpadminbar').length > 0) {
147						headerHeight = headerHeight + 28;
148					}
149					
150					jQuery('html, body').stop().animate({
151						scrollTop: jQuery(linkHref).offset().top + spacerHeight - headerHeight - 10
152					}, 1000, 'easeInOutExpo');
153					
154					e.preventDefault();
155					
156				} else {
157					return e;
158				}
159				
160			});
161			
162			// STICKY SIDEBAR
163			if (!isMobileAlt && sfIncluded.hasClass('stickysidebars') && jQuery('.sidebar').length > 0) {
164				page.stickySidebars();
165			}
166			
167			// PORTFOLIO STICKY SIDEBAR	
168			if (!isMobileAlt && jQuery('.sticky-details').length > 0) {
169				//portfolio.stickyDetails();
170			}
171			
172			// BUDDYPRESS ACTIVITY LINK CLICK
173			jQuery('.activity-time-since,.bp-secondary-action').on('click', function(e) {
174				e.preventDefault();
175				jQuery('.viewer').css('display', 'none');
176				window.location = jQuery(this).attr('href');
177			});
178		},
179		fitVids: function() {
180			//jQuery('.portfolio-items:not(.carousel-items),.blog-items:not(.carousel-items),article.type-portfolio,article.type-post,article.type-team,.spb_video_widget,.infocus-item,.recent-posts,.full-width-detail,#activity-stream').fitVids();
181		},
182		niceScroll: function() {
183			jQuery("html").niceScroll({	
184				scrollspeed: 50,
185				zindex: 999,
186				mousescrollstep: 30,
187				horizrailenabled: false
188			});
189		},
190		fancyHeading: function() {
191			jQuery('body,html').scrollTop(0);
192			if (jQuery('.fancy-heading').hasClass('fancy-image')) {
193				jQuery('.fancy-heading').parallax("50%", 0.5);
194			}
195			setTimeout(function() {
196				jQuery('.fancy-heading').slideDown({
197					duration: 600, 
198					easing: "easeInOutQuart" 
199				});		
200			}, 200);
201			$window.scroll(function() {
202				if ($window.width() > 767) {
203					var scrollTop = $window.scrollTop();
204					var isSafari = deviceAgent.indexOf("safari") !=-1 && deviceAgent.indexOf("chrome") == -1;
205					
206					if (!(isSafari)) {
207						
208						var paddingBottom = (120 - scrollTop / 5 > 0) ? 120 - scrollTop / 5 : 0,
209							letterSpacing = (scrollTop / 35 < 10) ? scrollTop / 35 : 10;
210						
211						jQuery(".fancy-heading").css("opacity", 1 - scrollTop / 300).css('padding-bottom', paddingBottom + "px");
212						jQuery(".fancy-heading .heading-text").css("opacity", 1 - scrollTop / 180).css("letter-spacing", letterSpacing);
213					}
214				}
215			});
216		},
217		fullscreenMedia: function() {
218			var fullscreenMedia = jQuery('.full-width-display-wrap'),
219				container = jQuery('#page-wrap'),
220				mediaOffset = container.offset().left,
221				windowWidth = $window.width();
222
223			if (windowWidth > 768) {
224				mediaOffset = mediaOffset;
225			} else {
226				mediaOffset = 24;
227			}
228			
229			if (jQuery('#container').hasClass('boxed-layout')) {
230				windowWidth = jQuery('#container').width() + 2;
231				
232				if (windowWidth > 1026) {
233					mediaOffset = 45;
234				} else if (windowWidth > 770) {
235					mediaOffset = 30;
236				} else if (windowWidth > 482) {
237					mediaOffset = 24;
238				} else {
239					mediaOffset = 7;
240				}
241			}
242						
243			fullscreenMedia.find('figure').css('width', windowWidth).css('margin-left', '-' + mediaOffset + 'px');
244			
245			if (!fullscreenMedia.find('figure').is(":visible")) {
246				fullscreenMedia.find('figure').slideDown(500);
247			} else {
248				var slider = fullscreenMedia.find('.item-slider').data('flexslider');
249				if (slider) {
250				slider.resize();
251				}
252			}
253			
254			if (fullscreenMedia.find('.portfolio-options-bar').length > 0) {
255				setTimeout(function() {
256					fullscreenMedia.find('.portfolio-options-bar').animate({
257						opacity: 1
258					}, 200);				
259				}, 700);
260			}
261		},
262		fullWidthArea: function() {
263			var fullWidthArea = jQuery('.full-width-area'),
264				container = jQuery('#page-wrap'),
265				mediaOffset = container.offset().left,
266				windowWidth = $window.width();
267
268			if (windowWidth > 768) {
269				mediaOffset = mediaOffset;
270			} else {
271				mediaOffset = 24;
272			}
273			
274			if (jQuery('#container').hasClass('boxed-layout')) {
275				windowWidth = jQuery('#container').width() + 2;
276				
277				if (windowWidth > 1026) {
278					mediaOffset = 45;
279				} else if (windowWidth > 770) {
280					mediaOffset = 30;
281				} else if (windowWidth > 482) {
282					mediaOffset = 24;
283				} else {
284					mediaOffset = 7;
285				}
286			}
287						
288			fullWidthArea.each( function() {
289				jQuery(this).css('width', windowWidth).css('margin-left', '-' + mediaOffset + 'px');
290			});
291		},
292		onePageNav: function() {
293				
294			var onePageNav = jQuery('#one-page-nav'),
295				onePageNavList = onePageNav.find('ul'),
296				onePageNavItems = "",
297				mainContent = jQuery('.page-content');
298			
299			mainContent.find('.blank_spacer').each(function() {
300				var linkID = jQuery(this).attr('id'),
301					linkName = jQuery(this).data('spacername');
302				
303				if (linkID && linkName.length > 0) {
304					onePageNavItems += '<li><a href="#'+linkID+'" rel="tooltip" data-original-title="'+linkName+'" data-placement="left"><i></i></a></li>';
305				}
306			});
307			
308			if (onePageNavItems.length > 0) {
309				onePageNavList.append(onePageNavItems);	
310				onePageNav.vCenter();
311				setTimeout(function() {
312					onePageNav.stop().animate({
313						'right': '40px',
314						'opacity': 1
315					}, 1000, "easeOutQuart");
316					
317					jQuery('#one-page-nav ul li a').bind('click', function(e) {
318						var anchor = jQuery(this),
319							spacerHeight = jQuery(anchor.attr('href')).height(),
320							headerHeight = 0;
321							
322						if (jQuery('.sticky-header').length > 0) {
323							headerHeight = jQuery('.sticky-header').height();
324						}
325						if (jQuery('#wpadminbar').length > 0) {
326							headerHeight = headerHeight + 28;
327						}
328						
329						jQuery('html, body').stop().animate({
330							scrollTop: jQuery(anchor.attr('href')).offset().top + spacerHeight - headerHeight - 30
331						}, 1000, 'easeInOutExpo');
332						
333						e.preventDefault();
334					});
335					
336					$window.scroll(function () {
337						var currentSection = jQuery('.blank_spacer:in-viewport:first').data('spacername');
338
339						if (onePageNav.is(':visible') && currentSection) {
340							onePageNavList.find('li').removeClass('selected');					
341							onePageNavList.find('li a[data-original-title="'+currentSection+'"]').parent().addClass('selected');
342						}
343					});
344					
345				}, 1000);
346			}
347		},
348		backToTop: function() {
349			var scrollPosition = $window.scrollTop();
350						
351			if (scrollPosition > 300) {
352				jQuery('#back-to-top').stop().animate({
353					'bottom': '10px',
354					'opacity': 1
355				}, 300, "easeOutQuart");
356			} else if (scrollPosition < 300) {
357				jQuery('#back-to-top').stop().animate({
358					'bottom': '-40px',
359					'opacity': 0
360				}, 300, "easeInQuart");
361			}
362		},
363		stickySidebars: function() {
364		
365			var stickyWidget = jQuery('.sticky-widget'),
366				sidebar = stickyWidget.parent(),
367				content = jQuery('.page-content'),
368				offset = 24;
369
370			if (jQuery('.sticky-header').length > 0) {
371				offset = offset + jQuery('.sticky-header').height() > 0 ? jQuery('.sticky-header').height() : jQuery('#header-section').height();
372			}
373			if (jQuery('#wpadminbar').length > 0) {
374				offset = offset + 32;
375			}
376
377			page.initStickyWidget(stickyWidget, sidebar, offset);
378
379			$window.smartresize( function() {
380				jQuery('.inner-page-wrap').stickem().destroy();
381				page.resizeStickyWidget(stickyWidget, sidebar);
382				page.initStickyWidget(stickyWidget, sidebar, offset);
383			});
384
385		},
386		initStickyWidget: function(stickyWidget, sidebar, offset) {
387			jQuery('.inner-page-wrap').stickem({
388				item: '.sticky-widget',
389				container: '.inner-page-wrap',
390				offset: offset + 24,
391				onStick: function() {
392					page.resizeStickyWidget(stickyWidget, sidebar);
393				}
394			});
395		},
396		resizeStickyWidget: function(stickyWidget, sidebar) {
397			var headerHeight = 0,
398				content = jQuery('.page-content'),
399				sidebarHeight = sidebar.find('.sidebar-widget-wrap').height(),
400				contentHeight = content.height();
401
402			if (jQuery('.sticky-header').length > 0) {
403				headerHeight = jQuery('.sticky-header').height() > 0 ? jQuery('.sticky-header').height() : jQuery('#header-section').height();
404			}
405			if (jQuery('#wpadminbar').length > 0) {
406				headerHeight = headerHeight + 32;
407			}
408			stickyWidget.css('width', sidebar.width()).css('top', headerHeight + 30);
409			if (contentHeight > sidebarHeight) {
410				sidebar.css('height', contentHeight);
411			} else {
412				sidebar.css('height', sidebarHeight);
413			}
414		},
415		getViewportHeight: function() {
416			var height = "innerHeight" in window ? window.innerHeight: document.documentElement.offsetHeight; 
417			return height;		
418		},
419		checkIE: function() {
420			// ----------------------------------------------------------
421			// A short snippet for detecting versions of IE in JavaScript
422			// without resorting to user-agent sniffing
423			// ----------------------------------------------------------
424			// If you're not in IE (or IE version is less than 5) then:
425			//     ie === undefined
426			// If you're in IE (>=5) then you can determine which version:
427			//     ie === 7; // IE7
428			// Thus, to detect IE:
429			//     if (ie) {}
430			// And to detect the version:
431			//     ie === 6 // IE6
432			//     ie > 7 // IE8, IE9 ...
433			//     ie < 9 // Anything less than IE9
434			// ----------------------------------------------------------
435			
436			// UPDATE: Now using Live NodeList idea from @jdalton
437			var undef,
438				v = 3,
439				div = document.createElement('div'),
440				all = div.getElementsByTagName('i');
441				
442			while (
443				div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
444				all[0]
445			);
446			
447			return v > 4 ? v : undef;
448		}
449	};
450
451	
452	/////////////////////////////////////////////
453	// SUPER SEARCH
454	/////////////////////////////////////////////
455		
456	var superSearch = {
457		init: function() {
458			
459			var deviceAgent = navigator.userAgent.toLowerCase(),
460				agentID = deviceAgent.match(/(iphone|ipod|ipad|android|iemobile)/);
461			
462			jQuery('.search-go').vCenter();
463			
464			jQuery('.search-options .ss-dropdown').on('click', function(e) {
465				e.preventDefault();
466				
467				var option = jQuery(this),
468					dropdown = option.find( 'ul' );
469								
470				if (agentID) {
471					if (dropdown.hasClass('show-dropdown')) {
472						dropdown.removeClass('show-dropdown');
473					} else {
474						dropdown.addClass('show-dropdown');							
475					}
476				} else {
477					if (dropdown.hasClass('show-dropdown')) {
478						dropdown.css('top', 30);
479						dropdown.removeClass('show-dropdown');
480					} else {
481						dropdown.css('top', -10);
482						dropdown.addClass('show-dropdown');							
483					}
484				}
485			});
486						
487			jQuery('.ss-option').on('click', function(e) {
488				e.preventDefault();
489				
490				var selectedOption = jQuery(this).attr('data-attr_value');
491				var parentOption = jQuery(this).parent().parent().parent();
492								
493				parentOption.find('li').removeClass('selected');
494				jQuery(this).parent().addClass('selected');
495				
496				parentOption.attr('data-attr_value', selectedOption);
497				parentOption.find('span').text(jQuery(this).text());
498			});
499			
500			jQuery('.swift-search-link').on('click', function(e) {
501				e.preventDefault();
502				
503				if (jQuery('#header > div').hasClass('is-sticky')) {
504					jQuery('body,html').animate({scrollTop: 0}, 400);
505					jQuery('body').addClass('header-aux-opening');
506					setTimeout(function() {
507						header.headerAuxShow('super-search');
508					}, 500);
509				} else {
510					header.headerAuxShow('super-search');
511				}
512			});
513
514			jQuery('.super-search-go').on('click', function(e) {
515				e.preventDefault();
516				var parentSearch = jQuery(this).parents('.sf-super-search'),
517					filterURL = superSearch.urlBuilder(parentSearch),
518					homeURL = jQuery(this).attr('data-home_url'),
519					shopURL = jQuery(this).attr('data-shop_url');
520				
521				if (filterURL.indexOf("product_cat") >= 0) {
522				location.href = homeURL + filterURL;
523				} else {
524				location.href = shopURL + filterURL;
525				}
526				
527			});
528			
529			jQuery('.super-search-close').on('click', function(e) {
530				e.preventDefault();
531				header.headerAuxClose();
532			});
533		
534		},
535		urlBuilder: function(searchInstance) {
536			
537			var queryString = "";
538			
539			jQuery(searchInstance).find('.search-options .ss-dropdown').each(function() {
540				
541				var attr = jQuery(this).attr('id');
542				var attrValue = jQuery(this).attr('data-attr_value');
543				if (attrValue !== "") {
544					if (attr === "product_cat") {
545						if (queryString === "") {
546							queryString += "?product_cat=" + attrValue;
547						} else {
548							queryString += "&product_cat=" + attrValue;
549						}
550					} else {
551						if (queryString === "") {
552						queryString += "?filter_" + attr + "=" + attrValue;				
553						} else {
554						queryString += "&filter_" + attr + "=" + attrValue;									
555						}
556					}
557				}
558			});
559			
560			jQuery('.search-options input').each(function() {
561				var attr = jQuery(this).attr('name');
562				var attrValue = jQuery(this).attr('value');
563				if (queryString === "") {
564					queryString += "?"+ attr + "=" + attrValue;				
565				} else {
566					queryString += "&" + attr + "=" + attrValue;									
567				}
568			});
569			
570			return queryString;
571		}
572	};
573	
574	
575	/////////////////////////////////////////////
576	// HEADER
577	/////////////////////////////////////////////
578		
579	var header = {
580		init: function() {
581			
582			var stickyHeaderMobile = !isMobileAlt,
583				lastAjaxSearchValue = "",
584				searchTimer = false;
585			
586			if (sfIncluded.hasClass('sticky-header-mobile')) {
587				stickyHeaderMobile = true;
588			}
589			
590			if (body.hasClass('header-overlay')) {
591				header.headerOverlaySet();
592				$window.smartresize( function() {  
593					header.headerOverlaySet();
594				});
595			}
596									
597			if (body.hasClass('mini-header-enabled') && stickyHeaderMobile) {
598				header.stickyHeaderInit();
599				$window.scroll(function() { 
600					var scrollTop = $window.scrollTop(),
601						stickyHeader = jQuery('.sticky-header'),
602						headerHeight = jQuery('#header-section').height(),
603						headerTop = jQuery('#header-section').offset().top;
604					
605					if (jQuery('#top-bar').length > 0) {
606						headerHeight = headerHeight + jQuery('#top-bar').height();
607					}
608					
609					if (scrollTop >= headerTop + headerHeight + 30) {
610						stickyHeader.addClass('sticky-header-resized');
611					} else if (stickyHeader.hasClass('sticky-header-resized')) {
612						stickyHeader.removeClass('sticky-header-resized');
613					}
614				});	
615			}
616			
617			jQuery('.header-search-link').on('click', function(e) {
618				e.preventDefault();
619				
620				if (jQuery('#header > div').hasClass('is-sticky')) {
621					jQuery('body,html').animate({scrollTop: 0}, 400);
622					jQuery('body').addClass('header-aux-opening');
623					setTimeout(function() {
624						header.headerAuxShow('search');
625					}, 500);
626				} else {
627					header.headerAuxShow('search');
628				}
629			});
630			
631			jQuery('.header-search-link-alt').on('click', function(e) {
632				e.preventDefault();
633				
634				var ajaxSearchWrap = jQuery('.ajax-search-wrap');
635				
636				if (ajaxSearchWrap.is(':visible')) {
637					ajaxSearchWrap.fadeOut(300);
638					setTimeout(function() {
639						jQuery('.ajax-search-results').slideUp(100).empty();
640						jQuery('.ajax-search-form input[name=s]').val('');
641					}, 300);
642				} else {
643					ajaxSearchWrap.fadeIn(300);
644					setTimeout(function() {
645						jQuery('.ajax-search-form input[name=s]').focus();
646						jQuery("#container").bind("click", function(e) {
647							var ajaxSearchWrap = jQuery('.ajax-search-wrap');
648							if (!jQuery(e.target).closest('.ajax-search-wrap').length) {
649								ajaxSearchWrap.fadeOut(300);
650								setTimeout(function() {
651									jQuery('.ajax-search-results').slideUp(100).empty();
652									jQuery('.ajax-search-form input[name=s]').val('');
653								}, 300);
654								jQuery("#container").unbind("click");
655							}
656						});
657					}, 300);
658				}
659				
660			});
661
662			jQuery('.ajax-search-form input[name=s]').on('keyup', function(e) {
663				var searchvalue = e.currentTarget.value;
664
665				clearTimeout(searchTimer);								
666				if (lastAjaxSearchValue != jQuery.trim(searchvalue) && searchvalue.length >= 3) {
667					searchTimer = setTimeout( function() {
668						header.ajaxSearch(e);
669					}, 400);
670				}
671			});
672			
673			jQuery('#header-search-close').on('click', function(e) {
674				e.preventDefault();
675				header.headerAuxClose();
676			});
677			
678			jQuery('#header-search input').on('blur', function() {
679				header.headerAuxClose();
680			});
681			
682			$window.scroll(function() { 
683				var scrollTop = $window.scrollTop();
684				
685				if (scrollTop > 100 && jQuery('body').hasClass('header-aux-open') && !jQuery('body').hasClass('header-aux-opening')) {
686					header.headerAuxClose();
687				}
688			});				
689		},
690		stickyHeaderInit: function() {
691			
692			var spacing = 0;
693			
694			if (jQuery('#wpadminbar').length > 0) {
695				spacing = jQuery('#wpadminbar').height();
696			}
697			
698			if (isMobileAlt && sfIncluded.hasClass('sticky-header-mobile')) {
699				jQuery('.header-wrap').sticky({
700					topSpacing: spacing
701				});
702			} else {
703				jQuery('.sticky-header').sticky({
704					topSpacing: spacing
705				});
706			}
707		},
708		headerOverlaySet: function() {
709			var headerWrapHeight = jQuery('.header-wrap').height();
710									
711			if (jQuery('#main-container').find('#swift-slider').length === 0 && jQuery('#main-container').find('.home-slider-wrap').length === 0 && jQuery('#main-container').find('.page-heading').length === 0) {
712				jQuery('.inner-page-wrap').animate({
713					'padding-top': headerWrapHeight + 30
714				}, 300);
715			} else if (!(jQuery('#main-container').find('#swift-slider').length > 0 || jQuery('#main-container').find('.home-slider-wrap').length > 0)) {
716				if (jQuery('.page-heading').hasClass('fancy-heading')) {
717					jQuery('.page-heading').animate({
718						'padding-top': headerWrapHeight + 110
719					}, 300);
720				} else {
721					jQuery('.page-heading').animate({
722						'padding-top': headerWrapHeight + 35
723					}, 300);
724				}
725			}
726			
727			if (jQuery('#main-container').find('#swift-slider').length > 0 || jQuery('#main-container').find('.home-slider-wrap').length > 0) {
728				if (jQuery('.page-heading').hasClass('fancy-heading')) {
729				jQuery('.page-heading').css('padding-top', 120);
730				} else {
731				jQuery('.page-heading').css('padding-top', 35);
732				}
733			}
734		},
735		headerAuxShow: function(type) {
736			jQuery('body').addClass('header-aux-open');
737			if (type == "search") {
738				if (jQuery('body > #super-search:visible')) {
739					header.headerSuperSearchFadeOut();
740				}
741				if (IEVersion && IEVersion < 9) {
742					jQuery('#header-search').show();
743				} else {
744					jQuery('#header-search').animate({
745						'opacity': 1
746					}, 500).css('z-index', '100');
747				}
748				jQuery('#header-search input').focus();
749			} else if (type == "super-search") {
750				if (jQuery('#header-search:visible')) {
751					header.headerSearchFadeOut();
752				}
753				if (IEVersion && IEVersion < 9) {
754					setTimeout(function() {
755						jQuery('body > #super-search').show();
756					}, 400);
757				} else {
758					setTimeout(function(){
759						jQuery('body > #super-search').animate({
760							'opacity': 1
761						}, 500).css('z-index', '100');
762					}, 400);
763				}
764				jQuery('body').addClass('ss-open');
765			}
766			setTimeout(function() {
767				jQuery('body').removeClass('header-aux-opening');
768			}, 500);			
769		},
770		headerAuxClose: function() {
771			jQuery('body').removeClass('header-aux-open');
772			jQuery('body').addClass('header-aux-closing');
773				header.headerSearchFadeOut();
774				header.headerSuperSearchFadeOut();
775			setTimeout(function() {
776				jQuery('body').removeClass('header-aux-closing');
777			}, 700);
778		},
779		headerSearchFadeOut: function() {
780			if (IEVersion && IEVersion < 9) {
781				jQuery('#header-search').hide();
782			} else {
783				jQuery('#header-search').animate({
784					'opacity': 0
785				}, 500).css('z-index', '');
786			}
787		},
788		headerSuperSearchFadeOut: function() {
789			if (IEVersion && IEVersion < 9) {
790				jQuery('body > #super-search').hide();
791			} else {
792				jQuery('body > #super-search').animate({
793					'opacity': 0
794				}, 500).css('z-index', '');
795			}
796			jQuery('body').removeClass('ss-open');
797		},
798		ajaxSearch: function(e) {			
799			var searchInput = jQuery(e.currentTarget),
800				searchValues = searchInput.parents('form').serialize() + '&action=sf_ajaxsearch',
801				results = jQuery('.ajax-search-results'),
802				loadingIndicator = jQuery('.ajax-search-wrap .ajax-loading');
803						
804			jQuery.ajax({
805				url: ajaxurl,
806				type: "POST",
807				data: searchValues,
808				beforeSend: function() {
809					loadingIndicator.fadeIn(50);
810				},
811				success: function(response) {
812					if (response === 0) {
813						response = "";
814					} else {
815						results.html(response);
816					}
817				},
818				complete: function() {
819					loadingIndicator.fadeOut(200);
820					results.slideDown(400);
821				}
822			});
823		}
824	};
825	
826	
827	/////////////////////////////////////////////
828	// NAVIGATION
829	/////////////////////////////////////////////
830	
831	var nav = {
832		init: function() {
833			
834			// Add parent class to items with sub-menus
835			jQuery("ul.sub-menu").parents('.menu-item').addClass('parent');
836			
837			// Menu parent click function
838			jQuery('.menu li.parent > a').on('click', function(e) {
839			
840				if (jQuery('#container').width() < 1024 || body.hasClass('standard-browser')) {
841					return e;
842				}
843				
844				var directDropdown = jQuery(this).parent().find('ul.sub-menu').first();
845				
846				if (directDropdown.css('opacity') === '1' || directDropdown.css('opacity') === 1) {
847					return e;
848				} else {
849					e.preventDefault();
850				}
851			});
852			
853			var menuTop = 40;
854			var menuTopReset = 80;
855			
856			// Enable hover dropdowns for window size above tablet width
857			jQuery("nav.std-menu").find(".menu li.parent").hoverIntent({
858				over: function() {
859					if (jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) {
860						
861						// Setup menuLeft variable, with main menu value
862						var subMenuWidth = jQuery(this).find('ul.sub-menu').first().outerWidth(true);
863						var mainMenuItemWidth = jQuery(this).outerWidth(true);
864						var menuLeft = '-' + (Math.round(subMenuWidth / 2) - Math.round(mainMenuItemWidth / 2)) + 'px';
865						var menuContainer = jQuery(this).parent().parent();
866												
867						// Check if this is the top bar menu		
868						if (menuContainer.hasClass("top-menu") || menuContainer.parent().hasClass("top-menu")) {
869							if (menuContainer.parent().parent().hasClass("tb-right")) {
870							menuLeft = "";
871							} else {
872							menuLeft = "-1px";
873							}
874							menuTop = 31;
875							menuTopReset = 40;
876						} else if (menuContainer.hasClass("header-menu")) {
877							menuLeft = "-1px";
878							menuTop = 28;
879							menuTopReset = 40;
880						} else if (menuContainer.hasClass("search-nav")) {
881							menuTop = 44;
882							menuTopReset = 64;
883						} else if (jQuery('#header-section').hasClass('header-1') || jQuery('#header-section').hasClass('header-2')) {
884							menuTop = 47;
885							menuTopReset = 67;
886						} else {
887							menuTop = 44;
888							menuTopReset = 64;
889						}
890						
891						// Check if second level dropdown
892						if (jQuery(this).find('ul.sub-menu').first().parent().parent().hasClass("sub-menu")) {
893							menuLeft = jQuery(this).find('ul.sub-menu').first().parent().parent().outerWidth(true) - 2;
894						}
895						
896						jQuery(this).find('ul.sub-menu').first().addClass('show-dropdown').css('top', menuTop);
897					}
898				},
899				out:function() {
900					if (jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) {
901						jQuery(this).find('.sub-menu').first().removeClass('show-dropdown').css('top', menuTopReset);
902					}
903				}
904			});
905			
906			jQuery(".shopping-bag-item").on("mouseenter", function() {
907				
908				var subMenuTop = 44,
909					subMenuTopReset = 64;
910				
911				if (jQuery(this).parent().parent().hasClass("top-menu")) {
912					subMenuTop = 31;
913					subMenuTopReset = 40;
914				} else if (jQuery(this).parent().parent().hasClass("mini-menu")) {
915					subMenuTop = 40;
916					menuTopReset = 60;
917				} else if (jQuery('#header-section').hasClass('header-1') || jQuery('#header-section').hasClass('header-2')) {
918					subMenuTop = 47;
919					menuTopReset = 67;
920				}
921				
922				jQuery(this).find('ul.sub-menu').first().addClass('show-dropdown').css('top', subMenuTop);
923				
924			}).on("mouseleave", function() {
925				if (jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) {
926					jQuery(this).find('ul.sub-menu').first().removeClass('show-dropdown').css('top', 56);
927				}
928			});
929			
930			
931			jQuery('.menu-item').on('click', 'a', function(e) {
932				
933				var isMobile = false;
934				
935				if (jQuery(this).parents('#mobile-menu').length > 0) {
936					isMobile = true;
937				}
938				
939				var linkHref = jQuery(this).attr('href');
940							
941				if (linkHref.indexOf('#') === 0) {
942					var spacerHeight = jQuery(linkHref).height(),
943						headerHeight = 0;
944						
945					if (jQuery('.sticky-header').length > 0) {
946						headerHeight = jQuery('.sticky-header').outerHeight();
947					}
948					if (jQuery('#wpadminbar').length > 0) {
949						headerHeight += jQuery('#wpadminbar').outerHeight();
950					}
951					
952					if (jQuery(linkHref).length > 0) {
953						jQuery('html, body').stop().animate({
954							scrollTop: jQuery(linkHref).offset().top + spacerHeight - headerHeight - 20
955						}, 1000, 'easeInOutExpo');
956					}
957					
958					if (isMobile) {
959						nav.hideMobileMenu();
960					}
961					
962					e.preventDefault();
963				} else {
964					return e;
965				}
966				
967			});
968		
969			// Toggle Mobile Nav show/hide			
970			jQuery('.mobile-menu-show').on('click', function(e) {
971				e.preventDefault();
972				if (body.hasClass('mobile-menu-open')) {
973				nav.hideMobileMenu();
974				} else {
975				nav.showMobileMenu();
976				}
977			});
978			
979			jQuery('.mobile-menu-close').on('click', function(e) {
980				e.preventDefault();
981				nav.hideMobileMenu();
982			});
983		
984			$window.smartresize( function() {  
985				if (jQuery('#container').width() > 767 || body.hasClass('responsive-fixed')) {
986					var menus = jQuery('nav').find('ul.menu');
987					menus.each(function() {
988						jQuery(this).css("display", "");
989					});
990				}
991			});
992			
993			// Set current language to top bar item
994			var currentLanguage = jQuery('li.aux-languages').find('.current-language').html();
995			if (currentLanguage !== "") {
996				jQuery('li.aux-languages > a').html(currentLanguage);
997			}
998			
999			// Change menu active when scroll through sections
1000			nav.currentScrollIndication();
1001			$window.scroll(function () {
1002				nav.currentScrollIndication();
1003			});
1004
1005		},
1006		load: function() {
1007			// Set up Mega Menu
1008			if ((!isMobile || $window.width() > 768) && !sfIncluded.hasClass('disable-megamenu')) {
1009				nav.megaMenu();
1010			}
1011		},
1012		currentScrollIndication: function() {
1013			var adjustment = 0;
1014			
1015			if (body.hasClass('sticky-header-enabled')) {
1016				adjustment = jQuery('.header-wrap').height();
1017			}
1018			
1019			var inview = jQuery('.blank_spacer:in-viewport:first').attr('id'),
1020				menuItems = jQuery('#main-navigation .menu li a'),
1021				link;
1022				
1023			if ( inview !== "" && typeof inview != 'undefined' ) {
1024				link = menuItems.filter('[href="#' + inview + '"]');
1025			}
1026			
1027			menuItems.parent().removeClass('current-scroll-item');
1028			menuItems.parent().parent().find('.current-menu-item').removeClass('indicator-disabled');
1029			
1030			if (typeof inview != 'undefined' && link.length > 0 && !link.hasClass('.current-scroll-item')) {
1031				menuItems.parent().removeClass('current-scroll-item');
1032				menuItems.parent().parent().find('.current-menu-item').addClass('indicator-disabled');
1033				link.parent().addClass('current-scroll-item');
1034			}
1035		},
1036		megaMenu: function() {
1037			jQuery('#main-navigation .menu').dcMegaMenu({
1038				rowItems: '5',
1039				speed: 200,
1040				effect: 'fade',
1041				fullWidth: true
1042			});
1043			
1044			// Set sub-menu position based on menu height
1045			var mainNav = jQuery('#main-navigation'),
1046				mainNavHeight = mainNav.height(),
1047				subMenu = mainNav.find('.sub-container');
1048			
1049			subMenu.each(function() {
1050				jQuery(this).css('top', mainNavHeight);
1051			});
1052		},
1053		showMobileMenu: function() {
1054			body.addClass('mobile-menu-open');
1055			setTimeout(function() {
1056				jQuery('#container').on('click', nav.containerClick);
1057			}, 500);
1058		},
1059		hideMobileMenu: function() {
1060			body.removeClass('mobile-menu-open');
1061			jQuery('#container').off('click', nav.containerClick);
1062		},
1063		containerClick: function() {
1064			body.removeClass('mobile-menu-open');
1065			nav.hideMobileMenu();
1066		}
1067	};
1068	
1069	
1070	/////////////////////////////////////////////
1071	// WOOCOMMERCE FUNCTIONS
1072	/////////////////////////////////////////////
1073	
1074	var woocommerce = {
1075		init: function() {
1076			
1077			// WISHLIST UPDATE
1078			jQuery(document).on('click', '.add_to_wishlist', function(){
1079				 				
1080				jQuery(this).parent().parent().find('.yith-wcwl-wishlistaddedbrowse').show().removeClass("hide").addClass("show");
1081				jQuery(this).hide().addClass("hide").removeClass("show");
1082															
1083			});
1084		
1085			// QUANTITY FUNCTIONS
1086			woocommerce.productQuantityAdjust();
1087		
1088			jQuery('.add_to_cart_button').on('click', function() {
1089				var button = jQuery(this);
1090				var added_text = button.attr("data-added_text");
1091				button.addClass("product-added");
1092				button.find('span').text(added_text);
1093			});
1094						
1095			jQuery('.show-products-link').on('click', function(e) {
1096				e.preventDefault();
1097				var linkHref = jQuery(this).attr('href').replace('?', ''),
1098					currentURL = document.location.href.replace('/page/2', '').replace('/page/3', '').replace('/page/4', '').replace('/page/5', '').replace('/page/6', '').replace('/page/7', '').replace('/page/8', '').replace('/page/9', ''),
1099					currentQuery = document.location.search;
1100				
1101				if (currentQuery.indexOf('?show') >= 0) {				
1102					window.location = jQuery(this).attr('href');
1103				} else if (currentQuery.indexOf('?') >= 0) {
1104					window.location = currentURL + '&' + linkHref;
1105				} else {
1106					window.location = currentURL + '?' + linkHref;
1107				}
1108			});
1109			
1110			jQuery('ul.products li').hover(function() {
1111				var imageOverlay = jQuery(this).find('.image-overlay');
1112				imageOverlay.animate({
1113					top: jQuery(this).height()*-1
1114				}, 400);
1115			}, function() {
1116				var imageOverlay = jQuery(this).find('.image-overlay');
1117				imageOverlay.animate({
1118					top: 0
1119				}, 400);
1120			});
1121			
1122			if (jQuery.fn.imagesLoaded) {
1123				//woocommerce.productSetup();
1124				
1125				$window.smartresize( function() {  
1126				//	woocommerce.productSetup();
1127				});
1128			}
1129			
1130			jQuery('.shipping-calculator-form input').keypress(function(e) {
1131				if(e.which == 10 || e.which == 13) {
1132					jQuery(".update-totals-button button").click();
1133				}
1134			}); 
1135		},
1136		productSetup: function() {
1137			jQuery('ul.products').imagesLoaded(function() {
1138				var captionVisible = jQuery(this).first('li.type-product').find('figure > figcaption').is(":visible");
1139				jQuery('ul.products li.type-product').each(function() {
1140					var productImageHeight = jQuery(this).find('.product-image > img').height();
1141					if (jQuery('#container').width() <= 1024 && captionVisible) {
1142						productImageHeight = productImageHeight + 20;
1143					}
1144					jQuery(this).find('figure').css('padding-bottom', productImageHeight  + 'px');
1145				});
1146			});
1147			
1148		},
1149		variations: function() {
1150			jQuery('.single_variation_wrap').on("show_variation", function() {
1151				if (jQuery('#sf-included').hasClass('has-productzoom')) {
1152					jQuery('.zoomContainer').remove();
1153					setTimeout(function() {
1154						jQuery('.product-slider-image').each(function() {
1155							jQuery(this).data('zoom-image', jQuery(this).parent().find('a.zoom').attr('href'));
1156						});
1157						var currentImage = jQuery('#product-img-slider li:first').find('.product-slider-image');
1158						woocommerce.productZoom(currentImage);
1159						jQuery('#product-img-slider').flexslider(0);
1160					}, 500);
1161				} else {
1162					setTimeout(function() {
1163						jQuery('#product-img-slider').flexslider(0);
1164						var flexViewport = jQuery('#product-img-slider').find('.flex-viewport'),
1165						flexsliderHeight = flexViewport.find('ul.slides').css('height');
1166					}, 500);
1167				}
1168				setTimeout(function() {
1169					// Update lightbox image
1170					jQuery('.product-slider-image').each(function() {
1171						var zoomImage = jQuery(this).attr('src');
1172						jQuery(this).parent().find('a.zoom').attr('href', zoomImage).attr('data-o_href', '').attr('data-o_href', zoomImage);
1173						lightbox.destroy();
1174						lightbox.init();
1175					});
1176				}, 600);
1177			});
1178		},
1179		productZoom: function(zoomObject) {
1180			
1181			if ( isMobileAlt ) {
1182				return;
1183			}
1184			
1185			zoomObject.elevateZoom({
1186				zoomType: "inner",
1187				cursor: "crosshair",
1188				zoomParent: '#product-img-slider',
1189				responsive: true,
1190				zoomWindowFadeIn: 500,
1191				zoomWindowFadeOut: 750
1192			});
1193		},
1194		productQuantityAdjust: function() {
1195		
1196			// Increase
1197			jQuery(document).on('click', '.qty-plus', function(e) {
1198				e.preventDefault();
1199				var quantityInput = jQuery(this).parents('.quantity').find('input.qty'),
1200					step = parseInt(quantityInput.attr('step'), 10),
1201					newValue = parseInt(quantityInput.val(), 10) + step,
1202					maxValue = parseInt(quantityInput.attr('max'), 10);
1203
1204				if (!maxValue) {
1205					maxValue = 9999999999;
1206				}
1207				
1208				if ( newValue <= maxValue ) {
1209					quantityInput.val(newValue);
1210					quantityInput.change();
1211				}
1212			});
1213
1214			// Decrease
1215			jQuery(document).on('click', '.qty-minus', function(e) {
1216				e.preventDefault();
1217				var quantityInput = jQuery(this).parents('.quantity').find('input.qty'),
1218					step = parseInt(quantityInput.attr('step'), 10),
1219					newValue = parseInt(quantityInput.val(), 10) - step,
1220					minValue = parseInt(quantityInput.attr('min'), 10);
1221					
1222				if (!minValue) {
1223					minValue = 1;
1224				}
1225				
1226				if ( newValue >= minValue ) {
1227					quantityInput.val(newValue);
1228					quantityInput.change();
1229				}
1230			});
1231
1232		}
1233	};
1234	
1235	/////////////////////////////////////////////
1236	// FLEXSLIDER FUNCTION
1237	/////////////////////////////////////////////
1238	
1239	var flexSlider = {
1240		init: function() {
1241			
1242			var hasProductZoom = false;
1243			
1244			if (jQuery('#sf-included').hasClass('has-productzoom') && !body.hasClass('mobile-browser')) {
1245				hasProductZoom = true;
1246			}
1247			
1248			if(jQuery('.recent-posts').length > 0) {
1249				flexSlider.thumb();
1250			}
1251			
1252			if (jQuery('#product-img-nav ul.slides li').length > 1) {
1253				jQuery('#product-img-nav').flexslider({
1254					animation: "slide",
1255					directionNav: false,
1256					controlNav: false,
1257					animationLoop: false,
1258					slideshow: false,
1259					itemWidth: 70,
1260					itemMargin: 30,
1261					asNavFor: '#product-img-slider'
1262				});
1263			} else {
1264				jQuery('#product-img-nav').css('display', 'none');
1265			}
1266			
1267			var currentImage = "";
1268			
1269			jQuery('#product-img-slider').flexslider({
1270				animation: "slide",
1271				controlNav: false,
1272				smoothHeight: true,
1273				animationLoop: false,
1274				slideshow: sliderAuto,	//Boolean: Animate slider automatically
1275				slideshowSpeed: sliderSlideSpeed,           //Integer: Set the speed of the slideshow cycling, in milliseconds
1276				animationDuration: sliderAnimSpeed,         //Integer: Set the speed of animations, in milliseconds
1277				sync: "#product-img-nav",
1278				start: function(productSlider) {
1279					if (hasProductZoom) {
1280						if (productSlider.slides) {
1281							currentImage = productSlider.slides.eq(productSlider.currentSlide).find('.product-slider-image');
1282							woocommerce.productZoom(currentImage);
1283						} else {
1284							currentImage = jQuery('#product-img-slider').find('.product-slider-image');
1285							woocommerce.productZoom(currentImage);
1286						}
1287					}
1288				},
1289				before: function() {
1290					if (hasProductZoom) {
1291						jQuery('.zoomContainer').remove();
1292					}
1293				},
1294				after: function(productSlider) {
1295					if (hasProductZoom) {
1296						currentImage = productSlider.slides.eq(productSlider.currentSlide).find('.product-slider-image');
1297						woocommerce.productZoom(currentImage);
1298					}
1299				}
1300			});
1301			
1302			var flexUseCSS = true;
1303			
1304			if (isMobileAlt) {
1305				flexUseCSS = false;
1306			}
1307					
1308			jQuery('.item-slider').flexslider({
1309				useCSS: flexUseCSS,
1310				animation: "slide",              //String: Select your animation type, "fade" or "slide"
1311				slideDirection: "horizontal",   //String: Select the sliding direction, "horizontal" or "vertical"
1312				slideshow: sliderAuto,	//Boolean: Animate slider automatically
1313				slideshowSpeed: sliderSlideSpeed,           //Integer: Set the speed of the slideshow cycling, in milliseconds
1314				animationDuration: sliderAnimSpeed,         //Integer: Set the speed of animations, in milliseconds
1315				smoothHeight: true,         
1316				directionNav: true,             //Boolean: Create navigation for previous/next navigation? (true/false)
1317				controlNav: true,               //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage
1318				keyboardNav: false,              //Boolean: Allow slider navigating via keyboard left/right keys
1319				mousewheel: false,              //Boolean: Allow slider navigating via mousewheel
1320				prevText: "Prev",           //String: Set the text for the "previous" directionNav item
1321				nextText: "Next",               //String: Set the text for the "next" directionNav item
1322				pausePlay: true,               //Boolean: Create pause/play dynamic element
1323				pauseText: '',             //String: Set the text for the "pause" pausePlay item
1324				playText: '',               //String: Set the text for the "play" pausePlay item
1325				randomize: false,               //Boolean: Randomize slide order
1326				slideToStart: 0,                //Integer: The slide that the slider should start on. Array notation (0 = first slide)
1327				animationLoop: true,            //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
1328				pauseOnAction: true,            //Boolean: Pause the slideshow when interacting with control elements, highly recommended.
1329				pauseOnHover: false,            //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering
1330				controlsContainer: "",          //Selector: Declare which container the navigation elements should be appended too. Default container is the flexSlider element. Example use would be ".flexslider-container", "#container", etc. If the given element is not found, the default action will be taken.
1331				manualControls: "",             //Selector: Declare custom control navigation. Example would be ".flex-control-nav li" or "#tabs-nav li img", etc. The number of elements in your controlNav should match the number of slides/tabs.
1332				start: function(){},            //Callback: function(slider) - Fires when the slider loads the first slide
1333				before: function(){},           //Callback: function(slider) - Fires asynchronously with each slider animation
1334				after: function(){},      //Callback: function(slider) - Fires after each slider animation completes
1335				end: function(){}               //Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous)
1336			});
1337			jQuery('#swift-slider').flexslider({
1338				animation: "slide",              //String: Select your animation type, "fade" or "slide"
1339				slideDirection: "horizontal",   //String: Select the sliding direction, "horizontal" or "vertical"
1340				slideshow: sliderAuto,	//Boolean: Animate slider automatically
1341				slideshowSpeed: sliderSlideSpeed,           //Integer: Set the speed of the slideshow cycling, in milliseconds
1342				animationDuration: sliderAnimSpeed,         //Integer: Set the speed of animations, in milliseconds
1343				directionNav: true,             //Boolean: Create navigation for previous/next navigation? (true/false)
1344				controlNav: false,               //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage
1345				keyboardNav: false,              //Boolean: Allow slider navigating via keyboard left/right keys
1346				mousewheel: false,              //Boolean: Allow slider navigating via mousewheel
1347				prevText: "Prev",           //String: Set the text for the "previous" directionNav item
1348				nextText: "Next",               //String: Set the text for the "next" directionNav item
1349				pausePlay: false,               //Boolean: Create pause/play dynamic element
1350				animationLoop: true,            //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
1351				pauseOnAction: true,            //Boolean: Pause the slideshow when interacting with control elements, highly recommended.
1352				pauseOnHover: true,
1353				start: function(postsSlider) {
1354					jQuery('.swift-slider-loading').fadeOut(200);
1355					if (postsSlider.slides) {
1356						postsSlider.slides.eq(postsSlider.currentSlide-1).addClass('flex-active-slide'); 
1357						if (postsSlider.slides.eq(postsSlider.currentSlide).has('.flex-caption-large')) {
1358							var chart = postsSlider.slides.eq(postsSlider.currentSlide).find('.fw-chart');
1359							if (body.hasClass("browser-ie")) {
1360							chart = postsSlider.slides.eq(postsSlider.currentSlide).find('.chart');
1361							}
1362							chart.each( function() {
1363								var countValue = parseInt(jQuery(this).attr('data-count'), 10);
1364								jQuery(this).data('easyPieChart').update(80);
1365								jQuery(this).find('span').replaceWith("<span>0</span>");
1366								jQuery(this).find('span').animateNumber(countValue);
1367							});
1368						}
1369						postsSlider.slides.eq(postsSlider.currentSlide).find('.comment-chart:not(.fw-chart) span').replaceWith("<span>0</span>");
1370					}
1371				},
1372				before: function(postsSlider) {
1373					if (postsSlider.slides) {
1374						if (postsSlider.slides.eq(postsSlider.currentSlide-1).has('.flex-caption-large')) {
1375							var chart = postsSlider.slides.eq(postsSlider.currentSlide).find('.fw-chart');
1376							if (body.hasClass("browser-ie")) {
1377							chart = postsSlider.slides.eq(postsSlider.currentSlide).find('.chart');
1378							}
1379							chart.each( function() {
1380								jQuery(this).data('easyPieChart').update(0);
1381								jQuery(this).find('span').replaceWith("<span>0</span>");
1382							});
1383						}
1384						setTimeout( function() {
1385							postsSlider.slides.eq(postsSlider.currentSlide).addClass('flex-active-slide');
1386							if (postsSlider.slides.eq(postsSlider.currentSlide).has('.flex-caption-large')) {
1387								var chart = postsSlider.slides.eq(postsSlider.currentSlide).find('.fw-chart');
1388								if (body.hasClass("browser-ie")) {
1389								chart = postsSlider.slides.eq(postsSlider.currentSlide).find('.chart');
1390								}
1391								chart.each( function() {
1392									var countValue = parseInt(jQuery(this).attr('data-count'), 10);
1393									jQuery(this).data('easyPieChart').update(80);
1394									jQuery(this).find('span').animateNumber(countValue);
1395								});
1396							}
1397						}, 1000);
1398					}
1399				}
1400			});
1401			jQuery('.content-slider').each(function() {
1402				var slider = jQuery(this),
1403					autoplay = ((slider.attr('data-autoplay') === "yes") ? true : false);
1404				
1405				slider.flexslider({
1406					animation: "fade",              //String: Select your animation type, "fade" or "slide"
1407					slideshow: autoplay,	//Boolean: Animate slider automatically
1408					slideshowSpeed: sliderSlideSpeed,           //Integer: Set the speed of the slideshow cycling, in milliseconds
1409					animationDuration: sliderAnimSpeed,         //Integer: Set the speed of animations, in milliseconds
1410					smoothHeight: true,         
1411					directionNav: true,             //Boolean: Create navigation for previous/next navigation? (true/false)
1412					controlNav: false,               //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage
1413					pauseOnHover: true,
1414					start: function() {}
1415				});
1416			});
1417						
1418			// LOAD THE LOVE-IT CHARTS
1419			jQuery('#swift-slider li').each( function() {
1420				jQuery(this).find('.chart').each( function() {
1421					jQuery(this).easyPieChart({
1422						animate: 1000,
1423						size: 70,
1424						barColor: jQuery(this).attr('data-barcolor'),
1425						trackColor: 'transparent',
1426						scaleColor: false
1427					});
1428					jQuery(this).find('span').replaceWith("<span>0</span>");
1429				});
1430			});
1431			
1432			// CAPTION HOVER ADD/REMOVE CLASSES
1433			jQuery('#swift-slider li').hover(function() {
1434				jQuery(this).find('.flex-caption-details').removeClass('closing');
1435				jQuery(this).find('.flex-caption-details').addClass('open');
1436			}, function() {
1437				jQuery(this).find('.flex-caption-details').addClass('closing');
1438				jQuery(this).find('.flex-caption-details').removeClass('open');
1439			});
1440						
1441			// CAPTION TRANSITION LISTENERS
1442			jQuery('.caption-details-inner').on('transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd', function() {
1443				var chart = jQuery(this).find('.chart');
1444				if (jQuery(this).parent().hasClass('closing')) {
1445					chart.each( function() {
1446						jQuery(this).data('easyPieChart').update(0);
1447						jQuery(this).find('span').replaceWith("<span>0</span>");
1448					});
1449					jQuery(this).parent().removeClass('closing');
1450				} else if (jQuery(this).parent().hasClass('open')) {
1451					chart.each( function() {
1452						var countValue = parseInt(jQuery(this).attr('data-count'), 10);
1453						jQuery(this).data('easyPieChart').update(80);
1454						jQuery(this).find('span').animateNumber(countValue);
1455					});
1456				}
1457			});
1458		},
1459		thumb: function() {
1460			jQuery('.thumb-slider').flexslider({
1461				animation: "fade",              //String: Select your animation type, "fade" or "slide"
1462				slideDirection: "horizontal",   //String: Select the sliding direction, "horizontal" or "vertical"
1463				slideshow: sliderAuto,	//Boolean: Animate slider automatically
1464				slideshowSpeed: sliderSlideSpeed,           //Integer: Set the speed of the slideshow cycling, in milliseconds
1465				animationDuration: sliderAnimSpeed,         //Integer: Set the speed of animations, in milliseconds
1466				directionNav: true,             //Boolean: Create navigation for previous/next navigation? (true/false)
1467				controlNav: false,               //Boolean: Create navigation for paging control of each slide? Note: Leave true for manualControls usage
1468				keyboardNav: false,              //Boolean: Allow slider navigating via keyboard left/right keys
1469				smoothHeight: true
1470			});
1471		},
1472		gallery: function() {
1473			
1474			jQuery('.spb_gallery_widget').each(function() {
1475				
1476				var gallerySlider = jQuery(this).find('.gallery-slider'),
1477					galleryNav = jQuery(this).find('.gallery-nav'),
1478					galleryAuto = gallerySlider.data('autoplay');
1479				
1480				if (galleryAuto === "yes") {
1481					galleryAuto = true;
1482				} else {
1483					galleryAuto = false;
1484				}
1485								
1486				galleryNav.flexslider({
1487					animation: "slide",
1488					directionNav: true,
1489					controlNav: false,
1490					animationLoop: false,
1491					slideshow: false,
1492					itemWidth: 100,
1493					itemMargin: 30, 
1494					asNavFor: gallerySlider
1495				});
1496				
1497				gallerySlider.flexslider({
1498					animation: gallerySlider.data('transition'),
1499					slideshow: galleryAuto,
1500					smoothHeight: true,
1501					slideshowSpeed: sliderSlideSpeed,           //Integer: Set the speed of the slideshow cycling, in milliseconds
1502					animationDuration: sliderAnimSpeed,         //Integer: Set the speed of animations, in milliseconds
1503					controlNav: false,
1504					animationLoop: galleryAuto,
1505					sync: galleryNav
1506				});
1507				
1508			});
1509			
1510		}
1511	};
1512	
1513	/////////////////////////////////////////////
1514	// PORTFOLIO
1515	/////////////////////////////////////////////
1516	
1517	var portfolioContainer = jQuery('.portfolio-wrap').find('.filterable-items');
1518	
1519	var portfolio = {
1520		init: function() {
1521			
1522			if (portfolioContainer.hasClass('masonry-items')) {
1523				portfolio.masonrySetup();
1524			} else {
1525				portfolio.standardSetup();
1526			}
1527						
1528			// PORTFOLIO WINDOW RESIZE
1529			$window.smartresize( function() {  
1530				portfolio.windowResized();
1531			});
1532			
1533			// Enable filter options on when there are items from that skill
1534			jQuery('.filtering li').each( function() {
1535				var itemCount = 0;
1536				var filter = jQuery(this),
1537					filterName = jQuery(this).find('a').attr('class'),
1538					portfolioItems = jQuery(this).parent().parent().parent().parent().find('.filterable-items');
1539				
1540				portfolioItems.find('.portfolio-item').each( function() {
1541					if ( jQuery(this).hasClass(filterName) ) {
1542						filter.addClass('has-items');
1543						itemCount++;
1544					}
1545				});
1546				
1547				if (jQuery(this).hasClass('all')) {
1548					itemCount = portfolioItems.children('li').length;
1549					jQuery(this).find('.item-count').text(itemCount);
1550				} else {
1551					jQuery(this).find('.item-count').text(itemCount);
1552				}
1553			}).parents('.portfolio-filter-tabs').animate({
1554				opacity: 1
1555			}, 400);
1556	
1557			// filter items when filter link is clicked
1558			jQuery('.filtering li').on('click', 'a', function(e) {
1559				e.preventDefault();
1560				jQuery(this).parent().parent().find('li').removeClass('selected');
1561				jQuery(this).parent().addClass('selected');
1562				var selector = jQuery(this).data('filter');
1563				var portfolioItems = jQuery(this).parent().parent().parent().parent().parent().find('.filterable-items');
1564				portfolioItems.isotope({ filter: selector });	
1565			});  
1566			
1567			jQuery('.filter-wrap > a').on('click', function(e) {
1568				e.preventDefault();
1569				jQuery(this).parent().find('.filter-slide-wrap').slideToggle();
1570			});
1571		},
1572		standardSetup: function() {
1573			// SET ITEM HEIGHTS
1574			portfolioContainer.imagesLoaded(function () {
1575				portfolio.setItemHeight();
1576				flexSlider.thumb();
1577				portfolioContainer.animate({opacity: 1}, 800);
1578				portfolioContainer.isotope({
1579					animationEngine: 'best-available',
1580					animationOptions: {
1581						duration: 300,
1582						easing: 'easeInOutQuad',
1583						queue: false
1584					},
1585					resizable: true,
1586					layoutMode: 'fitRows'
1587				});
1588				portfolioContainer.isotope("layout");
1589			});
1590		},
1591		masonrySetup: function() {
1592			//portfolioContainer.fitVids();
1593			portfolioContainer.imagesLoaded(function () {
1594				flexSlider.thumb();
1595				portfolioContainer.animate({opacity: 1}, 800);
1596				portfolioContainer.isotope({
1597					itemSelector : '.portfolio-item',
1598					animationEngine: 'best-available',
1599					animationOptions: {
1600						duration: 300,
1601						easing: 'easeInOutQuad',
1602						queue: false
1603					},
1604					resizable: true
1605				});
1606				
1607			});
1608		},
1609		setItemHeight: function() {
1610			if (!portfolioContainer.hasClass('masonry-items')) {
1611				portfolioContainer.children().css('min-height','0');
1612				portfolioContainer.equalHeights();
1613			}
1614		},
1615		windowResized: function() {
1616			if (!portfolioContainer.hasClass('masonry-items')) {
1617				portfolio.setItemHeight();
1618			}
1619			if (portfolioContainer.hasClass('full-width-area')) {
1620				setTimeout(function () {
1621					portfolioContainer.isotope("layout");
1622				}, 500);
1623			} else {
1624				portfolioContainer.isotope("layout");
1625			}
1626		},
1627		portfolioShowcaseInit: function() {
1628			flexSlider.thumb();
1629			portfolio.portfolioShowcaseWrap();
1630			portfolio.portfolioShowcaseItems();
1631			$window.smartresize( function() {
1632				portfolio.portfolioShowcaseWrap();
1633				portfolio.portfolioShowcaseItems();
1634			});
1635		},
1636		portfolioShowcaseWrap: function() {
1637			var portfolioShowcaseWrap = jQuery('.portfolio-showcase-wrap'),
1638				container = jQuery('#page-wrap'),
1639				mediaOffset = container.offset().left,
1640				windowWidth = $window.width() + 2;
1641		
1642			if (windowWidth > 768) {
1643				mediaOffset = mediaOffset - 15;
1644			} else {
1645				mediaOffset = 7;
1646			}
1647			
1648			if (jQuery('#container').hasClass('boxed-layout')) {
1649				windowWidth = jQuery('#container').width() + 2;
1650				
1651				if (windowWidth > 1026) {
1652					mediaOffset = 30;
1653				} else if (windowWidth > 770) {
1654					mediaOffset = 17;
1655				} else if (windowWidth > 482) {
1656					mediaOffset = 11;
1657				} else {
1658					mediaOffset = 7;
1659				}
1660			}
1661									
1662			portfolioShowcaseWrap.css('width', windowWidth);
1663			portfolioShowcaseWrap.css('margin-left', '-' + mediaOffset + 'px');
1664			portfolioShowcaseWrap.animate({opacity: 1}, 600);
1665		},
1666		portfolioShowcaseItems: function() {
1667			jQuery('.portfolio-showcase-wrap').each(function() {
1668				
1669				var contWidth = $window.width();
1670				
1671				if (jQuery('#container').hasClass('boxed-layout')) {
1672					contWidth = jQuery('#container').width();
1673				}
1674				
1675				var thisShowcase = jQuery(this),
1676					columns = thisShowcase.find('.portfolio-showcase-items').data('columns'),
1677					windowWidth = contWidth + 2,
1678					itemWidth = Math.floor(windowWidth / columns),
1679					maximisedWidth = Math.floor(windowWidth * 40 / 100),
1680					reducedWidth = Math.floor(windowWidth / 5),
1681					deselectedLeft = (itemWidth / 2 - maximisedWidth / 2) / 0.75,
1682					resetLeft = (reducedWidth / 2 - maximisedWidth / 2) / 1.3,
1683					isAnimating = !1,
1684					speed = 300;
1685
1686				var showcaseItem = thisShowcase.find('li.portfolio-item');
1687				
1688				if (columns === 5) {
1689					maximisedWidth = Math.floor(windowWidth * 25 / 100);
1690					reducedWidth = Math.floor(windowWidth / 5.33);
1691					deselectedLeft = (itemWidth / 2 - maximisedWidth / 2) / 0.75;
1692					resetLeft = (reducedWidth / 2 - maximisedWidth / 2) / 1.3;
1693					showcaseItem.css("width", itemWidth);
1694					showcaseItem.css("height", maximisedWidth / 1.5);
1695					showcaseItem.find('.main-image').css("width", maximisedWidth);
1696					showcaseItem.find('.main-image').css("left", resetLeft);
1697					showcaseItem.find('.main-image').css("top", - maximisedWidth / 6);
1698					speed = 200;
1699				} else {
1700					showcaseItem.css("width", itemWidth);
1701					showcaseItem.css("height", maximisedWidth / 2);
1702					showcaseItem.find('.main-image').css("width", maximisedWidth);
1703					showcaseItem.find('.main-image').css("left", resetLeft);
1704				}
1705							
1706				showcaseItem.each(function () {
1707					if (windowWidth > 768) {
1708						jQuery(this).mouseenter(function () {
1709							if (!isAnimating) {
1710								isAnimating = !0;
1711								jQuery(this).removeClass("deselected-item");
1712								thisShowcase.find(".deselected-item").stop().animate({
1713									width: reducedWidth
1714								}, speed);
1715								thisShowcase.find(".deselected-item").find(".main-image").stop().animate({
1716									left: deselectedLeft
1717								}, speed);
1718								jQuery(this).find(".main-image").stop().animate({
1719									left: 0
1720								}, speed);
1721								jQuery(this).stop().animate({
1722									width: maximisedWidth
1723								}, speed + 1, function () {
1724									jQuery(this).find(".item-info").stop().show();
1725									jQuery(this).find(".item-info").stop().animate({
1726										bottom: 0
1727									}, speed, "easeInOutQuart");
1728								});
1729							}
1730						});
1731						jQuery(this).mouseleave(function () {
1732							if (isAnimating) {
1733								isAnimating = !1;
1734								jQuery(this).addClass("deselected-item");
1735								thisShowcase.find(".portfolio-item").stop().animate({
1736									width: itemWidth
1737								}, speed);
1738								thisShowcase.find(".portfolio-item .main-image").stop().animate({
1739									left: resetLeft
1740								}, speed);
1741								jQuery(this).find(".item-info").stop().animate({
1742									bottom: -80
1743								}, speed, function () {
1744									jQuery(this).find(".item-info").stop().hide();
1745								});
1746							}
1747						});
1748					}
1749				});
1750			});			
1751		},
1752		stickyDetails: function() {
1753			
1754			var offset = 0,
1755				navSelectorElement = '.media-wrap',
1756				footerOffset = 160;
1757			
1758			if (jQuery('.page-heading').length > 0) {
1759				offset += jQuery('.page-heading').outerHeight(true);
1760			}
1761			
1762			if (jQuery('.inner-page-wrap').hasClass('portfolio-type-standard')) {
1763				offset += 130;
1764			}
1765			
1766			if (jQuery('.related-projects').length > 0) {
1767				footerOffset = 520;
1768			}
1769			
1770			jQuery('.sticky-details').stickySidebar({
1771				headerSelector: '.header-wrap',
1772				navSelector: navSelectorElement,
1773				contentSelector: '.article-body-wrap',
1774				footerSelector: '#footer-wrap',
1775				sidebarTopMargin: 0,
1776				footerThreshold: footerOffset,
1777				offset: offset
1778			});
1779			
1780			jQuery('.sticky-details').css('max-width', jQuery('.sticky-details').outerWidth(true));
1781			
1782			portfolio.stickyDetailsScroll();
1783			$window.scroll(function() { 
1784				portfolio.stickyDetailsScroll();
1785			});
1786		},
1787		stickyDetailsScroll: function() {
1788			
1789			var contentElement = jQuery('.article-body-wrap');
1790			
1791			if (jQuery('.inner-page-wrap').hasClass('portfolio-type-fw-media')) {
1792				contentElement = jQuery('.portfolio-detail-description');
1793			}
1794			
1795			if (jQuery('.sticky-details').hasClass('sticky')) {
1796				jQuery('.sticky-details').css('margin-left', contentElement.outerWidth(true));
1797			} else {
1798				jQuery('.sticky-details').css('margin-left', 0);			
1799			}
1800		},
1801	};
1802	
1803	
1804	/////////////////////////////////////////////
1805	// BLOG
1806	/////////////////////////////////////////////
1807	
1808	var blogItems = jQuery('.blog-wrap').find('.blog-items');
1809	
1810	var blog = {
1811		init: function() {
1812		
1813			// BLOG ITEM SETUP
1814			if (blogItems.hasClass('masonry-items')) {
1815				blog.masonryBlog();
1816			} else {
1817				flexSlider.thumb();
1818			}
1819			
1820			
1821			// BLOG AUX SLIDEOUT
1822			jQuery('.blog-slideout-trigger').on('click', function(e) {
1823				e.preventDefault();
1824				
1825				// VARIABLES
1826				var blogWrap = jQuery(this).parent().parent().parent().parent();
1827				var filterPanel = blogWrap.find('.filter-wrap .filter-slide-wrap');
1828				var auxType = jQuery(this).attr('data-aux');
1829								
1830				// ADD COLUMN SIZE AND REMOVE BRACKETS FROM COUNT
1831				blogWrap.find('.aux-list li').addClass('col-sm-2');
1832				blogWrap.find('.aux-list li a span').each(function() {
1833					jQuery(this).html(jQuery(this).html().replace("(","").replace(")",""));
1834				});
1835				
1836				// IF SELECTING AN OPTION THAT IS OPEN, CLOSE THE PANEL
1837				if (jQuery(this).parent().hasClass('selected') && !filterPanel.is(':animated')) {
1838					blogWrap.find('.blog-aux-options li').removeClass('selected');
1839					filterPanel.slideUp(400);
1840					return;
1841				}
1842				
1843				// AUX BUTTON SELECTED STATE
1844				blogWrap.find('.blog-aux-options li').removeClass('selected');	
1845				jQuery(this).parent().addClass('selected');
1846				
1847				// IF SLIDEOUT IS OPEN
1848				if (filterPanel.is(':visible')) {
1849					
1850					filterPanel.slideUp(400);
1851					setTimeout(function() {
1852						blogWrap.find('.aux-list').css('display', 'none');
1853						blogWrap.find('.aux-'+auxType).css('display', 'block');
1854						filterPanel.slideDown();
1855					}, 600);
1856					
1857				// IF SLIDEOUT IS CLOSED
1858				} else {
1859					
1860					blogWrap.find('.aux-list').css('display', 'none');
1861					blogWrap.find('.aux-'+auxType).css('display', 'block');
1862					filterPanel.slideDown();
1863					
1864				}
1865			});
1866			
1867		},
1868		masonryBlog: function() {
1869			flexSlider.thumb();
1870			if (!(IEVersion && IEVersion < 9)) {
1871				var scrollAnimateElement = new AnimOnScroll( document.getElementById( 'blogGrid' ), {
1872					minDuration : 0.4,
1873					maxDuration : 0.7,
1874					viewportFactor : 0.2
1875				});
1876			}
1877			blogItems.imagesLoaded(function () {
1878				flexSlider.thumb();
1879			});
1880			//blogItems.fitVids();
1881		},
1882		infiniteScroll: function() {
1883			if (!(IEVersion && IEVersion < 9)) {
1884				var infScrollData = jQuery('#inf-scroll-params');
1885				var infiniteScroll = {
1886					loading: {
1887						img: infScrollData.data('loadingimage'),
1888						msgText: infScrollData.data('msgtext'),
1889						finishedMsg: infScrollData.data('finishedmsg')
1890					},
1891					"nextSelector":".pagenavi li.next a",
1892					"navSelector":".pagenavi",
1893					"itemSelector":".blog-item",
1894					"contentSelector":".blog-items:not(.carousel-items)"
1895				};
1896				jQuery( infiniteScroll.contentSelector ).infinitescroll(
1897					infiniteScroll, function() {
1898						if (blogItems.parent().find('.pagination-wrap').hasClass('load-more')) {
1899							jQuery('.load-more-btn').fadeIn(400);
1900						}
1901						lightbox.destroy();
1902						lightbox.init();
1903						blogItems.imagesLoaded(function () {
1904							if (blogItems.hasClass('masonry-items')) {
1905								flexSlider.thumb();
1906								blog.masonryBlog();
1907							} else {
1908								flexSlider.thumb();
1909								//blogItems.fitVids();
1910							}
1911						});
1912					}
1913				);
1914				if (blogItems.parent().find('.pagination-wrap').hasClass('load-more')) {
1915					$window.unbind('.infscr');
1916					jQuery('.load-more-btn').on('click', function(e) {
1917						e.preventDefault();					
1918						jQuery( infiniteScroll.contentSelector ).infinitescroll('retrieve');
1919						jQuery('.load-more-btn').fadeOut(400);
1920					});
1921				}
1922			} else {
1923				jQuery('.pagination-wrap').removeClass('hidden');
1924			}
1925		}
1926	};
1927	
1928	
1929	/////////////////////////////////////////////
1930	// CAROUSEL FUNCTIONS
1931	/////////////////////////////////////////////
1932	
1933	var carouselWidgets = {
1934		init: function() {
1935
1936			// CAROUSELS
1937			var carousel = jQuery('.carousel-items'),
1938				carouselAuto = sfOptionParams.data('carousel-autoplay'),
1939				carouselPSpeed = sfOptionParams.data('carousel-pagespeed'),
1940				carouselSSpeed = sfOptionParams.data('carousel-slidespeed'),
1941				carouselPagination = sfOptionParams.data('carousel-pagination'),
1942				carouselPDirection = 'ltr',
1943				desktopWidth = 1199;
1944
1945			if (body.hasClass('vertical-header')) {
1946				desktopWidth = desktopWidth + jQuery('#header-section').width();
1947			}
1948
1949			if (carouselAuto) {
1950				carouselAuto = true;
1951			} else {
1952				carouselAuto = false;
1953			}
1954			if (carouselPagination) {
1955				carouselPagination = true;
1956			} else {
1957				carouselPagination = false;
1958			}
1959			if (isRTL) {
1960				carouselPDirection = 'rtl';
1961			}
1962
1963			carousel.each(function() {
1964				var carouselInstance = jQuery('#'+jQuery(this).attr('id')),
1965					carouselColumns = parseInt(carouselInstance.attr("data-columns"), 10),
1966					desktopCarouselItems = 4 > carouselColumns ? carouselColumns : 4,
1967					desktopSmallCarouselItems = 3 > carouselColumns ? carouselColumns : 3,
1968					mobileCarouselItems = 1,
1969					carouselAutoplay = carouselAuto;
1970
1971				if (carouselInstance.hasClass('clients-items')) {
1972					mobileCarouselItems = 2;
1973				}
1974				if (carouselInstance.hasClass('testimonials')) {
1975					desktopCarouselItems = 1;
1976					desktopSmallCarouselItems = 1;
1977					mobileCarouselItems = 1;
1978				}
1979				
1980				if ( carouselInstance.data('auto') ) {
1981					carouselAutoplay = true;
1982				}
1983
1984				carouselInstance.imagesLoaded(function () {
1985
1986					if (!carouselInstance.hasClass('no-gutters')) {
1987						var carouselWidth = carouselInstance.width();
1988						if (isRTL) {
1989						carouselInstance.css('margin-right', '-15px').css('width', carouselWidth + 30);
1990						} else {
1991						carouselInstance.css('margin-left', '-15px').css('width', carouselWidth + 30);
1992						}
1993					}
1994
1995					carouselInstance.owlCarousel({
1996						items : carouselColumns,
1997						itemsDesktop: [desktopWidth,desktopCarouselItems],
1998						itemsDesktopSmall: [desktopWidth-220,desktopSmallCarouselItems],
1999						itemsMobile: [479,mobileCarouselItems],
2000						paginationSpeed: carouselPSpeed,
2001						slideSpeed: carouselSSpeed,
2002						autoPlay: carouselAutoplay,
2003						autoPlayDirection : carouselPDirection,
2004						pagination: carouselPagination,
2005						autoHeight : false,
2006						beforeUpdate: function() {
2007							if (!carouselInstance.hasClass('no-gutters')) {
2008								var carouselWidth = carouselInstance.parent().width();
2009								carouselInstance.css('width', carouselWidth + 30);
2010							}
2011						},
2012						afterUpdate: function () {
2013							setTimeout(function() {
2014								flexSlider.thumb();
2015							}, 200);
2016						},
2017						afterInit: function() {
2018							flexSlider.thumb();
2019							$window.trigger('resize');
2020							setTimeout(function() {
2021								parallax.init(true);
2022							}, 200);
2023						},
2024						afterAction: function(){
2025							var carouselNext = carouselInstance.parents('.carousel-wrap').find('.carousel-next'),
2026								carouselPrev = carouselInstance.parents('.carousel-wrap').find('.carousel-prev');
2027								
2028						    if ( this.itemsAmount > this.visibleItems.length ) {
2029						        carouselNext.show();
2030						        carouselPrev.show();
2031						
2032						        carouselNext.removeClass('disabled');
2033						        carouselPrev.removeClass('disabled');
2034						        if ( this.currentItem === 0 ) {
2035						            carouselPrev.addClass('disabled');
2036						        }
2037						        if ( this.currentItem == this.maximumItem ) {
2038						            carouselNext.addClass('disabled');
2039						        }
2040						
2041						    } else {
2042						        carouselNext.hide();
2043						        carouselPrev.hide();
2044						    }
2045						}
2046					}).animate({
2047						'opacity': 1
2048					},800);
2049				});
2050			});
2051
2052			// Previous
2053			jQuery('.carousel-next').click( function(e) {
2054				e.preventDefault();
2055				var carousel = jQuery(this).closest('.spb_content_element').find('.owl-carousel');
2056				if (isRTL) {
2057				carousel.data( 'owlCarousel' ).prev();
2058				} else {
2059				carousel.data( 'owlCarousel' ).next();
2060				}
2061			});
2062
2063			// Next
2064			jQuery('.carousel-prev').click( function(e) {
2065				e.preventDefault();
2066				var carousel = jQuery(this).closest('.spb_content_element').find('.owl-carousel');
2067				if (isRTL) {
2068				carousel.data( 'owlCarousel' ).next();
2069				} else {
2070				carousel.data( 'owlCarousel' ).prev();
2071				}
2072			});
2073		},
2074		carouselSwipeIndicator: function(carousel) {
2075			carousel.appear(function() {
2076				var swipeIndicator = jQuery(this).parents('.carousel-wrap').find('.sf-swipe-indicator');
2077				setTimeout(function() {
2078					swipeIndicator.fadeIn(500);
2079				}, 400);
2080				setTimeout(function() {
2081					swipeIndicator.addClass('animate');
2082				}, 1000);
2083				setTimeout(function() {
2084					swipeIndicator.fadeOut(400);
2085				}, 3000);
2086			});
2087		},
2088		carouselMinHeight: function(carousel) {
2089			var minHeight = parseInt(carousel.find('.carousel-item:not(.no-thumb)').eq(0).css('height'));
2090			carousel.find('.owl-item').each(function () {
2091				jQuery(this).css('min-height',minHeight+'px');
2092			});
2093		}
2094	};
2095	
2096	
2097	/////////////////////////////////////////////
2098	// WIDGET FUNCTIONS
2099	/////////////////////////////////////////////
2100	
2101	var widgets = {
2102		init: function() {
2103			
2104			// CHARTS
2105			if (sfIncluded.hasClass('has-chart')) {
2106				jQuery('.chart-shortcode').each(function(){
2107					jQuery(this).easyPieChart({
2108						animate: 1000,
2109						lineCap: 'round',
2110						lineWidth: jQuery(this).attr('data-linewidth'),
2111						size: jQuery(this).attr('data-size'),
2112						barColor: jQuery(this).attr('data-barcolor'),
2113						trackColor: jQuery(this).attr('data-trackcolor'),
2114						scaleColor: 'transparent'
2115					});
2116				});
2117			}
2118			
2119			// LOAD WIDGETS
2120			widgets.accordion();
2121			widgets.tabs();
2122			widgets.toggle();
2123			widgets.fullWidthVideo();
2124			widgets.introAnimations();
2125			widgets.iconBoxes();
2126			widgets.countAssets();
2127			
2128			if (sfIncluded.hasClass('has-countdown')) {
2129			widgets.countdownAssets();
2130			}
2131			
2132			if (sfIncluded.hasClass('has-imagebanner')) {
2133			widgets.imageBanners();
2134			}
2135			
2136			jQuery('ul.nav-tabs li a, .spb_accordion_section > h3 a').click(function(){
2137				setTimeout(function() {
2138					$window.trigger('resize');
2139				}, 200);    		   
2140			});
2141			
2142			// RESIZE ASSETS
2143			widgets.resizeAssets();
2144			$window.smartresize( function() {  
2145				widgets.resizeAssets();
2146			});
2147			
2148			// SF TOOLTIPS
2149			jQuery('[rel=tooltip]').tooltip();
2150			
2151		},
2152		resizeAssets: function() {	
2153			var carousels = jQuery('.carousel-active .carousel-items,.carousel-active .products');
2154			var assets = jQuery('.alt-bg');
2155			var assetWidth = 0;
2156			
2157			if (jQuery('#container').width() < 460 && body.hasClass('responsive-fluid')) {
2158				assetWidth = jQuery('#container').width() - 40;			
2159				carousels.find('.carousel-item,.product').each(function() {
2160					jQuery(this).css("width", assetWidth + "px");
2161					
2162				});
2163			} else if (jQuery('#container').width() < 768 && body.hasClass('responsive-fluid')) {
2164				if (carousels.hasClass('testimonials')) {
2165				assetWidth = jQuery('#container').width() - 40;	
2166				} else {
2167				assetWidth = Math.floor(jQuery('#container').width() / 2) - 35;	
2168				}
2169				carousels.find('.carousel-item,.product').each(function() {
2170					jQuery(this).css("width", assetWidth + "px");
2171				});
2172			} else if (body.hasClass('responsive-fluid')) {
2173				carousels.find('.carousel-item,.product').each(function() {
2174					jQuery(this).css("width", "");
2175				});
2176			}
2177			
2178			if (jQuery('#container').width() < 768 && body.hasClass('responsive-fluid')) {
2179				assetWidth = jQuery('#container').width();
2180				assets.each(function() {
2181					jQuery(this).css("width", assetWidth + "px");
2182				});	
2183			} else {
2184				assets.each(function() {
2185					jQuery(this).css("width", "");
2186				});	
2187			}
2188		},
2189		accordion: function() {
2190			jQuery('.spb_accordion').each(function() {
2191				var spb_tabs,				
2192					active_tab = false,
2193					active_attr = parseInt(jQuery(this).attr('data-active'), 10);
2194							
2195				if (jQuery.type( active_attr ) === "number") { active_tab = active_attr; }
2196							
2197				spb_tabs = jQuery(this).find('.spb_accordion_wrapper').accordion({
2198					header: "> div > h3",
2199					autoHeight: true,
2200					collapsible: true,
2201					active: active_tab,
2202					heightStyle: "content"
2203				});
2204			}).fadeIn(400);
2205		},
2206		tabs: function() {
2207			// SET ACTIVE TABS PANE
2208			jQuery('.spb_tabs').each(function() {
2209				jQuery(this).find('.tab-pane').first().addClass('active');
2210				jQuery(this).find('.tab-pane').removeClass('load');
2211			});
2212			
2213			// SET ACTIVE TOUR PANE
2214			jQuery('.spb_tour').each(function() {
2215				jQuery(this).find('.tab-pane').first().addClass('active');
2216				jQuery(this).find('.tab-pane').removeClass('load');
2217			});
2218			
2219			// SET DESIRED TAB ON LOAD
2220			setTimeout(function() {
2221				if (jQuery('.spb_tabs').length > 0) {
2222					
2223					// Show correct tab on page load
2224					var url = document.location.toString();
2225					if (url.match('#') && jQuery('.nav-tabs a[href="#'+url.split('#')[1]+'"]').length > 0) {
2226					    var thisTab = jQuery('.nav-tabs a[href="#'+url.split('#')[1]+'"]'),
2227					    	parentTabs = thisTab.parents('.spb_tabs'),
2228					    	tabHash = url.split('#')[1];
2229					    
2230					    jQuery('.nav-tabs a[href="#'+tabHash+'"]').tab('show');
2231					} 
2232					
2233					// Change hash on tab click
2234					jQuery('.nav-tabs a').click(function (e) {
2235						var hash = e.target.hash;
2236						
2237						if (history.pushState) {
2238						    history.pushState(null, null, hash);
2239						} else {
2240						    location.hash = hash;
2241						}
2242					});
2243				}
2244			}, 50);
2245		},
2246		toggle: function() {
2247			jQuery('.spb_toggle').click(function() {
2248				if ( jQuery(this).hasClass('spb_toggle_title_active') ) {
2249					jQuery(this).removeClass('spb_toggle_title_active').next().slideUp(500);
2250				} else {
2251					jQuery(this).addClass('spb_toggle_title_active').next().slideDown(500);
2252				}
2253			});
2254			jQuery('.spb_toggle_content').each(function() {
2255				if ( jQuery(this).next().is('h4.spb_toggle') === false ) {
2256					jQuery('<div class="last_toggle_el_margin"></div>').insertAfter(this);
2257				}
2258			});
2259		},
2260		initSkillBars: function() {		
2261			// SKILL BARS
2262			widgets.animateSkillBars();
2263			jQuery('a.ui-tabs-anchor').click(function(){
2264				widgets.animateSkillBars();
2265			});
2266		},
2267		animateSkillBars: function() {
2268			jQuery('.progress').each(function(){
2269				var progress = jQuery(this);
2270				
2271				progress.appear(function() {
2272					var progressValue = progress.find('.bar').attr('data-value');
2273					
2274					if (!progress.hasClass('animated')) {
2275						progress.addClass('animated');
2276						progress.find('.bar').animate({
2277							width: progressValue + "%"
2278						}, 800, function() {
2279							progress.parent().find('.bar-text .progress-value').fadeIn(600);
2280						});
2281					}
2282				});
2283			});
2284		},
2285		charts: function() {
2286			widgets.animateCharts();
2287		},
2288		animateCharts: function() {
2289			jQuery('.chart-shortcode').each(function(){
2290				var chart = jQuery(this);
2291				chart.appear(function() {
2292					if (!jQuery(this).hasClass('animated')) {
2293						jQuery(this).addClass('animated');
2294						var animatePercentage = parseInt(jQuery(this).attr('data-animatepercent'), 10);
2295						jQuery(this).data('easyPieChart').update(animatePercentage);
2296					}
2297				});
2298			});
2299		},
2300		fullWidthVideo: function() {			
2301			jQuery(document).on('click', '.fw-video-link', function() {
2302				if (jQuery(this).data('video') !== "") {
2303					widgets.openFullWidthVideo(jQuery(this));
2304				}
2305				return false;
2306			});
2307			
2308			jQuery(document).on('click', '.fw-video-close', function() {
2309				widgets.closeFullWidthVideo();
2310			});
2311		},
2312		openFullWidthVideo: function(element) {
2313			jQuery('.fw-video-close').addClass('is-open');
2314			jQuery('.fw-video-spacer').animate({
2315				height: windowheight
2316			}, 1000, 'easeInOutExpo');
2317			
2318			jQuery('.fw-video-area').css('display', 'block').animate({
2319				top: 0,
2320				height: '100%'
2321			}, 1000, 'easeInOutExpo', function() {
2322				// load video here
2323				jQuery('.fw-video-area').append('<iframe class="fw-video" src="'+element.data('video')+'" width="100%" height="100%" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>');
2324			});
2325		},
2326		closeFullWidthVideo: function() {
2327			jQuery('.fw-video-close').removeClass('is-open');
2328			jQuery('.fw-video-spacer').animate({
2329				height: 0
2330			}, 1000, 'easeInOutExpo', function(){
2331			});
2332			jQuery('.fw-video-area').animate({
2333				top:'-100%'
2334			}, 1000, 'easeInOutExpo', function() {
2335				jQuery('.fw-video-area').css('display', 'none');
2336				jQuery('.fw-video-area .fw-video').remove();
2337			});
2338			
2339			// pause videos
2340			jQuery('.fw-video-area video').each(function(){
2341				this.pause();
2342			});
2343			setTimeout(function() {
2344				jQuery('.fw-video-area').find('iframe').remove();
2345			}, 1500);
2346			
2347			return false;
2348		},
2349		introAnimations: function() {
2350			
2351			if (!isMobileAlt) {
2352				jQuery('.sf-animation').each(function() {
2353	
2354					var animatedItem = jQuery(this),
2355						itemAnimation = animatedItem.data('animation'),
2356						itemDelay = animatedItem.data('delay');
2357										
2358					animatedItem.appear(function() {				
2359						if (itemAnimation == 'fade-from-left') {
2360							animatedItem.delay(itemDelay).animate({
2361								'opacity' : 1,
2362								'left' : '0px'
2363							}, 600, 'easeOutCubic');
2364						} else if (itemAnimation == 'fade-from-right') {
2365							animatedItem.delay(itemDelay).animate({
2366								'opacity' : 1,
2367								'right' : '0px'
2368							}, 600, 'easeOutCubic');
2369						} else if(itemAnimation == 'fade-from-bottom') {
2370							if (animatedItem.hasClass('image-banner-content')) {
2371								animatedItem.delay(itemDelay).animate({
2372									'opacity' : 1,
2373									'bottom' : '50%'
2374								}, 1000, 'easeOutCubic');
2375							} else {
2376								animatedItem.delay(itemDelay).animate({
2377									'opacity' : 1,
2378									'bottom' : '0px'
2379								}, 600, 'easeOutCubic');
2380							}
2381						} else if (itemAnimation == 'fade-in') {
2382							animatedItem.delay(itemDelay).animate({
2383								'opacity' : 1
2384							}, 600, 'easeOutCubic');
2385						} else if (itemAnimation == 'grow') {
2386							setTimeout(function(){ 
2387								animatedItem.addClass('sf-animate');
2388							}, itemDelay);
2389						} else {
2390							setTimeout(function() {
2391								animatedItem.addClass('sf-animate');						
2392							}, itemDelay);
2393						}
2394					}, {accX: 0, accY: -150}, 'easeInCubic');
2395				
2396				});
2397			}
2398		},
2399		iconBoxes: function() {
2400			if (isMobileAlt) {
2401				jQuery('.sf-icon-box').on('click', function() {
2402					jQuery(this).addClass('sf-mobile-hover');
2403				});
2404			} else {
2405				jQuery('.sf-icon-box').hover(
2406					function() {
2407						jQuery(this).addClass('sf-hover');
2408					}, function() {
2409						jQuery(this).removeClass('sf-hover');
2410					}
2411				);
2412			}
2413		},
2414		countAssets: function() {
2415			jQuery('.sf-count-asset').each(function() {
2416
2417				var countAsset = jQuery(this),
2418					countNumber = countAsset.find('.count-number'),
2419					countDivider = countAsset.find('.count-divider').find('span'),
2420					countSubject = countAsset.find('.count-subject');
2421				
2422				if (!isMobileAlt) {						
2423					countAsset.appear(function() {				
2424					
2425						countNumber.countTo({
2426							onComplete: function () {
2427								countDivider.animate({
2428									'width': 50
2429								}, 400, 'easeOutCubic');
2430								countSubject.delay(100).animate({
2431									'opacity' : 1,
2432									'bottom' : '0px'
2433								}, 600, 'easeOutCubic');
2434							}
2435						});
2436						
2437					}, {accX: 0, accY: -150}, 'easeInCubic');
2438				} else {
2439					countNumber.countTo({
2440						onComplete: function () {
2441							countDivider.animate({
2442								'width': 50
2443							}, 400, 'easeOutCubic');
2444							countSubject.delay(100).animate({
2445								'opacity' : 1,
2446								'bottom' : '0px'
2447							}, 600, 'easeOutCubic');
2448						}
2449					});
2450				}
2451			
2452			});
2453		},
2454		countdownAssets: function() {
2455			jQuery('.sf-countdown').each(function() {
2456				var countdownInstance = jQuery(this),
2457					year = parseInt(countdownInstance.data('year'), 10),
2458					month = parseInt(countdownInstance.data('month'), 10),
2459					day = parseInt(countdownInstance.data('day'), 10),
2460					hour = parseInt(countdownInstance.data('hour'), 10),
2461					countdownDate = new Date(year, month - 1, day, hour),
2462					type = countdownInstance.data('type');
2463				
2464				var labelStrings = jQuery('#countdown-locale'),
2465					pluralLabels = [labelStrings.data('label_years'),labelStrings.data('label_months'),labelStrings.data('label_weeks'),labelStrings.data('label_days'),labelStrings.data('label_hours'),labelStrings.data('label_mins'),labelStrings.data('label_secs')],
2466					singularLabels = [labelStrings.data('label_year'),labelStrings.data('label_month'),labelStrings.data('label_week'),labelStrings.data('label_day'),labelStrings.data('label_hour'),labelStrings.data('label_min'),labelStrings.data('label_sec')];
2467				
2468				if (type == "countup") {
2469					countdownInstance.countdown({
2470						since: countdownDate,
2471						format: 'dHMS',
2472						labels: pluralLabels,
2473						labels1: singularLabels,
2474						onExpiry: function() {
2475							setTimeout(function() {
2476								countdownInstance.fadeOut(500);						
2477							}, 1000);
2478						}
2479					});
2480				} else {
2481					countdownInstance.countdown({
2482						until: countdownDate,
2483						since: null,
2484						format: 'dHMS',
2485						labels: pluralLabels,
2486						labels1: singularLabels,
2487						onExpiry: function() {
2488							setTimeout(function() {
2489								countdownInstance.fadeOut(500);						
2490							}, 1000);
2491						}
2492					});
2493				}
2494			});
2495		},
2496		imageBanners: function() {
2497			jQuery('.sf-image-banner').each(function() {
2498				jQuery(this).find('.image-banner-content').vCenter();
2499			});
2500		}
2501	};
2502	
2503	
2504	/////////////////////////////////////////////
2505	// TEAM MEMBERS FUNCTION
2506	/////////////////////////////////////////////
2507	
2508	var teamMembers = {
2509		init: function() {
2510			// TEAM EQUAL HEIGHTS
2511			var team = jQuery('.team-members.carousel-items');
2512			team.imagesLoaded(function () {
2513				team.equalHeights();
2514			});
2515			
2516			// TEAM ASSETS
2517			$window.smartresize( function() {
2518				jQuery('.team-members.carousel-items').children().css('min-height','0');
2519				jQuery('.team-members.carousel-items').equalHeights();
2520			});
2521		}
2522	};
2523	
2524	
2525	/////////////////////////////////////////////
2526	// PARALLAX FUNCTION
2527	/////////////////////////////////////////////
2528	
2529	var parallax = {
2530		init: function(reset) {
2531
2532			jQuery('.spb_parallax_asset').each(function(reset) {
2533
2534				var parallaxAsset = jQuery(this),
2535					parallaxContent = parallaxAsset.find('div:first');
2536
2537				if (parallaxAsset.hasClass('sf-parallax-video')) {
2538
2539					if (!isMobileAlt) {
2540						parallax.parallaxVideoInit();
2541					} else {
2542						parallaxAsset.find('video').remove();
2543
2544						// Fade in
2545						parallaxContent.animate({
2546							'opacity': 1,
2547						}, 300, 'easeOutExpo');
2548					}
2549
2550					// Add resize handler
2551					$window.smartresize( function() {
2552						parallax.parallaxVideoResize(parallaxAsset);
2553					});
2554
2555				} else if (parallaxAsset.hasClass('parallax-window-height')) {
2556
2557					parallaxAsset.css('height', '');
2558					var assetHeight = $window.height();
2559
2560					if (parallaxAsset.height() > assetHeight && !reset) {
2561						assetHeight = parallaxAsset.height();
2562					}
2563
2564					parallaxAsset.height(assetHeight - (parseInt(parallaxAsset.css('padding-top'), 10) * 2));
2565					if (parallaxAsset.data('v-center') === "true") {
2566						parallaxAsset.find('div:first').vCenterTop();
2567					}
2568
2569					// Fade in
2570					parallaxContent.animate({
2571						'opacity': 1,
2572					}, 300, 'easeOutExpo');
2573
2574					// Add resize handler
2575					parallax.windowImageResize(parallaxAsset);
2576					$window.smartresize( function() {
2577						parallax.windowImageResize(parallaxAsset);
2578					});
2579				}
2580				
2581				if (parallaxAsset.hasClass('parallax-stellar')) {
2582					var parallaxSpeed = parallaxAsset.data('stellar-background-ratio');
2583					parallaxAsset.parallax("50%", parallaxSpeed);
2584				}
2585			});
2586		},
2587		videoScroll: function(asset) {
2588
2589			var offsetTop = asset.offset().top,
2590				windowTop = $window.scrollTop(),
2591				defaultHeight = parseInt(asset.data('height-default'), 10),
2592				diff = windowTop - offsetTop,
2593				currentTop = asset.find('.spb_content_wrapper').css('top'),
2594				heightDifference = defaultHeight - diff * 1.5;
2595
2596			if (windowTop > offsetTop) {
2597				asset.css('height', heightDifference);
2598				asset.find('.spb_content_wrapper').css('opacity', 1 - (diff / 300));
2599				if (asset.hasClass('parallax-window-height') && asset.data('v-center') === "true") {
2600				asset.find('.spb_content_wrapper').css('top', currentTop + (diff / 4));
2601				} else if (asset.data('v-center') === "true") {
2602				asset.find('.spb_content_wrapper').css('top', (diff / 3));
2603				}
2604			} else {
2605				asset.css('height', defaultHeight);
2606				asset.find('.spb_content_wrapper').css('opacity', 1);
2607				if (asset.hasClass('parallax-video-height') && asset.data('v-center') === "true") {
2608				asset.find('.spb_content_wrapper').css('top', '50%');
2609				} else {
2610				asset.find('.spb_content_wrapper').css('top', 0);
2611				}
2612			}
2613
2614		},
2615		windowImageResize: function(asset) {
2616
2617			if (asset.hasClass('spb-row-container')) {
2618
2619				var rowContentHeight = asset.find('> .spb_content_element').height();
2620
2621				if (asset.hasClass('parallax-window-height')) {
2622
2623					if (rowContentHeight < $window.height()) {
2624						rowContentHeight = $window.height();
2625					}
2626				}
2627
2628				asset.height(rowContentHeight);
2629
2630				if (asset.data('v-center')) {
2631				asset.find('> .spb_content_element').vCenterTop();
2632				}
2633
2634			} else {
2635
2636				var assetHeight = asset.height();
2637
2638				if (asset.hasClass('parallax-window-height')) {
2639
2640					if (assetHeight < $window.height()) {
2641						assetHeight = $window.height();
2642					}
2643				}
2644
2645				asset.height(assetHeight - asset.css('padding-top') / 2);
2646				asset.find('.spb_content_wrapper').vCenterTop();
2647			}
2648
2649		},
2650		parallaxVideoInit: function() {
2651			jQuery('.spb_parallax_asset.sf-parallax-video').each(function() {
2652				var parallaxAsset = jQuery(this),
2653					parallaxVideo = parallaxAsset.find('video'),
2654					parallaxVideoWidth = parallaxVideo.width(),
2655					parallaxContent = parallaxAsset.find('div:first'),
2656					parallaxAssetHeight = 0;
2657
2658				if (parallaxAsset.hasClass('parallax-window-height')) {
2659
2660					if (parallaxContent.height() > $window.height()) {
2661						parallaxAssetHeight = parallaxContent.height();
2662					} else {
2663						parallaxAssetHeight = $window.height();
2664					}
2665
2666					parallaxAsset.animate({
2667						'height': parallaxAssetHeight
2668					}, 400);
2669
2670					setTimeout(function() {
2671
2672						// Scale video
2673						parallax.parallaxVideoResize(parallaxAsset);
2674
2675						// Fade in
2676						parallaxContent.animate({
2677							'opacity': 1,
2678						}, 300, 'easeOutExpo');
2679
2680					}, 500);
2681
2682					setTimeout(function() {
2683						parallaxAsset.find('.video-overlay').animate({
2684							'opacity': 0.8
2685						}, 200);
2686					}, 100);
2687
2688					if (parallaxAsset.data('v-center') === "true") {
2689					parallaxContent.vCenterTop();
2690					}
2691
2692					setTimeout(function() {
2693						parallaxContent.animate({
2694							'opacity': 1,
2695							'top': '50%'
2696						}, 600, 'easeOutExpo');
2697					}, 600);
2698
2699					parallaxAsset.attr('data-height-default', parallaxVideo.height());
2700
2701				} else {
2702					parallax.scaleVideo(parallaxAsset);
2703				}
2704
2705				if ($window.width() < parallaxVideoWidth) {
2706					parallaxVideo.css('left', - (parallaxVideoWidth - $window.width()) /2);
2707				}
2708				
2709				var videoInstance = parallaxVideo.get( 0 );
2710				videoInstance.load();
2711				videoInstance.addEventListener( 'loadeddata' , function() {
2712				        parallax.parallaxVideoResize(parallaxAsset);
2713				    }
2714				);
2715
2716			});
2717		},
2718		parallaxVideoResize: function(parallaxAsset) {
2719			var parallaxContent = parallaxAsset.find('div:first'),
2720				parallaxAssetHeight = 0;
2721
2722			if (parallaxAsset.hasClass('parallax-window-height')) {
2723				if (parallaxContent.height() > $window.height()) {
2724					parallaxAssetHeight = parallaxContent.height();
2725				} else {
2726					parallaxAssetHeight = $window.height();
2727				}
2728
2729				parallaxAsset.animate({
2730					'height': parallaxAssetHeight
2731				}, 400);
2732
2733				if (parallaxAsset.data('v-center') === "true") {
2734				parallaxContent.vCenterTop();
2735				}
2736			}
2737
2738			parallax.scaleVideo(parallaxAsset);
2739		},
2740		scaleVideo: function(parallaxAsset) {
2741
2742			var video = parallaxAsset.find('video'),
2743				assetHeight = parallaxAsset.outerHeight(),
2744				assetWidth = parallaxAsset.outerWidth(),
2745				videoWidth = video[0].videoWidth,
2746				videoHeight = video[0].videoHeight;
2747
2748			// Use the largest scale factor of horizontal/vertical
2749			var scale_h = assetWidth / videoWidth;
2750			var scale_v = assetHeight / videoHeight;
2751			var scale = scale_h > scale_v ? scale_h : scale_v;
2752
2753			// Update minium width to never allow excess space
2754			var min_w = videoWidth/videoHeight * (assetHeight+20);
2755
2756			// Don't allow scaled width < minimum video width
2757			if (scale * videoWidth < min_w) {scale = min_w / videoWidth;}
2758
2759			// Scale the video
2760			video.width(Math.ceil(scale * videoWidth +2));
2761			video.height(Math.ceil(scale * videoHeight +50));
2762			video.css('margin-top', - (video.height() - assetHeight) /2);
2763			video.css('margin-left', - (video.width() - assetWidth) /2);
2764		},
2765
2766	};
2767	
2768	/////////////////////////////////////////////
2769	// LIGHTBOX FUNCTION
2770	/////////////////////////////////////////////
2771	
2772	var lightbox = {
2773		init: function() {
2774			
2775			if ( !lightboxEnabled ) {
2776				return;
2777			}
2778		
2779			// Lightbox Social
2780			var lightboxSocial = {};
2781			if (lightboxSharing) {
2782				lightboxSocial = {
2783					facebook: {
2784						source: 'https://www.facebook.com/sharer/sharer.php?u={URL}',
2785						text: 'Share on Facebook'
2786					},
2787					twitter: true,
2788					googleplus: true,
2789					pinterest: {
2790						source: "https://pinterest.com/pin/create/bookmarklet/?url={URL}",
2791						text: "Share on Pinterest"
2792					}
2793				};
2794			}
2795					
2796			// Lightbox Galleries
2797			var galleryArr = [];
2798			jQuery('[data-rel^="ilightbox["]').each(function () {
2799				var attr = this.getAttribute("data-rel");
2800				if ( jQuery(this).hasClass( 'ilightbox-enabled' ) ) {
2801					return;
2802				}
2803				if (jQuery.inArray(attr, galleryArr) == -1 ) {
2804					galleryArr.push(attr);
2805				}
2806			});
2807			jQuery.each(galleryArr, function (b, c) {
2808				jQuery('[data-rel="' + c + '"]').iLightBox({
2809					skin: lightboxSkin,
2810					social: {
2811						buttons: lightboxSocial
2812					},
2813					minScale: 0.1,
2814					maxScale: 0.6,
2815					path: 'horizontal',
2816					thumbnails: {
2817						maxWidth: 120,
2818						maxHeight: 120
2819					},
2820					controls: {
2821						arrows: lightboxControlArrows,
2822						thumbnail: lightboxThumbs
2823					}
2824				});
2825				jQuery('[data-rel="' + c + '"]').addClass( 'ilightbox-enabled' );
2826			});
2827		},
2828		destroy: function() {
2829		
2830			if ( !lightboxEnabled ) {
2831				return;
2832			}
2833			
2834			jQuery('[data-rel="ilightbox[product]"]').removeClass('ilightbox-enabled').iLightBox().destroy();
2835			jQuery('[data-rel="ilightbox[posts]"]').removeClass('ilightbox-enabled').iLightBox().destroy();
2836		}
2837	};
2838	
2839	
2840	/////////////////////////////////////////////
2841	// MAP FUNCTIONS
2842	/////////////////////////////////////////////
2843	
2844	var map = {
2845		init:function() {
2846			
2847			var maps = jQuery('.map-canvas');
2848			maps.each(function(index, element) {
2849				var mapContainer = element,
2850					mapAddress = mapContainer.getAttribute('data-address'),
2851					mapZoom = mapContainer.getAttribute('data-zoom'),
2852					mapType = mapContainer.getAttribute('data-maptype'),
2853					mapColor = mapContainer.getAttribute('data-mapcolor'),
2854					mapSaturation = mapContainer.getAttribute('data-mapsaturation'),
2855					pinLogoURL = mapContainer.getAttribute('data-pinimage'),
2856					pinLink = mapContainer.getAttribute('data-pinlink');
2857				
2858				map.getCoordinates(mapAddress, mapContainer, mapZoom, mapType, mapColor, mapSaturation, pinLogoURL, pinLink);
2859								
2860			});
2861			jQuery('ul.nav-tabs li a').click(function(){
2862				var thisTabHref = jQuery(this).attr('href');
2863				if (jQuery(thisTabHref).find('.spb_gmaps_widget').length > 0) {
2864					map.init();
2865				}
2866			});
2867			
2868			jQuery('.spb_accordion_section > h3 a').click(function(){
2869				var thisAccordion = jQuery(this).parents('.spb_accordion_section');
2870				if (thisAccordion.find('.spb_gmaps_widget').length > 0) {
2871					map.init();
2872				}
2873			});
2874			
2875		},
2876		getCoordinates: function(address, mapContainer, mapZoom, mapType, mapColor, mapSaturation, pinLogoURL, pinLink) {
2877			var geocoder;
2878			geocoder = new google.maps.Geocoder();			
2879			geocoder.geocode({
2880				'address': address
2881			}, function(results, status) {
2882				if (status == google.maps.GeocoderStatus.OK) {
2883					
2884					if (mapSaturation == "mono") {
2885						mapSaturation = -100;
2886					} else {
2887						mapSaturation = -20;
2888					}
2889					
2890					var styles = [
2891						{
2892							stylers: [
2893								{hue: mapColor},
2894								{saturation: mapSaturation}
2895							]
2896						}
2897					];
2898					
2899					var styledMap = new google.maps.StyledMapType(styles,{name: "Styled Map"});  
2900					
2901					var mapTypeIdentifier = "",
2902						companyPos = "",
2903						isDraggable = true,
2904						mapCoordinates = results[0].geometry.location,
2905						latitude = results[0].geometry.location.lat(),
2906						longitude = results[0].geometry.location.lng();				
2907					
2908					if (isMobileAlt) {
2909					isDraggable = false;
2910					}
2911					
2912					if (mapType === "SATELLITE") {
2913					mapTypeIdentifier = google.maps.MapTypeId.SATELLITE;
2914					} else if (mapType === "TERRAIN") {
2915					mapTypeIdentifier = google.maps.MapTypeId.TERRAIN;
2916					} else if (mapType === "HYBRID") {
2917					mapTypeIdentifier = google.maps.MapTypeId.HYBRID;
2918					} else {
2919					mapTypeIdentifier = google.maps.MapTypeId.ROADMAP;
2920					}
2921							
2922					var latlng = new google.maps.LatLng(latitude, longitude);
2923					var settings = {
2924						zoom: parseInt(mapZoom, 10),
2925						scrollwheel: false,
2926						center: latlng,
2927						draggable: isDraggable,
2928						mapTypeControl: true,
2929						mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
2930						navigationControl: true,
2931						navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
2932						mapTypeId: mapTypeIdentifier
2933					};
2934					var mapInstance = new google.maps.Map(mapContainer, settings);
2935					var companyMarker = "";
2936					
2937					// ADD MARKER AFTER 1 SECOND
2938					jQuery(mapContainer).appear(function() {
2939						setTimeout(function() {
2940							if (pinLogoURL) {
2941								var companyLogo = new google.maps.MarkerImage(pinLogoURL,
2942									new google.maps.Size(150,75),
2943									new google.maps.Point(0,0),
2944									new google.maps.Point(75,75)
2945								);
2946								companyPos = new google.maps.LatLng(latitude, longitude);
2947								companyMarker = new google.maps.Marker({
2948									position: mapCoordinates,
2949									map: mapInstance,
2950									icon: companyLogo,
2951									animation: google.maps.Animation.DROP
2952								});
2953							} else { 
2954								companyPos = new google.maps.LatLng(latitude, longitude);
2955								companyMarker = new google.maps.Marker({
2956									position: mapCoordinates,
2957									map: mapInstance,
2958									animation: google.maps.Animation.DROP
2959								});
2960							}
2961							
2962							google.maps.event.addListener(companyMarker, 'click', function() {
2963								//window.location.href = 'http://maps.google.com/maps?q='+companyPos;
2964								if (pinLink === "") {
2965									pinLink = 'http://maps.google.com/maps?q='+companyPos;
2966								}
2967								window.open(pinLink);
2968							});
2969							
2970							google.maps.event.addDomListener(window, 'resize', function() {
2971								mapInstance.setCenter(companyPos);
2972							});
2973						}, 1000);
2974					});
2975								
2976					// MAP COLOURIZE
2977					if (mapColor !== "") {
2978					mapInstance.mapTypes.set('map_style', styledMap);
2979					mapInstance.setMapTypeId('map_style');
2980					}
2981
2982				} else {
2983					console.log(status);
2984				}
2985			});			
2986		}
2987	};
2988		
2989	
2990	/////////////////////////////////////////////
2991	// RELOAD FUNCTIONS
2992	/////////////////////////////////////////////
2993	
2994	var reloadFunctions = {
2995		init:function() {	
2996	
2997			// Remove title attributes from images to avoid showing on hover 
2998			jQuery('img[title]').each(function() {
2999				jQuery(this).removeAttr('title');
3000			});
3001			
3002			if (!isAppleDevice) {
3003				jQuery('embed').show();
3004			}
3005						
3006			// Animate Top Links
3007			jQuery('.animate-top').on('click', function(e) {
3008				e.preventDefault();
3009				jQuery('body,html').animate({scrollTop: 0}, 800, 'easeOutCubic');           
3010			});
3011		},
3012		load:function() {
3013			if (!isMobile) {
3014			
3015				// Button hover tooltips
3016				jQuery('.tooltip').each( function() {
3017					jQuery(this).css( 'marginLeft', '-' + Math.round( (jQuery(this).outerWidth(true) / 2) ) + 'px' );
3018				});
3019				
3020				jQuery('.comment-avatar').hover( function() {
3021					jQuery(this).find('.tooltip' ).stop().animate({
3022						bottom: '44px',
3023						opacity: 1
3024					}, 500, 'easeInOutExpo');
3025				}, function() {
3026						jQuery(this).find('.tooltip').stop().animate({
3027							bottom: '25px',
3028							opacity: 0
3029						}, 400, 'easeInOutExpo');
3030				});
3031				
3032				jQuery('.grid-image').hover( function() {
3033					jQuery(this).find('.tooltip' ).stop().animate({
3034						bottom: '85px',
3035						opacity: 1
3036					}, 500, 'easeInOutExpo');
3037				}, function() {
3038						jQuery(this).find('.tooltip').stop().animate({
3039							bottom: '65px',
3040							opacity: 0
3041						}, 400, 'easeInOutExpo');
3042				});
3043				
3044				
3045				// HASH CHECK
3046				setTimeout(function() {
3047				 	var urlHash = document.location.toString();
3048					if (urlHash.match('#')) {
3049					    var hash = urlHash.split('#')[1];
3050					    		   
3051					    if ( jQuery('#' + hash).length > 0 ) {
3052					        var headerHeight = 0;
3053					        	
3054					        if (jQuery('.sticky-header').length > 0) {
3055					        	headerHeight = jQuery('.sticky-header').height();
3056					        }
3057					        if (jQuery('#wpadminbar').length > 0) {
3058					        	headerHeight = headerHeight + 28;
3059					        }
3060					        
3061					        jQuery('html, body').stop().animate({
3062					        	scrollTop: jQuery('#' + hash).offset().top - headerHeight - 30
3063					        }, 600, 'easeInOutExpo');
3064					        
3065					    }
3066					}
3067				}, 200);	
3068			}
3069		}
3070	};
3071	
3072	
3073	/////////////////////////////////////////////
3074	// GLOBAL VARIABLES
3075	/////////////////////////////////////////////
3076	
3077	var $window = jQuery(window),
3078		body = jQuery('body'),
3079		sfIncluded = jQuery('#sf-included'),
3080		sfOptionParams = jQuery('#sf-option-params'),
3081		windowheight = page.getViewportHeight(),
3082		deviceAgent = navigator.userAgent.toLowerCase(),
3083		isMobile = deviceAgent.match(/(iphone|ipod|android|iemobile)/),
3084		isMobileAlt = deviceAgent.match(/(iphone|ipod|ipad|android|iemobile)/),
3085		isAppleDevice = deviceAgent.match(/(iphone|ipod|ipad)/),
3086		isIEMobile = deviceAgent.match(/(iemobile)/),
3087		IEVersion = page.checkIE(),
3088		isRTL = false,
3089		lightboxEnabled = sfOptionParams.data('lightbox-enabled') ? true : false,
3090		lightboxControlArrows = sfOptionParams.data('lightbox-nav') === "arrows" ? true : false,
3091		lightboxThumbs = sfOptionParams.data('lightbox-thumbs') ? true : false,
3092		lightboxSkin = sfOptionParams.data('lightbox-skin') === "dark" ? "metro-black" : "metro-white",
3093		lightboxSharing = sfOptionParams.data('lightbox-sharing') ? true : false,
3094		sliderAuto = sfOptionParams.data('slider-autoplay') ? true : false,
3095		sliderSlideSpeed = sfOptionParams.data('slider-slidespeed'),
3096		sliderAnimSpeed = sfOptionParams.data('slider-animspeed');
3097		
3098	/////////////////////////////////////////////
3099	// LOAD + READY FUNCTION
3100	/////////////////////////////////////////////
3101		
3102	var onReady = {
3103		init: function(){
3104			page.init();
3105			if (jQuery('.sf-super-search').length > 0) {
3106			superSearch.init();
3107			}
3108			if (jQuery('#header-section').length > 0) {
3109			header.init();
3110			}
3111			nav.init();
3112			lightbox.init();
3113			if (sfIncluded.hasClass('has-products') || body.hasClass('woocommerce-cart') || body.hasClass('woocommerce-account')) {
3114			woocommerce.init();
3115			}
3116			if (sfIncluded.hasClass('has-portfolio')) {
3117			portfolio.init();
3118			}
3119			if (sfIncluded.hasClass('has-portfolio-showcase')) {
3120			portfolio.portfolioShowcaseInit();
3121			}
3122			if (sfIncluded.hasClass('has-blog')) {
3123			blog.init();
3124			}
3125			if (sfIncluded.hasClass('has-infscroll')) {
3126			blog.infiniteScroll();
3127			}
3128			widgets.init();
3129			if (sfIncluded.hasClass('has-team')) {
3130			//teamMembers.init();
3131			}
3132			if (sfIncluded.hasClass('has-carousel')) {
3133			carouselWidgets.init();
3134			}
3135			if (sfIncluded.hasClass('has-parallax')) {
3136			parallax.init();
3137			}
3138			reloadFunctions.init();
3139		}
3140	};
3141	var onLoad = {
3142		init: function(){
3143			nav.load();
3144			flexSlider.init();
3145			if (sfIncluded.hasClass('has-gallery')) {
3146			flexSlider.gallery();
3147			}
3148			if (sfIncluded.hasClass('has-chart')) {
3149			widgets.charts();
3150			}
3151			if (sfIncluded.hasClass('has-progress-bar')) {
3152			widgets.initSkillBars();
3153			}
3154			if (sfIncluded.hasClass('has-map')) {
3155			map.init();
3156			}
3157			reloadFunctions.load();
3158			woocommerce.variations();
3159			
3160			// ANCHOR ON LOAD
3161			var anchorID = window.location.hash;
3162			if (anchorID !== "" && jQuery(anchorID).length > 0) {	
3163				setTimeout(function() {
3164					var anchorPosition = jQuery(anchorID).offset(); 
3165					jQuery('body,html').scrollTop(anchorPosition.top - 200); 
3166				}, 300);
3167			}
3168		}
3169	};
3170	
3171	jQuery(document).ready(onReady.init);
3172	jQuery(window).load(onLoad.init);
3173	
3174})(jQuery);

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.