PageSourceSearch

https://tellmamauk.org/wp-content/themes/Divi/includes/builder/scripts/frontend-builder-scripts.js?ver=3.1

js tellmamauk.org collected 2026-10-02 03:55:47 UTC 139,907 bytes, 3,746 lines download raw bytes

1(function($){
2	var $et_window = $(window);
3
4	window.et_load_event_fired = false;
5
6	jQuery.fn.reverse = [].reverse;
7
8	jQuery.fn.closest_descendent = function( selector ) {
9		var $found,
10			$current_children = this.children();
11
12		while ( $current_children.length ) {
13			$found = $current_children.filter( selector );
14			if ( $found.length ) {
15				break;
16			}
17			$current_children = $current_children.children();
18		}
19
20		return $found;
21	};
22
23	window.et_pb_init_modules = function() {
24		$.et_pb_simple_slider = function(el, options) {
25			var settings = $.extend( {
26				slide         			: '.et-slide',				 	// slide class
27				arrows					: '.et-pb-slider-arrows',		// arrows container class
28				prev_arrow				: '.et-pb-arrow-prev',			// left arrow class
29				next_arrow				: '.et-pb-arrow-next',			// right arrow class
30				controls 				: '.et-pb-controllers a',		// control selector
31				carousel_controls 		: '.et_pb_carousel_item',		// carousel control selector
32				control_active_class	: 'et-pb-active-control',		// active control class name
33				previous_text			: et_pb_custom.previous,			// previous arrow text
34				next_text				: et_pb_custom.next,				// next arrow text
35				fade_speed				: 500,							// fade effect speed
36				use_arrows				: true,							// use arrows?
37				use_controls			: true,							// use controls?
38				manual_arrows			: '',							// html code for custom arrows
39				append_controls_to		: '',							// controls are appended to the slider element by default, here you can specify the element it should append to
40				controls_below			: false,
41				controls_class			: 'et-pb-controllers',				// controls container class name
42				slideshow				: false,						// automattic animation?
43				slideshow_speed			: 7000,							// automattic animation speed
44				show_progress_bar		: false,							// show progress bar if automattic animation is active
45				tabs_animation			: false,
46				use_carousel			: false
47			}, options );
48
49			var $et_slider 			= $(el),
50				$et_slide			= $et_slider.closest_descendent( settings.slide ),
51				et_slides_number	= $et_slide.length,
52				et_fade_speed		= settings.fade_speed,
53				et_active_slide		= 0,
54				$et_slider_arrows,
55				$et_slider_prev,
56				$et_slider_next,
57				$et_slider_controls,
58				$et_slider_carousel_controls,
59				et_slider_timer,
60				controls_html = '',
61				carousel_html = '',
62				$progress_bar = null,
63				progress_timer_count = 0,
64				$et_pb_container = $et_slider.find( '.et_pb_container' ),
65				et_pb_container_width = $et_pb_container.width(),
66				is_post_slider = $et_slider.hasClass( 'et_pb_post_slider' );
67
68				$et_slider.et_animation_running = false;
69
70				$.data(el, "et_pb_simple_slider", $et_slider);
71
72				$et_slide.eq(0).addClass( 'et-pb-active-slide' );
73
74				if ( ! settings.tabs_animation ) {
75					if ( !$et_slider.hasClass('et_pb_bg_layout_dark') && !$et_slider.hasClass('et_pb_bg_layout_light') ) {
76						$et_slider.addClass( et_get_bg_layout_color( $et_slide.eq(0) ) );
77					}
78				}
79
80				if ( settings.use_arrows && et_slides_number > 1 ) {
81					if ( settings.manual_arrows == '' )
82						$et_slider.append( '<div class="et-pb-slider-arrows"><a class="et-pb-arrow-prev" href="#">' + '<span>' +settings.previous_text + '</span>' + '</a><a class="et-pb-arrow-next" href="#">' + '<span>' + settings.next_text + '</span>' + '</a></div>' );
83					else
84						$et_slider.append( settings.manual_arrows );
85
86					$et_slider_arrows 	= $et_slider.find( settings.arrows );
87					$et_slider_prev 	= $et_slider.find( settings.prev_arrow );
88					$et_slider_next 	= $et_slider.find( settings.next_arrow );
89
90					$et_slider_next.click( function(){
91						if ( $et_slider.et_animation_running )	return false;
92
93						$et_slider.et_slider_move_to( 'next' );
94
95						return false;
96					} );
97
98					$et_slider_prev.click( function(){
99						if ( $et_slider.et_animation_running )	return false;
100
101						$et_slider.et_slider_move_to( 'previous' );
102
103						return false;
104					} );
105
106					// swipe support requires et-jquery-touch-mobile
107					$et_slider.find( settings.slide ).on( 'swipeleft', function() {
108						$et_slider.et_slider_move_to( 'next' );
109					});
110					$et_slider.find( settings.slide ).on( 'swiperight', function() {
111						$et_slider.et_slider_move_to( 'previous' );
112					});
113				}
114
115				if ( settings.use_controls && et_slides_number > 1 ) {
116					for ( var i = 1; i <= et_slides_number; i++ ) {
117						controls_html += '<a href="#"' + ( i == 1 ? ' class="' + settings.control_active_class + '"' : '' ) + '>
117' + i + '</a>';
118					}
119
120					controls_html =
121						'<div class="' + settings.controls_class + '">' +
122							controls_html +
123						'</div>';
124
125					if ( settings.append_controls_to == '' )
126						$et_slider.append( controls_html );
127					else
128						$( settings.append_controls_to ).append( controls_html );
129
130					if ( settings.controls_below )
131						$et_slider_controls	= $et_slider.parent().find( settings.controls );
132					else
133						$et_slider_controls	= $et_slider.find( settings.controls );
134
135					et_maybe_set_controls_color( $et_slide.eq(0) );
136
137					$et_slider_controls.click( function(){
138						if ( $et_slider.et_animation_running )	return false;
139
140						$et_slider.et_slider_move_to( $(this).index() );
141
142						return false;
143					} );
144				}
145
146				if ( settings.use_carousel && et_slides_number > 1 ) {
147					for ( var i = 1; i <= et_slides_number; i++ ) {
148						slide_id = i - 1;
149						image_src = ( $et_slide.eq(slide_id).data('image') !== undefined ) ? 'url(' + $et_slide.eq(slide_id).data('image') + ')' : 'none';
150						carousel_html += '<div class="et_pb_carousel_item ' + ( i == 1 ? settings.control_active_class : '' ) + '" data-slide-id="'+ slide_id +'">' +
151							'<div class="et_pb_video_overlay" href="#" style="background-image: ' + image_src + ';">' +
152								'<div class="et_pb_video_overlay_hover"><a href="#" class="et_pb_video_play"></a></div>' +
153							'</div>' +
154						'</div>';
155					}
156
157					carousel_html =
158						'<div class="et_pb_carousel">' +
159						'<div class="et_pb_carousel_items">' +
160							carousel_html +
161						'</div>' +
162						'</div>';
163					$et_slider.after( carousel_html );
164
165					$et_slider_carousel_controls = $et_slider.siblings('.et_pb_carousel').find( settings.carousel_controls );
166					$et_slider_carousel_controls.click( function(){
167						if ( $et_slider.et_animation_running )	return false;
168
169						var $this = $(this);
170						$et_slider.et_slider_move_to( $this.data('slide-id') );
171
172						return false;
173					} );
174				}
175
176				if ( settings.slideshow && et_slides_number > 1 ) {
177					$et_slider.hover( function() {
178						if ( $et_slider.hasClass( 'et_slider_auto_ignore_hover' ) ) {
179							return;
180						}
181
182						$et_slider.addClass( 'et_slider_hovered' );
183
184						if ( typeof et_slider_timer != 'undefined' ) {
185							clearInterval( et_slider_timer );
186						}
187					}, function() {
188						if ( $et_slider.hasClass( 'et_slider_auto_ignore_hover' ) ) {
189							return;
190						}
191
192						$et_slider.removeClass( 'et_slider_hovered' );
193
194						et_slider_auto_rotate();
195					} );
196				}
197
198				et_slider_auto_rotate();
199
200				function et_slider_auto_rotate(){
201					if ( settings.slideshow && et_slides_number > 1 && ! $et_slider.hasClass( 'et_slider_hovered' ) ) {
202						et_slider_timer = setTimeout( function() {
203							$et_slider.et_slider_move_to( 'next' );
204						}, settings.slideshow_speed );
205					}
206				}
207
208				$et_slider.et_slider_destroy = function() {
209					// Clear existing timer / auto rotate
210					if ( typeof et_slider_timer != 'undefined' ) {
211						clearInterval( et_slider_timer );
212					}
213
214					// Deregister existing events
215					$et_slider.unbind('mouseenter mouseleave');
216					$et_slider.find('.et-pb-slider-arrows a, .et-pb-controllers a').unbind('click');
217
218					// Removing existing style from slide(s)
219					$et_slider.find('.et_pb_slide').css({
220						'z-index': '',
221						'display': '',
222						'opacity': '',
223					});
224
225					// Removing existing classnames from slide(s)
226					$et_slider.find('.et-pb-active-slide').removeClass('et-pb-active-slide');
227					$et_slider.find('.et-pb-moved-slide').removeClass('et-pb-moved-slide');
228
229					// Removing DOM that was added by slider
230					$et_slider.find('.et-pb-slider-arrows, .et-pb-controllers').remove();
231					$et_slider.siblings('.et_pb_carousel').remove();
232				}
233
234				function et_stop_video( active_slide ) {
235					var $et_video, et_video_src;
236
237					// if there is a video in the slide, stop it when switching to another slide
238					if ( active_slide.has( 'iframe' ).length ) {
239						$et_video = active_slide.find( 'iframe' );
240						et_video_src = $et_video.attr( 'src' );
241
242						$et_video.attr( 'src', '' );
243						$et_video.attr( 'src', et_video_src );
244
245					} else if ( active_slide.has( 'video' ).length ) {
246						if ( !active_slide.find('.et_pb_section_video_bg').length ) {
247							$et_video = active_slide.find( 'video' );
248							$et_video[0].pause();
249						}
250					}
251				}
252
253				function et_fix_slider_content_images() {
254					var $this_slider           = $et_slider,
255						$slide_image_container = $this_slider.find( '.et-pb-active-slide .et_pb_slide_image' );
256						$slide_video_container = $this_slider.find( '.et-pb-active-slide .et_pb_slide_video' );
257						$slide                 = $slide_image_container.closest( '.et_pb_slide' ),
258						$slider                = $slide.closest( '.et_pb_slider' ),
259						slide_height           = $slider.innerHeight(),
260						image_height           = parseInt( slide_height * 0.8 ),
261						$top_header 		   = $('#top-header'),
262						$main_header		   = $('#main-header'),
263						$et_transparent_nav    = $( '.et_transparent_nav' ),
264						$et_vertical_nav 	   = $('.et_vertical_nav');
265
266					$slide_image_container.find( 'img' ).css( 'maxHeight', image_height + 'px' );
267
268					if ( $slide.hasClass( 'et_pb_media_alignment_center' ) ) {
269						$slide_image_container.css( 'marginTop', '-' + parseInt( $slide_image_container.height() / 2 ) + 'px' );
270					}
271
272					$slide_video_container.css( 'marginTop', '-' + parseInt( $slide_video_container.height() / 2 ) + 'px' );
273
274					$slide_image_container.find( 'img' ).addClass( 'active' );
275				}
276
277				function et_get_bg_layout_color( $slide ) {
278					if ( $slide.hasClass( 'et_pb_bg_layout_dark' ) ) {
279						return 'et_pb_bg_layout_dark';
280					}
281
282					return 'et_pb_bg_layout_light';
283				}
284
285				function et_maybe_set_controls_color( $slide ) {
286					var next_slide_dot_color,
287						$arrows,
288						arrows_color;
289
290					if ( typeof $et_slider_controls !== 'undefined' && $et_slider_controls.length ) {
291						next_slide_dot_color = $slide.attr( 'data-dots_color' ) || '';
292
293						if ( next_slide_dot_color !== '' ) {
294							$et_slider_controls.attr( 'style', 'background-color: ' + hex_to_rgba( next_slide_dot_color, '0.3' ) + ';' )
295							$et_slider_controls.filter( '.et-pb-active-control' ).attr( 'style', 'background-color: ' + hex_to_rgba( next_slide_dot_color ) + '!important;' );
296						} else {
297							$et_slider_controls.removeAttr( 'style' );
298						}
299					}
300
301					if ( typeof $et_slider_arrows !== 'undefined' && $et_slider_arrows.length ) {
302						$arrows      = $et_slider_arrows.find( 'a' );
303						arrows_color = $slide.attr( 'data-arrows_color' ) || '';
304
305						if ( arrows_color !== '' ) {
306							$arrows.css( 'color', arrows_color );
307						} else {
308							$arrows.css( 'color', 'inherit' );
309						}
310					}
311				}
312
313				// fix the appearance of some modules inside the post slider
314				function et_fix_builder_content() {
315					if ( is_post_slider ) {
316						setTimeout( function() {
317							var $et_pb_circle_counter = $( '.et_pb_circle_counter' ),
318								$et_pb_number_counter = $( '.et_pb_number_counter' );
319
320							window.et_fix_testimonial_inner_width();
321
322							if ( $et_pb_circle_counter.length ) {
323								window.et_pb_reinit_circle_counters( $et_pb_circle_counter );
324							}
325
326							if ( $et_pb_number_counter.length ) {
327								window.et_pb_reinit_number_counters( $et_pb_number_counter );
328							}
329							window.et_reinint_waypoint_modules();
330						}, 1000 );
331					}
332				}
333
334				function hex_to_rgba( color, alpha ) {
335					var color_16 = parseInt( color.replace( '#', '' ), 16 ),
336						red      = ( color_16 >> 16 ) & 255,
337						green    = ( color_16 >> 8 ) & 255,
338						blue     = color_16 & 255,
339						alpha    = alpha || 1,
340						rgba;
341
342					rgba = red + ',' + green + ',' + blue + ',' + alpha;
343					rgba = 'rgba(' + rgba + ')';
344
345					return rgba;
346				}
347
348				if ( window.et_load_event_fired ) {
349					et_fix_slider_content_images();
350				} else {
351					$et_window.load( function() {
352						et_fix_slider_content_images();
353					} );
354				}
355
356				$et_window.resize( function() {
357					et_fix_slider_content_images();
358				} );
359
360				$et_slider.et_slider_move_to = function ( direction ) {
361					var $active_slide = $et_slide.eq( et_active_slide ),
362						$next_slide;
363
364					$et_slider.et_animation_running = true;
365
366					$et_slider.removeClass('et_slide_transition_to_next et_slide_transition_to_previous').addClass('et_slide_transition_to_' + direction );
367
368					$et_slider.find('.et-pb-moved-slide').removeClass('et-pb-moved-slide');
369
370					if ( direction == 'next' || direction == 'previous' ){
371
372						if ( direction == 'next' )
373							et_active_slide = ( et_active_slide + 1 ) < et_slides_number ? et_active_slide + 1 : 0;
374						else
375							et_active_slide = ( et_active_slide - 1 ) >= 0 ? et_active_slide - 1 : et_slides_number - 1;
376
377					} else {
378
379						if ( et_active_slide == direction ) {
380							$et_slider.et_animation_running = false;
381							return;
382						}
383
384						et_active_slide = direction;
385
386					}
387
388					if ( typeof et_slider_timer != 'undefined' )
389						clearInterval( et_slider_timer );
390
391					$next_slide	= $et_slide.eq( et_active_slide );
392
393					if ( typeof $active_slide.find('video')[0] !== 'undefined' && typeof $active_slide.find('video')[0]['player'] !== 'undefined' ) {
394						$active_slide.find('video')[0].player.pause();
395					}
396
397					if ( typeof $next_slide.find('video')[0] !== 'undefined' && typeof $next_slide.find('video')[0]['player'] !== 'undefined' ) {
398						$next_slide.find('video')[0].player.play();
399					}
400
401					$et_slider.trigger( 'simple_slider_before_move_to', { direction : direction, next_slide : $next_slide });
402
403					$et_slide.each( function(){
404						$(this).css( 'zIndex', 1 );
405					} );
406					$active_slide.css( 'zIndex', 2 ).removeClass( 'et-pb-active-slide' ).addClass('et-pb-moved-slide');
407					$next_slide.css( { 'display' : 'block', opacity : 0 } ).addClass( 'et-pb-active-slide' );
408
409					et_fix_slider_content_images();
410
411					et_fix_builder_content();
412
413					if ( settings.use_controls )
414						$et_slider_controls.removeClass( settings.control_active_class ).eq( et_active_slide ).addClass( settings.control_active_class );
415
416					if ( settings.use_carousel )
417						$et_slider_carousel_controls.removeClass( settings.control_active_class ).eq( et_active_slide ).addClass( settings.control_active_class );
418
419					if ( ! settings.tabs_animation ) {
420						et_maybe_set_controls_color( $next_slide );
421
422						$next_slide.animate( { opacity : 1 }, et_fade_speed );
423						$active_slide.addClass( 'et_slide_transition' ).css( { 'display' : 'list-item', 'opacity' : 1 } ).animate( { opacity : 0 }, et_fade_speed, function(){
424							var active_slide_layout_bg_color = et_get_bg_layout_color( $active_slide ),
425								next_slide_layout_bg_color = et_get_bg_layout_color( $next_slide );
426
427							$(this).css('display', 'none').removeClass( 'et_slide_transition' );
428
429							et_stop_video( $active_slide );
430
431							$et_slider
432								.removeClass( active_slide_layout_bg_color )
433								.addClass( next_slide_layout_bg_color );
434
435							$et_slider.et_animation_running = false;
436
437							$et_slider.trigger( 'simple_slider_after_move_to', { next_slide : $next_slide } );
438						} );
439					} else {
440						$next_slide.css( { 'display' : 'none', opacity : 0 } );
441
442						$active_slide.addClass( 'et_slide_transition' ).css( { 'display' : 'block', 'opacity' : 1 } ).animate( { opacity : 0 }, et_fade_speed, function(){
443							$(this).css('display', 'none').removeClass( 'et_slide_transition' );
444
445							$next_slide.css( { 'display' : 'block', 'opacity' : 0 } ).animate( { opacity : 1 }, et_fade_speed, function() {
446								$et_slider.et_animation_running = false;
447
448								$et_slider.trigger( 'simple_slider_after_move_to', { next_slide : $next_slide } );
449							} );
450						} );
451					}
452
453					et_slider_auto_rotate();
454				}
455		}
456
457		$.fn.et_pb_simple_slider = function( options ) {
458			return this.each(function() {
459				new $.et_pb_simple_slider(this, options);
460			});
461		}
462
463		var et_hash_module_seperator = '||',
464			et_hash_module_param_seperator = '|';
465
466		function process_et_hashchange( hash ) {
467			if ( ( hash.indexOf( et_hash_module_seperator, 0 ) ) !== -1 ) {
468				modules = hash.split( et_hash_module_seperator );
469				for ( var i = 0; i < modules.length; i++ ) {
470					var module_params = modules[i].split( et_hash_module_param_seperator );
471					var element = module_params[0];
472					module_params.shift();
473					if ( $('#' + element ).length ) {
474						$('#' + element ).trigger({
475							type: "et_hashchange",
476							params: module_params
477						});
478					}
479				}
480			} else {
481				module_params = hash.split( et_hash_module_param_seperator );
482				var element = module_params[0];
483				module_params.shift();
484				if ( $('#' + element ).length ) {
485					$('#' + element ).trigger({
486						type: "et_hashchange",
487						params: module_params
488					});
489				}
490			}
491		}
492
493		function et_set_hash( module_state_hash ) {
494			module_id = module_state_hash.split( et_hash_module_param_seperator )[0];
495			if ( !$('#' + module_id ).length ) {
496				return;
497			}
498
499			if ( window.location.hash ) {
500				var hash = window.location.hash.substring(1), //Puts hash in variable, and removes the # character
501					new_hash = [];
502
503				if ( ( hash.indexOf( et_hash_module_seperator, 0 ) ) !== -1 ) {
504					modules = hash.split( et_hash_module_seperator );
505					var in_hash = false;
506					for ( var i = 0; i < modules.length; i++ ) {
507						var element = modules[i].split( et_hash_module_param_seperator )[0];
508						if ( element === module_id ) {
509							new_hash.push( module_state_hash );
510							in_hash = true;
511						} else {
512							new_hash.push( modules[i] );
513						}
514					}
515					if ( !in_hash ) {
516						new_hash.push( module_state_hash );
517					}
518				} else {
519					module_params = hash.split( et_hash_module_param_seperator );
520					var element = module_params[0];
521					if ( element !== module_id ) {
522						new_hash.push( hash );
523					}
524					new_hash.push( module_state_hash );
525				}
526
527				hash = new_hash.join( et_hash_module_seperator );
528			} else {
529				hash = module_state_hash;
530			}
531
532			var yScroll = document.body.scrollTop;
533			window.location.hash = hash;
534			document.body.scrollTop = yScroll;
535		}
536
537		$.et_pb_simple_carousel = function(el, options) {
538			var settings = $.extend( {
539				slide_duration	: 500,
540			}, options );
541
542			var $et_carousel 			= $(el),
543				$carousel_items 		= $et_carousel.find('.et_pb_carousel_items'),
544				$the_carousel_items 	= $carousel_items.find('.et_pb_carousel_item');
545
546			$et_carousel.et_animation_running = false;
547
548			$et_carousel.addClass('container-width-change-notify').on('containerWidthChanged', function( event ){
549				set_carousel_columns( $et_carousel );
550				set_carousel_height( $et_carousel );
551			});
552
553			$carousel_items.data('items', $the_carousel_items.toArray() );
554			$et_carousel.data('columns_setting_up', false );
555
556			$carousel_items.prepend('<div class="et-pb-slider-arrows"><a class="et-pb-slider-arrow et-pb-arrow-prev" href="#">' + '<span>' + et_pb_custom.previous + '</span>' + '</a><a class="et-pb-slider-arrow et-pb-arrow-next" href="#">' + '<span>' + et_pb_custom.next + '</span>' + '</a></div>');
557
558			set_carousel_columns( $et_carousel );
559			set_carousel_height( $et_carousel );
560
561			$et_carousel_next 	= $et_carousel.find( '.et-pb-arrow-next' );
562			$et_carousel_prev 	= $et_carousel.find( '.et-pb-arrow-prev'  );
563
564			$et_carousel.on( 'click', '.et-pb-arrow-next', function(){
565				if ( $et_carousel.et_animation_running ) return false;
566
567				$et_carousel.et_carousel_move_to( 'next' );
568
569				return false;
570			} );
571
572			$et_carousel.on( 'click', '.et-pb-arrow-prev', function(){
573				if ( $et_carousel.et_animation_running ) return false;
574
575				$et_carousel.et_carousel_move_to( 'previous' );
576
577				return false;
578			} );
579
580			// swipe support requires et-jquery-touch-mobile
581			$et_carousel.on( 'swipeleft', function() {
582				$et_carousel.et_carousel_move_to( 'next' );
583			});
584			$et_carousel.on( 'swiperight', function() {
585				$et_carousel.et_carousel_move_to( 'previous' );
586			});
587
588			function set_carousel_height( $the_carousel ) {
589				var carousel_items_width = $the_carousel_items.width(),
590					carousel_items_height = $the_carousel_items.height();
591
592				$carousel_items.css('height', carousel_items_height + 'px' );
593			}
594
595			function set_carousel_columns( $the_carousel ) {
596				var columns,
597					$carousel_parent = $the_carousel.parents('.et_pb_column'),
598					carousel_items_width = $carousel_items.width(),
599					carousel_item_count = $the_carousel_items.length;
600
601				if ( $carousel_parent.hasClass('et_pb_column_4_4') || $carousel_parent.hasClass('et_pb_column_3_4') || $carousel_parent.hasClass('et_pb_column_2_3') ) {
602					if ( $et_window.width() < 768 ) {
603						columns = 3;
604					} else {
605						columns = 4;
606					}
607				} else if ( $carousel_parent.hasClass('et_pb_column_1_2') || $carousel_parent.hasClass('et_pb_column_3_8') || $carousel_parent.hasClass('et_pb_column_1_3') ) {
608					columns = 3;
609				} else if ( $carousel_parent.hasClass('et_pb_column_1_4') ) {
610					if ( $et_window.width() > 480 && $et_window.width() < 980 ) {
611						columns = 3;
612					} else {
613						columns = 2;
614					}
615				}
616
617				if ( columns === $carousel_items.data('portfolio-columns') ) {
618					return;
619				}
620
621				if ( $the_carousel.data('columns_setting_up') ) {
622					return;
623				}
624
625				$the_carousel.data('columns_setting_up', true );
626
627				// store last setup column
628				$carousel_items.removeClass('columns-' + $carousel_items.data('portfolio-columns') );
629				$carousel_items.addClass('columns-' + columns );
630				$carousel_items.data('portfolio-columns', columns );
631
632				// kill all previous groups to get ready to re-group
633				if ( $carousel_items.find('.et-carousel-group').length ) {
634					$the_carousel_items.appendTo( $carousel_items );
635					$carousel_items.find('.et-carousel-group').remove();
636				}
637
638				// setup the grouping
639				var the_carousel_items = $carousel_items.data('items'),
640					$carousel_group = $('<div class="et-carousel-group active">').appendTo( $carousel_items );
641
642				$the_carousel_items.data('position', '');
643				if ( the_carousel_items.length <= columns ) {
644					$carousel_items.find('.et-pb-slider-arrows').hide();
645				} else {
646					$carousel_items.find('.et-pb-slider-arrows').show();
647				}
648
649				for ( position = 1, x=0 ;x < the_carousel_items.length; x++, position++ ) {
650					if ( x < columns ) {
651						$( the_carousel_items[x] ).show();
652						$( the_carousel_items[x] ).appendTo( $carousel_group );
653						$( the_carousel_items[x] ).data('position', position );
654						$( the_carousel_items[x] ).addClass('position_' + position );
655					} else {
656						position = $( the_carousel_items[x] ).data('position');
657						$( the_carousel_items[x] ).removeClass('position_' + position );
658						$( the_carousel_items[x] ).data('position', '' );
659						$( the_carousel_items[x] ).hide();
660					}
661				}
662
663				$the_carousel.data('columns_setting_up', false );
664
665			} /* end set_carousel_columns() */
666
667			$et_carousel.et_carousel_move_to = function ( direction ) {
668				var $active_carousel_group 	= $carousel_items.find('.et-carousel-group.active'),
669					items 					= $carousel_items.data('items'),
670					columns 				= $carousel_items.data('portfolio-columns');
671
672				$et_carousel.et_animation_running = true;
673
674				var left = 0;
675				$active_carousel_group.children().each(function(){
676					$(this).css({'position':'absolute', 'left': left });
677					left = left + $(this).outerWidth(true);
678				});
679
680				if ( direction == 'next' ) {
681					var $next_carousel_group,
682						current_position = 1,
683						next_position = 1,
684						active_items_start = items.indexOf( $active_carousel_group.children().first()[0] ),
685						active_items_end = active_items_start + columns,
686						next_items_start = active_items_end,
687						next_items_end = next_items_start + columns;
688
689					$next_carousel_group = $('<div class="et-carousel-group next" style="display: none;left: 100%;position: absolute;top: 0;">').insertAfter( $active_carousel_group );
690					$next_carousel_group.css({ 'width': $active_carousel_group.innerWidth() }).show();
691
692					// this is an endless loop, so it can decide internally when to break out, so that next_position
693					// can get filled up, even to the extent of an element having both and current_ and next_ position
694					for( x = 0, total = 0 ; ; x++, total++ ) {
695						if ( total >= active_items_start && total < active_items_end ) {
696							$( items[x] ).addClass( 'changing_position current_position current_position_' + current_position );
697							$( items[x] ).data('current_position', current_position );
698							current_position++;
699						}
700
701						if ( total >= next_items_start && total < next_items_end ) {
702							$( items[x] ).data('next_position', next_position );
703							$( items[x] ).addClass('changing_position next_position next_position_' + next_position );
704
705							if ( !$( items[x] ).hasClass( 'current_position' ) ) {
706								$( items[x] ).addClass('container_append');
707							} else {
708								$( items[x] ).clone(true).appendTo( $active_carousel_group ).hide().addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' );
709								$( items[x] ).addClass('delayed_container_append');
710							}
711
712							next_position++;
713						}
714
715						if ( next_position > columns ) {
716							break;
717						}
718
719						if ( x >= ( items.length -1 )) {
720							x = -1;
721						}
722					}
723
724					var sorted = $carousel_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) {
725						var el_a_position = parseInt( $(a).data('next_position') );
726						var el_b_position = parseInt( $(b).data('next_position') );
727						return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0;
728					});
729
730					$( sorted ).show().appendTo( $next_carousel_group );
731
732					var left = 0;
733					$next_carousel_group.children().each(function(){
734						$(this).css({'position':'absolute', 'left': left });
735						left = left + $(this).outerWidth(true);
736					});
737
738					$active_carousel_group.animate({
739						left: '-100%'
740					}, {
741						duration: settings.slide_duration,
742						complete: function() {
743							$carousel_items.find('.delayed_container_append').each(function(){
744								left = $( '#' + $(this).attr('id') + '-dup' ).css('left');
745								$(this).css({'position':'absolute', 'left': left });
746								$(this).appendTo( $next_carousel_group );
747							});
748
749							$active_carousel_group.removeClass('active');
750							$active_carousel_group.children().each(function(){
751								position = $(this).data('position');
752								current_position = $(this).data('current_position');
753								$(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position );
754								$(this).data('position', '');
755								$(this).data('current_position', '');
756								$(this).hide();
757								$(this).css({'position': '', 'left': ''});
758								$(this).appendTo( $carousel_items );
759							});
760
761							$active_carousel_group.remove();
762
763						}
764					} );
765
766					next_left = $active_carousel_group.width() + parseInt( $the_carousel_items.first().css('marginRight').slice(0, -2) );
767					$next_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: next_left });
768					$next_carousel_group.animate({
769						left: '0%'
770					}, {
771						duration: settings.slide_duration,
772						complete: function(){
773							$next_carousel_group.removeClass('next').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''});
774
775							$next_carousel_group.find('.changing_position').each(function( index ){
776								position = $(this).data('position');
777								current_position = $(this).data('current_position');
778								next_position = $(this).data('next_position');
779								$(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' next_position next_position_' + next_position );
780								$(this).data('current_position', '');
781								$(this).data('next_position', '');
782								$(this).data('position', ( index + 1 ) );
783							});
784
785							$next_carousel_group.children().css({'position': '', 'left': ''});
786							$next_carousel_group.find('.delayed_container_append_dup').remove();
787
788							$et_carousel.et_animation_running = false;
789						}
790					} );
791
792				} else if ( direction == 'previous' ) {
793					var $prev_carousel_group,
794						current_position = columns,
795						prev_position = columns,
796						columns_span = columns - 1,
797						active_items_start = items.indexOf( $active_carousel_group.children().last()[0] ),
798						active_items_end = active_items_start - columns_span,
799						prev_items_start = active_items_end - 1,
800						prev_items_end = prev_items_start - columns_span;
801
802					$prev_carousel_group = $('<div class="et-carousel-group prev" style="display: none;left: 100%;position: absolute;top: 0;">').insertBefore( $active_carousel_group );
803					$prev_carousel_group.css({ 'left': '-' + $active_carousel_group.innerWidth(), 'width': $active_carousel_group.innerWidth() }).show();
804
805					// this is an endless loop, so it can decide internally when to break out, so that next_position
806					// can get filled up, even to the extent of an element having both and current_ and next_ position
807					for( x = ( items.length - 1 ), total = ( items.length - 1 ) ; ; x--, total-- ) {
808
809						if ( total <= active_items_start && total >= active_items_end ) {
810							$( items[x] ).addClass( 'changing_position current_position current_position_' + current_position );
811							$( items[x] ).data('current_position', current_position );
812							current_position--;
813						}
814
815						if ( total <= prev_items_start && total >= prev_items_end ) {
816							$( items[x] ).data('prev_position', prev_position );
817							$( items[x] ).addClass('changing_position prev_position prev_position_' + prev_position );
818
819							if ( !$( items[x] ).hasClass( 'current_position' ) ) {
820								$( items[x] ).addClass('container_append');
821							} else {
822								$( items[x] ).clone(true).appendTo( $active_carousel_group ).addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' );
823								$( items[x] ).addClass('delayed_container_append');
824							}
825
826							prev_position--;
827						}
828
829						if ( prev_position <= 0 ) {
830							break;
831						}
832
833						if ( x == 0 ) {
834							x = items.length;
835						}
836					}
837
838					var sorted = $carousel_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) {
839						var el_a_position = parseInt( $(a).data('prev_position') );
840						var el_b_position = parseInt( $(b).data('prev_position') );
841						return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0;
842					});
843
844					$( sorted ).show().appendTo( $prev_carousel_group );
845
846					var left = 0;
847					$prev_carousel_group.children().each(function(){
848						$(this).css({'position':'absolute', 'left': left });
849						left = left + $(this).outerWidth(true);
850					});
851
852					$active_carousel_group.animate({
853						left: '100%'
854					}, {
855						duration: settings.slide_duration,
856						complete: function() {
857							$carousel_items.find('.delayed_container_append').reverse().each(function(){
858								left = $( '#' + $(this).attr('id') + '-dup' ).css('left');
859								$(this).css({'position':'absolute', 'left': left });
860								$(this).prependTo( $prev_carousel_group );
861							});
862
863							$active_carousel_group.removeClass('active');
864							$active_carousel_group.children().each(function(){
865								position = $(this).data('position');
866								current_position = $(this).data('current_position');
867								$(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position );
868								$(this).data('position', '');
869								$(this).data('current_position', '');
870								$(this).hide();
871								$(this).css({'position': '', 'left': ''});
872								$(this).appendTo( $carousel_items );
873							});
874
875							$active_carousel_group.remove();
876						}
877					} );
878
879					prev_left = (-1) * $active_carousel_group.width() - parseInt( $the_carousel_items.first().css('marginRight').slice(0, -2) );
880					$prev_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: prev_left });
881					$prev_carousel_group.animate({
882						left: '0%'
883					}, {
884						duration: settings.slide_duration,
885						complete: function(){
886							$prev_carousel_group.removeClass('prev').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''});
887
888							$prev_carousel_group.find('.delayed_container_append_dup').remove();
889
890							$prev_carousel_group.find('.changing_position').each(function( index ){
891								position = $(this).data('position');
892								current_position = $(this).data('current_position');
893								prev_position = $(this).data('prev_position');
894								$(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' prev_position prev_position_' + prev_position );
895								$(this).data('current_position', '');
896								$(this).data('prev_position', '');
897								position = index + 1;
898								$(this).data('position', position );
899								$(this).addClass('position_' + position );
900							});
901
902							$prev_carousel_group.children().css({'position': '', 'left': ''});
903							$et_carousel.et_animation_running = false;
904						}
905					} );
906				}
907			}
908		}
909
910		$.fn.et_pb_simple_carousel = function( options ) {
911			return this.each(function() {
912				new $.et_pb_simple_carousel(this, options);
913			});
914		}
915
916		$(document).ready( function(){
917			/**
918			 * Provide event listener for plugins to hook up to
919			 */
920			document.dispatchEvent( new Event('et_pb_before_init_modules') );
921
922			var $et_pb_slider  = $( '.et_pb_slider' ),
923				$et_pb_tabs    = $( '.et_pb_tabs' ),
924				$et_pb_video_section = $('.et_pb_section_video_bg'),
925				$et_pb_newsletter_button = $( '.et_pb_newsletter_button' ),
926				$et_pb_filterable_portfolio = $( '.et_pb_filterable_portfolio' ),
927				$et_pb_fullwidth_portfolio = $( '.et_pb_fullwidth_portfolio' ),
928				$et_pb_gallery = $( '.et_pb_gallery' ),
929				$et_pb_countdown_timer = $( '.et_pb_countdown_timer' ),
930				$et_post_gallery = $( '.et_post_gallery' ),
931				$et_lightbox_image = $( '.et_pb_lightbox_image'),
932				$et_pb_map    = $( '.et_pb_map_container' ),
933				$et_pb_circle_counter = $( '.et_pb_circle_counter' ),
934				$et_pb_number_counter = $( '.et_pb_number_counter' ),
935				$et_pb_parallax = $( '.et_parallax_bg' ),
936				$et_pb_shop = $( '.et_pb_shop' ),
937				$et_pb_post_fullwidth = $( '.single.et_pb_pagebuilder_layout.et_full_width_page' ),
938				et_is_mobile_device = navigator.userAgent.match( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/ ) !== null,
939				et_is_ipad = navigator.userAgent.match( /iPad/ ),
940				et_is_ie9 = navigator.userAgent.match( /MSIE 9.0/ ) !== null,
941				$et_container = ! et_pb_custom.is_builder_plugin_used ? $( '.container' ) : $( '.et_pb_row' ),
942				et_container_width = $et_container.width(),
943				et_is_fixed_nav = $( 'body' ).hasClass( 'et_fixed_nav' ),
944				et_is_vertical_nav = $( 'body' ).hasClass( 'et_vertical_nav' ),
945				et_is_vertical_fixed_nav = $( 'body' ).hasClass( 'et_vertical_fixed' ),
946				et_is_rtl = $( 'body' ).hasClass( 'rtl' ),
947				et_hide_nav = $( 'body' ).hasClass( 'et_hide_nav' ),
948				et_header_style_left = $( 'body' ).hasClass( 'et_header_style_left' ),
949				et_vertical_navigation = $( 'body' ).hasClass( 'et_vertical_nav' ),
950				$top_header = $('#top-header'),
951				$main_header = $('#main-header'),
952				$main_container_wrapper = $( '#page-container' ),
953				$et_transparent_nav = $( '.et_transparent_nav' ),
954				$et_pb_first_row = $( 'body.et_pb_pagebuilder_layout .et_pb_section:first-child' ),
955				$et_main_content_first_row = $( '#main-content .container:first-child' ),
956				$et_main_content_first_row_meta_wrapper = $et_main_content_first_row.find('.et_post_meta_wrapper:first'),
957				$et_main_content_first_row_meta_wrapper_title = $et_main_content_first_row_meta_wrapper.find( 'h1' ),
958				$et_main_content_first_row_content = $et_main_content_first_row.find('.entry-content:first'),
959				$et_single_post = $( 'body.single-post' ),
960				etRecalculateOffset = false,
961				et_header_height,
962				et_header_modifier,
963				et_header_offset,
964				et_primary_header_top,
965				$et_vertical_nav = $('.et_vertical_nav'),
966				$et_header_style_split = $('.et_header_style_split'),
967				$et_top_navigation = $('#et-top-navigation'),
968				$logo = $('#logo'),
969				$et_sticky_image = $('.et_pb_image_sticky'),
970				$et_pb_counter_amount = $('.et_pb_counter_amount'),
971				$et_pb_carousel = $( '.et_pb_carousel' ),
972				$et_menu_selector = et_pb_custom.is_divi_theme_used ? $( 'ul.nav' ) : $( '.et_pb_fullwidth_menu ul.nav' ),
973				et_pb_ab_bounce_rate = et_pb_custom.ab_bounce_rate * 1000,
974				et_pb_ab_logged_status = {
975					read_page: false,
976					read_goal: false,
977					view_goal: false,
978					click_goal: false,
979					con_goal: false,
980					con_short: false,
981				};
982
983			window.et_pb_slider_init = function( $this_slider ) {
984				var et_slider_settings = {
985						fade_speed 		: 700,
986						slide			: ! $this_slider.hasClass( 'et_pb_gallery' ) ? '.et_pb_slide' : '.et_pb_gallery_item'
987					}
988
989				if ( $this_slider.hasClass('et_pb_slider_no_arrows') )
990					et_slider_settings.use_arrows = false;
991
992				if ( $this_slider.hasClass('et_pb_slider_no_pagination') )
993					et_slider_settings.use_controls = false;
994
995				if ( $this_slider.hasClass('et_slider_auto') ) {
996					var et_slider_autospeed_class_value = /et_slider_speed_(\d+)/g;
997
998					et_slider_settings.slideshow = true;
999
1000					et_slider_autospeed = et_slider_autospeed_class_value.exec( $this_slider.attr('class') );
1001
1002					et_slider_settings.slideshow_speed = et_slider_autospeed === null ? 10 : et_slider_autospeed[1];
1003				}
1004
1005				if ( $this_slider.parent().hasClass('et_pb_video_slider') ) {
1006					et_slider_settings.controls_below = true;
1007					et_slider_settings.append_controls_to = $this_slider.parent();
1008
1009					setTimeout( function() {
1010						$( '.et_pb_preload' ).removeClass( 'et_pb_preload' );
1011					}, 500 );
1012				}
1013
1014				if ( $this_slider.hasClass('et_pb_slider_carousel') )
1015					et_slider_settings.use_carousel = true;
1016
1017				$this_slider.et_pb_simple_slider( et_slider_settings );
1018			}
1019
1020			var $et_top_menu = $et_menu_selector,
1021				et_parent_menu_longpress_limit = 300,
1022				et_parent_menu_longpress_start,
1023				et_parent_menu_click = true,
1024				is_frontend_builder = $('body').hasClass('et-fb'),
1025				et_menu_hover_triggered = false;
1026
1027			// log the conversion if visitor is on Thank You page and comes from the Shop module which is the Goal
1028			if ( $( '.et_pb_ab_shop_conversion' ).length && typeof et_pb_get_cookie_value( 'et_pb_ab_shop_log' ) !== 'undefined' && '' !== et_pb_get_cookie_value( 'et_pb_ab_shop_log' ) ) {
1029				var shop_log_data = et_pb_get_cookie_value( 'et_pb_ab_shop_log' ).split( '_' );
1030					page_id = shop_log_data[0],
1031					subject_id = shop_log_data[1],
1032					test_id = shop_log_data[2];
1033
1034				et_pb_ab_update_stats( 'con_goal', page_id, subject_id, test_id );
1035
1036				// remove the cookie after conversion is logged
1037				et_pb_set_cookie( 0, 'et_pb_ab_shop_log=true' );
1038			}
1039
1040			// log the conversion if visitor is on page with tracking shortcode
1041			if ( $( '.et_pb_ab_split_track' ).length ) {
1042				$( '.et_pb_ab_split_track' ).each( function() {
1043					var tracking_test = $( this ).data( 'test_id' ),
1044						cookies_name = 'et_pb_ab_shortcode_track_' + tracking_test;
1045
1046					if ( typeof et_pb_get_cookie_value( cookies_name ) !== 'undefined' && '' !== et_pb_get_cookie_value( cookies_name ) ) {
1047						var track_data = et_pb_get_cookie_value( cookies_name ).split( '_' );
1048							page_id = track_data[0],
1049							subject_id = track_data[1],
1050							test_id = track_data[2];
1051
1052						et_pb_ab_update_stats( 'con_short', page_id, subject_id, test_id );
1053
1054						// remove the cookie after conversion is logged
1055						et_pb_set_cookie( 0, cookies_name + '=true' );
1056					}
1057				});
1058			}
1059
1060			// init split testing if enabled
1061			if ( et_pb_custom.is_ab_testing_active ) {
1062				et_pb_init_ab_test();
1063			}
1064
1065			if ( $( '.et_pb_row' ).length ) {
1066				$( '.et_pb_row' ).each( function() {
1067					var $this_row = $( this ),
1068						row_class = '';
1069
1070					row_class = et_get_column_types( $this_row.find( '>.et_pb_column' ) );
1071
1072					if ( '' !== row_class && ( -1 !== row_class.indexOf( '1-4' ) || '_4col' === row_class ) ) {
1073						$this_row.addClass( 'et_pb_row' + row_class );
1074					}
1075
1076					if ( $this_row.find( '.et_pb_row_inner' ).length ) {
1077						$this_row.find( '.et_pb_row_inner' ).each( function() {
1078							var $this_row_inner = $( this );
1079							row_class = et_get_column_types( $this_row_inner.find( '.et_pb_column' ) );
1080
1081							if ( '' !== row_class && -1 !== row_class.indexOf( '1-4' ) ) {
1082								$this_row_inner.addClass( 'et_pb_row' + row_class );
1083							}
1084						});
1085					}
1086				});
1087			}
1088
1089			function et_get_column_types( $columns ) {
1090				var row_class = '';
1091
1092				if ( $columns.length ) {
1093					$columns.each( function() {
1094						var $this_column = $( this ),
1095							column_type = $this_column.attr( 'class' ).split( 'et_pb_column_' )[1],
1096							column_type_clean = typeof column_type !== 'undefined' ? column_type.split( ' ', 1 )[0] : '4_4',
1097							column_type_updated = column_type_clean.replace( '_', '-' ).trim();
1098
1099						row_class += '_' + column_type_updated;
1100					});
1101
1102					row_class = '_1-4_1-4_1-4_1-4' === row_class ? '_4col' : row_class;
1103				}
1104
1105				return row_class;
1106			}
1107
1108			$et_top_menu.find( 'li' ).hover( function() {
1109				if ( ! $(this).closest( 'li.mega-menu' ).length || $(this).hasClass( 'mega-menu' ) ) {
1110					$(this).addClass( 'et-show-dropdown' );
1111					$(this).removeClass( 'et-hover' ).addClass( 'et-hover' );
1112					et_menu_hover_triggered = true;
1113				}
1114			}, function() {
1115				var $this_el = $(this);
1116
1117				$this_el.removeClass( 'et-show-dropdown' ).addClass( 'et-dropdown-removing' );
1118
1119				et_menu_hover_triggered = false;
1120
1121				setTimeout( function() {
1122					if ( ! $this_el.hasClass( 'et-show-dropdown' ) ) {
1123						$this_el.removeClass( 'et-hover' ).removeClass( 'et-dropdown-removing' );
1124					}
1125				}, 200 );
1126			} );
1127
1128			// Dropdown menu adjustment for touch screen
1129			$et_top_menu.find('.menu-item-has-children > a').on( 'touchstart', function(){
1130				et_parent_menu_longpress_start = new Date().getTime();
1131			} ).on( 'touchend', function(){
1132				var et_parent_menu_longpress_end = new Date().getTime()
1133				if ( et_parent_menu_longpress_end  >= et_parent_menu_longpress_start + et_parent_menu_longpress_limit ) {
1134					et_parent_menu_click = true;
1135				} else {
1136					et_parent_menu_click = false;
1137
1138					// Some devices emulate hover event on touch, so check that hover event was not triggered to avoid extra mouseleave event triggering
1139					if ( ! et_menu_hover_triggered ) {
1140						// Close sub-menu if toggled
1141						var $et_parent_menu = $(this).parent('li');
1142						if ( $et_parent_menu.hasClass( 'et-hover') ) {
1143							$et_parent_menu.trigger( 'mouseleave' );
1144						} else {
1145							$et_parent_menu.trigger( 'mouseenter' );
1146						}
1147					}
1148				}
1149				et_parent_menu_longpress_start = 0;
1150			} ).click(function() {
1151				if ( et_parent_menu_click ) {
1152					return true;
1153				}
1154
1155				return false;
1156			} );
1157
1158			$et_top_menu.find( 'li.mega-menu' ).each(function(){
1159				var $li_mega_menu           = $(this),
1160					$li_mega_menu_item      = $li_mega_menu.children( 'ul' ).children( 'li' ),
1161					li_mega_menu_item_count = $li_mega_menu_item.length;
1162
1163				if ( li_mega_menu_item_count < 4 ) {
1164					$li_mega_menu.addClass( 'mega-menu-parent mega-menu-parent-' + li_mega_menu_item_count );
1165				}
1166			});
1167
1168			$et_sticky_image.each( function() {
1169				var $this_el            = $(this),
1170					$row                = $this_el.closest('.et_pb_row'),
1171					$section            = $row.closest('.et_pb_section'),
1172					$column             = $this_el.closest( '.et_pb_column' ),
1173					sticky_class        = 'et_pb_section_sticky',
1174					sticky_mobile_class = 'et_pb_section_sticky_mobile';
1175
1176				// If it is not in the last row, continue
1177				if ( ! $row.is( ':last-child' ) ) {
1178					return true;
1179				}
1180
1181				// Make sure sticky image is the last element in the column
1182				if ( ! $this_el.is( ':last-child' ) ) {
1183					return true;
1184				}
1185
1186				// If it is in the last row, find the parent section and attach new class to it
1187				if ( ! $section.hasClass( sticky_class ) ) {
1188					$section.addClass( sticky_class );
1189				}
1190
1191				$column.addClass( 'et_pb_row_sticky' );
1192
1193				if ( ! $section.hasClass( sticky_mobile_class ) && $column.is( ':last-child' ) ) {
1194					$section.addClass( sticky_mobile_class );
1195				}
1196			} );
1197
1198			if ( et_is_mobile_device ) {
1199				$( '.et_pb_section_video_bg' ).each( function() {
1200					var $this_el = $(this);
1201
1202					$this_el.closest( '.et_pb_preload' ).removeClass( 'et_pb_preload' )
1203
1204					$this_el.remove();
1205				} );
1206
1207				$( 'body' ).addClass( 'et_mobile_device' );
1208
1209				if ( ! et_is_ipad ) {
1210					$( 'body' ).addClass( 'et_mobile_device_not_ipad' );
1211				}
1212			}
1213
1214			if ( et_is_ie9 ) {
1215				$( 'body' ).addClass( 'et_ie9' );
1216			}
1217
1218			if ( $et_pb_video_section.length || is_frontend_builder ) {
1219				window.et_pb_video_section_init = function( $et_pb_video_section ) {
1220					$et_pb_video_section.find( 'video' ).mediaelementplayer( {
1221						pauseOtherPlayers: false,
1222						success : function( mediaElement, domObject ) {
1223							mediaElement.addEventListener( 'loadeddata', function() {
1224								et_pb_resize_section_video_bg( $(domObject) );
1225								et_pb_center_video( $(domObject) );
1226							}, false );
1227
1228							mediaElement.addEventListener( 'canplay', function() {
1229								$(domObject).closest( '.et_pb_preload' ).removeClass( 'et_pb_preload' );
1230							}, false );
1231						}
1232					} );
1233				}
1234				et_pb_video_section_init( $et_pb_video_section );
1235			}
1236
1237			if ( $et_post_gallery.length ) {
1238				// swipe support in magnific popup only if gallery exists
1239				var magnificPopup = $.magnificPopup.instance;
1240
1241				$( 'body' ).on( 'swiperight', '.mfp-container', function() {
1242					magnificPopup.prev();
1243				} );
1244				$( 'body' ).on( 'swipeleft', '.mfp-container', function() {
1245					magnificPopup.next();
1246				} );
1247
1248				$et_post_gallery.each(function() {
1249					$(this).magnificPopup( {
1250						delegate: '.et_pb_gallery_image a',
1251						type: 'image',
1252						removalDelay: 500,
1253						gallery: {
1254							enabled: true,
1255							navigateByImgClick: true
1256						},
1257						mainClass: 'mfp-fade',
1258						zoom: {
1259							enabled: true,
1260							duration: 500,
1261							opener: function(element) {
1262								return element.find('img');
1263							}
1264						}
1265					} );
1266				} );
1267				// prevent attaching of any further actions on click
1268				$et_post_gallery.find( 'a' ).unbind( 'click' );
1269			}
1270
1271			if ( $et_lightbox_image.length || is_frontend_builder ) {
1272				// prevent attaching of any further actions on click
1273				$et_lightbox_image.unbind( 'click' );
1274				$et_lightbox_image.bind( 'click' );
1275
1276				window.et_pb_image_lightbox_init = function( $et_lightbox_image ) {
1277					$et_lightbox_image.magnificPopup( {
1278						type: 'image',
1279						removalDelay: 500,
1280						mainClass: 'mfp-fade',
1281						zoom: {
1282							enabled: true,
1283							duration: 500,
1284							opener: function(element) {
1285								return element.find('img');
1286							}
1287						}
1288					} );
1289				}
1290
1291				et_pb_image_lightbox_init( $et_lightbox_image );
1292			}
1293
1294			if ( $et_pb_slider.length || is_frontend_builder ) {
1295				$et_pb_slider.each( function() {
1296					$this_slider = $(this);
1297
1298					et_pb_slider_init( $this_slider );
1299				} );
1300			}
1301
1302			$et_pb_carousel  = $( '.et_pb_carousel' );
1303			if ( $et_pb_carousel.length || is_frontend_builder ) {
1304				$et_pb_carousel.each( function() {
1305					var $this_carousel = $(this),
1306						et_carousel_settings = {
1307							fade_speed 		: 1000
1308						};
1309
1310					$this_carousel.et_pb_simple_carousel( et_carousel_settings );
1311				} );
1312			}
1313
1314			if ( $et_pb_fullwidth_portfolio.length || is_frontend_builder ) {
1315
1316			 	window.et_fullwidth_portfolio_init = function( $the_portfolio ) {
1317					var $portfolio_items = $the_portfolio.find('.et_pb_portfolio_items');
1318
1319						$portfolio_items.data('items', $portfolio_items.find('.et_pb_portfolio_item').toArray() );
1320						$the_portfolio.data('columns_setting_up', false );
1321
1322					if ( $the_portfolio.hasClass('et_pb_fullwidth_portfolio_carousel') ) {
1323						// add left and right arrows
1324						$portfolio_items.prepend('<div class="et-pb-slider-arrows"><a class="et-pb-arrow-prev" href="#">
1324' + '<span>' + et_pb_custom.previous + '</span>' + '</a><a class="et-pb-arrow-next" href="#">' + '<span>' + et_pb_custom.next + '</span>' + '</a></div>');
1325
1326						set_fullwidth_portfolio_columns( $the_portfolio, true );
1327
1328						et_carousel_auto_rotate( $the_portfolio );
1329
1330						// swipe support
1331						$the_portfolio.on( 'swiperight', function() {
1332							$( this ).find( '.et-pb-arrow-prev' ).click();
1333						});
1334						$the_portfolio.on( 'swipeleft', function() {
1335							$( this ).find( '.et-pb-arrow-next' ).click();
1336						});
1337
1338						$the_portfolio.hover(
1339							function(){
1340								$(this).addClass('et_carousel_hovered');
1341								if ( typeof $(this).data('et_carousel_timer') != 'undefined' ) {
1342									clearInterval( $(this).data('et_carousel_timer') );
1343								}
1344							},
1345							function(){
1346								$(this).removeClass('et_carousel_hovered');
1347								et_carousel_auto_rotate( $(this) );
1348							}
1349						);
1350
1351						$the_portfolio.data('carouseling', false );
1352
1353						$the_portfolio.on('click', '.et-pb-slider-arrows a', function(e){
1354							fullwidth_portfolio_carousel_slide( $( this) );
1355							e.preventDefault();
1356							return false;
1357						});
1358
1359					} else {
1360						// setup fullwidth portfolio grid
1361						set_fullwidth_portfolio_columns( $the_portfolio, false );
1362					}
1363			 	}
1364
1365			 	function fullwidth_portfolio_carousel_slide( $arrow ) {
1366			 		var $the_portfolio = $arrow.parents('.et_pb_fullwidth_portfolio'),
1367						$portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'),
1368						$the_portfolio_items = $portfolio_items.find('.et_pb_portfolio_item'),
1369						$active_carousel_group = $portfolio_items.find('.et_pb_carousel_group.active'),
1370						slide_duration = 700,
1371						items = $portfolio_items.data('items'),
1372						columns = $portfolio_items.data('portfolio-columns'),
1373						item_width = $active_carousel_group.innerWidth() / columns, //$active_carousel_group.children().first().innerWidth(),
1374						original_item_width = ( 100 / columns ) + '%';
1375
1376
1377
1378					if ( $the_portfolio.data('carouseling') ) {
1379						return;
1380					}
1381
1382					$the_portfolio.data('carouseling', true);
1383
1384					$active_carousel_group.children().each(function(){
1385						$(this).css({'width': $(this).innerWidth() + 1, 'position':'absolute', 'left': ( $(this).innerWidth() * ( $(this).data('position') - 1 ) ) });
1386					});
1387
1388					if ( $arrow.hasClass('et-pb-arrow-next') ) {
1389						var $next_carousel_group,
1390							current_position = 1,
1391							next_position = 1,
1392							active_items_start = items.indexOf( $active_carousel_group.children().first()[0] ),
1393							active_items_end = active_items_start + columns,
1394							next_items_start = active_items_end,
1395							next_items_end = next_items_start + columns;
1396
1397						$next_carousel_group = $('<div class="et_pb_carousel_group next" style="display: none;left: 100%;position: absolute;top: 0;">').insertAfter( $active_carousel_group );
1398						$next_carousel_group.css({ 'width': $active_carousel_group.innerWidth() }).show();
1399
1400						// this is an endless loop, so it can decide internally when to break out, so that next_position
1401						// can get filled up, even to the extent of an element having both and current_ and next_ position
1402						for( x = 0, total = 0 ; ; x++, total++ ) {
1403							if ( total >= active_items_start && total < active_items_end ) {
1404								$( items[x] ).addClass( 'changing_position current_position current_position_' + current_position );
1405								$( items[x] ).data('current_position', current_position );
1406								current_position++;
1407							}
1408
1409							if ( total >= next_items_start && total < next_items_end ) {
1410								$( items[x] ).data('next_position', next_position );
1411								$( items[x] ).addClass('changing_position next_position next_position_' + next_position );
1412
1413								if ( !$( items[x] ).hasClass( 'current_position' ) ) {
1414									$( items[x] ).addClass('container_append');
1415								} else {
1416									$( items[x] ).clone(true).appendTo( $active_carousel_group ).hide().addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' );
1417									$( items[x] ).addClass('delayed_container_append');
1418								}
1419
1420								next_position++;
1421							}
1422
1423							if ( next_position > columns ) {
1424								break;
1425							}
1426
1427							if ( x >= ( items.length -1 )) {
1428								x = -1;
1429							}
1430						}
1431
1432						sorted = $portfolio_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) {
1433							var el_a_position = parseInt( $(a).data('next_position') );
1434							var el_b_position = parseInt( $(b).data('next_position') );
1435							return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0;
1436						});
1437
1438						$( sorted ).show().appendTo( $next_carousel_group );
1439
1440						$next_carousel_group.children().each(function(){
1441							$(this).css({'width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('next_position') - 1 ) ) });
1442						});
1443
1444						$active_carousel_group.animate({
1445							left: '-100%'
1446						}, {
1447							duration: slide_duration,
1448							complete: function() {
1449								$portfolio_items.find('.delayed_container_append').each(function(){
1450									$(this).css({'width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('next_position') - 1 ) ) });
1451									$(this).appendTo( $next_carousel_group );
1452								});
1453
1454								$active_carousel_group.removeClass('active');
1455								$active_carousel_group.children().each(function(){
1456									position = $(this).data('position');
1457									current_position = $(this).data('current_position');
1458									$(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position );
1459									$(this).data('position', '');
1460									$(this).data('current_position', '');
1461									$(this).hide();
1462									$(this).css({'position': '', 'width': '', 'left': ''});
1463									$(this).appendTo( $portfolio_items );
1464								});
1465
1466								$active_carousel_group.remove();
1467
1468								et_carousel_auto_rotate( $the_portfolio );
1469
1470							}
1471						} );
1472
1473						$next_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: '100%'});
1474						$next_carousel_group.animate({
1475							left: '0%'
1476						}, {
1477							duration: slide_duration,
1478							complete: function(){
1479								setTimeout(function(){
1480									$next_carousel_group.removeClass('next').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''});
1481
1482									$next_carousel_group.find('.delayed_container_append_dup').remove();
1483
1484									$next_carousel_group.find('.changing_position').each(function( index ){
1485										position = $(this).data('position');
1486										current_position = $(this).data('current_position');
1487										next_position = $(this).data('next_position');
1488										$(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' next_position next_position_' + next_position );
1489										$(this).data('current_position', '');
1490										$(this).data('next_position', '');
1491										$(this).data('position', ( index + 1 ) );
1492									});
1493
1494									$next_carousel_group.children().css({'position': '', 'width': original_item_width, 'left': ''});
1495
1496									$the_portfolio.data('carouseling', false);
1497								}, 100 );
1498							}
1499						} );
1500
1501					} else {
1502						var $prev_carousel_group,
1503							current_position = columns,
1504							prev_position = columns,
1505							columns_span = columns - 1,
1506							active_items_start = items.indexOf( $active_carousel_group.children().last()[0] ),
1507							active_items_end = active_items_start - columns_span,
1508							prev_items_start = active_items_end - 1,
1509							prev_items_end = prev_items_start - columns_span;
1510
1511						$prev_carousel_group = $('<div class="et_pb_carousel_group prev" style="display: none;left: 100%;position: absolute;top: 0;">').insertBefore( $active_carousel_group );
1512						$prev_carousel_group.css({ 'left': '-' + $active_carousel_group.innerWidth(), 'width': $active_carousel_group.innerWidth() }).show();
1513
1514						// this is an endless loop, so it can decide internally when to break out, so that next_position
1515						// can get filled up, even to the extent of an element having both and current_ and next_ position
1516						for( x = ( items.length - 1 ), total = ( items.length - 1 ) ; ; x--, total-- ) {
1517
1518							if ( total <= active_items_start && total >= active_items_end ) {
1519								$( items[x] ).addClass( 'changing_position current_position current_position_' + current_position );
1520								$( items[x] ).data('current_position', current_position );
1521								current_position--;
1522							}
1523
1524							if ( total <= prev_items_start && total >= prev_items_end ) {
1525								$( items[x] ).data('prev_position', prev_position );
1526								$( items[x] ).addClass('changing_position prev_position prev_position_' + prev_position );
1527
1528								if ( !$( items[x] ).hasClass( 'current_position' ) ) {
1529									$( items[x] ).addClass('container_append');
1530								} else {
1531									$( items[x] ).clone(true).appendTo( $active_carousel_group ).addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' );
1532									$( items[x] ).addClass('delayed_container_append');
1533								}
1534
1535								prev_position--;
1536							}
1537
1538							if ( prev_position <= 0 ) {
1539								break;
1540							}
1541
1542							if ( x == 0 ) {
1543								x = items.length;
1544							}
1545						}
1546
1547						sorted = $portfolio_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) {
1548							var el_a_position = parseInt( $(a).data('prev_position') );
1549							var el_b_position = parseInt( $(b).data('prev_position') );
1550							return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0;
1551						});
1552
1553						$( sorted ).show().appendTo( $prev_carousel_group );
1554
1555						$prev_carousel_group.children().each(function(){
1556							$(this).css({'width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('prev_position') - 1 ) ) });
1557						});
1558
1559						$active_carousel_group.animate({
1560							left: '100%'
1561						}, {
1562							duration: slide_duration,
1563							complete: function() {
1564								$portfolio_items.find('.delayed_container_append').reverse().each(function(){
1565									$(this).css({'width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('prev_position') - 1 ) ) });
1566									$(this).prependTo( $prev_carousel_group );
1567								});
1568
1569								$active_carousel_group.removeClass('active');
1570								$active_carousel_group.children().each(function(){
1571									position = $(this).data('position');
1572									current_position = $(this).data('current_position');
1573									$(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position );
1574									$(this).data('position', '');
1575									$(this).data('current_position', '');
1576									$(this).hide();
1577									$(this).css({'position': '', 'width': '', 'left': ''});
1578									$(this).appendTo( $portfolio_items );
1579								});
1580
1581								$active_carousel_group.remove();
1582							}
1583						} );
1584
1585						$prev_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: '-100%'});
1586						$prev_carousel_group.animate({
1587							left: '0%'
1588						}, {
1589							duration: slide_duration,
1590							complete: function(){
1591								setTimeout(function(){
1592									$prev_carousel_group.removeClass('prev').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''});
1593
1594									$prev_carousel_group.find('.delayed_container_append_dup').remove();
1595
1596									$prev_carousel_group.find('.changing_position').each(function( index ){
1597										position = $(this).data('position');
1598										current_position = $(this).data('current_position');
1599										prev_position = $(this).data('prev_position');
1600										$(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' prev_position prev_position_' + prev_position );
1601										$(this).data('current_position', '');
1602										$(this).data('prev_position', '');
1603										position = index + 1;
1604										$(this).data('position', position );
1605										$(this).addClass('position_' + position );
1606									});
1607
1608									$prev_carousel_group.children().css({'position': '', 'width': original_item_width, 'left': ''});
1609									$the_portfolio.data('carouseling', false);
1610								}, 100 );
1611							}
1612						} );
1613					}
1614			 	}
1615
1616				function set_fullwidth_portfolio_columns( $the_portfolio, carousel_mode ) {
1617					var columns,
1618						$portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'),
1619						portfolio_items_width = $portfolio_items.width(),
1620						$the_portfolio_items = $portfolio_items.find('.et_pb_portfolio_item'),
1621						portfolio_item_count = $the_portfolio_items.length;
1622
1623					if ('undefined' === typeof $the_portfolio_items) {
1624						return;
1625					}
1626
1627					// calculate column breakpoints
1628					if ( portfolio_items_width >= 1600 ) {
1629						columns = 5;
1630					} else if ( portfolio_items_width >= 1024 ) {
1631						columns = 4;
1632					} else if ( portfolio_items_width >= 768 ) {
1633						columns = 3;
1634					} else if ( portfolio_items_width >= 480 ) {
1635						columns = 2;
1636					} else {
1637						columns = 1;
1638					}
1639
1640					// set height of items
1641					portfolio_item_width = portfolio_items_width / columns;
1642					portfolio_item_height = portfolio_item_width * .75;
1643
1644					if ( carousel_mode ) {
1645						$portfolio_items.css({ 'height' : portfolio_item_height });
1646					}
1647
1648					$the_portfolio_items.css({ 'height' : portfolio_item_height });
1649
1650					if ( columns === $portfolio_items.data('portfolio-columns') ) {
1651						return;
1652					}
1653
1654					if ( $the_portfolio.data('columns_setting_up') ) {
1655						return;
1656					}
1657
1658					$the_portfolio.data('columns_setting_up', true );
1659
1660					var portfolio_item_width_percentage = ( 100 / columns ) + '%';
1661					$the_portfolio_items.css({ 'width' : portfolio_item_width_percentage });
1662
1663					// store last setup column
1664					$portfolio_items.removeClass('columns-' + $portfolio_items.data('portfolio-columns') );
1665					$portfolio_items.addClass('columns-' + columns );
1666					$portfolio_items.data('portfolio-columns', columns );
1667
1668					if ( !carousel_mode ) {
1669						return $the_portfolio.data('columns_setting_up', false );
1670					}
1671
1672					// kill all previous groups to get ready to re-group
1673					if ( $portfolio_items.find('.et_pb_carousel_group').length ) {
1674						$the_portfolio_items.appendTo( $portfolio_items );
1675						$portfolio_items.find('.et_pb_carousel_group').remove();
1676					}
1677
1678					// setup the grouping
1679					var the_portfolio_items = $portfolio_items.data('items' ),
1680						$carousel_group = $('<div class="et_pb_carousel_group active">').appendTo( $portfolio_items );
1681
1682					if ('undefined' === typeof the_portfolio_items) {
1683						return;
1684					}
1685
1686					$the_portfolio_items.data('position', '');
1687					if ( the_portfolio_items.length <= columns ) {
1688						$portfolio_items.find('.et-pb-slider-arrows').hide();
1689					} else {
1690						$portfolio_items.find('.et-pb-slider-arrows').show();
1691					}
1692
1693					for ( position = 1, x=0 ;x < the_portfolio_items.length; x++, position++ ) {
1694						if ( x < columns ) {
1695							$( the_portfolio_items[x] ).show();
1696							$( the_portfolio_items[x] ).appendTo( $carousel_group );
1697							$( the_portfolio_items[x] ).data('position', position );
1698							$( the_portfolio_items[x] ).addClass('position_' + position );
1699						} else {
1700							position = $( the_portfolio_items[x] ).data('position');
1701							$( the_portfolio_items[x] ).removeClass('position_' + position );
1702							$( the_portfolio_items[x] ).data('position', '' );
1703							$( the_portfolio_items[x] ).hide();
1704						}
1705					}
1706
1707					$the_portfolio.data('columns_setting_up', false );
1708
1709				}
1710
1711				function et_carousel_auto_rotate( $carousel ) {
1712					if ( 'on' === $carousel.data('auto-rotate') && $carousel.find('.et_pb_portfolio_item').length > $carousel.find('.et_pb_carousel_group .et_pb_portfolio_item').length && ! $carousel.hasClass( 'et_carousel_hovered' ) ) {
1713
1714						et_carousel_timer = setTimeout( function() {
1715							fullwidth_portfolio_carousel_slide( $carousel.find('.et-pb-arrow-next') );
1716						}, $carousel.data('auto-rotate-speed') );
1717
1718						$carousel.data('et_carousel_timer', et_carousel_timer);
1719					}
1720				}
1721
1722				$et_pb_fullwidth_portfolio.each(function(){
1723					et_fullwidth_portfolio_init( $(this) );
1724				});
1725			}
1726
1727			function et_audio_module_set() {
1728				if ( $( '.et_pb_audio_module .mejs-audio' ).length || $( '.et_audio_content .mejs-audio' ).length ) {
1729					$( '.et_audio_container' ).each( function(){
1730						et_pb_audio_module_init( $(this) );
1731					});
1732				}
1733			}
1734
1735			window.et_pb_audio_module_init = function( $audio_container ) {
1736				var $this_player = $audio_container,
1737					$time_rail = $this_player.find( '.mejs-time-rail' ),
1738					$time_slider = $this_player.find( '.mejs-time-slider' );
1739				// remove previously added width and min-width attributes to calculate the new sizes accurately
1740				$time_rail.removeAttr( 'style' );
1741				$time_slider.removeAttr( 'style' );
1742
1743				var $count_timer = $this_player.find( 'div.mejs-currenttime-container' ),
1744					player_width = $this_player.width(),
1745					controls_play_width = $this_player.find( '.mejs-play' ).outerWidth(),
1746					time_width = $this_player.find( '.mejs-currenttime-container' ).outerWidth(),
1747					volume_icon_width = $this_player.find( '.mejs-volume-button' ).outerWidth(),
1748					volume_bar_width = $this_player.find( '.mejs-horizontal-volume-slider' ).outerWidth(),
1749					new_time_rail_width;
1750
1751				$count_timer.addClass( 'custom' );
1752				$this_player.find( '.mejs-controls div.mejs-duration-container' ).replaceWith( $count_timer );
1753				new_time_rail_width = player_width - ( controls_play_width + time_width + volume_icon_width + volume_bar_width + 65 );
1754
1755				if ( 0 < new_time_rail_width ) {
1756					$time_rail.attr( 'style', 'min-width: ' + new_time_rail_width + 'px;' );
1757					$time_slider.attr( 'style', 'min-width: ' + new_time_rail_width + 'px;' );
1758				}
1759			}
1760
1761			if ( $('.et_pb_section_video').length ) {
1762				window._wpmejsSettings.pauseOtherPlayers = false;
1763			}
1764
1765			if ( $et_pb_filterable_portfolio.length || is_frontend_builder ) {
1766
1767				window.et_pb_filterable_portfolio_init = function( $selector ) {
1768					if ( typeof $selector !== 'undefined' ){
1769						set_filterable_portfolio_init( $selector );
1770					} else {
1771						$et_pb_filterable_portfolio.each(function(){
1772							set_filterable_portfolio_init( $(this) )
1773						});
1774					}
1775				}
1776
1777				window.set_filterable_portfolio_init = function( $the_portfolio ) {
1778					var $the_portfolio_items = $the_portfolio.find('.et_pb_portfolio_items'),
1779						$left_orientatation = true == $the_portfolio.data( 'rtl' ) ? false : true;
1780
1781					$the_portfolio.show();
1782
1783					set_filterable_grid_items( $the_portfolio );
1784
1785					$the_portfolio.on('click', '.et_pb_portfolio_filter a', function(e){
1786						e.preventDefault();
1787						var category_slug = $(this).data('category-slug');
1788						$the_portfolio_items = $(this).parents('.et_pb_filterable_portfolio').find('.et_pb_portfolio_items');
1789
1790						if ( 'all' == category_slug ) {
1791							$the_portfolio.find('.et_pb_portfolio_filter a').removeClass('active');
1792							$the_portfolio.find('.et_pb_portfolio_filter_all a').addClass('active');
1793							$the_portfolio.find('.et_pb_portfolio_item').removeClass('active inactive');
1794							$the_portfolio.find('.et_pb_portfolio_item').show();
1795							$the_portfolio.find('.et_pb_portfolio_item').addClass('active');
1796						} else {
1797							$the_portfolio.find('.et_pb_portfolio_filter_all').removeClass('active');
1798							$the_portfolio.find('.et_pb_portfolio_filter a').removeClass('active');
1799							$the_portfolio.find('.et_pb_portfolio_filter_all a').removeClass('active');
1800							$(this).addClass('active');
1801
1802							$the_portfolio_items.find('.et_pb_portfolio_item').hide();
1803							$the_portfolio_items.find('.et_pb_portfolio_item').addClass( 'inactive' );
1804							$the_portfolio_items.find('.et_pb_portfolio_item').removeClass('active');
1805							$the_portfolio_items.find('.et_pb_portfolio_item.project_category_' + $(this).data('category-slug') ).show();
1806							$the_portfolio_items.find('.et_pb_portfolio_item.project_category_' + $(this).data('category-slug') ).addClass('active').removeClass( 'inactive' );
1807						}
1808
1809						set_filterable_grid_items( $the_portfolio );
1810						setTimeout(function(){
1811							set_filterable_portfolio_hash( $the_portfolio );
1812						}, 500 );
1813					});
1814
1815					$the_portfolio.on('click', '.et_pb_portofolio_pagination a', function(e){
1816						e.preventDefault();
1817
1818						var to_page = $(this).data('page'),
1819							$the_portfolio = $(this).parents('.et_pb_filterable_portfolio'),
1820							$the_portfolio_items = $the_portfolio.find('.et_pb_portfolio_items');
1821
1822						et_pb_smooth_scroll( $the_portfolio, false, 800 );
1823
1824						if ( $(this).hasClass('page-prev') ) {
1825							to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) - 1;
1826						} else if ( $(this).hasClass('page-next') ) {
1827							to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) + 1;
1828						}
1829
1830						$(this).parents('ul').find('a').removeClass('active');
1831						$(this).parents('ul').find('a.page-' + to_page ).addClass('active');
1832
1833						var current_index = $(this).parents('ul').find('a.page-' + to_page ).parent().index(),
1834							total_pages = $(this).parents('ul').find('li.page').length;
1835
1836						$(this).parent().nextUntil('.page-' + ( current_index + 3 ) ).show();
1837						$(this).parent().prevUntil('.page-' + ( current_index - 3 ) ).show();
1838
1839						$(this).parents('ul').find('li.page').each(function(i){
1840							if ( !$(this).hasClass('prev') && !$(this).hasClass('next') ) {
1841								if ( i < ( current_index - 3 ) ) {
1842									$(this).hide();
1843								} else if ( i > ( current_index + 1 ) ) {
1844									$(this).hide();
1845								} else {
1846									$(this).show();
1847								}
1848
1849								if ( total_pages - current_index <= 2 && total_pages - i <= 5 ) {
1850									$(this).show();
1851								} else if ( current_index <= 3 && i <= 4 ) {
1852									$(this).show();
1853								}
1854
1855							}
1856						});
1857
1858						if ( to_page > 1 ) {
1859							$(this).parents('ul').find('li.prev').show();
1860						} else {
1861							$(this).parents('ul').find('li.prev').hide();
1862						}
1863
1864						if ( $(this).parents('ul').find('a.active').hasClass('last-page') ) {
1865							$(this).parents('ul').find('li.next').hide();
1866						} else {
1867							$(this).parents('ul').find('li.next').show();
1868						}
1869
1870						$the_portfolio.find('.et_pb_portfolio_item').hide();
1871						$the_portfolio.find('.et_pb_portfolio_item').filter(function( index ) {
1872							return $(this).data('page') === to_page;
1873						}).show();
1874
1875						setTimeout(function(){
1876							set_filterable_portfolio_hash( $the_portfolio );
1877						}, 500 );
1878					});
1879
1880					$(this).on('et_hashchange', function( event ){
1881						var params = event.params;
1882						$the_portfolio = $( '#' + event.target.id );
1883
1884						if ( !$the_portfolio.find('.et_pb_portfolio_filter a[data-category-slug="' + params[0] + '"]').hasClass('active') ) {
1885							$the_portfolio.find('.et_pb_portfolio_filter a[data-category-slug="' + params[0] + '"]').click();
1886						}
1887
1888						if ( params[1] ) {
1889							setTimeout(function(){
1890								if ( !$the_portfolio.find('.et_pb_portofolio_pagination a.page-' + params[1]).hasClass('active') ) {
1891									$the_portfolio.find('.et_pb_portofolio_pagination a.page-' + params[1]).addClass('active').click();
1892								}
1893							}, 300 );
1894						}
1895					});
1896				}
1897
1898				// init portfolio if .load event was fired already, wait for the window load otherwise.
1899				if ( window.et_load_event_fired ) {
1900					et_pb_filterable_portfolio_init();
1901				} else {
1902					$(window).load(function(){
1903						et_pb_filterable_portfolio_init();
1904					}); // End $(window).load()
1905				}
1906
1907				function set_filterable_grid_items( $the_portfolio ) {
1908					var active_category = $the_portfolio.find('.et_pb_portfolio_filter > a.active').data('category-slug'),
1909						container_width = $the_portfolio.find( '.et_pb_portfolio_items' ).innerWidth(),
1910						item_width = $the_portfolio.find( '.et_pb_portfolio_item' ).outerWidth( true ),
1911						last_item_margin = item_width - $the_portfolio.find( '.et_pb_portfolio_item' ).outerWidth(),
1912						columns_count = Math.round( ( container_width + last_item_margin ) / item_width ),
1913						counter = 1,
1914						first_in_row = 1;
1915
1916						$the_portfolio.find( '.et_pb_portfolio_item' ).removeClass( 'last_in_row first_in_row' );
1917						$the_portfolio.find( '.et_pb_portfolio_item' ).each( function() {
1918							var $this_el = $( this );
1919
1920							if ( ! $this_el.hasClass( 'inactive' ) ) {
1921								if ( first_in_row === counter ) {
1922									$this_el.addClass( 'first_in_row' );
1923								}
1924
1925								if ( 0 === counter % columns_count ) {
1926									$this_el.addClass( 'last_in_row' );
1927									first_in_row = counter + 1;
1928								}
1929								counter++;
1930							}
1931						});
1932
1933					if ( 'all' === active_category ) {
1934						$the_portfolio_visible_items = $the_portfolio.find('.et_pb_portfolio_item');
1935					} else {
1936						$the_portfolio_visible_items = $the_portfolio.find('.et_pb_portfolio_item.project_category_' + active_category);
1937					}
1938
1939					var visible_grid_items = $the_portfolio_visible_items.length,
1940						posts_number = $the_portfolio.data('posts-number'),
1941						pages = Math.ceil( visible_grid_items / posts_number );
1942
1943					set_filterable_grid_pages( $the_portfolio, pages );
1944
1945					var visible_grid_items = 0;
1946					var _page = 1;
1947					$the_portfolio.find('.et_pb_portfolio_item').data('page', '');
1948					$the_portfolio_visible_items.each(function(i){
1949						visible_grid_items++;
1950						if ( 0 === parseInt( visible_grid_items % posts_number ) ) {
1951							$(this).data('page', _page);
1952							_page++;
1953						} else {
1954							$(this).data('page', _page);
1955						}
1956					});
1957
1958					$the_portfolio_visible_items.filter(function() {
1959						return $(this).data('page') == 1;
1960					}).show();
1961
1962					$the_portfolio_visible_items.filter(function() {
1963						return $(this).data('page') != 1;
1964					}).hide();
1965				}
1966
1967				function set_filterable_grid_pages( $the_portfolio, pages ) {
1968					$pagination = $the_portfolio.find('.et_pb_portofolio_pagination');
1969
1970					if ( !$pagination.length ) {
1971						return;
1972					}
1973
1974					$pagination.html('<ul></ul>');
1975					if ( pages <= 1 ) {
1976						return;
1977					}
1978
1979					$pagination_list = $pagination.children('ul');
1980					$pagination_list.append('<li class="prev" style="display:none;"><a href="#" data-page="prev" class="page-prev">' + et_pb_custom.prev + '</a></li>');
1981					for( var page = 1; page <= pages; page++ ) {
1982						var first_page_class = page === 1 ? ' active' : '',
1983							last_page_class = page === pages ? ' last-page' : '',
1984							hidden_page_class = page >= 5 ? ' style="display:none;"' : '';
1985						$pagination_list.append('<li' + hidden_page_class + ' class="page page-' + page + '"><a href="#" data-page="' + page + '" class="page-' + page + first_page_class + last_page_class + '">' + page + '</a></li>');
1986					}
1987					$pagination_list.append('<li class="next"><a href="#" data-page="next" class="page-next">' + et_pb_custom.next + '</a></li>');
1988				}
1989
1990				function set_filterable_portfolio_hash( $the_portfolio ) {
1991
1992					if ( !$the_portfolio.attr('id') ) {
1993						return;
1994					}
1995
1996					var this_portfolio_state = [];
1997					this_portfolio_state.push( $the_portfolio.attr('id') );
1998					this_portfolio_state.push( $the_portfolio.find('.et_pb_portfolio_filter > a.active').data('category-slug') );
1999
2000					if ( $the_portfolio.find('.et_pb_portofolio_pagination a.active').length ) {
2001						this_portfolio_state.push( $the_portfolio.find('.et_pb_portofolio_pagination a.active').data('page') );
2002					} else {
2003						this_portfolio_state.push( 1 );
2004					}
2005
2006					this_portfolio_state = this_portfolio_state.join( et_hash_module_param_seperator );
2007
2008					et_set_hash( this_portfolio_state );
2009				}
2010			} /*  end if ( $et_pb_filterable_portfolio.length ) */
2011
2012			if ( $et_pb_gallery.length || is_frontend_builder ) {
2013
2014				window.set_gallery_grid_items = function( $the_gallery ) {
2015					var $the_gallery_items_container = $the_gallery.find('.et_pb_gallery_items'),
2016						$the_gallery_items = $the_gallery_items_container.find('.et_pb_gallery_item');
2017
2018					var total_grid_items = $the_gallery_items.length,
2019						posts_number = $the_gallery_items_container.attr('data-per_page'),
2020						pages = Math.ceil( total_grid_items / posts_number );
2021
2022					set_gallery_grid_pages( $the_gallery, pages );
2023
2024					var total_grid_items = 0;
2025					var _page = 1;
2026					$the_gallery_items.data('page', '');
2027					$the_gallery_items.each(function(i){
2028						total_grid_items++;
2029						if ( 0 === parseInt( total_grid_items % posts_number ) ) {
2030							$(this).data('page', _page);
2031							_page++;
2032						} else {
2033							$(this).data('page', _page);
2034						}
2035
2036					});
2037
2038					var visible_items = $the_gallery_items.filter(function() {
2039						return $(this).data('page') == 1;
2040					}).show();
2041
2042					$the_gallery_items.filter(function() {
2043						return $(this).data('page') != 1;
2044					}).hide();
2045				}
2046
2047				window.set_gallery_grid_pages = function( $the_gallery, pages ) {
2048					$pagination = $the_gallery.find('.et_pb_gallery_pagination');
2049
2050					if ( !$pagination.length ) {
2051						return;
2052					}
2053
2054					$pagination.html('<ul></ul>');
2055					if ( pages <= 1 ) {
2056						$pagination.hide();
2057						return;
2058					}
2059
2060					$pagination_list = $pagination.children('ul');
2061					$pagination_list.append('<li class="prev" style="display:none;"><a href="#" data-page="prev" class="page-prev">' + et_pb_custom.prev + '</a></li>');
2062					for( var page = 1; page <= pages; page++ ) {
2063						var first_page_class = page === 1 ? ' active' : '',
2064							last_page_class = page === pages ? ' last-page' : '',
2065							hidden_page_class = page >= 5 ? ' style="display:none;"' : '';
2066						$pagination_list.append('<li' + hidden_page_class + ' class="page page-' + page + '"><a href="#" data-page="' + page + '" class="page-' + page + first_page_class + last_page_class + '">' + page + '</a></li>');
2067					}
2068					$pagination_list.append('<li class="next"><a href="#" data-page="next" class="page-next">' + et_pb_custom.next + '</a></li>');
2069				}
2070
2071				window.set_gallery_hash = function( $the_gallery ) {
2072
2073					if ( !$the_gallery.attr('id') ) {
2074						return;
2075					}
2076
2077					var this_gallery_state = [];
2078					this_gallery_state.push( $the_gallery.attr('id') );
2079
2080					if ( $the_gallery.find('.et_pb_gallery_pagination a.active').length ) {
2081						this_gallery_state.push( $the_gallery.find('.et_pb_gallery_pagination a.active').data('page') );
2082					} else {
2083						this_gallery_state.push( 1 );
2084					}
2085
2086					this_gallery_state = this_gallery_state.join( et_hash_module_param_seperator );
2087
2088					et_set_hash( this_gallery_state );
2089				}
2090
2091				window.et_pb_gallery_init = function( $the_gallery ) {
2092					if ( $the_gallery.hasClass( 'et_pb_gallery_grid' ) ) {
2093
2094						$the_gallery.show();
2095						set_gallery_grid_items( $the_gallery );
2096
2097						$the_gallery.on('et_hashchange', function( event ){
2098							var params = event.params;
2099							$the_gallery = $( '#' + event.target.id );
2100
2101							if ( page_to = params[0] ) {
2102								if ( !$the_gallery.find('.et_pb_gallery_pagination a.page-' + page_to ).hasClass('active') ) {
2103									$the_gallery.find('.et_pb_gallery_pagination a.page-' + page_to ).addClass('active').click();
2104								}
2105							}
2106						});
2107					}
2108				}
2109
2110				$et_pb_gallery.each(function(){
2111					var $the_gallery = $(this);
2112
2113					et_pb_gallery_init( $the_gallery );
2114				});
2115
2116				$et_pb_gallery.data('paginating', false );
2117
2118				window.et_pb_gallery_pagination_nav = function( $the_gallery ) {
2119					$the_gallery.on('click', '.et_pb_gallery_pagination a', function(e){
2120						e.preventDefault();
2121
2122						var to_page = $(this).data('page'),
2123							$the_gallery = $(this).parents('.et_pb_gallery'),
2124							$the_gallery_items_container = $the_gallery.find('.et_pb_gallery_items'),
2125							$the_gallery_items = $the_gallery_items_container.find('.et_pb_gallery_item');
2126
2127						if ( $the_gallery.data('paginating') ) {
2128							return;
2129						}
2130
2131						$the_gallery.data('paginating', true );
2132
2133						if ( $(this).hasClass('page-prev') ) {
2134							to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) - 1;
2135						} else if ( $(this).hasClass('page-next') ) {
2136							to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) + 1;
2137						}
2138
2139						$(this).parents('ul').find('a').removeClass('active');
2140						$(this).parents('ul').find('a.page-' + to_page ).addClass('active');
2141
2142						var current_index = $(this).parents('ul').find('a.page-' + to_page ).parent().index(),
2143							total_pages = $(this).parents('ul').find('li.page').length;
2144
2145						$(this).parent().nextUntil('.page-' + ( current_index + 3 ) ).show();
2146						$(this).parent().prevUntil('.page-' + ( current_index - 3 ) ).show();
2147
2148						$(this).parents('ul').find('li.page').each(function(i){
2149							if ( !$(this).hasClass('prev') && !$(this).hasClass('next') ) {
2150								if ( i < ( current_index - 3 ) ) {
2151									$(this).hide();
2152								} else if ( i > ( current_index + 1 ) ) {
2153									$(this).hide();
2154								} else {
2155									$(this).show();
2156								}
2157
2158								if ( total_pages - current_index <= 2 && total_pages - i <= 5 ) {
2159									$(this).show();
2160								} else if ( current_index <= 3 && i <= 4 ) {
2161									$(this).show();
2162								}
2163
2164							}
2165						});
2166
2167						if ( to_page > 1 ) {
2168							$(this).parents('ul').find('li.prev').show();
2169						} else {
2170							$(this).parents('ul').find('li.prev').hide();
2171						}
2172
2173						if ( $(this).parents('ul').find('a.active').hasClass('last-page') ) {
2174							$(this).parents('ul').find('li.next').hide();
2175						} else {
2176							$(this).parents('ul').find('li.next').show();
2177						}
2178
2179						$the_gallery_items.hide();
2180						var visible_items = $the_gallery_items.filter(function( index ) {
2181							return $(this).data('page') === to_page;
2182						}).show();
2183
2184						$the_gallery.data('paginating', false );
2185
2186						setTimeout(function(){
2187							set_gallery_hash( $the_gallery );
2188						}, 100 );
2189
2190						$( 'html, body' ).animate( { scrollTop : $the_gallery.offset().top - 200 }, 200 );
2191					});
2192				}
2193				et_pb_gallery_pagination_nav( $et_pb_gallery );
2194
2195				// Frontend builder's interface wouldn't be able to use $et_pb_gallery as selector
2196				// due to its react component's nature. Using more global selector works.
2197				if ( is_frontend_builder ) {
2198					et_pb_gallery_pagination_nav( $('#et-fb-app') );
2199				}
2200
2201			} /*  end if ( $et_pb_gallery.length ) */
2202
2203			if ( $et_pb_counter_amount.length ) {
2204				$et_pb_counter_amount.each(function(){
2205					var $bar_item      
2205     = $(this),
2206						bar_item_width      = $bar_item.attr( 'data-width' ),
2207						bar_item_padding    = Math.ceil( parseFloat( $bar_item.css('paddingLeft') ) ) + Math.ceil( parseFloat( $bar_item.css('paddingRight') ) ),
2208						$bar_item_text      = $bar_item.children( '.et_pb_counter_amount_number' ),
2209						bar_item_text_width = $bar_item_text.width() + bar_item_padding;
2210
2211					$bar_item.css({
2212						'width' : bar_item_width,
2213						'min-width' : bar_item_text_width
2214					});
2215				});
2216			} /* $et_pb_counter_amount.length */
2217
2218			window.et_countdown_timer = function( timer ) {
2219				var end_date = parseInt( timer.attr( 'data-end-timestamp') ),
2220					current_date = new Date().getTime() / 1000,
2221					seconds_left = ( end_date - current_date );
2222
2223				days = parseInt(seconds_left / 86400);
2224				days = days > 0 ? days : 0;
2225				seconds_left = seconds_left % 86400;
2226
2227				hours = parseInt(seconds_left / 3600);
2228				hours = hours > 0 ? hours : 0;
2229
2230				seconds_left = seconds_left % 3600;
2231
2232				minutes = parseInt(seconds_left / 60);
2233				minutes = minutes > 0 ? minutes : 0;
2234
2235				seconds = parseInt(seconds_left % 60);
2236				seconds = seconds > 0 ? seconds : 0;
2237
2238				var $days_section = timer.find('.days > .value').parent('.section'),
2239					$hours_section = timer.find('.hours > .value').parent('.section'),
2240					$minutes_section = timer.find('.minutes > .value').parent('.section'),
2241					$seconds_section = timer.find('.seconds > .value').parent('.section');
2242
2243
2244				if ( days == 0 ) {
2245					if ( ! $days_section.hasClass('zero') ) {
2246						timer.find('.days > .value').html( '000' ).parent('.section').addClass('zero').next().addClass('zero');
2247					}
2248				} else {
2249					days_slice = days.toString().length >= 3 ? days.toString().length : 3;
2250					timer.find('.days > .value').html( ('000' + days).slice(-days_slice) );
2251
2252					if ( $days_section.hasClass('zero') ) {
2253						$days_section.removeClass('zero').next().removeClass('zero');
2254					}
2255				}
2256
2257				if ( days == 0 && hours == 0 ) {
2258					if ( ! $hours_section.hasClass('zero') ) {
2259						timer.find('.hours > .value').html('00').parent('.section').addClass('zero').next().addClass('zero');
2260					}
2261				} else {
2262					timer.find('.hours > .value').html( ( '0' + hours ).slice(-2) );
2263
2264					if ( $hours_section.hasClass('zero') ) {
2265						$hours_section.removeClass('zero').next().removeClass('zero');
2266					}
2267				}
2268
2269				if ( days == 0 && hours == 0 && minutes == 0 ) {
2270					if ( ! $minutes_section.hasClass('zero') ) {
2271						timer.find('.minutes > .value').html('00').parent('.section').addClass('zero').next().addClass('zero');
2272					}
2273				} else {
2274					timer.find('.minutes > .value').html( ( '0' + minutes ).slice(-2) );
2275
2276					if ( $minutes_section.hasClass('zero') ) {
2277						$minutes_section.removeClass('zero').next().removeClass('zero');
2278					}
2279				}
2280
2281				if ( days == 0 && hours == 0 && minutes == 0 && seconds == 0 ) {
2282					if ( ! $seconds_section.hasClass('zero') ) {
2283						timer.find('.seconds > .value').html('00').parent('.section').addClass('zero');
2284					}
2285				} else {
2286					timer.find('.seconds > .value').html( ( '0' + seconds ).slice(-2) );
2287
2288					if ( $seconds_section.hasClass('zero') ) {
2289						$seconds_section.removeClass('zero').next().removeClass('zero');
2290					}
2291				}
2292			}
2293
2294			window.et_countdown_timer_labels = function( timer ) {
2295				if ( timer.closest( '.et_pb_column_3_8' ).length || timer.closest( '.et_pb_column_1_4' ).length || timer.children('.et_pb_countdown_timer_container').width() <= 400 ) {
2296					timer.find('.days .label').html( timer.find('.days').data('short') );
2297					timer.find('.hours .label').html( timer.find('.hours').data('short') );
2298					timer.find('.minutes .label').html( timer.find('.minutes').data('short') );
2299					timer.find('.seconds .label').html( timer.find('.seconds').data('short') );
2300				} else {
2301					timer.find('.days .label').html( timer.find('.days').data('full') );
2302					timer.find('.hours .label').html( timer.find('.hours').data('full') );
2303					timer.find('.minutes .label').html( timer.find('.minutes').data('full') );
2304					timer.find('.seconds .label').html( timer.find('.seconds').data('full') );
2305				}
2306			}
2307
2308			if ( $et_pb_countdown_timer.length || is_frontend_builder ) {
2309				window.et_pb_countdown_timer_init = function( $et_pb_countdown_timer ) {
2310					$et_pb_countdown_timer.each(function(){
2311						var timer = $(this);
2312						et_countdown_timer_labels( timer );
2313						et_countdown_timer( timer );
2314						setInterval(function(){
2315							et_countdown_timer( timer );
2316						}, 1000);
2317					});
2318				}
2319				et_pb_countdown_timer_init( $et_pb_countdown_timer );
2320			}
2321
2322			if ( $et_pb_tabs.length || is_frontend_builder ) {
2323				window.et_pb_tabs_init = function( $et_pb_tabs ) {
2324					var $et_pb_tabs_li = $et_pb_tabs.find( '.et_pb_tabs_controls li' );
2325
2326					$et_pb_tabs.et_pb_simple_slider( {
2327						use_controls   : false,
2328						use_arrows     : false,
2329						slide          : '.et_pb_all_tabs > div',
2330						tabs_animation : true
2331					} ).on('et_hashchange', function( event ){
2332						var params = event.params;
2333						var $the_tabs = $( '#' + event.target.id );
2334						var active_tab = params[0];
2335						if ( !$the_tabs.find( '.et_pb_tabs_controls li' ).eq( active_tab ).hasClass('et_pb_tab_active') ) {
2336							$the_tabs.find( '.et_pb_tabs_controls li' ).eq( active_tab ).click();
2337						}
2338					});
2339
2340					$et_pb_tabs_li.click( function() {
2341						var $this_el        = $(this),
2342							$tabs_container = $this_el.closest( '.et_pb_tabs' ).data('et_pb_simple_slider');
2343
2344						if ( $tabs_container.et_animation_running ) return false;
2345
2346						$this_el.addClass( 'et_pb_tab_active' ).siblings().removeClass( 'et_pb_tab_active' );
2347
2348						$tabs_container.data('et_pb_simple_slider').et_slider_move_to( $this_el.index() );
2349
2350						if ( $this_el.closest( '.et_pb_tabs' ).attr('id') ) {
2351							var tab_state = [];
2352							tab_state.push( $this_el.closest( '.et_pb_tabs' ).attr('id') );
2353							tab_state.push( $this_el.index() );
2354							tab_state = tab_state.join( et_hash_module_param_seperator );
2355							et_set_hash( tab_state );
2356						}
2357
2358						return false;
2359					} );
2360				}
2361				window.et_pb_tabs_init( $et_pb_tabs );
2362			}
2363
2364			if ( $et_pb_map.length || is_frontend_builder ) {
2365				function et_pb_init_maps() {
2366					$et_pb_map.each(function(){
2367						et_pb_map_init( $(this) );
2368					});
2369				}
2370
2371				window.et_pb_map_init = function( $this_map_container ) {
2372					var $this_map = $this_map_container.children('.et_pb_map'),
2373						this_map_grayscale = $this_map_container.attr( 'data-grayscale' ) || 0,
2374						is_draggable = ( et_is_mobile_device && $this_map.data('mobile-dragging') !== 'off' ) || ! et_is_mobile_device,
2375						infowindow_active;
2376
2377					if ( this_map_grayscale !== 0 ) {
2378						this_map_grayscale = '-' + this_map_grayscale.toString();
2379					}
2380
2381					$this_map_container.data('map', new google.maps.Map( $this_map[0], {
2382						zoom: parseInt( $this_map.attr('data-zoom') ),
2383						center: new google.maps.LatLng( parseFloat( $this_map.attr('data-center-lat') ) , parseFloat( $this_map.attr('data-center-lng') )),
2384						mapTypeId: google.maps.MapTypeId.ROADMAP,
2385						scrollwheel: $this_map.attr('data-mouse-wheel') == 'on' ? true : false,
2386						draggable: is_draggable,
2387						panControlOptions: {
2388							position: $this_map_container.is( '.et_beneath_transparent_nav' ) ? google.maps.ControlPosition.LEFT_BOTTOM : google.maps.ControlPosition.LEFT_TOP
2389						},
2390						zoomControlOptions: {
2391							position: $this_map_container.is( '.et_beneath_transparent_nav' ) ? google.maps.ControlPosition.LEFT_BOTTOM : google.maps.ControlPosition.LEFT_TOP
2392						},
2393						styles: [ {
2394							stylers: [
2395								{ saturation: parseInt( this_map_grayscale ) }
2396							]
2397						} ]
2398					}));
2399
2400					$this_map_container.find('.et_pb_map_pin').each(function(){
2401						var $this_marker = $(this);
2402
2403						var marker = new google.maps.Marker({
2404							position: new google.maps.LatLng( parseFloat( $this_marker.attr('data-lat') ) , parseFloat( $this_marker.attr('data-lng') ) ),
2405							map: $this_map_container.data('map'),
2406							title: $this_marker.attr('data-title'),
2407							icon: { url: et_pb_custom.builder_images_uri + '/marker.png', size: new google.maps.Size( 46, 43 ), anchor: new google.maps.Point( 16, 43 ) },
2408							shape: { coord: [1, 1, 46, 43], type: 'rect' },
2409							anchorPoint: new google.maps.Point(0, -45)
2410						});
2411
2412						if ( $this_marker.find('.infowindow').length ) {
2413							var infowindow = new google.maps.InfoWindow({
2414								content: $this_marker.html()
2415							});
2416
2417							google.maps.event.addListener( $this_map_container.data('map'), 'click', function() {
2418								infowindow.close();
2419							});
2420
2421							google.maps.event.addListener(marker, 'click', function() {
2422								if( infowindow_active ) {
2423									infowindow_active.close();
2424								}
2425								infowindow_active = infowindow;
2426
2427								infowindow.open( $this_map_container.data('map'), marker );
2428							});
2429						}
2430					});
2431				}
2432
2433				if ( window.et_load_event_fired ) {
2434					et_pb_init_maps();
2435				} else {
2436					google.maps.event.addDomListener(window, 'load', function() {
2437						et_pb_init_maps();
2438					} );
2439				}
2440			}
2441
2442			if ( $et_pb_shop.length ) {
2443				$et_pb_shop.each( function() {
2444					var $this_el = $(this),
2445						icon     = $this_el.data('icon') || '';
2446
2447					if ( icon === '' ) {
2448						return true;
2449					}
2450
2451					$this_el.find( '.et_overlay' )
2452						.attr( 'data-icon', icon )
2453						.addClass( 'et_pb_inline_icon' );
2454				} );
2455			}
2456
2457			if ( $et_pb_circle_counter.length || is_frontend_builder ) {
2458
2459				window.et_pb_circle_counter_init = function($the_counter, animate) {
2460					if ( 0 === $the_counter.width() ) {
2461						return;
2462					}
2463
2464					$the_counter.easyPieChart({
2465						animate: {
2466							duration: 1800,
2467							enabled: true
2468						},
2469						size: 0 !== $the_counter.width() ? $the_counter.width() : 10, // set the width to 10 if actual width is 0 to avoid js errors
2470						barColor: $the_counter.data( 'bar-bg-color' ),
2471						trackColor: $the_counter.data( 'color' ) || '#000000',
2472						trackAlpha: $the_counter.data( 'alpha' ) || '0.1',
2473						scaleColor: false,
2474						lineWidth: 5,
2475						onStart: function() {
2476							$(this.el).find('.percent p').css({ 'visibility' : 'visible' });
2477						},
2478						onStep: function(from, to, percent) {
2479							$(this.el).find('.percent-value').text( Math.round( parseInt( percent ) ) );
2480						},
2481						onStop: function(from, to) {
2482							$(this.el).find('.percent-value').text( $(this.el).data('number-value') );
2483						}
2484					});
2485				}
2486
2487				window.et_pb_reinit_circle_counters = function( $et_pb_circle_counter ) {
2488					$et_pb_circle_counter.each(function(){
2489						var $the_counter = $(this);
2490						window.et_pb_circle_counter_init($the_counter, false);
2491
2492						$the_counter.on('containerWidthChanged', function( event ){
2493							$the_counter = $( event.target );
2494							$the_counter.find('canvas').remove();
2495							$the_counter.removeData('easyPieChart' );
2496							window.et_pb_circle_counter_init($the_counter, true);
2497						});
2498
2499					});
2500				}
2501				window.et_pb_reinit_circle_counters( $et_pb_circle_counter );
2502			}
2503
2504			if ( $et_pb_number_counter.length || is_frontend_builder ) {
2505				window.et_pb_reinit_number_counters = function( $et_pb_number_counter ) {
2506					if ( $.fn.fitText ) {
2507						$et_pb_number_counter.find( '.percent p' ).fitText( 0.3 );
2508					}
2509
2510					$et_pb_number_counter.each(function(){
2511						var $this_counter = $(this);
2512						$this_counter.easyPieChart({
2513							animate: {
2514								duration: 1800,
2515								enabled: true
2516							},
2517							size: 0,
2518							trackColor: false,
2519							scaleColor: false,
2520							lineWidth: 0,
2521							onStart: function() {
2522								$(this.el).find('.percent p').css({ 'visibility' : 'visible' });
2523							},
2524							onStep: function(from, to, percent) {
2525								if ( percent != to )
2526									$(this.el).find('.percent-value').text( Math.round( parseInt( percent ) ) );
2527							},
2528							onStop: function(from, to) {
2529								$(this.el).find('.percent-value').text( $(this.el).data('number-value') );
2530							}
2531						});
2532					});
2533				}
2534				window.et_pb_reinit_number_counters( $et_pb_number_counter );
2535			}
2536
2537			window.et_apply_parallax = function() {
2538				if ( ! $(this).length || typeof $(this) === 'undefined' || typeof $(this).offset() === 'undefined') {
2539					return;
2540				}
2541
2542				var $this = $(this),
2543					element_top = $this.offset().top,
2544					window_top = $et_window.scrollTop(),
2545					y_pos = ( ( ( window_top + $et_window.height() ) - element_top ) * 0.3 ),
2546					main_position;
2547
2548				main_position = 'translate(0, ' + y_pos + 'px)';
2549
2550				$this.find('.et_parallax_bg').css( {
2551					'-webkit-transform' : main_position,
2552					'-moz-transform'    : main_position,
2553					'-ms-transform'     : main_position,
2554					'transform'         : main_position
2555				} );
2556			}
2557
2558			window.et_parallax_set_height = function() {
2559				var $this = $(this),
2560					bg_height;
2561
2562				bg_height = ( $et_window.height() * 0.3 + $this.innerHeight() );
2563
2564				$this.find('.et_parallax_bg').css( { 'height' : bg_height } );
2565			}
2566
2567			$( '.et_pb_section' ).on( 'click', '.et_pb_toggle_title', function() {
2568				var $this_heading         = $(this),
2569					$module               = $this_heading.closest('.et_pb_toggle'),
2570					$section              = $module.parents( '.et_pb_section' ),
2571					$content              = $module.find('.et_pb_toggle_content'),
2572					$accordion            = $module.closest( '.et_pb_accordion' ),
2573					is_accordion          = $accordion.length,
2574					is_accordion_toggling = $accordion.hasClass( 'et_pb_accordion_toggling' ),
2575					window_offset_top     = $(window).scrollTop(),
2576					fixed_header_height   = 0,
2577					initial_toggle_state  = $module.hasClass( 'et_pb_toggle_close' ) ? 'closed' : 'opened',
2578					$accordion_active_toggle,
2579					module_offset;
2580
2581				if ( is_accordion ) {
2582					if ( $module.hasClass('et_pb_toggle_open') || is_accordion_toggling ) {
2583						return false;
2584					}
2585
2586					$accordion.addClass( 'et_pb_accordion_toggling' );
2587					$accordion_active_toggle = $module.siblings('.et_pb_toggle_open');
2588				}
2589
2590				if ( $content.is( ':animated' ) ) {
2591					return;
2592				}
2593
2594				$content.slideToggle( 700, function() {
2595					if ( 'closed' === initial_toggle_state ) {
2596						$module.removeClass('et_pb_toggle_close').addClass('et_pb_toggle_open');
2597					} else {
2598						$module.removeClass('et_pb_toggle_open').addClass('et_pb_toggle_close');
2599					}
2600
2601					if ( $section.hasClass( 'et_pb_section_parallax' ) && !$section.children().hasClass( 'et_pb_parallax_css') ) {
2602						$.proxy( et_parallax_set_height, $section )();
2603					}
2604				} );
2605
2606				if ( is_accordion ) {
2607					$accordion_active_toggle.find('.et_pb_toggle_content').slideToggle( 700, function() {
2608						$accordion_active_toggle.removeClass( 'et_pb_toggle_open' ).addClass('et_pb_toggle_close');
2609						$accordion.removeClass( 'et_pb_accordion_toggling' );
2610
2611						module_offset = $module.offset();
2612
2613						// Calculate height of fixed nav
2614						if ( $('#wpadminbar').length ) {
2615							fixed_header_height += $('#wpadminbar').height();
2616						}
2617
2618						if ( $('#top-header').length ) {
2619							fixed_header_height += $('#top-header').height();
2620						}
2621
2622						if ( $('#main-header').length && ! et_is_vertical_nav ) {
2623							fixed_header_height += $('#main-header').height();
2624						}
2625
2626						// Compare accordion offset against window's offset and adjust accordingly
2627						if ( ( window_offset_top + fixed_header_height ) > module_offset.top ) {
2628							$('html, body').animate({ scrollTop : ( module_offset.top - fixed_header_height - 50 ) });
2629						}
2630					} );
2631				}
2632			} );
2633
2634			var $et_contact_container = $( '.et_pb_contact_form_container' );
2635
2636			if ( $et_contact_container.length ) {
2637				$et_contact_container.each( function() {
2638					var $this_contact_container = $( this ),
2639						$et_contact_form = $this_contact_container.find( 'form' ),
2640						$et_contact_submit = $this_contact_container.find( 'input.et_pb_contact_submit' ),
2641						$et_inputs = $et_contact_form.find( 'input[type=text],textarea' ),
2642						et_email_reg = /^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$/,
2643						redirect_url = typeof $this_contact_container.data( 'redirect_url' ) !== 'undefined' ? $this_contact_container.data( 'redirect_url' ) : '';
2644
2645					$et_inputs.live( 'focus', function() {
2646						if ( $( this ).val() === $( this ).siblings('label').text() ) {
2647							$( this ).val('');
2648						}
2649					}).live( 'blur', function() {
2650						if ( '' === $( this ).val() ) {
2651							$( this ).val( $( this ).siblings( 'label' ).text() );
2652						}
2653					});
2654
2655					$et_contact_form.on( 'submit', function( event ) {
2656						var $this_contact_form = $( this ),
2657							$this_inputs = $this_contact_form.find( 'input[type=text],textarea' ),
2658							this_et_contact_error = false,
2659							$et_contact_message = $this_contact_form.closest( '.et_pb_contact_form_container' ).find( '.et-pb-contact-message' ),
2660							et_message = '',
2661							et_fields_message = '',
2662							$this_contact_container = $this_contact_form.closest( '.et_pb_contact_form_container' ),
2663							$captcha_field = $this_contact_form.find( '.et_pb_contact_captcha' ),
2664							form_unique_id = typeof $this_contact_container.data( 'form_unique_num' ) !== 'undefined' ? $this_contact_container.data( 'form_unique_num' ) : 0,
2665							inputs_list = [];
2666						et_message = '<ul>';
2667
2668						$this_inputs.removeClass( 'et_contact_error' );
2669
2670						$this_inputs.each( function(){
2671							var $this_el = $( this ),
2672								this_val = $this_el.val(),
2673								this_label = $this_el.siblings( 'label' ).text(),
2674								field_type = typeof $this_el.data( 'field_type' ) !== 'undefined' ? $this_el.data( 'field_type' ) : 'text',
2675								required_mark = typeof $this_el.data( 'required_mark' ) !== 'undefined' ? $this_el.data( 'required_mark' ) : 'not_required',
2676								original_id = typeof $this_el.data( 'original_id' ) !== 'undefined' ? $this_el.data( 'original_id' ) : '',
2677								default_value;
2678
2679							// add current field data into array of inputs
2680							if ( typeof $this_el.attr( 'id' ) !== 'undefined' ) {
2681								inputs_list.push( { 'field_id' : $this_el.attr( 'id' ), 'original_id' : original_id, 'required_mark' : required_mark, 'field_type' : field_type, 'field_label' : this_label } );
2682							}
2683
2684							// add error message for the field if it is required and empty
2685							if ( 'required' === required_mark && ( '' === this_val || this_label === this_val ) ) {
2686								$this_el.addClass( 'et_contact_error' );
2687								this_et_contact_error = true;
2688
2689								default_value = this_label;
2690
2691								if ( '' === default_value ) {
2692									default_value = et_pb_custom.captcha;
2693								}
2694
2695								et_fields_message += '<li>' + default_value + '</li>';
2696							}
2697
2698							// add error message if email field is not empty and fails the email validation
2699							if ( 'email' === field_type && '' !== this_val && this_label !== this_val && ! et_email_reg.test( this_val ) ) {
2700								$this_el.addClass( 'et_contact_error' );
2701								this_et_contact_error = true;
2702
2703								if ( ! et_email_reg.test( this_val ) ) {
2704									et_message += '<li>' + et_pb_custom.invalid + '</li>';
2705								}
2706							}
2707						});
2708
2709						// check the captcha value if required for current form
2710						if ( $captcha_field.length && '' !== $captcha_field.val() ) {
2711							var first_digit = parseInt( $captcha_field.data( 'first_digit' ) ),
2712								second_digit = parseInt( $captcha_field.data( 'second_digit' ) );
2713
2714							if ( parseInt( $captcha_field.val() ) !== first_digit + second_digit ) {
2715
2716								et_message += '<li>' + et_pb_custom.wrong_captcha + '</li>';
2717								this_et_contact_error = true;
2718
2719								// generate new digits for captcha
2720								first_digit = Math.floor( ( Math.random() * 15 ) + 1 );
2721								second_digit = Math.floor( ( Math.random() * 15 ) + 1 );
2722
2723								// set new digits for captcha
2724								$captcha_field.data( 'first_digit', first_digit );
2725								$captcha_field.data( 'second_digit', second_digit );
2726
2727								// regenerate captcha on page
2728								$this_contact_form.find( '.et_pb_contact_captcha_question' ).empty().append( first_digit  + ' + ' + second_digit );
2729							}
2730
2731						}
2732
2733						if ( ! this_et_contact_error ) {
2734							var $href = $( this ).attr( 'action' ),
2735								form_data = $( this ).serializeArray();
2736
2737							form_data.push( { 'name': 'et_pb_contact_email_fields_' + form_unique_id, 'value' : JSON.stringify( inputs_list ) } );
2738
2739							$this_contact_container.fadeTo( 'fast', 0.2 ).load( $href + ' #' + $this_contact_form.closest( '.et_pb_contact_form_container' ).attr( 'id' ), form_data, function( responseText ) {
2740								if ( ! $( responseText ).find( '.et_pb_contact_error_text').length ) {
2741
2742									et_pb_maybe_log_event( $this_contact_container, 'con_goal' );
2743
2744									// redirect if redirect URL is not empty and no errors in contact form
2745									if ( '' !== redirect_url ) {
2746										window.location.href = redirect_url;
2747									}
2748								}
2749
2750								$this_contact_container.fadeTo( 'fast', 1 );
2751							} );
2752						}
2753
2754						et_message += '</ul>';
2755
2756						if ( '' !== et_fields_message ) {
2757							if ( et_message != '<ul></ul>' ) {
2758								et_message = '<p class="et_normal_padding">' + et_pb_custom.contact_error_message + '</p>' + et_message;
2759							}
2760
2761							et_fields_message = '<ul>' + et_fields_message + '</ul>';
2762
2763							et_fields_message = '<p>' + et_pb_custom.fill_message + '</p>' + et_fields_message;
2764
2765							et_message = et_fields_message + et_message;
2766						}
2767
2768						if ( et_message != '<ul></ul>' ) {
2769							$et_contact_message.html( et_message );
2770
2771							// If parent of this contact form uses parallax
2772							if ( $this_contact_container.parents('.et_pb_section_parallax').length ) {
2773								$this_contact_container.parents('.et_pb_section_parallax').each(function() {
2774									var $parallax_element = $(this),
2775										$parallax         = $parallax_element.children('.et_parallax_bg'),
2776										is_true_parallax  = ( ! $parallax.hasClass( 'et_pb_parallax_css' ) );
2777
2778									if ( is_true_parallax ) {
2779										$et_window.trigger( 'resize' );
2780									}
2781								});
2782							}
2783						}
2784
2785						event.preventDefault();
2786					});
2787				});
2788			}
2789
2790			window.et_pb_play_overlayed_video = function( $play_video ) {
2791				var $this        = $play_video,
2792					$video_image = $this.closest( '.et_pb_video_overlay' );
2793
2794				$video_image.fadeTo( 500, 0, function() {
2795					var $image = $(this);
2796
2797					$image.css( 'display', 'none' );
2798				} );
2799			}
2800
2801			$( '.et_pb_video .et_pb_video_overlay, .et_pb_video_wrap .et_pb_video_overlay' ).click( function() {
2802				var $this = $(this);
2803
2804				et_pb_play_overlayed_video( $this );
2805
2806				return false;
2807			} );
2808
2809			window.et_pb_resize_section_video_bg = function( $video ) {
2810				$element = typeof $video !== 'undefined' ? $video.closest( '.et_pb_section_video_bg' ) : $( '.et_pb_section_video_bg' );
2811
2812				$element.each( function() {
2813					var $this_el = $(this),
2814						ratio = ( typeof $this_el.attr( 'data-ratio' ) !== 'undefined' ) && ! is_frontend_builder
2815							? $this_el.attr( 'data-ratio' )
2816							: $this_el.find('video').attr( 'width' ) / $this_el.find('video').attr( 'height' ),
2817						$video_elements = $this_el.find( '.mejs-video, video, object' ).css( 'margin', 0 ),
2818						$container = $this_el.closest( '.et_pb_section_video' ).length
2819							? $this_el.closest( '.et_pb_section_video' )
2820							: $this_el.closest( '.et_pb_slides' ),
2821						body_width = $container.innerWidth(),
2822						container_height = $container.innerHeight(),
2823						width, height;
2824					if ( typeof $this_el.attr( 'data-ratio' ) == 'undefined' && !isNaN(ratio) ) {
2825						$this_el.attr( 'data-ratio', ratio );
2826					}
2827
2828					if ( body_width / container_height < ratio ) {
2829						width = container_height * ratio;
2830						height = container_height;
2831					} else {
2832						width = body_width;
2833						height = body_width / ratio;
2834					}
2835
2836					$video_elements.width( width ).height( height );
2837
2838					// need to re-set the values to make it work correctly in Frontend builder
2839					if ( is_frontend_builder ) {
2840						setTimeout( function() {
2841							$video_elements.width( width ).height( height );
2842						}, 0 );
2843					}
2844				} );
2845			}
2846
2847			window.et_pb_center_video = function( $video ) {
2848				$element = typeof $video !== 'undefined' ? $video : $( '.et_pb_section_video_bg .mejs-video' );
2849
2850					$element.each( function() {
2851						var $this_el = $(this);
2852						var $video_width = $this_el.width() / 2;
2853						var $video_width_negative = 0 - $video_width;
2854						$this_el.css("margin-left",$video_width_negative );
2855
2856						// need to re-calculate the values in Frontend builder
2857						if ( is_frontend_builder ) {
2858							setTimeout( function() {
2859								var $video_width = $this_el.width() / 2;
2860								var $video_width_negative = 0 - $video_width;
2861								$this_el.css("margin-left",$video_width_negative );
2862							}, 0 );
2863						}
2864
2865						if ( typeof $video !== 'undefined' ) {
2866							if ( $video.closest( '.et_pb_slider' ).length && ! $video.closest( '.et_pb_first_video' ).length ) {
2867								return false;
2868							}
2869						}
2870					} );
2871			}
2872
2873			window.et_fix_slider_height = function( $slider ) {
2874				var $this_slider = typeof $slider !== 'undefined' ? $slider : $et_pb_slider;
2875				if ( ! $this_slider.length ) return;
2876
2877				$this_slider.each( function() {
2878					var $slide_section = $(this).parent( '.et_pb_section' ),
2879						$slide = $(this).find( '.et_pb_slide' ),
2880						$slide_container = $slide.find( '.et_pb_container' ),
2881						max_height = 0;
2882
2883					// If this is appears at the first section benath transparent nav, skip it
2884					// leave it to et_fix_page_container_position()
2885					if ( $slide_section.is( '.et_pb_section_first' ) ){
2886						return true;
2887					}
2888
2889					$slide_container.css( 'min-height', 0 );
2890
2891					$slide.each( function() {
2892						var $this_el = $(this),
2893							height = $this_el.innerHeight();
2894
2895						if ( max_height < height )
2896							max_height = height;
2897					} );
2898
2899					$slide_container.css( 'min-height', max_height );
2900				} );
2901			}
2902
2903			/**
2904			 * Add conditional class to prevent unwanted dropdown nav
2905			 */
2906			function et_fix_nav_direction() {
2907				window_width = $(window).width();
2908				$('.nav li.et-reverse-direction-nav').removeClass( 'et-reverse-direction-nav' );
2909				$('.nav li li ul').each(function(){
2910					var $dropdown       = $(this),
2911						dropdown_width  = $dropdown.width(),
2912						dropdown_offset = $dropdown.offset(),
2913						$parents        = $dropdown.parents('.nav > li');
2914
2915					if ( dropdown_offset.left > ( window_width - dropdown_width ) ) {
2916						$parents.addClass( 'et-reverse-direction-nav' );
2917					}
2918				});
2919			}
2920			et_fix_nav_direction();
2921
2922			et_pb_form_placeholders_init( $( '.et_pb_newsletter_form' ) );
2923
2924			$('.et_pb_fullwidth_menu ul.nav').each(function(i) {
2925				i++;
2926				et_duplicate_menu( $(this), $(this).parents('.et_pb_row').find('div .mobile_nav'), 'mobile_menu' + i, 'et_mobile_menu' );
2927			});
2928
2929			$('.et_pb_fullwidth_menu').each(function() {
2930				var this_menu = $( this ),
2931					bg_color = this_menu.data( 'bg_color' );
2932				if ( bg_color ) {
2933					this_menu.find( 'ul' ).css( { 'background-color' : bg_color } );
2934				}
2935			});
2936
2937			$et_pb_newsletter_button.click( function( event ) {
2938				et_pb_submit_newsletter( $(this) );
2939			} );
2940
2941			window.et_pb_submit_newsletter = function( $submit ) {
2942				if ( $submit.closest( '.et_pb_login_form' ).length || $submit.closest( '.et_pb_feedburner_form' ).length ) {
2943					et_pb_maybe_log_event( $submit.closest( '.et_pb_newsletter' ), 'con_goal' );
2944					return;
2945				}
2946
2947				event.preventDefault();
2948
2949				var $newsletter_container = $submit.closest( '.et_pb_newsletter' ),
2950					$firstname = $newsletter_container.find( 'input[name="et_pb_signup_firstname"]' ),
2951					$lastname = $newsletter_container.find( 'input[name="et_pb_signup_lastname"]' ),
2952					$email = $newsletter_container.find( 'input[name="et_pb_signup_email"]' ),
2953					list_id = $newsletter_container.find( 'input[name="et_pb_signup_list_id"]' ).val(),
2954					$result = $newsletter_container.find( '.et_pb_newsletter_result' ).hide(),
2955					service = $submit.closest( '.et_pb_newsletter_form' ).data( 'service' ) || 'mailchimp';
2956
2957				$firstname.removeClass( 'et_pb_signup_error' );
2958				$lastname.removeClass( 'et_pb_signup_error' );
2959				$email.removeClass( 'et_pb_signup_error' );
2960
2961				et_pb_remove_placeholder_text( $submit.closest( '.et_pb_newsletter_form' ) );
2962
2963				if ( $firstname.val() == '' || $email.val() == '' || list_id === '' ) {
2964					if ( $firstname.val() == '' ) $firstname.addClass( 'et_pb_signup_error' );
2965
2966					if ( $email.val() == '' ) $email.addClass( 'et_pb_signup_error' );
2967
2968					if ( $firstname.val() == '' )
2969						$firstname.val( $firstname.siblings( '.et_pb_contact_form_label' ).text() );
2970
2971					if ( $lastname.val() == '' )
2972						$lastname.val( $lastname.siblings( '.et_pb_contact_form_label' ).text() );
2973
2974					if ( $email.val() == '' )
2975						$email.val( $email.siblings( '.et_pb_contact_form_label' ).text() );
2976
2977					return;
2978				}
2979
2980				$.ajax( {
2981					type: "POST",
2982					url: et_pb_custom.ajaxurl,
2983					dataType: "json",
2984					data:
2985					{
2986						action : 'et_pb_submit_subscribe_form',
2987						et_frontend_nonce : et_pb_custom.et_frontend_nonce,
2988						et_list_id : list_id,
2989						et_firstname : $firstname.val(),
2990						et_lastname : $lastname.val(),
2991						et_email : $email.val(),
2992						et_service : service
2993					},
2994					beforeSend: function() {
2995						$newsletter_container
2996							.find( '.et_pb_newsletter_button' )
2997							.addClass( 'et_pb_button_text_loading' )
2998							.find('.et_subscribe_loader')
2999							.show();
3000					},
3001					complete: function(){
3002						$newsletter_container
3003							.find( '.et_pb_newsletter_button' )
3004							.removeClass( 'et_pb_button_text_loading' )
3005							.find('.et_subscribe_loader')
3006							.hide();
3007					},
3008					success: function( data ){
3009						if ( data ) {
3010							if ( data.error ) {
3011								$result.html( data.error ).show();
3012							}
3013							if ( data.success ) {
3014								$newsletter_container.find( '.et_pb_newsletter_form > p' ).hide();
3015								$result.html( data.success ).show();
3016
3017								et_pb_maybe_log_event( $newsletter_container, 'con_goal' );
3018							}
3019						} else {
3020							$result.html( et_pb_custom.subscription_failed ).show();
3021						}
3022					}
3023				} );
3024			}
3025
3026			window.et_fix_testimonial_inner_width = function() {
3027				var window_width = $( window ).width();
3028
3029				if( window_width > 767 ){
3030					$( '.et_pb_testimonial' ).each( function() {
3031						if ( ! $(this).is(':visible') ) {
3032							return;
3033						}
3034
3035						var $testimonial      = $(this),
3036							testimonial_width = $testimonial.width(),
3037							$portrait         = $testimonial.find( '.et_pb_testimonial_portrait' ),
3038							portrait_width    = $portrait.width(),
3039							$testimonial_inner= $testimonial.find( '.et_pb_testimonial_description_inner' ),
3040							$outer_column     = $testimonial.closest( '.et_pb_column' ),
3041							testimonial_inner_width = testimonial_width,
3042							subtract = ! ( $outer_column.hasClass( 'et_pb_column_1_3' ) || $outer_column.hasClass( 'et_pb_column_1_4' ) || $outer_column.hasClass( 'et_pb_column_3_8' ) ) ? portrait_width + 31 : 0;
3043
3044							$testimonial_inner.width( testimonial_inner_width - subtract );
3045					} );
3046				} else {
3047					$( '.et_pb_testimonial_description_inner' ).removeAttr( 'style' );
3048				}
3049			}
3050			window.et_fix_testimonial_inner_width();
3051
3052			window.et_pb_video_background_init = function( $this_video_background, this_video_background ) {
3053				var $video_background_wrapper = $this_video_background.closest( '.et_pb_section_video_bg' ),
3054					this_video_player = this_video_background.player;
3055
3056				// Entering video's top viewport
3057				$video_background_wrapper.waypoint({
3058					offset: '100%',
3059					handler : function( direction ) {
3060						if ( $this_video_background.is(':visible') && direction === 'down' ) {
3061							this_video_player.play();
3062						} else if ( $this_video_background.is(':visible') && direction === 'up' ) {
3063							this_video_player.pause();
3064						}
3065					}
3066				});
3067
3068				// Entering video's bottom viewport
3069				$video_background_wrapper.waypoint({
3070					offset: '-50%',
3071					handler : function( direction ) {
3072						if ( $this_video_background.is(':visible') && direction === 'up' ) {
3073							this_video_player.play();
3074						} else if ( $this_video_background.is(':visible') && direction === 'down' ) {
3075							this_video_player.pause();
3076						}
3077					}
3078				});
3079			}
3080
3081			window.et_reinint_waypoint_modules = function() {
3082				if ( $.fn.waypoint ) {
3083					var $et_pb_circle_counter = $( '.et_pb_circle_counter' ),
3084						$et_pb_number_counter = $( '.et_pb_number_counter' ),
3085						$et_pb_video_background = $( '.et_pb_section_video_bg video' );
3086
3087					$( '.et_pb_counter_container, .et-waypoint' ).waypoint( {
3088						offset: '75%',
3089						handler: function() {
3090							$(this.element).addClass( 'et-animated' );
3091						}
3092					} );
3093
3094					// fallback to 'bottom-in-view' offset, to make sure element become visible when it's on the bottom of page and other offsets are not triggered
3095					$( '.et_pb_counter_container, .et-waypoint' ).waypoint( {
3096						offset: 'bottom-in-view',
3097						handler: function() {
3098							$(this.element).addClass( 'et-animated' );
3099						}
3100					} );
3101
3102					if ( $et_pb_circle_counter.length ) {
3103						$et_pb_circle_counter.each(function(){
3104							var $this_counter = $(this);
3105							if ( ! $this_counter.is( ':visible' ) ) {
3106								return;
3107							}
3108							$this_counter.waypoint({
3109								offset: '65%',
3110								handler: function() {
3111									if ( $this_counter.data( 'PieChartHasLoaded' ) ) {
3112										return;
3113									}
3114
3115									$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
3116
3117									$this_counter.data( 'PieChartHasLoaded', true );
3118								}
3119							});
3120
3121							// fallback to 'bottom-in-view' offset, to make sure animation applied when element is on the bottom of page and other offsets are not triggered
3122							$this_counter.waypoint({
3123								offset: 'bottom-in-view',
3124								handler: function() {
3125									if ( $this_counter.data( 'PieChartHasLoaded' ) ) {
3126										return;
3127									}
3128
3129									$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
3130
3131									$this_counter.data( 'PieChartHasLoaded', true );
3132								}
3133							});
3134						});
3135					}
3136
3137					if ( $et_pb_number_counter.length ) {
3138						$et_pb_number_counter.each(function(){
3139							var $this_counter = $(this);
3140							$this_counter.waypoint({
3141								offset: '75%',
3142								handler: function() {
3143									$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
3144								}
3145							});
3146
3147							// fallback to 'bottom-in-view' offset, to make sure animation applied when element is on the bottom of page and other offsets are not triggered
3148							$this_counter.waypoint({
3149								offset: 'bottom-in-view',
3150								handler: function() {
3151									$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
3152								}
3153							});
3154						});
3155					}
3156
3157					if ( $( '.et_pb_ab_goal' ).length ) {
3158						var $et_pb_ab_goal = $( '.et_pb_ab_goal' );
3159
3160						$et_pb_ab_goal.waypoint({
3161							offset: '80%',
3162							handler: function() {
3163								if ( et_pb_ab_logged_status['read_goal'] || ! $et_pb_ab_goal.visible( true ) ) {
3164									return;
3165								}
3166
3167								// log the goal_read if goal is still visible after 3 seconds.
3168								setTimeout( function() {
3169									if ( $et_pb_ab_goal.visible( true ) && ! et_pb_ab_logged_status['read_goal'] ) {
3170										et_pb_ab_update_stats( 'read_goal' );
3171									}
3172								}, 3000 );
3173
3174								et_pb_maybe_log_event( $et_pb_ab_goal, 'view_goal' );
3175							}
3176						});
3177					}
3178
3179					if ( $et_pb_video_background.length ) {
3180						$et_pb_video_background.each( function(){
3181							var $this_video_background = $(this);
3182
3183							et_pb_video_background_init( $this_video_background, this );
3184						});
3185					}
3186				}
3187			}
3188
3189			function et_pb_init_ab_test() {
3190				var $et_pb_ab_goal = $( '.et_pb_ab_goal' ),
3191					et_ab_subject_id = et_pb_get_subject_id();
3192
3193				$.each( et_pb_ab_logged_status, function( key, value ) {
3194					var cookie_subject = 'click_goal' === key || 'con_short' === key ? '' : et_ab_subject_id;
3195
3196					et_pb_ab_logged_status[key] = et_pb_check_cookie_value( 'et_pb_ab_' + key + '_' + et_pb_custom.page_id + et_pb_custom.unique_test_id + cookie_subject, 'true' );
3197
3198				});
3199
3200				// log the page read event if user stays on page long enough and if not logged for current subject
3201				if ( ! et_pb_ab_logged_status['read_page'] ) {
3202					setTimeout( function() {
3203						et_pb_ab_update_stats( 'read_page' );
3204					}, et_pb_ab_bounce_rate );
3205				}
3206
3207				// add the cookies for shortcode tracking, if enabled
3208				if ( 'on' === et_pb_custom.is_shortcode_tracking && ! et_pb_ab_logged_status['con_short'] ) {
3209					et_pb_set_cookie( 365, 'et_pb_ab_shortcode_track_' + et_pb_custom.page_id + '=' + et_pb_custom.page_id + '_' + et_pb_get_subject_id() + '_' + et_pb_custom.unique_test_id );
3210				}
3211
3212				if ( $et_pb_ab_goal.length ) {
3213					// if goal is a module and has a button then track the conversions, otherwise track clicks
3214					if ( $et_pb_ab_goal.hasClass( 'et_pb_module' ) && ( $et_pb_ab_goal.hasClass( 'et_pb_button' ) || $et_pb_ab_goal.find( '.et_pb_button' ).length ) ) {
3215						// Log con_goal if current goal doesn't require any specific conversion calculation
3216						if ( ! $et_pb_ab_goal.hasClass( 'et_pb_contact_form_container' ) && ! $et_pb_ab_goal.hasClass( 'et_pb_newsletter' ) ) {
3217							var $goal_button = $et_pb_ab_goal.hasClass( 'et_pb_button' ) ? $et_pb_ab_goal : $et_pb_ab_goal.find( '.et_pb_button' );
3218
3219							if ( $et_pb_ab_goal.hasClass( 'et_pb_comments_module' ) ) {
3220								var page_url = window.location.href,
3221									comment_submitted = -1 !== page_url.indexOf( '#comment-' ) ? true : false,
3222									log_conversion = et_pb_check_cookie_value( 'et_pb_ab_comment_log_' + et_pb_custom.page_id + et_pb_custom.unique_test_id, 'true' );
3223
3224								if ( comment_submitted && log_conversion ) {
3225									et_pb_ab_update_stats( 'con_goal' );
3226									et_pb_set_cookie( 0, 'et_pb_ab_comment_log_' + et_pb_custom.page_id + et_pb_custom.unique_test_id + '=true' );
3227								}
3228							}
3229
3230							$goal_button.click( function(){
3231								if ( $et_pb_ab_goal.hasClass( 'et_pb_comments_module' ) && ! et_pb_ab_logged_status['con_goal'] ) {
3232									et_pb_set_cookie( 365, 'et_pb_ab_comment_log_' + et_pb_custom.page_id + et_pb_custom.unique_test_id + '=true' );
3233									return;
3234								}
3235
3236								et_pb_maybe_log_event( $et_pb_ab_goal, 'click_goal' );
3237							});
3238						}
3239					} else {
3240						$et_pb_ab_goal.click( function() {
3241							if ( $et_pb_ab_goal.hasClass( 'et_pb_shop' ) && ! et_pb_ab_logged_status['con_goal'] ) {
3242								et_pb_set_cookie( 365, 'et_pb_ab_shop_log=' + et_pb_custom.page_id + '_' + et_pb_get_subject_id() + '_' + et_pb_custom.unique_test_id );
3243							}
3244
3245							et_pb_maybe_log_event( $et_pb_ab_goal, 'click_goal' );
3246						});
3247					}
3248				}
3249			}
3250
3251			function et_pb_maybe_log_event( $goal_container, event ) {
3252				var log_event = typeof event === 'undefined' ? 'con_goal' : event;
3253
3254				if ( ! $goal_container.hasClass( 'et_pb_ab_goal' ) || et_pb_ab_logged_status[ log_event ] ) {
3255					return;
3256				}
3257
3258				// log the event if it's not logged for current user
3259				et_pb_ab_update_stats( log_event );
3260			}
3261
3262			function et_pb_ab_update_stats( record_type, set_page_id, set_subject_id, set_test_id ) {
3263				var subject_id = typeof set_subject_id === 'undefined' ? et_pb_get_subject_id() : set_subject_id,
3264					page_id = typeof set_page_id === 'undefined' ? et_pb_custom.page_id : set_page_id,
3265					test_id = typeof set_test_id === 'undefined' ? et_pb_custom.unique_test_id : set_test_id,
3266					stats_data = JSON.stringify({ 'test_id' : page_id, 'subject_id' : subject_id, 'record_type' : record_type }),
3267					cookie_subject = 'click_goal' === record_type || 'con_short' === record_type ? '' : subject_id;
3268
3269				et_pb_set_cookie( 365, 'et_pb_ab_' + record_type + '_' + page_id + test_id + cookie_subject + '=true' );
3270
3271				et_pb_ab_logged_status[record_type] = true;
3272
3273				$.ajax({
3274					type: 'POST',
3275					url: et_pb_custom.ajaxurl,
3276					data: {
3277						action : 'et_pb_update_stats_table',
3278						stats_data_array : stats_data,
3279						et_ab_log_nonce : et_pb_custom.et_ab_log_nonce
3280					}
3281				});
3282			}
3283
3284			function et_pb_get_subject_id() {
3285				var subject_id_raw = $( '.et_pb_ab_subject' ).attr( 'class' ).split( 'et_pb_ab_subject_id-' )[1],
3286					subject_id_clean = subject_id_raw.split( ' ' )[0],
3287					subject_id_separated = subject_id_clean.split( '_' ),
3288					subject_id = subject_id_separated[1];
3289
3290				return subject_id;
3291			}
3292
3293			function et_pb_set_cookie_expire( days ) {
3294				var ms = days*24*60*60*1000;
3295
3296				var date = new Date();
3297				date.setTime( date.getTime() + ms );
3298
3299				return "; expires=" + date.toUTCString();
3300			}
3301
3302			function et_pb_check_cookie_value( cookie_name, value ) {
3303				return et_pb_get_cookie_value( cookie_name ) == value;
3304			}
3305
3306			function et_pb_get_cookie_value( cookie_name ) {
3307				return et_pb_parse_cookies()[cookie_name];
3308			}
3309
3310			function et_pb_parse_cookies() {
3311				var cookies = document.cookie.split( '; ' );
3312
3313				var ret = {};
3314				for ( var i = cookies.length - 1; i >= 0; i-- ) {
3315				  var el = cookies[i].split( '=' );
3316				  ret[el[0]] = el[1];
3317				}
3318				return ret;
3319			}
3320
3321			function et_pb_set_cookie( expire, cookie_content ) {
3322				cookie_expire = et_pb_set_cookie_expire( expire );
3323				document.cookie = cookie_content + cookie_expire + "; path=/";
3324			}
3325
3326			window.et_calc_fullscreen_section = function() {
3327				var $et_window = $(window),
3328					$body = $( 'body' ),
3329					$wpadminbar = $( '#wpadminbar' ),
3330					et_is_vertical_nav = $body.hasClass( 'et_vertical_nav' ),
3331					$this_section = $(this),
3332					this_section_index = $this_section.index('.et_pb_fullwidth_header'),
3333					$header = $this_section.children('.et_pb_fullwidth_header_container'),
3334					$header_content = $header.children('.header-content-container'),
3335					$header_image = $header.children('.header-image-container'),
3336					sectionHeight = $et_window.height(),
3337					$wpadminbar = $('#wpadminbar'),
3338					$top_header = $('#top-header'),
3339					$main_header = $('#main-header'),
3340					et_header_height,
3341					secondary_nav_height;
3342
3343					secondary_nav_height = $top_header.length && $top_header.is( ':visible' ) ? $top_header.innerHeight() : 0;
3344					et_header_height = $main_header.length ? $main_header.innerHeight() + secondary_nav_height : 0;
3345
3346				var calc_header_offset = ( $wpadminbar.length ) ? et_header_height + $wpadminbar.innerHeight() - 1 : et_header_height - 1;
3347
3348				// Section height adjustment differs in vertical and horizontal nav
3349				if ( $body.hasClass('et_vertical_nav') ) {
3350					if ( $et_window.width() >= 980 && $top_header.length ) {
3351						sectionHeight -= $top_header.height();
3352					}
3353
3354					if ( $wpadminbar.length ) {
3355						sectionHeight -= $wpadminbar.height();
3356					}
3357				} else {
3358					if ( $body.hasClass('et_hide_nav' ) ) {
3359						// If user is logged in and hide navigation is in use, adjust the section height
3360						if ( $wpadminbar.length ) {
3361							sectionHeight -= $wpadminbar.height();
3362						}
3363
3364						// In mobile, header always appears. Adjust the section height
3365						if ( $et_window.width() < 981 && ! $body.hasClass('et_transparent_nav') ) {
3366							sectionHeight -= $('#main-header').height();
3367						}
3368					} else {
3369						if ( $this_section.offset().top <= calc_header_offset + 3 ) {
3370							if ( et_is_vertical_nav ) {
3371								var $top_header = $('#top-header'),
3372									top_header_height = ( $top_header.length && 0 === $this_section.index( '.et_pb_fullscreen' ) ) ? $top_header.height() : 0,
3373									wpadminbar_height = ( $wpadminbar.length && 0 === $this_section.index( '.et_pb_fullscreen' ) ) ? $wpadminbar.height() : 0,
3374									calc_header_offset_vertical = wpadminbar_height + top_header_height;
3375
3376								sectionHeight -= calc_header_offset_vertical;
3377							} else {
3378								sectionHeight -= calc_header_offset;
3379							}
3380						}
3381					}
3382				}
3383
3384				// If the transparent primary nav + hide nav until scroll is being used,
3385				// cancel automatic padding-top added by transparent nav mechanism
3386				if ( $body.hasClass('et_transparent_nav') && $body.hasClass( 'et_hide_nav' ) &&  0 === this_section_index ) {
3387					$this_section.css( 'padding-top', '' );
3388				}
3389
3390				$this_section.css('min-height', sectionHeight + 'px' );
3391				$header.css('min-height', sectionHeight + 'px' );
3392
3393				if ( $header.hasClass('center') && $header_content.hasClass('bottom') && $header_image.hasClass('bottom') ) {
3394					$header.addClass('bottom-bottom');
3395				}
3396
3397				if ( $header.hasClass('center') && $header_content.hasClass('center') && $header_image.hasClass('center') ) {
3398					$header.addClass('center-center');
3399				}
3400
3401				if ( $header.hasClass('center') && $header_content.hasClass('center') && $header_image.hasClass('bottom') ) {
3402					$header.addClass('center-bottom');
3403
3404					var contentHeight = sectionHeight - $header_image.outerHeight( true );
3405
3406					if ( contentHeight > 0 ) {
3407						$header_content.css('min-height', contentHeight + 'px' );
3408					}
3409				}
3410
3411				if ( $header.hasClass('center') && $header_content.hasClass('bottom') && $header_image.hasClass('center') ) {
3412					$header.addClass('bottom-center');
3413				}
3414
3415				if ( ( $header.hasClass('left') || $header.hasClass('right') ) && !$header_content.length && $header_image.length ) {
3416					$header.css('justify-content', 'flex-end');
3417				}
3418
3419				if ( $header.hasClass('center') && $header_content.hasClass('bottom') && !$header_image.length ) {
3420					$header_content.find('.header-content').css( 'margin-bottom', 80 + 'px' );
3421				}
3422
3423				if ( $header_content.hasClass('bottom') && $header_image.hasClass('center') ) {
3424					$header_image.find('.header-image').css( 'margin-bottom', 80 + 'px' );
3425					$header_image.css('align-self', 'flex-end');
3426				}
3427			}
3428
3429			window.et_pb_parallax_init = function( $this_parallax ) {
3430				if ( $this_parallax.hasClass('et_pb_parallax_css') ) {
3431					return;
3432				}
3433
3434				var $this_parent = $this_parallax.parent();
3435
3436				$.proxy( et_parallax_set_height, $this_parent )();
3437
3438				$.proxy( et_apply_parallax, $this_parent )();
3439
3440				$et_window.on( 'scroll', $.proxy( et_apply_parallax, $this_parent ) );
3441
3442				$et_window.on( 'resize', $.proxy( et_parallax_set_height, $this_parent ) );
3443
3444				$et_window.on( 'resize', $.proxy( et_apply_parallax, $this_parent ) );
3445
3446				$this_parent.find('.et-learn-more .heading-more').click( function() {
3447					setTimeout(function(){
3448						$.proxy( et_parallax_set_height, $this_parent )();
3449					}, 300 );
3450				});
3451			}
3452
3453			$( window ).resize( function(){
3454				var window_width                = $et_window.width(),
3455					et_container_css_width      = $et_container.css( 'width' ),
3456					et_container_width_in_pixel = ( typeof et_container_css_width !== 'undefined' ) ? et_container_css_width.substr( -1, 1 ) !== '%' : '',
3457					et_container_actual_width   = ( et_container_width_in_pixel ) ? $et_container.width() : ( ( $et_container.width() / 100 ) * window_width ), // $et_container.width() doesn't recognize pixel or percentage unit. It's our duty to understand what it returns and convert it properly
3458					containerWidthChanged       = et_container_width !== et_container_actual_width;
3459
3460				et_pb_resize_section_video_bg();
3461				et_pb_center_video();
3462				et_fix_slider_height();
3463				et_fix_nav_direction();
3464
3465				$et_pb_fullwidth_portfolio.each(function(){
3466					set_container_height = $(this).hasClass('et_pb_fullwidth_portfolio_carousel') ? true : false;
3467					set_fullwidth_portfolio_columns( $(this), set_container_height );
3468				});
3469
3470				if ( containerWidthChanged ) {
3471					$('.container-width-change-notify').trigger('containerWidthChanged');
3472
3473					setTimeout( function() {
3474						$et_pb_filterable_portfolio.each(function(){
3475							set_filterable_grid_items( $(this) );
3476						});
3477						$et_pb_gallery.each(function(){
3478							if ( $(this).hasClass( 'et_pb_gallery_grid' ) ) {
3479								set_gallery_grid_items( $(this) );
3480							}
3481						});
3482					}, 100 );
3483
3484					et_container_width = et_container_actual_width;
3485
3486					etRecalculateOffset = true;
3487
3488					if ( $et_pb_circle_counter.length ) {
3489						$et_pb_circle_counter.each(function(){
3490							var $this_counter = $(this);
3491							if ( ! $this_counter.is( ':visible' ) ) {
3492								return;
3493							}
3494
3495							$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
3496						});
3497					}
3498					if ( $et_pb_countdown_timer.length ) {
3499						$et_pb_countdown_timer.each(function(){
3500							var timer = $(this);
3501							et_countdown_timer_labels( timer );
3502						} );
3503					}
3504				}
3505
3506				window.et_fix_testimonial_inner_width();
3507
3508				et_audio_module_set();
3509			} );
3510
3511			$( window ).ready( function(){
3512				if ( $.fn.fitVids ) {
3513					$( '.et_pb_slide_video' ).fitVids();
3514					$( '.et_pb_module' ).fitVids( { customSelector: "iframe[src^='http://www.hulu.com'], iframe[src^='http://www.dailymotion.com'], iframe[src^='http://www.funnyordie.com'], iframe[src^='https://embed-ssl.ted.com'], iframe[src^='http://embed.revision3.com'], iframe[src^='https://flickr.com'], iframe[src^='http://blip.tv'], iframe[src^='http://www.collegehumor.com']"} );
3515				}
3516
3517				et_fix_video_wmode('.fluid-width-video-wrapper');
3518
3519				et_fix_slider_height();
3520
3521				// calculate fullscreen section sizes on $( window ).ready to avoid jumping in some cases
3522				$( 'section.et_pb_fullscreen' ).each( function(){
3523					var $this_section = $( this );
3524
3525					$.proxy( et_calc_fullscreen_section, $this_section )();
3526
3527					$et_window.on( 'resize', $.proxy( et_calc_fullscreen_section, $this_section ) );
3528				});
3529			} );
3530
3531			window.et_pb_fullwidth_header_scroll = function( event ) {
3532				event.preventDefault();
3533
3534				var $this_section      = $(this).parents( 'section' ),
3535					is_next_fullscreen = $this_section.next().hasClass( 'et_pb_fullscreen' ),
3536					$wpadminbar        = $('#wpadminbar'),
3537					wpadminbar_height  = ( $wpadminbar.length && ! is_next_fullscreen ) ? $wpadminbar.height() : 0,
3538					main_header_height = is_next_fullscreen || ! et_is_fixed_nav ? 0 : $main_header.height(),
3539					top_header_height  = is_next_fullscreen || ! et_is_fixed_nav ? 0 : $top_header.height(),
3540					section_bottom     = $this_section.offset().top + $this_section.outerHeight( true ) - ( wpadminbar_height + top_header_height + main_header_height );
3541
3542				// Fixed menu is turned off on 980px below screen
3543				if ( 980 > $et_window.width() ) {
3544					section_bottom += main_header_height;
3545					section_bottom += top_header_height;
3546				}
3547
3548				// Admin bar is sticked to the top of page on 600px screen below
3549				if ( 600 > $et_window.width() ) {
3550					section_bottom += wpadminbar_height;
3551				}
3552
3553				if ( $this_section.length ) {
3554					$( 'html, body' ).animate( { scrollTop : section_bottom }, 800 );
3555
3556					if ( ! $( '#main-header' ).hasClass( 'et-fixed-header' ) && $( 'body' ).hasClass( 'et_fixed_nav' ) && $( window ).width() > 980 ) {
3557						setTimeout(function(){
3558							var section_offset_top = $this_section.offset().top,
3559								section_height     = $this_section.outerHeight( true ),
3560								main_header_height = is_next_fullscreen ? 0 : $main_header.height(),
3561								section_bottom     = section_offset_top + section_height - ( main_header_height + top_header_height + wpadminbar_height);
3562
3563							$( 'html, body' ).animate( { scrollTop : section_bottom }, 280, 'linear' );
3564						}, 780 );
3565					}
3566				}
3567			}
3568
3569			function et_pb_window_load_scripts() {
3570				et_fix_fullscreen_section();
3571
3572				// recalculate fullscreen section sizes on load
3573				$( 'section.et_pb_fullscreen' ).each( function(){
3574					var $this_section = $( this );
3575
3576					$.proxy( et_calc_fullscreen_section, $this_section )();
3577				});
3578
3579				$( '.et_pb_fullwidth_header_scroll' ).on('click', 'a', et_pb_fullwidth_header_scroll );
3580
3581				setTimeout( function() {
3582					$( '.et_pb_preload' ).removeClass( 'et_pb_preload' );
3583				}, 500 );
3584
3585				if ( $.fn.hashchange ) {
3586					$(window).hashchange( function(){
3587						var hash = window.location.hash.substring(1);
3588						process_et_hashchange( hash );
3589					});
3590					$(window).hashchange();
3591				}
3592
3593				if ( $et_pb_parallax.length && !et_is_mobile_device ) {
3594					$et_pb_parallax.each(function(){
3595						et_pb_parallax_init( $(this) );
3596					});
3597				}
3598
3599				et_audio_module_set();
3600
3601				window.et_reinint_waypoint_modules();
3602
3603				if ( $( '.et_audio_content' ).length ) {
3604					$( window ).trigger( 'resize' );
3605				}
3606			}
3607
3608			if ( window.et_load_event_fired ) {
3609				et_pb_window_load_scripts();
3610			} else {
3611				$( window ).load( function() {
3612					et_pb_window_load_scripts();
3613				} );
3614			}
3615
3616			if ( $( '.et_section_specialty' ).length ) {
3617				$( '.et_section_specialty' ).each( function() {
3618					var this_row = $( this ).find( '.et_pb_row' );
3619
3620					this_row.find( '>.et_pb_column:not(.et_pb_specialty_column)' ).addClass( 'et_pb_column_single' );
3621				});
3622			}
3623
3624			/**
3625			* In particular browser, map + parallax doesn't play well due the use of CSS 3D transform
3626			*/
3627			if ( $('.et_pb_section_parallax').length && $('.et_pb_map').length ) {
3628				$('body').addClass( 'parallax-map-support' );
3629			}
3630
3631			/**
3632			 * Add conditional class for search widget in sidebar module
3633			 */
3634			$('.et_pb_widget_area ' + et_pb_custom.widget_search_selector ).each( function() {
3635				var $search_wrap              = $(this),
3636					$search_input_submit      = $search_wrap.find('input[type="submit"]'),
3637					search_input_submit_text = $search_input_submit.attr( 'value' ),
3638					$search_button            = $search_wrap.find('button'),
3639					search_button_text       = $search_button.text(),
3640					has_submit_button         = $search_input_submit.length || $search_button.length ? true : false,
3641					min_column_width          = 150;
3642
3643				if ( ! $search_wrap.find( 'input[type="text"]' ).length && ! $search_wrap.find( 'input[type="search"]' ).length ) {
3644					return;
3645				}
3646
3647				// Mark no button state
3648				if ( ! has_submit_button ) {
3649					$search_wrap.addClass( 'et-no-submit-button' );
3650				}
3651
3652				// Mark narrow state
3653				if ( $search_wrap.width() < 150 ) {
3654					$search_wrap.addClass( 'et-narrow-wrapper' );
3655				}
3656
3657				// Fixes issue where theme's search button has no text: treat it as non-existent
3658				if ( $search_input_submit.length && ( typeof search_input_submit_text == 'undefined' || search_input_submit_text === '' ) ) {
3659					$search_input_submit.remove();
3660					$search_wrap.addClass( 'et-no-submit-button' );
3661				}
3662
3663				if ( $search_button.length && ( typeof search_button_text == 'undefined' || search_button_text === '' ) ) {
3664					$search_button.remove();
3665					$search_wrap.addClass( 'et-no-submit-button' );
3666				}
3667
3668			} );
3669
3670			if ( $( '.et_pb_search' ).length ) {
3671				$( '.et_pb_search' ).each( function() {
3672					var $this_module = $( this ),
3673						$input_field = $this_module.find( '.et_pb_s' ),
3674						$button = $this_module.find( '.et_pb_searchsubmit' ),
3675						input_padding = $this_module.hasClass( 'et_pb_text_align_right' ) ? 'paddingLeft' : 'paddingRight',
3676						disabled_button = $this_module.hasClass( 'et_pb_hide_search_button' );
3677
3678					if ( $button.innerHeight() > $input_field.innerHeight() ) {
3679						$input_field.height( $button.innerHeight() );
3680					}
3681
3682					if ( ! disabled_button ) {
3683						$input_field.css( input_padding, $button.innerWidth() + 10 );
3684					}
3685				});
3686			}
3687
3688			// apply required classes for the Reply buttons in Comments Module
3689			if ( $( '.et_pb_comments_module' ).length ) {
3690				$( '.et_pb_comments_module' ).each( function() {
3691					var $comments_module = $( this ),
3692						$comments_module_button = $comments_module.find( '.comment-reply-link' );
3693
3694					if ( $comments_module_button.length ) {
3695						$comments_module_button.addClass( 'et_pb_button' );
3696
3697						if ( typeof $comments_module.data( 'icon' ) !== 'undefined' ) {
3698							$comments_module_button.attr( 'data-icon', $comments_module.data( 'icon' ) );
3699							$comments_module_button.addClass( 'et_pb_custom_button_icon' );
3700						}
3701					}
3702				});
3703			}
3704
3705			/**
3706			 * Provide event listener for plugins to hook up to
3707			 */
3708			document.dispatchEvent( new Event('et_pb_after_init_modules') );
3709		});
3710	}
3711
3712	if ( et_pb_custom.is_ab_testing_active && 'yes' === et_pb_custom.is_cache_plugin_active ) {
3713		// update the window.et_load_event_fired variable to initiate the scripts properly
3714		$( window ).load( function() {
3715			window.et_load_event_fired = true;
3716		});
3717
3718		// get the subject id for current visitor and display it
3719		// this ajax request performed only if split testing is enabled and cache plugin active
3720		$.ajax( {
3721			type: "POST",
3722			url: et_pb_custom.ajaxurl,
3723			dataType: "json",
3724			data:
3725			{
3726				action : 'et_pb_ab_get_subject_id',
3727				et_frontend_nonce : et_pb_custom.et_frontend_nonce,
3728				et_pb_ab_test_id : et_pb_custom.page_id
3729			},
3730			success: function( subject_data ) {
3731				if ( subject_data ) {
3732					// append the subject content to appropriate placeholder
3733					$( '.et_pb_subject_placeholder_id_' + subject_data.id ).after( subject_data.content );
3734					// remove all other placeholders from the DOM
3735					$( '.et_pb_subject_placeholder' ).remove();
3736
3737					// init all scripts once the subject loaded
3738					window.et_pb_init_modules();
3739					$( 'body' ).trigger( 'et_pb_ab_subject_ready' );
3740				}
3741			}
3742		});
3743	} else {
3744		window.et_pb_init_modules();
3745	}
3746})(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.