PageSourceSearch

https://tpocambodia.org/wp-content/themes/Divi/js/custom.js

js tpocambodia.org collected 2026-10-03 17:36:42 UTC 133,457 bytes, 3,617 lines download raw bytes

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