PageSourceSearch

https://www.sorinailie.ro/wp-content/themes/dante/js/functions.js

js sorinailie.ro collected 2026-10-05 19:25:33 UTC 98,684 bytes, 3,128 lines download raw bytes

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