PageSourceSearch

https://citizensclimateinitiative.eu/wp-content/themes/dante/js/functions.js

js citizensclimateinitiative.eu collected 2026-10-03 20:46:08 UTC 99,643 bytes, 3,172 lines download raw bytes

1/*global jQuery,google,AnimOnScroll */
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 = 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					newValue = parseInt(quantityInput.val(), 10) + 1,
1201					maxValue = parseInt(quantityInput.attr('max'), 10);
1202
1203				if (!maxValue) {
1204					maxValue = 9999999999;
1205				}
1206				
1207				if ( newValue <= maxValue ) {
1208					quantityInput.val(newValue);
1209					quantityInput.change();
1210				}
1211			});
1212
1213			// Decrease
1214			jQuery(document).on('click', '.qty-minus', function(e) {
1215				e.preventDefault();
1216				var quantityInput = jQuery(this).parents('.quantity').find('input.qty'),
1217					newValue = parseInt(quantityInput.val(), 10) - 1,
1218					minValue = parseInt(quantityInput.attr('min'), 10);
1219					
1220				if (!minValue) {
1221					minValue = 1;
1222				}
1223				
1224				if ( newValue >= minValue ) {
1225					quantityInput.val(newValue);
1226					quantityInput.change();
1227				}
1228			});
1229
1230		}
1231	};
1232	
1233	/////////////////////////////////////////////
1234	// FLEXSLIDER FUNCTION
1235	/////////////////////////////////////////////
1236	
1237	var flexSlider = {
1238		init: function() {
1239			
1240			var hasProductZoom = false;
1241			
1242			if (jQuery('#sf-included').hasClass('has-productzoom') && !body.hasClass('mobile-browser')) {
1243				hasProductZoom = true;
1244			}
1245			
1246			if(jQuery('.recent-posts').length > 0) {
1247				flexSlider.thumb();
1248			}
1249			
1250			if (jQuery('#product-img-nav ul.slides li').length > 1) {
1251				jQuery('#product-img-nav').flexslider({
1252					animation: "slide",
1253					directionNav: false,
1254					controlNav: false,
1255					animationLoop: false,
1256					slideshow: false,
1257					itemWidth: 70,
1258					itemMargin: 30,
1259					asNavFor: '#product-img-slider'
1260				});
1261			} else {
1262				jQuery('#product-img-nav').css('display', 'none');
1263			}
1264			
1265			var currentImage = "";
1266			
1267			jQuery('#product-img-slider').flexslider({
1268				animation: "slide",
1269				controlNav: false,
1270				smoothHeight: true,
1271				animationLoop: false,
1272				slideshow: sliderAuto,	//Boolean: Animate slider automatically
1273				slideshowSpeed: sliderSlideSpeed,           //Integer: Set the speed of the slideshow cycling, in milliseconds
1274				animationDuration: sliderAnimSpeed,         //Integer: Set the speed of animations, in milliseconds
1275				sync: "#product-img-nav",
1276				start: function(productSlider) {
1277					if (hasProductZoom) {
1278						if (productSlider.slides) {
1279							currentImage = productSlider.slides.eq(productSlider.currentSlide).find('.product-slider-image');
1280							woocommerce.productZoom(currentImage);
1281						} else {
1282							currentImage = jQuery('#product-img-slider').find('.product-slider-image');
1283							woocommerce.productZoom(currentImage);
1284						}
1285					}
1286				},
1287				before: function() {
1288					if (hasProductZoom) {
1289						jQuery('.zoomContainer').remove();
1290					}
1291				},
1292				after: function(productSlider) {
1293					if (hasProductZoom) {
1294						currentImage = productSlider.slides.eq(productSlider.currentSlide).find('.product-slider-image');
1295						woocommerce.productZoom(currentImage);
1296					}
1297				}
1298			});
1299			
1300			var flexUseCSS = true;
1301			
1302			if (isMobileAlt) {
1303				flexUseCSS = false;
1304			}
1305					
1306			jQuery('.item-slider').flexslider({
1307				useCSS: flexUseCSS,
1308				animation: "slide",              //String: Select your animation type, "fade" or "slide"
1309				slideDirection: "horizontal",   //String: Select the sliding direction, "horizontal" or "vertical"
1310				slideshow: sliderAuto,	//Boolean: Animate slider automatically
1311				slideshowSpeed: sliderSlideSpeed,           //Integer: Set the speed of the slideshow cycling, in milliseconds
1312				animationDuration: sliderAnimSpeed,         //Integer: Set the speed of animations, in milliseconds
1313				smoothHeight: true,         
1314				directionNav: true,             //Boolean: Create navigation for previous/next navigation? (true/false)
1315				controlNav: true,               //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage
1316				keyboardNav: false,              //Boolean: Allow slider navigating via keyboard left/right keys
1317				mousewheel: false,              //Boolean: Allow slider navigating via mousewheel
1318				prevText: "Prev",           //String: Set the text for the "previous" directionNav item
1319				nextText: "Next",               //String: Set the text for the "next" directionNav item
1320				pausePlay: true,               //Boolean: Create pause/play dynamic element
1321				pauseText: '',             //String: Set the text for the "pause" pausePlay item
1322				playText: '',               //String: Set the text for the "play" pausePlay item
1323				randomize: false,               //Boolean: Randomize slide order
1324				slideToStart: 0,                //Integer: The slide that the slider should start on. Array notation (0 = first slide)
1325				animationLoop: true,            //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
1326				pauseOnAction: true,            //Boolean: Pause the slideshow when interacting with control elements, highly recommended.
1327				pauseOnHover: false,            //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering
1328				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.
1329				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.
1330				start: function(){},            //Callback: function(slider) - Fires when the slider loads the first slide
1331				before: function(){},           //Callback: function(slider) - Fires asynchronously with each slider animation
1332				after: function(){},      //Callback: function(slider) - Fires after each slider animation completes
1333				end: function(){}               //Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous)
1334			});
1335			jQuery('#swift-slider').flexslider({
1336				animation: "slide",              //String: Select your animation type, "fade" or "slide"
1337				slideDirection: "horizontal",   //String: Select the sliding direction, "horizontal" or "vertical"
1338				slideshow: sliderAuto,	//Boolean: Animate slider automatically
1339				slideshowSpeed: sliderSlideSpeed,           //Integer: Set the speed of the slideshow cycling, in milliseconds
1340				animationDuration: sliderAnimSpeed,         //Integer: Set the speed of animations, in milliseconds
1341				directionNav: true,             //Boolean: Create navigation for previous/next navigation? (true/false)
1342				controlNav: false,               //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage
1343				keyboardNav: false,              //Boolean: Allow slider navigating via keyboard left/right keys
1344				mousewheel: false,              //Boolean: Allow slider navigating via mousewheel
1345				prevText: "Prev",           //String: Set the text for the "previous" directionNav item
1346				nextText: "Next",               //String: Set the text for the "next" directionNav item
1347				pausePlay: false,               //Boolean: Create pause/play dynamic element
1348				animationLoop: true,            //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
1349				pauseOnAction: true,            //Boolean: Pause the slideshow when interacting with control elements, highly recommended.
1350				pauseOnHover: true,
1351				start: function(postsSlider) {
1352					jQuery('.swift-slider-loading').fadeOut(200);
1353					if (postsSlider.slides) {
1354						postsSlider.slides.eq(postsSlider.currentSlide-1).addClass('flex-active-slide'); 
1355						if (postsSlider.slides.eq(postsSlider.currentSlide).has('.flex-caption-large')) {
1356							var chart = postsSlider.slides.eq(postsSlider.currentSlide).find('.fw-chart');
1357							if (body.hasClass("browser-ie")) {
1358							chart = postsSlider.slides.eq(postsSlider.currentSlide).find('.chart');
1359							}
1360							chart.each( function() {
1361								var countValue = parseInt(jQuery(this).attr('data-count'), 10);
1362								jQuery(this).data('easyPieChart').update(80);
1363								jQuery(this).find('span').replaceWith("<span>0</span>");
1364								jQuery(this).find('span').animateNumber(countValue);
1365							});
1366						}
1367						postsSlider.slides.eq(postsSlider.currentSlide).find('.comment-chart:not(.fw-chart) span').replaceWith("<span>0</span>");
1368					}
1369				},
1370				before: function(postsSlider) {
1371					if (postsSlider.slides) {
1372						if (postsSlider.slides.eq(postsSlider.currentSlide-1).has('.flex-caption-large')) {
1373							var chart = postsSlider.slides.eq(postsSlider.currentSlide).find('.fw-chart');
1374							if (body.hasClass("browser-ie")) {
1375							chart = postsSlider.slides.eq(postsSlider.currentSlide).find('.chart');
1376							}
1377							chart.each( function() {
1378								jQuery(this).data('easyPieChart').update(0);
1379								jQuery(this).find('span').replaceWith("<span>0</span>");
1380							});
1381						}
1382						setTimeout( function() {
1383							postsSlider.slides.eq(postsSlider.currentSlide).addClass('flex-active-slide');
1384							if (postsSlider.slides.eq(postsSlider.currentSlide).has('.flex-caption-large')) {
1385								var chart = postsSlider.slides.eq(postsSlider.currentSlide).find('.fw-chart');
1386								if (body.hasClass("browser-ie")) {
1387								chart = postsSlider.slides.eq(postsSlider.currentSlide).find('.chart');
1388								}
1389								chart.each( function() {
1390									var countValue = parseInt(jQuery(this).attr('data-count'), 10);
1391									jQuery(this).data('easyPieChart').update(80);
1392									jQuery(this).find('span').animateNumber(countValue);
1393								});
1394							}
1395						}, 1000);
1396					}
1397				}
1398			});
1399			jQuery('.content-slider').each(function() {
1400				var slider = jQuery(this),
1401					autoplay = ((slider.attr('data-autoplay') === "yes") ? true : false);
1402				
1403				slider.flexslider({
1404					animation: "fade",              //String: Select your animation type, "fade" or "slide"
1405					slideshow: autoplay,	//Boolean: Animate slider automatically
1406					slideshowSpeed: sliderSlideSpeed,           //Integer: Set the speed of the slideshow cycling, in milliseconds
1407					animationDuration: sliderAnimSpeed,         //Integer: Set the speed of animations, in milliseconds
1408					smoothHeight: true,         
1409					directionNav: true,             //Boolean: Create navigation for previous/next navigation? (true/false)
1410					controlNav: false,               //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage
1411					pauseOnHover: true,
1412					start: function() {}
1413				});
1414			});
1415						
1416			// LOAD THE LOVE-IT CHARTS
1417			jQuery('#swift-slider li').each( function() {
1418				jQuery(this).find('.chart').each( function() {
1419					jQuery(this).easyPieChart({
1420						animate: 1000,
1421						size: 70,
1422						barColor: jQuery(this).attr('data-barcolor'),
1423						trackColor: 'transparent',
1424						scaleColor: false
1425					});
1426					jQuery(this).find('span').replaceWith("<span>0</span>");
1427				});
1428			});
1429			
1430			// CAPTION HOVER ADD/REMOVE CLASSES
1431			jQuery('#swift-slider li').hover(function() {
1432				jQuery(this).find('.flex-caption-details').removeClass('closing');
1433				jQuery(this).find('.flex-caption-details').addClass('open');
1434			}, function() {
1435				jQuery(this).find('.flex-caption-details').addClass('closing');
1436				jQuery(this).find('.flex-caption-details').removeClass('open');
1437			});
1438						
1439			// CAPTION TRANSITION LISTENERS
1440			jQuery('.caption-details-inner').on('transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd', function() {
1441				var chart = jQuery(this).find('.chart');
1442				if (jQuery(this).parent().hasClass('closing')) {
1443					chart.each( function() {
1444						jQuery(this).data('easyPieChart').update(0);
1445						jQuery(this).find('span').replaceWith("<span>0</span>");
1446					});
1447					jQuery(this).parent().removeClass('closing');
1448				} else if (jQuery(this).parent().hasClass('open')) {
1449					chart.each( function() {
1450						var countValue = parseInt(jQuery(this).attr('data-count'), 10);
1451						jQuery(this).data('easyPieChart').update(80);
1452						jQuery(this).find('span').animateNumber(countValue);
1453					});
1454				}
1455			});
1456		},
1457		thumb: function() {
1458			jQuery('.thumb-slider').flexslider({
1459				animation: "fade",              //String: Select your animation type, "fade" or "slide"
1460				slideDirection: "horizontal",   //String: Select the sliding direction, "horizontal" or "vertical"
1461				slideshow: sliderAuto,	//Boolean: Animate slider automatically
1462				slideshowSpeed: sliderSlideSpeed,           //Integer: Set the speed of the slideshow cycling, in milliseconds
1463				animationDuration: sliderAnimSpeed,         //Integer: Set the speed of animations, in milliseconds
1464				directionNav: true,             //Boolean: Create navigation for previous/next navigation? (true/false)
1465				controlNav: false,               //Boolean: Create navigation for paging control of each slide? Note: Leave true for manualControls usage
1466				keyboardNav: false,              //Boolean: Allow slider navigating via keyboard left/right keys
1467				smoothHeight: true
1468			});
1469		},
1470		gallery: function() {
1471			
1472			jQuery('.spb_gallery_widget').each(function() {
1473				
1474				var gallerySlider = jQuery(this).find('.gallery-slider'),
1475					galleryNav = jQuery(this).find('.gallery-nav'),
1476					galleryAuto = gallerySlider.data('autoplay');
1477				
1478				if (galleryAuto === "yes") {
1479					galleryAuto = true;
1480				} else {
1481					galleryAuto = false;
1482				}
1483								
1484				galleryNav.flexslider({
1485					animation: "slide",
1486					directionNav: true,
1487					controlNav: false,
1488					animationLoop: false,
1489					slideshow: false,
1490					itemWidth: 100,
1491					itemMargin: 30, 
1492					asNavFor: gallerySlider
1493				});
1494				
1495				gallerySlider.flexslider({
1496					animation: gallerySlider.data('transition'),
1497					slideshow: galleryAuto,
1498					smoothHeight: true,
1499					slideshowSpeed: sliderSlideSpeed,           //Integer: Set the speed of the slideshow cycling, in milliseconds
1500					animationDuration: sliderAnimSpeed,         //Integer: Set the speed of animations, in milliseconds
1501					controlNav: false,
1502					animationLoop: galleryAuto,
1503					sync: galleryNav
1504				});
1505				
1506			});
1507			
1508		}
1509	};
1510	
1511	/////////////////////////////////////////////
1512	// PORTFOLIO
1513	/////////////////////////////////////////////
1514	
1515	var portfolioContainer = jQuery('.portfolio-wrap').find('.filterable-items');
1516	
1517	var portfolio = {
1518		init: function() {
1519			
1520			if (portfolioContainer.hasClass('masonry-items')) {
1521				portfolio.masonrySetup();
1522			} else {
1523				portfolio.standardSetup();
1524			}
1525						
1526			// PORTFOLIO WINDOW RESIZE
1527			$window.smartresize( function() {  
1528				portfolio.windowResized();
1529			});
1530			
1531			// Enable filter options on when there are items from that skill
1532			jQuery('.filtering li').each( function() {
1533				var itemCount = 0;
1534				var filter = jQuery(this),
1535					filterName = jQuery(this).find('a').attr('class'),
1536					portfolioItems = jQuery(this).parent().parent().parent().parent().find('.filterable-items');
1537				
1538				portfolioItems.find('.portfolio-item').each( function() {
1539					if ( jQuery(this).hasClass(filterName) ) {
1540						filter.addClass('has-items');
1541						itemCount++;
1542					}
1543				});
1544				
1545				if (jQuery(this).hasClass('all')) {
1546					itemCount = portfolioItems.children('li').length;
1547					jQuery(this).find('.item-count').text(itemCount);
1548				} else {
1549					jQuery(this).find('.item-count').text(itemCount);
1550				}
1551			}).parents('.portfolio-filter-tabs').animate({
1552				opacity: 1
1553			}, 400);
1554	
1555			// filter items when filter link is clicked
1556			jQuery('.filtering li').on('click', 'a', function(e) {
1557				e.preventDefault();
1558				jQuery(this).parent().parent().find('li').removeClass('selected');
1559				jQuery(this).parent().addClass('selected');
1560				var selector = jQuery(this).data('filter');
1561				var portfolioItems = jQuery(this).parent().parent().parent().parent().parent().find('.filterable-items');
1562				portfolioItems.isotope({ filter: selector });	
1563			});  
1564			
1565			jQuery('.filter-wrap > a').on('click', function(e) {
1566				e.preventDefault();
1567				jQuery(this).parent().find('.filter-slide-wrap').slideToggle();
1568			});
1569		},
1570		standardSetup: function() {
1571			// SET ITEM HEIGHTS
1572			portfolioContainer.imagesLoaded(function () {
1573				portfolio.setItemHeight();
1574				flexSlider.thumb();
1575				portfolioContainer.animate({opacity: 1}, 800);
1576				portfolioContainer.isotope({
1577					animationEngine: 'best-available',
1578					animationOptions: {
1579						duration: 300,
1580						easing: 'easeInOutQuad',
1581						queue: false
1582					},
1583					resizable: true,
1584					layoutMode: 'fitRows'
1585				});
1586				portfolioContainer.isotope("layout");
1587			});
1588		},
1589		masonrySetup: function() {
1590			//portfolioContainer.fitVids();
1591			portfolioContainer.imagesLoaded(function () {
1592				flexSlider.thumb();
1593				portfolioContainer.animate({opacity: 1}, 800);
1594				portfolioContainer.isotope({
1595					itemSelector : '.portfolio-item',
1596					animationEngine: 'best-available',
1597					animationOptions: {
1598						duration: 300,
1599						easing: 'easeInOutQuad',
1600						queue: false
1601					},
1602					resizable: true
1603				});
1604				
1605			});
1606		},
1607		setItemHeight: function() {
1608			if (!portfolioContainer.hasClass('masonry-items')) {
1609				portfolioContainer.children().css('min-height','0');
1610				portfolioContainer.equalHeights();
1611			}
1612		},
1613		windowResized: function() {
1614			if (!portfolioContainer.hasClass('masonry-items')) {
1615				portfolio.setItemHeight();
1616			}
1617			if (portfolioContainer.hasClass('full-width-area')) {
1618				setTimeout(function () {
1619					portfolioContainer.isotope("layout");
1620				}, 500);
1621			} else {
1622				portfolioContainer.isotope("layout");
1623			}
1624		},
1625		portfolioShowcaseInit: function() {
1626			flexSlider.thumb();
1627			portfolio.portfolioShowcaseWrap();
1628			portfolio.portfolioShowcaseItems();
1629			$window.smartresize( function() {
1630				portfolio.portfolioShowcaseWrap();
1631				portfolio.portfolioShowcaseItems();
1632			});
1633		},
1634		portfolioShowcaseWrap: function() {
1635			var portfolioShowcaseWrap = jQuery('.portfolio-showcase-wrap'),
1636				container = jQuery('#page-wrap'),
1637				mediaOffset = container.offset().left,
1638				windowWidth = $window.width() + 2;
1639		
1640			if (windowWidth > 768) {
1641				mediaOffset = mediaOffset - 15;
1642			} else {
1643				mediaOffset = 7;
1644			}
1645			
1646			if (jQuery('#container').hasClass('boxed-layout')) {
1647				windowWidth = jQuery('#container').width() + 2;
1648				
1649				if (windowWidth > 1026) {
1650					mediaOffset = 30;
1651				} else if (windowWidth > 770) {
1652					mediaOffset = 17;
1653				} else if (windowWidth > 482) {
1654					mediaOffset = 11;
1655				} else {
1656					mediaOffset = 7;
1657				}
1658			}
1659									
1660			portfolioShowcaseWrap.css('width', windowWidth);
1661			portfolioShowcaseWrap.css('margin-left', '-' + mediaOffset + 'px');
1662			portfolioShowcaseWrap.animate({opacity: 1}, 600);
1663		},
1664		portfolioShowcaseItems: function() {
1665			jQuery('.portfolio-showcase-wrap').each(function() {
1666				
1667				var contWidth = $window.width();
1668				
1669				if (jQuery('#container').hasClass('boxed-layout')) {
1670					contWidth = jQuery('#container').width();
1671				}
1672				
1673				var thisShowcase = jQuery(this),
1674					columns = thisShowcase.find('.portfolio-showcase-items').data('columns'),
1675					windowWidth = contWidth + 2,
1676					itemWidth = Math.floor(windowWidth / columns),
1677					maximisedWidth = Math.floor(windowWidth * 40 / 100),
1678					reducedWidth = Math.floor(windowWidth / 5),
1679					deselectedLeft = (itemWidth / 2 - maximisedWidth / 2) / 0.75,
1680					resetLeft = (reducedWidth / 2 - maximisedWidth / 2) / 1.3,
1681					isAnimating = !1,
1682					speed = 300;
1683
1684				var showcaseItem = thisShowcase.find('li.portfolio-item');
1685				
1686				if (columns === 5) {
1687					maximisedWidth = Math.floor(windowWidth * 25 / 100);
1688					reducedWidth = Math.floor(windowWidth / 5.33);
1689					deselectedLeft = (itemWidth / 2 - maximisedWidth / 2) / 0.75;
1690					resetLeft = (reducedWidth / 2 - maximisedWidth / 2) / 1.3;
1691					showcaseItem.css("width", itemWidth);
1692					showcaseItem.css("height", maximisedWidth / 1.5);
1693					showcaseItem.find('.main-image').css("width", maximisedWidth);
1694					showcaseItem.find('.main-image').css("left", resetLeft);
1695					showcaseItem.find('.main-image').css("top", - maximisedWidth / 6);
1696					speed = 200;
1697				} else {
1698					showcaseItem.css("width", itemWidth);
1699					showcaseItem.css("height", maximisedWidth / 2);
1700					showcaseItem.find('.main-image').css("width", maximisedWidth);
1701					showcaseItem.find('.main-image').css("left", resetLeft);
1702				}
1703							
1704				showcaseItem.each(function () {
1705					if (windowWidth > 768) {
1706						jQuery(this).mouseenter(function () {
1707							if (!isAnimating) {
1708								isAnimating = !0;
1709								jQuery(this).removeClass("deselected-item");
1710								thisShowcase.find(".deselected-item").stop().animate({
1711									width: reducedWidth
1712								}, speed);
1713								thisShowcase.find(".deselected-item").find(".main-image").stop().animate({
1714									left: deselectedLeft
1715								}, speed);
1716								jQuery(this).find(".main-image").stop().animate({
1717									left: 0
1718								}, speed);
1719								jQuery(this).stop().animate({
1720									width: maximisedWidth
1721								}, speed + 1, function () {
1722									jQuery(this).find(".item-info").stop().show();
1723									jQuery(this).find(".item-info").stop().animate({
1724										bottom: 0
1725									}, speed, "easeInOutQuart");
1726								});
1727							}
1728						});
1729						jQuery(this).mouseleave(function () {
1730							if (isAnimating) {
1731								isAnimating = !1;
1732								jQuery(this).addClass("deselected-item");
1733								thisShowcase.find(".portfolio-item").stop().animate({
1734									width: itemWidth
1735								}, speed);
1736								thisShowcase.find(".portfolio-item .main-image").stop().animate({
1737									left: resetLeft
1738								}, speed);
1739								jQuery(this).find(".item-info").stop().animate({
1740									bottom: -80
1741								}, speed, function () {
1742									jQuery(this).find(".item-info").stop().hide();
1743								});
1744							}
1745						});
1746					}
1747				});
1748			});			
1749		},
1750		stickyDetails: function() {
1751			
1752			var offset = 0,
1753				navSelectorElement = '.media-wrap',
1754				footerOffset = 160;
1755			
1756			if (jQuery('.page-heading').length > 0) {
1757				offset += jQuery('.page-heading').outerHeight(true);
1758			}
1759			
1760			if (jQuery('.inner-page-wrap').hasClass('portfolio-type-standard')) {
1761				offset += 130;
1762			}
1763			
1764			if (jQuery('.related-projects').length > 0) {
1765				footerOffset = 520;
1766			}
1767			
1768			jQuery('.sticky-details').stickySidebar({
1769				headerSelector: '.header-wrap',
1770				navSelector: navSelectorElement,
1771				contentSelector: '.article-body-wrap',
1772				footerSelector: '#footer-wrap',
1773				sidebarTopMargin: 0,
1774				footerThreshold: footerOffset,
1775				offset: offset
1776			});
1777			
1778			jQuery('.sticky-details').css('max-width', jQuery('.sticky-details').outerWidth(true));
1779			
1780			portfolio.stickyDetailsScroll();
1781			$window.scroll(function() { 
1782				portfolio.stickyDetailsScroll();
1783			});
1784		},
1785		stickyDetailsScroll: function() {
1786			
1787			var contentElement = jQuery('.article-body-wrap');
1788			
1789			if (jQuery('.inner-page-wrap').hasClass('portfolio-type-fw-media')) {
1790				contentElement = jQuery('.portfolio-detail-description');
1791			}
1792			
1793			if (jQuery('.sticky-details').hasClass('sticky')) {
1794				jQuery('.sticky-details').css('margin-left', contentElement.outerWidth(true));
1795			} else {
1796				jQuery('.sticky-details').css('margin-left', 0);			
1797			}
1798		},
1799	};
1800	
1801	
1802	/////////////////////////////////////////////
1803	// BLOG
1804	/////////////////////////////////////////////
1805	
1806	var blogItems = jQuery('.blog-wrap').find('.blog-items');
1807	
1808	var blog = {
1809		init: function() {
1810		
1811			// BLOG ITEM SETUP
1812			if (blogItems.hasClass('masonry-items')) {
1813				blog.masonryBlog();
1814			} else {
1815				flexSlider.thumb();
1816			}
1817			
1818			
1819			// BLOG AUX SLIDEOUT
1820			jQuery('.blog-slideout-trigger').on('click', function(e) {
1821				e.preventDefault();
1822				
1823				// VARIABLES
1824				var blogWrap = jQuery(this).parent().parent().parent().parent();
1825				var filterPanel = blogWrap.find('.filter-wrap .filter-slide-wrap');
1826				var auxType = jQuery(this).attr('data-aux');
1827								
1828				// ADD COLUMN SIZE AND REMOVE BRACKETS FROM COUNT
1829				blogWrap.find('.aux-list li').addClass('col-sm-2');
1830				blogWrap.find('.aux-list li a span').each(function() {
1831					jQuery(this).html(jQuery(this).html().replace("(","").replace(")",""));
1832				});
1833				
1834				// IF SELECTING AN OPTION THAT IS OPEN, CLOSE THE PANEL
1835				if (jQuery(this).parent().hasClass('selected') && !filterPanel.is(':animated')) {
1836					blogWrap.find('.blog-aux-options li').removeClass('selected');
1837					filterPanel.slideUp(400);
1838					return;
1839				}
1840				
1841				// AUX BUTTON SELECTED STATE
1842				blogWrap.find('.blog-aux-options li').removeClass('selected');	
1843				jQuery(this).parent().addClass('selected');
1844				
1845				// IF SLIDEOUT IS OPEN
1846				if (filterPanel.is(':visible')) {
1847					
1848					filterPanel.slideUp(400);
1849					setTimeout(function() {
1850						blogWrap.find('.aux-list').css('display', 'none');
1851						blogWrap.find('.aux-'+auxType).css('display', 'block');
1852						filterPanel.slideDown();
1853					}, 600);
1854					
1855				// IF SLIDEOUT IS CLOSED
1856				} else {
1857					
1858					blogWrap.find('.aux-list').css('display', 'none');
1859					blogWrap.find('.aux-'+auxType).css('display', 'block');
1860					filterPanel.slideDown();
1861					
1862				}
1863			});
1864			
1865		},
1866		masonryBlog: function() {
1867			flexSlider.thumb();
1868			if (!(IEVersion && IEVersion < 9)) {
1869				var scrollAnimateElement = new AnimOnScroll( document.getElementById( 'blogGrid' ), {
1870					minDuration : 0.4,
1871					maxDuration : 0.7,
1872					viewportFactor : 0.2
1873				});
1874			}
1875			blogItems.imagesLoaded(function () {
1876				flexSlider.thumb();
1877			});
1878			//blogItems.fitVids();
1879		},
1880		infiniteScroll: function() {
1881			if (!(IEVersion && IEVersion < 9)) {
1882				var infScrollData = jQuery('#inf-scroll-params');
1883				var infiniteScroll = {
1884					loading: {
1885						img: infScrollData.data('loadingimage'),
1886						msgText: infScrollData.data('msgtext'),
1887						finishedMsg: infScrollData.data('finishedmsg')
1888					},
1889					"nextSelector":".pagenavi li.next a",
1890					"navSelector":".pagenavi",
1891					"itemSelector":".blog-item",
1892					"contentSelector":".blog-items:not(.carousel-items)"
1893				};
1894				jQuery( infiniteScroll.contentSelector ).infinitescroll(
1895					infiniteScroll, function() {
1896						if (blogItems.parent().find('.pagination-wrap').hasClass('load-more')) {
1897							jQuery('.load-more-btn').fadeIn(400);
1898						}
1899						lightbox.destroy();
1900						lightbox.init();
1901						blogItems.imagesLoaded(function () {
1902							if (blogItems.hasClass('masonry-items')) {
1903								flexSlider.thumb();
1904								blog.masonryBlog();
1905							} else {
1906								flexSlider.thumb();
1907								//blogItems.fitVids();
1908							}
1909						});
1910					}
1911				);
1912				if (blogItems.parent().find('.pagination-wrap').hasClass('load-more')) {
1913					$window.unbind('.infscr');
1914					jQuery('.load-more-btn').on('click', function(e) {
1915						e.preventDefault();					
1916						jQuery( infiniteScroll.contentSelector ).infinitescroll('retrieve');
1917						jQuery('.load-more-btn').fadeOut(400);
1918					});
1919				}
1920			} else {
1921				jQuery('.pagination-wrap').removeClass('hidden');
1922			}
1923		}
1924	};
1925	
1926	
1927	/////////////////////////////////////////////
1928	// CAROUSEL FUNCTIONS
1929	/////////////////////////////////////////////
1930	
1931	var carouselWidgets = {
1932		init: function() {
1933
1934			// CAROUSELS
1935			var carousel = jQuery('.carousel-items'),
1936				carouselAuto = sfOptionParams.data('carousel-autoplay'),
1937				carouselPSpeed = sfOptionParams.data('carousel-pagespeed'),
1938				carouselSSpeed = sfOptionParams.data('carousel-slidespeed'),
1939				carouselPagination = sfOptionParams.data('carousel-pagination'),
1940				carouselPDirection = 'ltr',
1941				desktopWidth = 1199;
1942
1943			if (body.hasClass('vertical-header')) {
1944				desktopWidth = desktopWidth + jQuery('#header-section').width();
1945			}
1946
1947			if (carouselAuto) {
1948				carouselAuto = true;
1949			} else {
1950				carouselAuto = false;
1951			}
1952			if (carouselPagination) {
1953				carouselPagination = true;
1954			} else {
1955				carouselPagination = false;
1956			}
1957			if (isRTL) {
1958				carouselPDirection = 'rtl';
1959			}
1960
1961			carousel.each(function() {
1962				var carouselInstance = jQuery('#'+jQuery(this).attr('id')),
1963					carouselColumns = parseInt(carouselInstance.attr("data-columns"), 10),
1964					desktopCarouselItems = 4 > carouselColumns ? carouselColumns : 4,
1965					desktopSmallCarouselItems = 3 > carouselColumns ? carouselColumns : 3,
1966					mobileCarouselItems = 1,
1967					carouselAutoplay = carouselAuto;
1968
1969				if (carouselInstance.hasClass('clients-items')) {
1970					mobileCarouselItems = 2;
1971				}
1972				if (carouselInstance.hasClass('testimonials')) {
1973					desktopCarouselItems = 1;
1974					desktopSmallCarouselItems = 1;
1975					mobileCarouselItems = 1;
1976				}
1977				
1978				if ( carouselInstance.data('auto') ) {
1979					carouselAutoplay = true;
1980				}
1981
1982				carouselInstance.imagesLoaded(function () {
1983
1984					if (!carouselInstance.hasClass('no-gutters')) {
1985						var carouselWidth = carouselInstance.width();
1986						if (isRTL) {
1987						carouselInstance.css('margin-right', '-15px').css('width', carouselWidth + 30);
1988						} else {
1989						carouselInstance.css('margin-left', '-15px').css('width', carouselWidth + 30);
1990						}
1991					}
1992
1993					carouselInstance.owlCarousel({
1994						items : carouselColumns,
1995						itemsDesktop: [desktopWidth,desktopCarouselItems],
1996						itemsDesktopSmall: [desktopWidth-220,desktopSmallCarouselItems],
1997						itemsMobile: [479,mobileCarouselItems],
1998						paginationSpeed: carouselPSpeed,
1999						slideSpeed: carouselSSpeed,
2000						autoPlay: carouselAutoplay,
2001						autoPlayDirection : carouselPDirection,
2002						pagination: carouselPagination,
2003						autoHeight : false,
2004						beforeUpdate: function() {
2005							if (!carouselInstance.hasClass('no-gutters')) {
2006								var carouselWidth = carouselInstance.parent().width();
2007								carouselInstance.css('width', carouselWidth + 30);
2008							}
2009						},
2010						afterUpdate: function () {
2011							setTimeout(function() {
2012								flexSlider.thumb();
2013							}, 200);
2014						},
2015						afterInit: function() {
2016							flexSlider.thumb();
2017							$window.trigger('resize');
2018							setTimeout(function() {
2019								parallax.init(true);
2020							}, 200);
2021						},
2022						afterAction: function(){
2023							var carouselNext = carouselInstance.parents('.carousel-wrap').find('.carousel-next'),
2024								carouselPrev = carouselInstance.parents('.carousel-wrap').find('.carousel-prev');
2025								
2026						    if ( this.itemsAmount > this.visibleItems.length ) {
2027						        carouselNext.show();
2028						        carouselPrev.show();
2029						
2030						        carouselNext.removeClass('disabled');
2031						        carouselPrev.removeClass('disabled');
2032						        if ( this.currentItem === 0 ) {
2033						            carouselPrev.addClass('disabled');
2034						        }
2035						        if ( this.currentItem == this.maximumItem ) {
2036						            carouselNext.addClass('disabled');
2037						        }
2038						
2039						    } else {
2040						        carouselNext.hide();
2041						        carouselPrev.hide();
2042						    }
2043						}
2044					}).animate({
2045						'opacity': 1
2046					},800);
2047				});
2048			});
2049
2050			// Previous
2051			jQuery('.carousel-next').click( function(e) {
2052				e.preventDefault();
2053				var carousel = jQuery(this).closest('.spb_content_element').find('.owl-carousel');
2054				if (isRTL) {
2055				carousel.data( 'owlCarousel' ).prev();
2056				} else {
2057				carousel.data( 'owlCarousel' ).next();
2058				}
2059			});
2060
2061			// Next
2062			jQuery('.carousel-prev').click( function(e) {
2063				e.preventDefault();
2064				var carousel = jQuery(this).closest('.spb_content_element').find('.owl-carousel');
2065				if (isRTL) {
2066				carousel.data( 'owlCarousel' ).next();
2067				} else {
2068				carousel.data( 'owlCarousel' ).prev();
2069				}
2070			});
2071		},
2072		carouselSwipeIndicator: function(carousel) {
2073			carousel.appear(function() {
2074				var swipeIndicator = jQuery(this).parents('.carousel-wrap').find('.sf-swipe-indicator');
2075				setTimeout(function() {
2076					swipeIndicator.fadeIn(500);
2077				}, 400);
2078				setTimeout(function() {
2079					swipeIndicator.addClass('animate');
2080				}, 1000);
2081				setTimeout(function() {
2082					swipeIndicator.fadeOut(400);
2083				}, 3000);
2084			});
2085		},
2086		carouselMinHeight: function(carousel) {
2087			var minHeight = parseInt(carousel.find('.carousel-item:not(.no-thumb)').eq(0).css('height'));
2088			carousel.find('.owl-item').each(function () {
2089				jQuery(this).css('min-height',minHeight+'px');
2090			});
2091		}
2092	};
2093	
2094	
2095	/////////////////////////////////////////////
2096	// WIDGET FUNCTIONS
2097	/////////////////////////////////////////////
2098	
2099	var widgets = {
2100		init: function() {
2101			
2102			// CHARTS
2103			if (sfIncluded.hasClass('has-chart')) {
2104				jQuery('.chart-shortcode').each(function(){
2105					jQuery(this).easyPieChart({
2106						animate: 1000,
2107						lineCap: 'round',
2108						lineWidth: jQuery(this).attr('data-linewidth'),
2109						size: jQuery(this).attr('data-size'),
2110						barColor: jQuery(this).attr('data-barcolor'),
2111						trackColor: jQuery(this).attr('data-trackcolor'),
2112						scaleColor: 'transparent'
2113					});
2114				});
2115			}
2116			
2117			// LOAD WIDGETS
2118			widgets.accordion();
2119			widgets.tabs();
2120			widgets.toggle();
2121			widgets.fullWidthVideo();
2122			widgets.introAnimations();
2123			widgets.iconBoxes();
2124			widgets.countAssets();
2125			
2126			if (sfIncluded.hasClass('has-countdown')) {
2127			widgets.countdownAssets();
2128			}
2129			
2130			if (sfIncluded.hasClass('has-imagebanner')) {
2131			widgets.imageBanners();
2132			}
2133			
2134			jQuery('ul.nav-tabs li a, .spb_accordion_section > h3 a').click(function(){
2135				setTimeout(function() {
2136					$window.trigger('resize');
2137				}, 200);    		   
2138			});
2139			
2140			// RESIZE ASSETS
2141			widgets.resizeAssets();
2142			$window.smartresize( function() {  
2143				widgets.resizeAssets();
2144			});
2145			
2146			// SF TOOLTIPS
2147			jQuery('[rel=tooltip]').tooltip();
2148			
2149		},
2150		resizeAssets: function() {	
2151			var carousels = jQuery('.carousel-active .carousel-items,.carousel-active .products');
2152			var assets = jQuery('.alt-bg');
2153			var assetWidth = 0;
2154			
2155			if (jQuery('#container').width() < 460 && body.hasClass('responsive-fluid')) {
2156				assetWidth = jQuery('#container').width() - 40;			
2157				carousels.find('.carousel-item,.product').each(function() {
2158					jQuery(this).css("width", assetWidth + "px");
2159					
2160				});
2161			} else if (jQuery('#container').width() < 768 && body.hasClass('responsive-fluid')) {
2162				if (carousels.hasClass('testimonials')) {
2163				assetWidth = jQuery('#container').width() - 40;	
2164				} else {
2165				assetWidth = Math.floor(jQuery('#container').width() / 2) - 35;	
2166				}
2167				carousels.find('.carousel-item,.product').each(function() {
2168					jQuery(this).css("width", assetWidth + "px");
2169				});
2170			} else if (body.hasClass('responsive-fluid')) {
2171				carousels.find('.carousel-item,.product').each(function() {
2172					jQuery(this).css("width", "");
2173				});
2174			}
2175			
2176			if (jQuery('#container').width() < 768 && body.hasClass('responsive-fluid')) {
2177				assetWidth = jQuery('#container').width();
2178				assets.each(function() {
2179					jQuery(this).css("width", assetWidth + "px");
2180				});	
2181			} else {
2182				assets.each(function() {
2183					jQuery(this).css("width", "");
2184				});	
2185			}
2186		},
2187		accordion: function() {
2188			jQuery('.spb_accordion').each(function() {
2189				var spb_tabs,				
2190					active_tab = false,
2191					active_attr = parseInt(jQuery(this).attr('data-active'), 10);
2192							
2193				if (jQuery.type( active_attr ) === "number") { active_tab = active_attr; }
2194							
2195				spb_tabs = jQuery(this).find('.spb_accordion_wrapper').accordion({
2196					header: "> div > h3",
2197					autoHeight: true,
2198					collapsible: true,
2199					active: active_tab,
2200					heightStyle: "content"
2201				});
2202			}).fadeIn(400);
2203		},
2204		tabs: function() {
2205			// SET ACTIVE TABS PANE
2206			jQuery('.spb_tabs').each(function() {
2207				jQuery(this).find('.tab-pane').first().addClass('active');
2208				jQuery(this).find('.tab-pane').removeClass('load');
2209			});
2210			
2211			// SET ACTIVE TOUR PANE
2212			jQuery('.spb_tour').each(function() {
2213				jQuery(this).find('.tab-pane').first().addClass('active');
2214				jQuery(this).find('.tab-pane').removeClass('load');
2215			});
2216			
2217			// SET DESIRED TAB ON LOAD
2218			setTimeout(function() {
2219				if (jQuery('.spb_tabs').length > 0) {
2220					
2221					// Show correct tab on page load
2222					var url = document.location.toString();
2223					if (url.match('#') && jQuery('.nav-tabs a[href="#'+url.split('#')[1]+'"]').length > 0) {
2224					    var thisTab = jQuery('.nav-tabs a[href="#'+url.split('#')[1]+'"]'),
2225					    	parentTabs = thisTab.parents('.spb_tabs'),
2226					    	tabHash = url.split('#')[1];
2227					    
2228					    jQuery('.nav-tabs a[href="#'+tabHash+'"]').tab('show');
2229					} 
2230					
2231					// Change hash on tab click
2232					jQuery('.nav-tabs a').click(function (e) {
2233						var hash = e.target.hash;
2234						
2235						if (history.pushState) {
2236						    history.pushState(null, null, hash);
2237						} else {
2238						    location.hash = hash;
2239						}
2240					});
2241				}
2242			}, 50);
2243		},
2244		toggle: function() {
2245			jQuery('.spb_toggle').click(function() {
2246				if ( jQuery(this).hasClass('spb_toggle_title_active') ) {
2247					jQuery(this).removeClass('spb_toggle_title_active').next().slideUp(500);
2248				} else {
2249					jQuery(this).addClass('spb_toggle_title_active').next().slideDown(500);
2250				}
2251			});
2252			jQuery('.spb_toggle_content').each(function() {
2253				if ( jQuery(this).next().is('h4.spb_toggle') === false ) {
2254					jQuery('<div class="last_toggle_el_margin"></div>').insertAfter(this);
2255				}
2256			});
2257		},
2258		initSkillBars: function() {		
2259			// SKILL BARS
2260			widgets.animateSkillBars();
2261			jQuery('a.ui-tabs-anchor').click(function(){
2262				widgets.animateSkillBars();
2263			});
2264		},
2265		animateSkillBars: function() {
2266			jQuery('.progress').each(function(){
2267				var progress = jQuery(this);
2268				
2269				progress.appear(function() {
2270					var progressValue = progress.find('.bar').attr('data-value');
2271					
2272					if (!progress.hasClass('animated')) {
2273						progress.addClass('animated');
2274						progress.find('.bar').animate({
2275							width: progressValue + "%"
2276						}, 800, function() {
2277							progress.parent().find('.bar-text .progress-value').fadeIn(600);
2278						});
2279					}
2280				});
2281			});
2282		},
2283		charts: function() {
2284			widgets.animateCharts();
2285		},
2286		animateCharts: function() {
2287			jQuery('.chart-shortcode').each(function(){
2288				var chart = jQuery(this);
2289				chart.appear(function() {
2290					if (!jQuery(this).hasClass('animated')) {
2291						jQuery(this).addClass('animated');
2292						var animatePercentage = parseInt(jQuery(this).attr('data-animatepercent'), 10);
2293						jQuery(this).data('easyPieChart').update(animatePercentage);
2294					}
2295				});
2296			});
2297		},
2298		fullWidthVideo: function() {			
2299			jQuery(document).on('click', '.fw-video-link', function() {
2300				if (jQuery(this).data('video') !== "") {
2301					widgets.openFullWidthVideo(jQuery(this));
2302				}
2303				return false;
2304			});
2305			
2306			jQuery(document).on('click', '.fw-video-close', function() {
2307				widgets.closeFullWidthVideo();
2308			});
2309		},
2310		openFullWidthVideo: function(element) {
2311			jQuery('.fw-video-close').addClass('is-open');
2312			jQuery('.fw-video-spacer').animate({
2313				height: windowheight
2314			}, 1000, 'easeInOutExpo');
2315			
2316			jQuery('.fw-video-area').css('display', 'block').animate({
2317				top: 0,
2318				height: '100%'
2319			}, 1000, 'easeInOutExpo', function() {
2320				// load video here
2321				jQuery('.fw-video-area').append('<iframe class="fw-video" src="'+element.data('video')+'" width="100%" height="100%" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>');
2322			});
2323		},
2324		closeFullWidthVideo: function() {
2325			jQuery('.fw-video-close').removeClass('is-open');
2326			jQuery('.fw-video-spacer').animate({
2327				height: 0
2328			}, 1000, 'easeInOutExpo', function(){
2329			});
2330			jQuery('.fw-video-area').animate({
2331				top:'-100%'
2332			}, 1000, 'easeInOutExpo', function() {
2333				jQuery('.fw-video-area').css('display', 'none');
2334				jQuery('.fw-video-area .fw-video').remove();
2335			});
2336			
2337			// pause videos
2338			jQuery('.fw-video-area video').each(function(){
2339				this.pause();
2340			});
2341			setTimeout(function() {
2342				jQuery('.fw-video-area').find('iframe').remove();
2343			}, 1500);
2344			
2345			return false;
2346		},
2347		introAnimations: function() {
2348			
2349			if (!isMobileAlt) {
2350				jQuery('.sf-animation').each(function() {
2351	
2352					var animatedItem = jQuery(this),
2353						itemAnimation = animatedItem.data('animation'),
2354						itemDelay = animatedItem.data('delay');
2355										
2356					animatedItem.appear(function() {				
2357						if (itemAnimation == 'fade-from-left') {
2358							animatedItem.delay(itemDelay).animate({
2359								'opacity' : 1,
2360								'left' : '0px'
2361							}, 600, 'easeOutCubic');
2362						} else if (itemAnimation == 'fade-from-right') {
2363							animatedItem.delay(itemDelay).animate({
2364								'opacity' : 1,
2365								'right' : '0px'
2366							}, 600, 'easeOutCubic');
2367						} else if(itemAnimation == 'fade-from-bottom') {
2368							if (animatedItem.hasClass('image-banner-content')) {
2369								animatedItem.delay(itemDelay).animate({
2370									'opacity' : 1,
2371									'bottom' : '50%'
2372								}, 1000, 'easeOutCubic');
2373							} else {
2374								animatedItem.delay(itemDelay).animate({
2375									'opacity' : 1,
2376									'bottom' : '0px'
2377								}, 600, 'easeOutCubic');
2378							}
2379						} else if (itemAnimation == 'fade-in') {
2380							animatedItem.delay(itemDelay).animate({
2381								'opacity' : 1
2382							}, 600, 'easeOutCubic');
2383						} else if (itemAnimation == 'grow') {
2384							setTimeout(function(){ 
2385								animatedItem.addClass('sf-animate');
2386							}, itemDelay);
2387						} else {
2388							setTimeout(function() {
2389								animatedItem.addClass('sf-animate');						
2390							}, itemDelay);
2391						}
2392					}, {accX: 0, accY: -150}, 'easeInCubic');
2393				
2394				});
2395			}
2396		},
2397		iconBoxes: function() {
2398			if (isMobileAlt) {
2399				jQuery('.sf-icon-box').on('click', function() {
2400					jQuery(this).addClass('sf-mobile-hover');
2401				});
2402			} else {
2403				jQuery('.sf-icon-box').hover(
2404					function() {
2405						jQuery(this).addClass('sf-hover');
2406					}, function() {
2407						jQuery(this).removeClass('sf-hover');
2408					}
2409				);
2410			}
2411		},
2412		countAssets: function() {
2413			jQuery('.sf-count-asset').each(function() {
2414
2415				var countAsset = jQuery(this),
2416					countNumber = countAsset.find('.count-number'),
2417					countDivider = countAsset.find('.count-divider').find('span'),
2418					countSubject = countAsset.find('.count-subject');
2419				
2420				if (!isMobileAlt) {						
2421					countAsset.appear(function() {				
2422					
2423						countNumber.countTo({
2424							onComplete: function () {
2425								countDivider.animate({
2426									'width': 50
2427								}, 400, 'easeOutCubic');
2428								countSubject.delay(100).animate({
2429									'opacity' : 1,
2430									'bottom' : '0px'
2431								}, 600, 'easeOutCubic');
2432							}
2433						});
2434						
2435					}, {accX: 0, accY: -150}, 'easeInCubic');
2436				} else {
2437					countNumber.countTo({
2438						onComplete: function () {
2439							countDivider.animate({
2440								'width': 50
2441							}, 400, 'easeOutCubic');
2442							countSubject.delay(100).animate({
2443								'opacity' : 1,
2444								'bottom' : '0px'
2445							}, 600, 'easeOutCubic');
2446						}
2447					});
2448				}
2449			
2450			});
2451		},
2452		countdownAssets: function() {
2453			jQuery('.sf-countdown').each(function() {
2454				var countdownInstance = jQuery(this),
2455					year = parseInt(countdownInstance.data('year'), 10),
2456					month = parseInt(countdownInstance.data('month'), 10),
2457					day = parseInt(countdownInstance.data('day'), 10),
2458					hour = parseInt(countdownInstance.data('hour'), 10),
2459					countdownDate = new Date(year, month - 1, day, hour),
2460					type = countdownInstance.data('type');
2461				
2462				var labelStrings = jQuery('#countdown-locale'),
2463					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')],
2464					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')];
2465				
2466				if (type == "countup") {
2467					countdownInstance.countdown({
2468						since: countdownDate,
2469						format: 'dHMS',
2470						labels: pluralLabels,
2471						labels1: singularLabels,
2472						onExpiry: function() {
2473							setTimeout(function() {
2474								countdownInstance.fadeOut(500);						
2475							}, 1000);
2476						}
2477					});
2478				} else {
2479					countdownInstance.countdown({
2480						until: countdownDate,
2481						since: null,
2482						format: 'dHMS',
2483						labels: pluralLabels,
2484						labels1: singularLabels,
2485						onExpiry: function() {
2486							setTimeout(function() {
2487								countdownInstance.fadeOut(500);						
2488							}, 1000);
2489						}
2490					});
2491				}
2492			});
2493		},
2494		imageBanners: function() {
2495			jQuery('.sf-image-banner').each(function() {
2496				jQuery(this).find('.image-banner-content').vCenter();
2497			});
2498		}
2499	};
2500	
2501	
2502	/////////////////////////////////////////////
2503	// TEAM MEMBERS FUNCTION
2504	/////////////////////////////////////////////
2505	
2506	var teamMembers = {
2507		init: function() {
2508			// TEAM EQUAL HEIGHTS
2509			var team = jQuery('.team-members.carousel-items');
2510			team.imagesLoaded(function () {
2511				team.equalHeights();
2512			});
2513			
2514			// TEAM ASSETS
2515			$window.smartresize( function() {
2516				jQuery('.team-members.carousel-items').children().css('min-height','0');
2517				jQuery('.team-members.carousel-items').equalHeights();
2518			});
2519		}
2520	};
2521	
2522	
2523	/////////////////////////////////////////////
2524	// PARALLAX FUNCTION
2525	/////////////////////////////////////////////
2526	
2527	var parallax = {
2528		init: function(reset) {
2529
2530			jQuery('.spb_parallax_asset').each(function(reset) {
2531
2532				var parallaxAsset = jQuery(this),
2533					parallaxContent = parallaxAsset.find('div:first');
2534
2535				if (parallaxAsset.hasClass('sf-parallax-video')) {
2536
2537					if (!isMobileAlt) {
2538						parallax.parallaxVideoInit();
2539					} else {
2540						parallaxAsset.find('video').remove();
2541
2542						// Fade in
2543						parallaxContent.animate({
2544							'opacity': 1,
2545						}, 300, 'easeOutExpo');
2546					}
2547
2548					// Add resize handler
2549					$window.smartresize( function() {
2550						parallax.parallaxVideoResize(parallaxAsset);
2551					});
2552
2553				} else if (parallaxAsset.hasClass('parallax-window-height')) {
2554
2555					parallaxAsset.css('height', '');
2556					var assetHeight = $window.height();
2557
2558					if (parallaxAsset.height() > assetHeight && !reset) {
2559						assetHeight = parallaxAsset.height();
2560					}
2561
2562					parallaxAsset.height(assetHeight - (parseInt(parallaxAsset.css('padding-top'), 10) * 2));
2563					if (parallaxAsset.data('v-center') === "true") {
2564						parallaxAsset.find('div:first').vCenterTop();
2565					}
2566
2567					// Fade in
2568					parallaxContent.animate({
2569						'opacity': 1,
2570					}, 300, 'easeOutExpo');
2571
2572					// Add resize handler
2573					parallax.windowImageResize(parallaxAsset);
2574					$window.smartresize( function() {
2575						parallax.windowImageResize(parallaxAsset);
2576					});
2577				}
2578				
2579				if (parallaxAsset.hasClass('parallax-stellar')) {
2580					var parallaxSpeed = parallaxAsset.data('stellar-background-ratio');
2581					parallaxAsset.parallax("50%", parallaxSpeed);
2582				}
2583			});
2584		},
2585		videoScroll: function(asset) {
2586
2587			var offsetTop = asset.offset().top,
2588				windowTop = $window.scrollTop(),
2589				defaultHeight = parseInt(asset.data('height-default'), 10),
2590				diff = windowTop - offsetTop,
2591				currentTop = asset.find('.spb_content_wrapper').css('top'),
2592				heightDifference = defaultHeight - diff * 1.5;
2593
2594			if (windowTop > offsetTop) {
2595				asset.css('height', heightDifference);
2596				asset.find('.spb_content_wrapper').css('opacity', 1 - (diff / 300));
2597				if (asset.hasClass('parallax-window-height') && asset.data('v-center') === "true") {
2598				asset.find('.spb_content_wrapper').css('top', currentTop + (diff / 4));
2599				} else if (asset.data('v-center') === "true") {
2600				asset.find('.spb_content_wrapper').css('top', (diff / 3));
2601				}
2602			} else {
2603				asset.css('height', defaultHeight);
2604				asset.find('.spb_content_wrapper').css('opacity', 1);
2605				if (asset.hasClass('parallax-video-height') && asset.data('v-center') === "true") {
2606				asset.find('.spb_content_wrapper').css('top', '50%');
2607				} else {
2608				asset.find('.spb_content_wrapper').css('top', 0);
2609				}
2610			}
2611
2612		},
2613		windowImageResize: function(asset) {
2614
2615			if (asset.hasClass('spb-row-container')) {
2616
2617				var rowContentHeight = asset.find('> .spb_content_element').height();
2618
2619				if (asset.hasClass('parallax-window-height')) {
2620
2621					if (rowContentHeight < $window.height()) {
2622						rowContentHeight = $window.height();
2623					}
2624				}
2625
2626				asset.height(rowContentHeight);
2627
2628				if (asset.data('v-center')) {
2629				asset.find('> .spb_content_element').vCenterTop();
2630				}
2631
2632			} else {
2633
2634				var assetHeight = asset.height();
2635
2636				if (asset.hasClass('parallax-window-height')) {
2637
2638					if (assetHeight < $window.height()) {
2639						assetHeight = $window.height();
2640					}
2641				}
2642
2643				asset.height(assetHeight - asset.css('padding-top') / 2);
2644				asset.find('.spb_content_wrapper').vCenterTop();
2645			}
2646
2647		},
2648		parallaxVideoInit: function() {
2649			jQuery('.spb_parallax_asset.sf-parallax-video').each(function() {
2650				var parallaxAsset = jQuery(this),
2651					parallaxVideo = parallaxAsset.find('video'),
2652					parallaxVideoWidth = parallaxVideo.width(),
2653					parallaxContent = parallaxAsset.find('div:first'),
2654					parallaxAssetHeight = 0;
2655
2656				if (parallaxAsset.hasClass('parallax-window-height')) {
2657
2658					if (parallaxContent.height() > $window.height()) {
2659						parallaxAssetHeight = parallaxContent.height();
2660					} else {
2661						parallaxAssetHeight = $window.height();
2662					}
2663
2664					parallaxAsset.animate({
2665						'height': parallaxAssetHeight
2666					}, 400);
2667
2668					setTimeout(function() {
2669
2670						// Scale video
2671						parallax.parallaxVideoResize(parallaxAsset);
2672
2673						// Fade in
2674						parallaxContent.animate({
2675							'opacity': 1,
2676						}, 300, 'easeOutExpo');
2677
2678					}, 500);
2679
2680					setTimeout(function() {
2681						parallaxAsset.find('.video-overlay').animate({
2682							'opacity': 0.8
2683						}, 200);
2684					}, 100);
2685
2686					if (parallaxAsset.data('v-center') === "true") {
2687					parallaxContent.vCenterTop();
2688					}
2689
2690					setTimeout(function() {
2691						parallaxContent.animate({
2692							'opacity': 1,
2693							'top': '50%'
2694						}, 600, 'easeOutExpo');
2695					}, 600);
2696
2697					parallaxAsset.attr('data-height-default', parallaxVideo.height());
2698
2699				} else {
2700					parallax.scaleVideo(parallaxAsset);
2701				}
2702
2703				if ($window.width() < parallaxVideoWidth) {
2704					parallaxVideo.css('left', - (parallaxVideoWidth - $window.width()) /2);
2705				}
2706				
2707				var videoInstance = parallaxVideo.get( 0 );
2708				videoInstance.load();
2709				videoInstance.addEventListener( 'loadeddata' , function() {
2710				        parallax.parallaxVideoResize(parallaxAsset);
2711				    }
2712				);
2713
2714			});
2715		},
2716		parallaxVideoResize: function(parallaxAsset) {
2717			var parallaxContent = parallaxAsset.find('div:first'),
2718				parallaxAssetHeight = 0;
2719
2720			if (parallaxAsset.hasClass('parallax-window-height')) {
2721				if (parallaxContent.height() > $window.height()) {
2722					parallaxAssetHeight = parallaxContent.height();
2723				} else {
2724					parallaxAssetHeight = $window.height();
2725				}
2726
2727				parallaxAsset.animate({
2728					'height': parallaxAssetHeight
2729				}, 400);
2730
2731				if (parallaxAsset.data('v-center') === "true") {
2732				parallaxContent.vCenterTop();
2733				}
2734			}
2735
2736			parallax.scaleVideo(parallaxAsset);
2737		},
2738		scaleVideo: function(parallaxAsset) {
2739
2740			var video = parallaxAsset.find('video'),
2741				assetHeight = parallaxAsset.outerHeight(),
2742				assetWidth = parallaxAsset.outerWidth(),
2743				videoWidth = video[0].videoWidth,
2744				videoHeight = video[0].videoHeight;
2745
2746			// Use the largest scale factor of horizontal/vertical
2747			var scale_h = assetWidth / videoWidth;
2748			var scale_v = assetHeight / videoHeight;
2749			var scale = scale_h > scale_v ? scale_h : scale_v;
2750
2751			// Update minium width to never allow excess space
2752			var min_w = videoWidth/videoHeight * (assetHeight+20);
2753
2754			// Don't allow scaled width < minimum video width
2755			if (scale * videoWidth < min_w) {scale = min_w / videoWidth;}
2756
2757			// Scale the video
2758			video.width(Math.ceil(scale * videoWidth +2));
2759			video.height(Math.ceil(scale * videoHeight +50));
2760			video.css('margin-top', - (video.height() - assetHeight) /2);
2761			video.css('margin-left', - (video.width() - assetWidth) /2);
2762		},
2763
2764	};
2765	
2766	/////////////////////////////////////////////
2767	// LIGHTBOX FUNCTION
2768	/////////////////////////////////////////////
2769	
2770	var lightbox = {
2771		init: function() {
2772			
2773			if ( !lightboxEnabled ) {
2774				return;
2775			}
2776		
2777			// Lightbox Social
2778			var lightboxSocial = {};
2779			if (lightboxSharing) {
2780				lightboxSocial = {
2781					facebook: {
2782						source: 'https://www.facebook.com/sharer/sharer.php?u={URL}',
2783						text: 'Share on Facebook'
2784					},
2785					twitter: true,
2786					googleplus: true,
2787					pinterest: {
2788						source: "https://pinterest.com/pin/create/bookmarklet/?url={URL}",
2789						text: "Share on Pinterest"
2790					}
2791				};
2792			}
2793					
2794			// Lightbox Galleries
2795			var galleryArr = [];
2796			jQuery('[data-rel^="ilightbox["]').each(function () {
2797				var attr = this.getAttribute("data-rel");
2798				if ( jQuery(this).hasClass( 'ilightbox-enabled' ) ) {
2799					return;
2800				}
2801				if (jQuery.inArray(attr, galleryArr) == -1 ) {
2802					galleryArr.push(attr);
2803				}
2804			});
2805			jQuery.each(galleryArr, function (b, c) {
2806				jQuery('[data-rel="' + c + '"]').iLightBox({
2807					skin: lightboxSkin,
2808					social: {
2809						buttons: lightboxSocial
2810					},
2811					minScale: 0.1,
2812					maxScale: 0.6,
2813					path: 'horizontal',
2814					thumbnails: {
2815						maxWidth: 120,
2816						maxHeight: 120
2817					},
2818					controls: {
2819						arrows: lightboxControlArrows,
2820						thumbnail: lightboxThumbs
2821					}
2822				});
2823				jQuery('[data-rel="' + c + '"]').addClass( 'ilightbox-enabled' );
2824			});
2825		},
2826		destroy: function() {
2827		
2828			if ( !lightboxEnabled ) {
2829				return;
2830			}
2831			
2832			jQuery('[data-rel="ilightbox[product]"]').removeClass('ilightbox-enabled').iLightBox().destroy();
2833			jQuery('[data-rel="ilightbox[posts]"]').removeClass('ilightbox-enabled').iLightBox().destroy();
2834		}
2835	};
2836	
2837	
2838	/////////////////////////////////////////////
2839	// MAP FUNCTIONS
2840	/////////////////////////////////////////////
2841	
2842	var map = {
2843		init:function() {
2844			
2845			var maps = jQuery('.map-canvas');
2846			maps.each(function(index, element) {
2847				var mapContainer = element,
2848					mapAddress = mapContainer.getAttribute('data-address'),
2849					mapZoom = mapContainer.getAttribute('data-zoom'),
2850					mapType = mapContainer.getAttribute('data-maptype'),
2851					mapColor = mapContainer.getAttribute('data-mapcolor'),
2852					mapSaturation = mapContainer.getAttribute('data-mapsaturation'),
2853					pinLogoURL = mapContainer.getAttribute('data-pinimage'),
2854					pinLink = mapContainer.getAttribute('data-pinlink');
2855				
2856				map.getCoordinates(mapAddress, mapContainer, mapZoom, mapType, mapColor, mapSaturation, pinLogoURL, pinLink);
2857								
2858			});
2859			jQuery('ul.nav-tabs li a').click(function(){
2860				var thisTabHref = jQuery(this).attr('href');
2861				if (jQuery(thisTabHref).find('.spb_gmaps_widget').length > 0) {
2862					map.init();
2863				}
2864			});
2865			
2866			jQuery('.spb_accordion_section > h3 a').click(function(){
2867				var thisAccordion = jQuery(this).parents('.spb_accordion_section');
2868				if (thisAccordion.find('.spb_gmaps_widget').length > 0) {
2869					map.init();
2870				}
2871			});
2872			
2873		},
2874		getCoordinates: function(address, mapContainer, mapZoom, mapType, mapColor, mapSaturation, pinLogoURL, pinLink) {
2875			var geocoder;
2876			geocoder = new google.maps.Geocoder();			
2877			geocoder.geocode({
2878				'address': address
2879			}, function(results, status) {
2880				if (status == google.maps.GeocoderStatus.OK) {
2881					
2882					if (mapSaturation == "mono") {
2883						mapSaturation = -100;
2884					} else {
2885						mapSaturation = -20;
2886					}
2887					
2888					var styles = [
2889						{
2890							stylers: [
2891								{hue: mapColor},
2892								{saturation: mapSaturation}
2893							]
2894						}
2895					];
2896					
2897					var styledMap = new google.maps.StyledMapType(styles,{name: "Styled Map"});  
2898					
2899					var mapTypeIdentifier = "",
2900						companyPos = "",
2901						isDraggable = true,
2902						mapCoordinates = results[0].geometry.location,
2903						latitude = results[0].geometry.location.lat(),
2904						longitude = results[0].geometry.location.lng();				
2905					
2906					if (isMobileAlt) {
2907					isDraggable = false;
2908					}
2909					
2910					if (mapType === "SATELLITE") {
2911					mapTypeIdentifier = google.maps.MapTypeId.SATELLITE;
2912					} else if (mapType === "TERRAIN") {
2913					mapTypeIdentifier = google.maps.MapTypeId.TERRAIN;
2914					} else if (mapType === "HYBRID") {
2915					mapTypeIdentifier = google.maps.MapTypeId.HYBRID;
2916					} else {
2917					mapTypeIdentifier = google.maps.MapTypeId.ROADMAP;
2918					}
2919							
2920					var latlng = new google.maps.LatLng(latitude, longitude);
2921					var settings = {
2922						zoom: parseInt(mapZoom, 10),
2923						scrollwheel: false,
2924						center: latlng,
2925						draggable: isDraggable,
2926						mapTypeControl: true,
2927						mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
2928						navigationControl: true,
2929						navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
2930						mapTypeId: mapTypeIdentifier
2931					};
2932					var mapInstance = new google.maps.Map(mapContainer, settings);
2933					var companyMarker = "";
2934					
2935					// ADD MARKER AFTER 1 SECOND
2936					jQuery(mapContainer).appear(function() {
2937						setTimeout(function() {
2938							if (pinLogoURL) {
2939								var companyLogo = new google.maps.MarkerImage(pinLogoURL,
2940									new google.maps.Size(150,75),
2941									new google.maps.Point(0,0),
2942									new google.maps.Point(75,75)
2943								);
2944								companyPos = new google.maps.LatLng(latitude, longitude);
2945								companyMarker = new google.maps.Marker({
2946									position: mapCoordinates,
2947									map: mapInstance,
2948									icon: companyLogo,
2949									animation: google.maps.Animation.DROP
2950								});
2951							} else { 
2952								companyPos = new google.maps.LatLng(latitude, longitude);
2953								companyMarker = new google.maps.Marker({
2954									position: mapCoordinates,
2955									map: mapInstance,
2956									animation: google.maps.Animation.DROP
2957								});
2958							}
2959							
2960							google.maps.event.addListener(companyMarker, 'click', function() {
2961								//window.location.href = 'http://maps.google.com/maps?q='+companyPos;
2962								if (pinLink === "") {
2963									pinLink = 'http://maps.google.com/maps?q='+companyPos;
2964								}
2965								window.open(pinLink);
2966							});
2967							
2968							google.maps.event.addDomListener(window, 'resize', function() {
2969								mapInstance.setCenter(companyPos);
2970							});
2971						}, 1000);
2972					});
2973								
2974					// MAP COLOURIZE
2975					if (mapColor !== "") {
2976					mapInstance.mapTypes.set('map_style', styledMap);
2977					mapInstance.setMapTypeId('map_style');
2978					}
2979
2980				} else {
2981					console.log(status);
2982				}
2983			});			
2984		}
2985	};
2986		
2987	
2988	/////////////////////////////////////////////
2989	// RELOAD FUNCTIONS
2990	/////////////////////////////////////////////
2991	
2992	var reloadFunctions = {
2993		init:function() {	
2994	
2995			// Remove title attributes from images to avoid showing on hover 
2996			jQuery('img[title]').each(function() {
2997				jQuery(this).removeAttr('title');
2998			});
2999			
3000			if (!isAppleDevice) {
3001				jQuery('embed').show();
3002			}
3003						
3004			// Animate Top Links
3005			jQuery('.animate-top').on('click', function(e) {
3006				e.preventDefault();
3007				jQuery('body,html').animate({scrollTop: 0}, 800, 'easeOutCubic');           
3008			});
3009		},
3010		load:function() {
3011			if (!isMobile) {
3012			
3013				// Button hover tooltips
3014				jQuery('.tooltip').each( function() {
3015					jQuery(this).css( 'marginLeft', '-' + Math.round( (jQuery(this).outerWidth(true) / 2) ) + 'px' );
3016				});
3017				
3018				jQuery('.comment-avatar').hover( function() {
3019					jQuery(this).find('.tooltip' ).stop().animate({
3020						bottom: '44px',
3021						opacity: 1
3022					}, 500, 'easeInOutExpo');
3023				}, function() {
3024						jQuery(this).find('.tooltip').stop().animate({
3025							bottom: '25px',
3026							opacity: 0
3027						}, 400, 'easeInOutExpo');
3028				});
3029				
3030				jQuery('.grid-image').hover( function() {
3031					jQuery(this).find('.tooltip' ).stop().animate({
3032						bottom: '85px',
3033						opacity: 1
3034					}, 500, 'easeInOutExpo');
3035				}, function() {
3036						jQuery(this).find('.tooltip').stop().animate({
3037							bottom: '65px',
3038							opacity: 0
3039						}, 400, 'easeInOutExpo');
3040				});
3041				
3042				
3043				// HASH CHECK
3044				setTimeout(function() {
3045				 	var urlHash = document.location.toString();
3046					if (urlHash.match('#')) {
3047					    var hash = urlHash.split('#')[1];
3048					    		   
3049					    if ( jQuery('#' + hash).length > 0 ) {
3050					        var headerHeight = 0;
3051					        	
3052					        if (jQuery('.sticky-header').length > 0) {
3053					        	headerHeight = jQuery('.sticky-header').height();
3054					        }
3055					        if (jQuery('#wpadminbar').length > 0) {
3056					        	headerHeight = headerHeight + 28;
3057					        }
3058					        
3059					        jQuery('html, body').stop().animate({
3060					        	scrollTop: jQuery('#' + hash).offset().top - headerHeight - 30
3061					        }, 600, 'easeInOutExpo');
3062					        
3063					    }
3064					}
3065				}, 200);	
3066			}
3067		}
3068	};
3069	
3070	
3071	/////////////////////////////////////////////
3072	// GLOBAL VARIABLES
3073	/////////////////////////////////////////////
3074	
3075	var $window = jQuery(window),
3076		body = jQuery('body'),
3077		sfIncluded = jQuery('#sf-included'),
3078		sfOptionParams = jQuery('#sf-option-params'),
3079		windowheight = page.getViewportHeight(),
3080		deviceAgent = navigator.userAgent.toLowerCase(),
3081		isMobile = deviceAgent.match(/(iphone|ipod|android|iemobile)/),
3082		isMobileAlt = deviceAgent.match(/(iphone|ipod|ipad|android|iemobile)/),
3083		isAppleDevice = deviceAgent.match(/(iphone|ipod|ipad)/),
3084		isIEMobile = deviceAgent.match(/(iemobile)/),
3085		IEVersion = page.checkIE(),
3086		isRTL = false,
3087		lightboxEnabled = sfOptionParams.data('lightbox-enabled') ? true : false,
3088		lightboxControlArrows = sfOptionParams.data('lightbox-nav') === "arrows" ? true : false,
3089		lightboxThumbs = sfOptionParams.data('lightbox-thumbs') ? true : false,
3090		lightboxSkin = sfOptionParams.data('lightbox-skin') === "dark" ? "metro-black" : "metro-white",
3091		lightboxSharing = sfOptionParams.data('lightbox-sharing') ? true : false,
3092		sliderAuto = sfOptionParams.data('slider-autoplay') ? true : false,
3093		sliderSlideSpeed = sfOptionParams.data('slider-slidespeed'),
3094		sliderAnimSpeed = sfOptionParams.data('slider-animspeed');
3095		
3096	/////////////////////////////////////////////
3097	// LOAD + READY FUNCTION
3098	/////////////////////////////////////////////
3099		
3100	var onReady = {
3101		init: function(){
3102			page.init();
3103			if (jQuery('.sf-super-search').length > 0) {
3104			superSearch.init();
3105			}
3106			if (jQuery('#header-section').length > 0) {
3107			header.init();
3108			}
3109			nav.init();
3110			lightbox.init();
3111			if (sfIncluded.hasClass('has-products') || body.hasClass('woocommerce-cart') || body.hasClass('woocommerce-account')) {
3112			woocommerce.init();
3113			}
3114			if (sfIncluded.hasClass('has-portfolio')) {
3115			portfolio.init();
3116			}
3117			if (sfIncluded.hasClass('has-portfolio-showcase')) {
3118			portfolio.portfolioShowcaseInit();
3119			}
3120			if (sfIncluded.hasClass('has-blog')) {
3121			blog.init();
3122			}
3123			if (sfIncluded.hasClass('has-infscroll')) {
3124			blog.infiniteScroll();
3125			}
3126			widgets.init();
3127			if (sfIncluded.hasClass('has-team')) {
3128			//teamMembers.init();
3129			}
3130			if (sfIncluded.hasClass('has-carousel')) {
3131			carouselWidgets.init();
3132			}
3133			if (sfIncluded.hasClass('has-parallax')) {
3134			parallax.init();
3135			}
3136			reloadFunctions.init();
3137		}
3138	};
3139	var onLoad = {
3140		init: function(){
3141			nav.load();
3142			flexSlider.init();
3143			if (sfIncluded.hasClass('has-gallery')) {
3144			flexSlider.gallery();
3145			}
3146			if (sfIncluded.hasClass('has-chart')) {
3147			widgets.charts();
3148			}
3149			if (sfIncluded.hasClass('has-progress-bar')) {
3150			widgets.initSkillBars();
3151			}
3152			if (sfIncluded.hasClass('has-map')) {
3153			map.init();
3154			}
3155			reloadFunctions.load();
3156			woocommerce.variations();
3157			
3158			// ANCHOR ON LOAD
3159			var anchorID = window.location.hash;
3160			if (anchorID !== "" && jQuery(anchorID).length > 0) {	
3161				setTimeout(function() {
3162					var anchorPosition = jQuery(anchorID).offset(); 
3163					jQuery('body,html').scrollTop(anchorPosition.top - 200); 
3164				}, 300);
3165			}
3166		}
3167	};
3168	
3169	jQuery(document).ready(onReady.init);
3170	jQuery(window).load(onLoad.init);
3171	
3172})(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.