PageSourceSearch

https://instabill.com/s/8c4ca8.js

js instabill.com collected 2026-10-02 05:53:26 UTC 269,332 bytes, 6,118 lines download raw bytes

1try{var $tm_pb_slider  = jQuery( '.tm_pb_slider' ),
2	$tm_pb_tabs    = jQuery( '.tm_pb_tabs' ),
3	$tm_pb_tabs_li = $tm_pb_tabs.find( '.tm_pb_tabs_controls li' ),
4	$tm_pb_video_section = jQuery('.tm_pb_section_video_bg'),
5	$tm_pb_newsletter_button = jQuery( '.tm_pb_newsletter_button' ),
6	$tm_pb_filterable_portfolio = jQuery( '.tm_pb_filterable_portfolio' ),
7	$tm_pb_fullwidth_portfolio = jQuery( '.tm_pb_fullwidth_portfolio' ),
8	$tm_pb_gallery = jQuery( '.tm_pb_gallery' ),
9	$tm_pb_countdown_timer = jQuery( '.tm_pb_countdown_timer' ),
10	$tm_post_gallery = jQuery( '.tm_post_gallery' ),
11	$tm_lightbox_image = jQuery( '.tm_pb_lightbox_image'),
12	$tm_pb_map    = jQuery( '.tm_pb_map_container' ),
13	$tm_pb_circle_counter = jQuery( '.tm_pb_circle_counter_bar' ),
14	$tm_pb_number_counter = jQuery( '.tm_pb_number_counter' ),
15	$tm_pb_parallax = jQuery( '.tm_parallax_bg' ),
16	$tm_pb_shop = jQuery( '.tm_pb_shop' ),
17	$tm_pb_post_fullwidth = jQuery( '.single.tm_pb_pagebuilder_layout.tm_full_width_page' ),
18	tm_is_mobile_device = navigator.userAgent.match( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/ ),
19	tm_is_ipad = navigator.userAgent.match( /iPad/ ),
20	$tm_container = ! tm_pb_custom.is_builder_plugin_used ? jQuery( '.container' ) : jQuery( '.tm_pb_row' ),
21	tm_container_width = $tm_container.width(),
22	tm_is_fixed_nav = jQuery( 'body' ).hasClass( 'tm_fixed_nav' ),
23	tm_is_vertical_fixed_nav = jQuery( 'body' ).hasClass( 'tm_vertical_fixed' ),
24	tm_is_rtl = jQuery( 'body' ).hasClass( 'rtl' ),
25	tm_hide_nav = jQuery( 'body' ).hasClass( 'tm_hide_nav' ),
26	tm_header_style_left = jQuery( 'body' ).hasClass( 'tm_header_style_left' ),
27	tm_vertical_navigation = jQuery( 'body' ).hasClass( 'tm_vertical_nav' ),
28	$top_header = jQuery('#top-header'),
29	$main_header = jQuery('#main-header'),
30	$main_container_wrapper = jQuery( '#page-container' ),
31	$tm_transparent_nav = jQuery( '.tm_transparent_nav' ),
32	$tm_pb_first_row = jQuery( 'body.tm_pb_pagebuilder_layout .tm_pb_section:first-child' ),
33	$tm_main_content_first_row = jQuery( '#main-content .container:first-child' ),
34	$tm_main_content_first_row_meta_wrapper = $tm_main_content_first_row.find('.tm_post_meta_wrapper:first'),
35	$tm_main_content_first_row_meta_wrapper_title = $tm_main_content_first_row_meta_wrapper.find( 'h1' ),
36	$tm_main_content_first_row_content = $tm_main_content_first_row.find('.entry-content:first'),
37	$tm_single_post = jQuery( 'body.single-post' ),
38	$tm_window = jQuery(window),
39	etRecalculateOffset = false,
40	tm_header_height,
41	tm_header_modifier,
42	tm_header_offset,
43	tm_primary_header_top,
44	$tm_vertical_nav = jQuery('.tm_vertical_nav'),
45	$tm_header_style_split = jQuery('.tm_header_style_split'),
46	$tm_top_navigation = jQuery('#tm-top-navigation'),
47	$logo = jQuery('#logo'),
48	$tm_sticky_image = jQuery('.tm_pb_image_sticky'),
49	$tm_pb_counter_amount = jQuery('.tm_pb_counter_amount'),
50	$tm_pb_carousel = jQuery( '.tm_pb_carousel' ),
51	$tm_menu_selector = tm_pb_custom.is_divi_theme_used ? jQuery( 'ul.nav' ) : jQuery( '.tm_pb_fullwidth_menu ul.nav' );
52
53jQuery(document).ready( function($){
54	var $tm_top_menu = $tm_menu_selector,
55		tm_parent_menu_longpress_limit = 300,
56		tm_parent_menu_longpress_start,
57		tm_parent_menu_click = true;
58
59	$( '.tm_pb_posts' ).each( function() {
60
61		var $item  = $( this ),
62			loader = '<div class="tm-pb-spinner tm-pb-spinner-double-bounce"><div class="tm-pb-double-bounce1"></div><div class="tm-pb-double-bounce2"></div></div>';
63
64		$item.on( 'click', '.tm_pb_ajax_more', function( event ) {
65
66			var $this   = $( this ),
67				$result = $item.find( '.tm-posts_listing .row' ),
68				pages   = $item.data( 'pages' ),
69				data    = new Object();
70
71			event.preventDefault();
72
73			if ( $this.hasClass( 'in-progress' ) ) {
74				return;
75			}
76
77			data.page   = $item.data( 'page' );
78			data.atts   = $item.data( 'atts' );
79			data.action = 'tm_pb_load_more';
80
81			$this.addClass( 'in-progress' ).after( loader );
82
83			$.ajax({
84				url: window.tm_pb_custom.ajaxurl,
85				type: 'post',
86				dataType: 'json',
87				data: data,
88				error: function() {
89					$this.removeClass( 'in-progress' ).next( '.tm-pb-spinner' ).remove();
90				}
91			}).done( function( response ) {
92				$result.append( response.data.result );
93				$item.data( 'page', response.data.page );
94				$this.removeClass( 'in-progress' ).next( '.tm-pb-spinner' ).remove();
95				if ( response.data.page == pages ) {
96					$this.addClass( 'btn-hidden' );
97				}
98
99			});
100
101		});
102
103	});
104
105	if ( $( '.tm_pb_row' ).length ) {
106		$( '.tm_pb_row' ).each( function() {
107			var $this_row = $( this ),
108				row_class = '';
109
110			row_class = tm_get_column_types( $this_row.find( '>.tm_pb_column' ) );
111
112			if ( '' !== row_class && ( -1 !== row_class.indexOf( '1-4' ) || '_4col' === row_class ) ) {
113				$this_row.addClass( 'tm_pb_row' + row_class );
114			}
115
116			if ( $this_row.find( '.tm_pb_row_inner' ).length ) {
117				$this_row.find( '.tm_pb_row_inner' ).each( function() {
118					var $this_row_inner = $( this );
119					row_class = tm_get_column_types( $this_row_inner.find( '.tm_pb_column' ) );
120
121					if ( '' !== row_class && -1 !== row_class.indexOf( '1-4' ) ) {
122						$this_row_inner.addClass( 'tm_pb_row' + row_class );
123					}
124				});
125			}
126		});
127	}
128
129	function tm_get_column_types( $columns ) {
130		var row_class = '';
131
132		if ( $columns.length ) {
133			$columns.each( function() {
134				var $this_column = $( this ),
135					column_type = $this_column.attr( 'class' ).split( 'tm_pb_column_' )[1],
136					column_type_clean = column_type.split( ' ', 1 )[0],
137					column_type_updated = column_type_clean.replace( '_', '-' ).trim();
138
139				row_class += '_' + column_type_updated;
140			});
141
142			row_class = '_1-4_1-4_1-4_1-4' === row_class ? '_4col' : row_class;
143		}
144
145		return row_class;
146	}
147
148	$tm_top_menu.find( 'li' ).hover( function() {
149		if ( ! $(this).closest( 'li.mega-menu' ).length || $(this).hasClass( 'mega-menu' ) ) {
150			$(this).addClass( 'tm-show-dropdown' );
151			$(this).removeClass( 'tm-hover' ).addClass( 'tm-hover' );
152		}
153	}, function() {
154		var $this_el = $(this);
155
156		$this_el.removeClass( 'tm-show-dropdown' );
157
158		setTimeout( function() {
159			if ( ! $this_el.hasClass( 'tm-show-dropdown' ) ) {
160				$this_el.removeClass( 'tm-hover' );
161			}
162		}, 200 );
163	} );
164
165	// Dropdown menu adjustment for touch screen
166	$tm_top_menu.find('.menu-item-has-children > a').on( 'touchstart', function(){
167		tm_parent_menu_longpress_start = new Date().getTime();
168	} ).on( 'touchend', function(){
169		var tm_parent_menu_longpress_end = new Date().getTime()
170		if ( tm_parent_menu_longpress_end  >= tm_parent_menu_longpress_start + tm_parent_menu_longpress_limit ) {
171			tm_parent_menu_click = true;
172		} else {
173			tm_parent_menu_click = false;
174
175			// Close sub-menu if toggled
176			var $tm_parent_menu = $(this).parent('li');
177			if ( $tm_parent_menu.hasClass( 'tm-hover') ) {
178				$tm_parent_menu.trigger( 'mouseleave' );
179			} else {
180				$tm_parent_menu.trigger( 'mouseenter' );
181			}
182		}
183		tm_parent_menu_longpress_start = 0;
184	} ).click(function() {
185		if ( tm_parent_menu_click ) {
186			return true;
187		}
188
189		return false;
190	} );
191
192	$tm_top_menu.find( 'li.mega-menu' ).each(function(){
193		var $li_mega_menu           = $(this),
194			$li_mega_menu_item      = $li_mega_menu.children( 'ul' ).children( 'li' ),
195			li_mega_menu_item_count = $li_mega_menu_item.length;
196
197		if ( li_mega_menu_item_count < 4 ) {
198			$li_mega_menu.addClass( 'mega-menu-parent mega-menu-parent-' + li_mega_menu_item_count );
199		}
200	});
201
202	$tm_sticky_image.each( function() {
203		var $this_el            = $(this),
204			$row                = $this_el.closest('.tm_pb_row'),
205			$section            = $row.closest('.tm_pb_section'),
206			$column             = $this_el.closest( '.tm_pb_column' ),
207			sticky_class        = 'tm_pb_section_sticky',
208			sticky_mobile_class = 'tm_pb_section_sticky_mobile';
209
210		// If it is not in the last row, continue
211		if ( ! $row.is( ':last-child' ) ) {
212			return true;
213		}
214
215		// Make sure sticky image is the last element in the column
216		if ( ! $this_el.is( ':last-child' ) ) {
217			return true;
218		}
219
220		// If it is in the last row, find the parent section and attach new class to it
221		if ( ! $section.hasClass( sticky_class ) ) {
222			$section.addClass( sticky_class );
223		}
224
225		$column.addClass( 'tm_pb_row_sticky' );
226
227		if ( ! $section.hasClass( sticky_mobile_class ) && $column.is( ':last-child' ) ) {
228			$section.addClass( sticky_mobile_class );
229		}
230	} );
231
232	if ( tm_is_mobile_device ) {
233		$( '.tm_pb_section_video_bg' ).each( function() {
234			var $this_el = $(this);
235
236			$this_el.css( 'visibility', 'hidden' ).closest( '.tm_pb_preload' ).removeClass( 'tm_pb_preload' )
237		} );
238
239		$( 'body' ).addClass( 'tm_mobile_device' );
240
241		if ( ! tm_is_ipad ) {
242			$( 'body' ).addClass( 'tm_mobile_device_not_ipad' );
243		}
244	}
245
246	if ( $tm_pb_video_section.length ) {
247		$tm_pb_video_section.find( 'video' ).mediaelementplayer( {
248			pauseOtherPlayers: false,
249			success : function( mediaElement, domObject ) {
250				mediaElement.addEventListener( 'loadeddata', function() {
251					tm_pb_resize_section_video_bg( $(domObject) );
252					tm_pb_center_video( $(domObject) );
253				}, false );
254
255				mediaElement.addEventListener( 'canplay', function() {
256					$(domObject).closest( '.tm_pb_preload' ).removeClass( 'tm_pb_preload' );
257				}, false );
258			}
259		} );
260	}
261
262	if ( $tm_post_gallery.length ) {
263		// swipe support in magnific popup only if gallery exists
264		var magnificPopup = $.magnificPopup.instance;
265
266		$( 'body' ).on( 'swiperight', '.mfp-container', function() {
267			magnificPopup.prev();
268		} );
269		$( 'body' ).on( 'swipeleft', '.mfp-container', function() {
270			magnificPopup.next();
271		} );
272
273		$tm_post_gallery.each(function() {
274			$(this).magnificPopup( {
275				delegate: 'a',
276				type: 'image',
277				removalDelay: 500,
278				gallery: {
279					enabled: true,
280					navigateByImgClick: true
281				},
282				mainClass: 'mfp-fade',
283				zoom: {
284					enabled: true,
285					duration: 500,
286					opener: function(element) {
287						return element.find('img');
288					}
289				}
290			} );
291		} );
292		// prevent attaching of any further actions on click
293		$tm_post_gallery.find( 'a' ).unbind( 'click' );
294	}
295
296	if ( $tm_lightbox_image.length ) {
297		// prevent attaching of any further actions on click
298		$tm_lightbox_image.unbind( 'click' );
299		$tm_lightbox_image.bind( 'click' );
300
301		$tm_lightbox_image.magnificPopup( {
302			type: 'image',
303			removalDelay: 500,
304			mainClass: 'mfp-fade',
305			zoom: {
306				enabled: true,
307				duration: 500,
308				opener: function(element) {
309					return element.find('img');
310				}
311			}
312		} );
313	}
314
315	if ( $tm_pb_slider.length ) {
316		$tm_pb_slider.each( function() {
317			var $this_slider = $(this),
318				tm_slider_settings = {
319					fade_speed 		: 700,
320					slide			: ! $this_slider.hasClass( 'tm_pb_gallery' ) ? '.tm_pb_slide' : '.tm_pb_gallery_item'
321				}
322
323			if ( $this_slider.hasClass('tm_pb_slider_no_arrows') )
324				tm_slider_settings.use_arrows = false;
325
326			if ( $this_slider.hasClass('tm_pb_slider_no_pagination') )
327				tm_slider_settings.use_controls = false;
328
329			if ( $this_slider.hasClass('tm_slider_auto') ) {
330				var tm_slider_autospeed_class_value = /tm_slider_speed_(\d+)/g;
331
332				tm_slider_settings.slideshow = true;
333
334				tm_slider_autospeed = tm_slider_autospeed_class_value.exec( $this_slider.attr('class') );
335
336				tm_slider_settings.slideshow_speed = tm_slider_autospeed[1];
337			}
338
339			if ( $this_slider.parent().hasClass('tm_pb_video_slider') ) {
340				tm_slider_settings.controls_below = true;
341				tm_slider_settings.append_controls_to = $this_slider.parent();
342
343				setTimeout( function() {
344					$( '.tm_pb_preload' ).removeClass( 'tm_pb_preload' );
345				}, 500 );
346			}
347
348			if ( $this_slider.hasClass('tm_pb_slider_carousel') )
349				tm_slider_settings.use_carousel = true;
350
351			$this_slider.tm_pb_simple_slider( tm_slider_settings );
352
353		} );
354	}
355
356	$tm_pb_carousel  = $( '.tm_pb_carousel' );
357	if ( $tm_pb_carousel.length ) {
358		$tm_pb_carousel.each( function() {
359			var $this_carousel = $(this),
360				tm_carousel_settings = {
361					fade_speed 		: 1000
362				};
363
364			$this_carousel.tm_pb_simple_carousel( tm_carousel_settings );
365		} );
366	}
367
368	if ( $tm_pb_fullwidth_portfolio.length ) {
369
370		function set_fullwidth_portfolio_columns( $the_portfolio, carousel_mode ) {
371			var columns,
372				$portfolio_items = $the_portfolio.find('.tm_pb_portfolio_items'),
373				portfolio_items_width = $portfolio_items.width(),
374				$the_portfolio_items = $portfolio_items.find('.tm_pb_portfolio_item'),
375				portfolio_item_count = $the_portfolio_items.length;
376
377			// calculate column breakpoints
378			if ( portfolio_items_width >= 1600 ) {
379				columns = 5;
380			} else if ( portfolio_items_width >= 1024 ) {
381				columns = 4;
382			} else if ( portfolio_items_width >= 768 ) {
383				columns = 3;
384			} else if ( portfolio_items_width >= 480 ) {
385				columns = 2;
386			} else {
387				columns = 1;
388			}
389
390			// set height of items
391			portfolio_item_width = portfolio_items_width / columns;
392			portfolio_item_height = portfolio_item_width * .75;
393
394			if ( carousel_mode ) {
395				$portfolio_items.css({ 'height' : portfolio_item_height });
396			}
397
398			$the_portfolio_items.css({ 'height' : portfolio_item_height });
399
400			if ( columns === $portfolio_items.data('portfolio-columns') ) {
401				return;
402			}
403
404			if ( $the_portfolio.data('columns_setting_up') ) {
405				return;
406			}
407
408			$the_portfolio.data('columns_setting_up', true );
409
410			var portfolio_item_width_percentage = ( 100 / columns ) + '%';
411			$the_portfolio_items.css({ 'width' : portfolio_item_width_percentage });
412
413			// store last setup column
414			$portfolio_items.removeClass('columns-' + $portfolio_items.data('portfolio-columns') );
415			$portfolio_items.addClass('columns-' + columns );
416			$portfolio_items.data('portfolio-columns', columns );
417
418			if ( !carousel_mode ) {
419				return $the_portfolio.data('columns_setting_up', false );
420			}
421
422			// kill all previous groups to get ready to re-group
423			if ( $portfolio_items.find('.tm_pb_carousel_group').length ) {
424				$the_portfolio_items.appendTo( $portfolio_items );
425				$portfolio_items.find('.tm_pb_carousel_group').remove();
426			}
427
428			// setup the grouping
429			var the_portfolio_items = $portfolio_items.data('items' ),
430				$carousel_group = $('<div class="tm_pb_carousel_group active">').appendTo( $portfolio_items );
431
432			$the_portfolio_items.data('position', '');
433			if ( the_portfolio_items.length <= columns ) {
434				$portfolio_items.find('.tm-pb-slider-arrows').hide();
435			} else {
436				$portfolio_items.find('.tm-pb-slider-arrows').show();
437			}
438
439			for ( position = 1, x=0 ;x < the_portfolio_items.length; x++, position++ ) {
440				if ( x < columns ) {
441					$( the_portfolio_items[x] ).show();
442					$( the_portfolio_items[x] ).appendTo( $carousel_group );
443					$( the_portfolio_items[x] ).data('position', position );
444					$( the_portfolio_items[x] ).addClass('position_' + position );
445				} else {
446					position = $( the_portfolio_items[x] ).data('position');
447					$( the_portfolio_items[x] ).removeClass('position_' + position );
448					$( the_portfolio_items[x] ).data('position', '' );
449					$( the_portfolio_items[x] ).hide();
450				}
451			}
452
453			$the_portfolio.data('columns_setting_up', false );
454
455		}
456
457		function tm_carousel_auto_rotate( $carousel ) {
458			if ( 'on' === $carousel.data('auto-rotate') && $carousel.find('.tm_pb_portfolio_item').length > $carousel.find('.tm_pb_carousel_group .tm_pb_portfolio_item').length && ! $carousel.hasClass( 'tm_carousel_hovered' ) ) {
459
460				tm_carousel_timer = setTimeout( function() {
461					$carousel.find('.tm-pb-arrow-next').click();
462				}, $carousel.data('auto-rotate-speed') );
463
464				$carousel.data('tm_carousel_timer', tm_carousel_timer);
465			}
466		}
467
468		$tm_pb_fullwidth_portfolio.each(function(){
469			var $the_portfolio = $(this),
470				$portfolio_items = $the_portfolio.find('.tm_pb_portfolio_items');
471
472				$portfolio_items.data('items', $portfolio_items.find('.tm_pb_portfolio_item').toArray() );
473				$the_portfolio.data('columns_setting_up', false );
474
475			if ( $the_portfolio.hasClass('tm_pb_fullwidth_portfolio_carousel') ) {
476				// add left and right arrows
477				$portfolio_items.prepend('<div class="tm-pb-slider-arrows"><a class="tm-pb-arrow-prev" href="#">' + '<span>' + tm_pb_custom.previous + '</span>' + '</a><a class="tm-pb-arrow-next" href="#">' + '<span>' + tm_pb_custom.next + '</span>' + '</a></div>');
478
479				set_fullwidth_portfolio_columns( $the_portfolio, true );
480
481				tm_carousel_auto_rotate( $the_portfolio );
482
483				// swipe support
484				$the_portfolio.on( 'swiperight', function() {
485					$( this ).find( '.tm-pb-arrow-prev' ).click();
486				});
487				$the_portfolio.on( 'swipeleft', function() {
488					$( this ).find( '.tm-pb-arrow-next' ).click();
489				});
490
491				$the_portfolio.hover(
492					function(){
493						$(this).addClass('tm_carousel_hovered');
494						if ( typeof $(this).data('tm_carousel_timer') != 'undefined' ) {
495							clearInterval( $(this).data('tm_carousel_timer') );
496						}
497					},
498					function(){
499						$(this).removeClass('tm_carousel_hovered');
500						tm_carousel_auto_rotate( $(this) );
501					}
502				);
503
504				$the_portfolio.data('carouseling', false );
505
506				$the_portfolio.on('click', '.tm-pb-slider-arrows a', function(e){
507					var $the_portfolio = $(this).parents('.tm_pb_fullwidth_portfolio'),
508						$portfolio_items = $the_portfolio.find('.tm_pb_portfolio_items'),
509						$the_portfolio_items = $portfolio_items.find('.tm_pb_portfolio_item'),
510						$active_carousel_group = $portfolio_items.find('.tm_pb_carousel_group.active'),
511						slide_duration = 700,
512						items = $portfolio_items.data('items'),
513						columns = $portfolio_items.data('portfolio-columns'),
514						item_width = $active_carousel_group.innerWidth() / columns, //$active_carousel_group.children().first().innerWidth(),
515						original_item_width = ( 100 / columns ) + '%';
516
517					e.preventDefault();
518
519					if ( $the_portfolio.data('carouseling') ) {
520						return;
521					}
522
523					$the_portfolio.data('carouseling', true);
524
525					$active_carousel_group.children().each(function(){
526						$(this).css({'width': $(this).innerWidth() + 1, 'position':'absolute', 'left': ( $(this).innerWidth() * ( $(this).data('position') - 1 ) ) });
527					});
528
529					if ( $(this).hasClass('tm-pb-arrow-next') ) {
530						var $next_carousel_group,
531							current_position = 1,
532							next_position = 1,
533							active_items_start = items.indexOf( $active_carousel_group.children().first()[0] ),
534							active_items_end = active_items_start + columns,
535							next_items_start = active_items_end,
536							next_items_end = next_items_start + columns;
537
538						$next_carousel_group = $('<div class="tm_pb_carousel_group next" style="display: none;left: 100%;position: absolute;top: 0;">').insertAfter( $active_carousel_group );
539						$next_carousel_group.css({ 'width': $active_carousel_group.innerWidth() }).show();
540
541						// this is an endless loop, so it can decide internally when to break out, so that next_position
542						// can get filled up, even to the extent of an element having both and current_ and next_ position
543						for( x = 0, total = 0 ; ; x++, total++ ) {
544							if ( total >= active_items_start && total < active_items_end ) {
545								$( items[x] ).addClass( 'changing_position current_position current_position_' + current_position );
546								$( items[x] ).data('current_position', current_position );
547								current_position++;
548							}
549
550							if ( total >= next_items_start && total < next_items_end ) {
551								$( items[x] ).data('next_position', next_position );
552								$( items[x] ).addClass('changing_position next_position next_position_' + next_position );
553
554								if ( !$( items[x] ).hasClass( 'current_position' ) ) {
555									$( items[x] ).addClass('container_append');
556								} else {
557									$( items[x] ).clone(true).appendTo( $active_carousel_group ).hide().addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' );
558									$( items[x] ).addClass('delayed_container_append');
559								}
560
561								next_position++;
562							}
563
564							if ( next_position > columns ) {
565								break;
566							}
567
568							if ( x >= ( items.length -1 )) {
569								x = -1;
570							}
571						}
572
573						sorted = $portfolio_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) {
574							var el_a_position = parseInt( $(a).data('next_position') );
575							var el_b_position = parseInt( $(b).data('next_position') );
576							return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0;
577						});
578
579						$( sorted ).show().appendTo( $next_carousel_group );
580
581						$next_carousel_group.children().each(function(){
582							$(this).css({'width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('next_position') - 1 ) ) });
583						});
584
585						$active_carousel_group.animate({
586							left: '-100%'
587						}, {
588							duration: slide_duration,
589							complete: function() {
590								$portfolio_items.find('.delayed_container_append').each(function(){
591									$(this).css({'width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('next_position') - 1 ) ) });
592									$(this).appendTo( $next_carousel_group );
593								});
594
595								$active_carousel_group.removeClass('active');
596								$active_carousel_group.children().each(function(){
597									position = $(this).data('position');
598									current_position = $(this).data('current_position');
599									$(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position );
600									$(this).data('position', '');
601									$(this).data('current_position', '');
602									$(this).hide();
603									$(this).css({'position': '', 'width': '', 'left': ''});
604									$(this).appendTo( $portfolio_items );
605								});
606
607								$active_carousel_group.remove();
608
609								tm_carousel_auto_rotate( $the_portfolio );
610
611							}
612						} );
613
614						$next_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: '100%'});
615						$next_carousel_group.animate({
616							left: '0%'
617						}, {
618							duration: slide_duration,
619							complete: function(){
620								setTimeout(function(){
621									$next_carousel_group.removeClass('next').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''});
622
623									$next_carousel_group.find('.delayed_container_append_dup').remove();
624
625									$next_carousel_group.find('.changing_position').each(function( index ){
626										position = $(this).data('position');
627										current_position = $(this).data('current_position');
628										next_position = $(this).data('next_position');
629										$(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' next_position next_position_' + next_position );
630										$(this).data('current_position', '');
631										$(this).data('next_position', '');
632										$(this).data('position', ( index + 1 ) );
633									});
634
635									$next_carousel_group.children().css({'position': '', 'width': original_item_width, 'left': ''});
636
637									$the_portfolio.data('carouseling', false);
638								}, 100 );
639							}
640						} );
641
642					} else {
643						var $prev_carousel_group,
644							current_position = columns,
645							prev_position = columns,
646							columns_span = columns - 1,
647							active_items_start = items.indexOf( $active_carousel_group.children().last()[0] ),
648							active_items_end = active_items_start - columns_span,
649							prev_items_start = active_items_end - 1,
650							prev_items_end = prev_items_start - columns_span;
651
652						$prev_carousel_group = $('<div class="tm_pb_carousel_group prev" style="display: none;left: 100%;position: absolute;top: 0;">').insertBefore( $active_carousel_group );
653						$prev_carousel_group.css({ 'left': '-' + $active_carousel_group.innerWidth(), 'width': $active_carousel_group.innerWidth() }).show();
654
655						// this is an endless loop, so it can decide internally when to break out, so that next_position
656						// can get filled up, even to the extent of an element having both and current_ and next_ position
657						for( x = ( items.length - 1 ), total = ( items.length - 1 ) ; ; x--, total-- ) {
658
659							if ( total <= active_items_start && total >= active_items_end ) {
660								$( items[x] ).addClass( 'changing_position current_position current_position_' + current_position );
661								$( items[x] ).data('current_position', current_position );
662								current_position--;
663							}
664
665							if ( total <= prev_items_start && total >= prev_items_end ) {
666								$( items[x] ).data('prev_position', prev_position );
667								$( items[x] ).addClass('changing_position prev_position prev_position_' + prev_position );
668
669								if ( !$( items[x] ).hasClass( 'current_position' ) ) {
670									$( items[x] ).addClass('container_append');
671								} else {
672									$( items[x] ).clone(true).appendTo( $active_carousel_group ).addClass('delayed_container_append_dup').attr('id', $( items[x] ).attr('id') + '-dup' );
673									$( items[x] ).addClass('delayed_container_append');
674								}
675
676								prev_position--;
677							}
678
679							if ( prev_position <= 0 ) {
680								break;
681							}
682
683							if ( x == 0 ) {
684								x = items.length;
685							}
686						}
687
688						sorted = $portfolio_items.find('.container_append, .delayed_container_append_dup').sort(function (a, b) {
689							var el_a_position = parseInt( $(a).data('prev_position') );
690							var el_b_position = parseInt( $(b).data('prev_position') );
691							return ( el_a_position < el_b_position ) ? -1 : ( el_a_position > el_b_position ) ? 1 : 0;
692						});
693
694						$( sorted ).show().appendTo( $prev_carousel_group );
695
696						$prev_carousel_group.children().each(function(){
697							$(this).css({'width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('prev_position') - 1 ) ) });
698						});
699
700						$active_carousel_group.animate({
701							left: '100%'
702						}, {
703							duration: slide_duration,
704							complete: function() {
705								$portfolio_items.find('.delayed_container_append').reverse().each(function(){
706									$(this).css({'width': item_width, 'position':'absolute', 'left': ( item_width * ( $(this).data('prev_position') - 1 ) ) });
707									$(this).prependTo( $prev_carousel_group );
708								});
709
710								$active_carousel_group.removeClass('active');
711								$active_carousel_group.children().each(function(){
712									position = $(this).data('position');
713									current_position = $(this).data('current_position');
714									$(this).removeClass('position_' + position + ' ' + 'changing_position current_position current_position_' + current_position );
715									$(this).data('position', '');
716									$(this).data('current_position', '');
717									$(this).hide();
718									$(this).css({'position': '', 'width': '', 'left': ''});
719									$(this).appendTo( $portfolio_items );
720								});
721
722								$active_carousel_group.remove();
723							}
724						} );
725
726						$prev_carousel_group.addClass('active').css({'position':'absolute', 'top':0, left: '-100%'});
727						$prev_carousel_group.animate({
728							left: '0%'
729						}, {
730							duration: slide_duration,
731							complete: function(){
732								setTimeout(function(){
733									$prev_carousel_group.removeClass('prev').addClass('active').css({'position':'', 'width':'', 'top':'', 'left': ''});
734
735									$prev_carousel_group.find('.delayed_container_append_dup').remove();
736
737									$prev_carousel_group.find('.changing_position').each(function( index ){
738										position = $(this).data('position');
739										current_position = $(this).data('current_position');
740										prev_position = $(this).data('prev_position');
741										$(this).removeClass('container_append delayed_container_append position_' + position + ' ' + 'changing_position current_position current_position_' + current_position + ' prev_position prev_position_' + prev_position );
742										$(this).data('current_position', '');
743										$(this).data('prev_position', '');
744										position = index + 1;
745										$(this).data('position', position );
746										$(this).addClass('position_' + position );
747									});
748
749									$prev_carousel_group.children().css({'position': '', 'width': original_item_width, 'left': ''});
750									$the_portfolio.data('carouseling', false);
751								}, 100 );
752							}
753						} );
754					}
755
756					return false;
757				});
758
759			} else {
760				// setup fullwidth portfolio grid
761				set_fullwidth_portfolio_columns( $the_portfolio, false );
762			}
763
764		});
765	}
766
767	function tm_audio_module_set() {
768		if ( $( '.tm_pb_audio_module .mejs-audio' ).length || $( '.tm_audio_content .mejs-audio' ).length ) {
769			$( '.tm_audio_container' ).each( function(){
770				var $this_player = $( this ),
771					$time_rail = $this_player.find( '.mejs-time-rail' ),
772					$time_slider = $this_player.find( '.mejs-time-slider' );
773				// remove previously added width and min-width attributes to calculate the new sizes accurately
774				$time_rail.removeAttr( 'style' );
775				$time_slider.removeAttr( 'style' );
776
777				var $count_timer = $this_player.find( 'div.mejs-currenttime-container' ),
778					player_width = $this_player.width(),
779					controls_play_width = $this_player.find( '.mejs-play' ).outerWidth(),
780					time_width = $this_player.find( '.mejs-currenttime-container' ).outerWidth(),
781					volume_icon_width = $this_player.find( '.mejs-volume-button' ).outerWidth(),
782					volume_bar_width = $this_player.find( '.mejs-horizontal-volume-slider' ).outerWidth(),
783					new_time_rail_width;
784
785				$count_timer.addClass( 'custom' );
786				$this_player.find( '.mejs-controls div.mejs-duration-container' ).replaceWith( $count_timer );
787				new_time_rail_width = player_width - ( controls_play_width + time_width + volume_icon_width + volume_bar_width + 100 );
788
789				if ( 0 < new_time_rail_width ) {
790					$time_rail.attr( 'style', 'min-width: ' + new_time_rail_width + 'px;' );
791					$time_slider.attr( 'style', 'min-width: ' + new_time_rail_width + 'px;' );
792				}
793			});
794		}
795	}
796
797	if ( $('.tm_pb_section_video').length ) {
798		window._wpmejsSettings.pauseOtherPlayers = false;
799	}
800
801	if ( $tm_pb_filterable_portfolio.length ) {
802
803		$(window).load(function(){
804
805			$tm_pb_filterable_portfolio.each(function(){
806				var $the_portfolio = $(this),
807					$the_portfolio_items = $the_portfolio.find('.tm_pb_portfolio_items'),
808					$left_orientatation = true == $the_portfolio.data( 'rtl' ) ? false : true;
809
810				$the_portfolio.show();
811
812				set_filterable_grid_items( $the_portfolio );
813
814				$the_portfolio.on('click', '.tm_pb_portfolio_filter a', function(e){
815					e.preventDefault();
816					var category_slug = $(this).data('category-slug');
817					$the_portfolio_items = $(this).parents('.tm_pb_filterable_portfolio').find('.tm_pb_portfolio_items');
818
819					if ( 'all' == category_slug ) {
820						$the_portfolio.find('.tm_pb_portfolio_filter a').removeClass('active');
821						$the_portfolio.find('.tm_pb_portfolio_filter_all a').addClass('active');
822						$the_portfolio.find('.tm_pb_portfolio_item').removeClass('active inactive');
823						$the_portfolio.find('.tm_pb_portfolio_item').show();
824						$the_portfolio.find('.tm_pb_portfolio_item').addClass('active');
825					} else {
826						$the_portfolio.find('.tm_pb_portfolio_filter_all').removeClass('active');
827						$the_portfolio.find('.tm_pb_portfolio_filter a').removeClass('active');
828						$the_portfolio.find('.tm_pb_portfolio_filter_all a').removeClass('active');
829						$(this).addClass('active');
830
831						$the_portfolio_items.find('.tm_pb_portfolio_item').hide();
832						$the_portfolio_items.find('.tm_pb_portfolio_item').addClass( 'inactive' );
833						$the_portfolio_items.find('.tm_pb_portfolio_item').removeClass('active');
834						$the_portfolio_items.find('.tm_pb_portfolio_item.project_category_' + $(this).data('category-slug') ).show();
835						$the_portfolio_items.find('.tm_pb_portfolio_item.project_category_' + $(this).data('category-slug') ).addClass('active').removeClass( 'inactive' );
836					}
837
838					set_filterable_grid_items( $the_portfolio );
839					setTimeout(function(){
840						set_filterable_portfolio_hash( $the_portfolio );
841					}, 500 );
842				});
843
844				$(this).on('tm_hashchange', function( event ){
845					var params = event.params;
846					$the_portfolio = $( '#' + event.target.id );
847
848					if ( !$the_portfolio.find('.tm_pb_portfolio_filter a[data-category-slug="' + params[0] + '"]').hasClass('active') ) {
849						$the_portfolio.find('.tm_pb_portfolio_filter a[data-category-slug="' + params[0] + '"]').click();
850					}
851
852					if ( params[1] ) {
853						setTimeout(function(){
854							if ( !$the_portfolio.find('.tm_pb_portofolio_pagination a.page-' + params[1]).hasClass('active') ) {
855								$the_portfolio.find('.tm_pb_portofolio_pagination a.page-' + params[1]).addClass('active').click();
856							}
857						}, 300 );
858					}
859				});
860			});
861
862		}); // End $(window).load()
863
864		function set_filterable_grid_items( $the_portfolio ) {
865			var active_category = $the_portfolio.find('.tm_pb_portfolio_filter > a.active').data('category-slug'),
866				container_width = $the_portfolio.find( '.tm_pb_portfolio_items' ).innerWidth(),
867				item_width = $the_portfolio.find( '.tm_pb_portfolio_item' ).outerWidth( true ),
868				last_item_margin = item_width - $the_portfolio.find( '.tm_pb_portfolio_item' ).outerWidth(),
869				columns_count = Math.round( ( container_width + last_item_margin ) / item_width ),
870				counter = 1,
871				first_in_row = 1;
872
873				$the_portfolio.find( '.tm_pb_portfolio_item' ).removeClass( 'last_in_row first_in_row' );
874				$the_portfolio.find( '.tm_pb_portfolio_item' ).each( function() {
875					var $this_el = $( this );
876
877					if ( ! $this_el.hasClass( 'inactive' ) ) {
878						if ( first_in_row === counter ) {
879							$this_el.addClass( 'first_in_row' );
880						}
881
882						if ( 0 === counter % columns_count ) {
883							$this_el.addClass( 'last_in_row' );
884							first_in_row = counter + 1;
885						}
886						counter++;
887					}
888				});
889
890			if ( 'all' === active_category ) {
891				$the_portfolio_visible_items = $the_portfolio.find('.tm_pb_portfolio_item');
892			} else {
893				$the_portfolio_visible_items = $the_portfolio.find('.tm_pb_portfolio_item.project_category_' + active_category);
894			}
895
896			var visible_grid_items = $the_portfolio_visible_items.length,
897				posts_number = $the_portfolio.data('posts-number'),
898				pages = Math.ceil( visible_grid_items / posts_number );
899
900			set_filterable_grid_pages( $the_portfolio, pages );
901
902			var visible_grid_items = 0;
903			var _page = 1;
904			$the_portfolio.find('.tm_pb_portfolio_item').data('page', '');
905			$the_portfolio_visible_items.each(function(i){
906				visible_grid_items++;
907				if ( 0 === parseInt( visible_grid_items % posts_number ) ) {
908					$(this).data('page', _page);
909					_page++;
910				} else {
911					$(this).data('page', _page);
912				}
913			});
914
915			$the_portfolio_visible_items.filter(function() {
916				return $(this).data('page') == 1;
917			}).show();
918
919			$the_portfolio_visible_items.filter(function() {
920				return $(this).data('page') != 1;
921			}).hide();
922		}
923
924		function set_filterable_grid_pages( $the_portfolio, pages ) {
925			$pagination = $the_portfolio.find('.tm_pb_portofolio_pagination');
926
927			if ( !$pagination.length ) {
928				return;
929			}
930
931			$pagination.html('<ul></ul>');
932			if ( pages <= 1 ) {
933				return;
934			}
935
936			$pagination_list = $pagination.children('ul');
937			$pagination_list.append('<li class="prev" style="display:none;"><a href="#" data-page="prev" class="page-prev">' + tm_pb_custom.prev + '</a></li>');
938			for( var page = 1; page <= pages; page++ ) {
939				var first_page_class = page === 1 ? ' active' : '',
940					last_page_class = page === pages ? ' last-page' : '',
941					hidden_page_class = page >= 5 ? ' style="display:none;"' : '';
942				$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>');
943			}
944			$pagination_list.append('<li class="next"><a href="#" data-page="next" class="page-next">' + tm_pb_custom.next + '</a></li>');
945		}
946
947		$tm_pb_filterable_portfolio.on('click', '.tm_pb_portofolio_pagination a', function(e){
948			e.preventDefault();
949
950			var to_page = $(this).data('page'),
951				$the_portfolio = $(this).parents('.tm_pb_filterable_portfolio'),
952				$the_portfolio_items = $the_portfolio.find('.tm_pb_portfolio_items');
953
954			tm_pb_smooth_scroll( $the_portfolio, false, 800 );
955
956			if ( $(this).hasClass('page-prev') ) {
957				to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) - 1;
958			} else if ( $(this).hasClass('page-next') ) {
959				to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) + 1;
960			}
961
962			$(this).parents('ul').find('a').removeClass('active');
963			$(this).parents('ul').find('a.page-' + to_page ).addClass('active');
964
965			var current_index = $(this).parents('ul').find('a.page-' + to_page ).parent().index(),
966				total_pages = $(this).parents('ul').find('li.page').length;
967
968			$(this).parent().nextUntil('.page-' + ( current_index + 3 ) ).show();
969			$(this).parent().prevUntil('.page-' + ( current_index - 3 ) ).show();
970
971			$(this).parents('ul').find('li.page').each(function(i){
972				if ( !$(this).hasClass('prev') && !$(this).hasClass('next') ) {
973					if ( i < ( current_index - 3 ) ) {
974						$(this).hide();
975					} else if ( i > ( current_index + 1 ) ) {
976						$(this).hide();
977					} else {
978						$(this).show();
979					}
980
981					if ( total_pages - current_index <= 2 && total_pages - i <= 5 ) {
982						$(this).show();
983					} else if ( current_index <= 3 && i <= 4 ) {
984						$(this).show();
985					}
986
987				}
988			});
989
990			if ( to_page > 1 ) {
991				$(this).parents('ul').find('li.prev').show();
992			} else {
993				$(this).parents('ul').find('li.prev').hide();
994			}
995
996			if ( $(this).parents('ul').find('a.active').hasClass('last-page') ) {
997				$(this).parents('ul').find('li.next').hide();
998			} else {
999				$(this).parents('ul').find('li.next').show();
1000			}
1001
1002			$the_portfolio.find('.tm_pb_portfolio_item').hide();
1003			$the_portfolio.find('.tm_pb_portfolio_item').filter(function( index ) {
1004				return $(this).data('page') === to_page;
1005			}).show();
1006
1007			setTimeout(function(){
1008				set_filterable_portfolio_hash( $the_portfolio );
1009			}, 500 );
1010		});
1011
1012		function set_filterable_portfolio_hash( $the_portfolio ) {
1013
1014			if ( !$the_portfolio.attr('id') ) {
1015				return;
1016			}
1017
1018			var this_portfolio_state = [];
1019			this_portfolio_state.push( $the_portfolio.attr('id') );
1020			this_portfolio_state.push( $the_portfolio.find('.tm_pb_portfolio_filter > a.active').data('category-slug') );
1021
1022			if ( $the_portfolio.find('.tm_pb_portofolio_pagination a.active').length ) {
1023				this_portfolio_state.push( $the_portfolio.find('.tm_pb_portofolio_pagination a.active').data('page') );
1024			} else {
1025				this_portfolio_state.push( 1 );
1026			}
1027
1028			this_portfolio_state = this_portfolio_state.join( tm_hash_module_param_seperator );
1029
1030			tm_set_hash( this_portfolio_state );
1031		}
1032	} /*  end if ( $tm_pb_filterable_portfolio.length ) */
1033
1034	if ( $tm_pb_gallery.length ) {
1035
1036		function set_gallery_grid_items( $the_gallery ) {
1037			var $the_gallery_items_container = $the_gallery.find('.tm_pb_gallery_items'),
1038				$the_gallery_items = $the_gallery_items_container.find('.tm_pb_gallery_item');
1039
1040			var total_grid_items = $the_gallery_items.length,
1041				posts_number = $the_gallery_items_container.data('per_page'),
1042				pages = Math.ceil( total_grid_items / posts_number );
1043
1044			set_gallery_grid_pages( $the_gallery, pages );
1045
1046			var total_grid_items = 0;
1047			var _page = 1;
1048			$the_gallery_items.data('page', '');
1049			$the_gallery_items.each(function(i){
1050				total_grid_items++;
1051				if ( 0 === parseInt( total_grid_items % posts_number ) ) {
1052					$(this).data('page', _page);
1053					_page++;
1054				} else {
1055					$(this).data('page', _page);
1056				}
1057
1058			});
1059
1060			var visible_items = $the_gallery_items.filter(function() {
1061				return $(this).data('page') == 1;
1062			}).show();
1063
1064			$the_gallery_items.filter(function() {
1065				return $(this).data('page') != 1;
1066			}).hide();
1067		}
1068
1069		function set_gallery_grid_pages( $the_gallery, pages ) {
1070			$pagination = $the_gallery.find('.tm_pb_gallery_pagination');
1071
1072			if ( !$pagination.length ) {
1073				return;
1074			}
1075
1076			$pagination.html('<ul></ul>');
1077			if ( pages <= 1 ) {
1078				$pagination.hide();
1079				return;
1080			}
1081
1082			$pagination_list = $pagination.children('ul');
1083			$pagination_list.append('<li class="prev" style="display:none;"><a href="#" data-page="prev" class="page-prev">' + tm_pb_custom.prev + '</a></li>');
1084			for( var page = 1; page <= pages; page++ ) {
1085				var first_page_class = page === 1 ? ' active' : '',
1086					last_page_class = page === pages ? ' last-page' : '',
1087					hidden_page_class = page >= 5 ? ' style="display:none;"' : '';
1088				$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>');
1089			}
1090			$pagination_list.append('<li class="next"><a href="#" data-page="next" class="page-next">' + tm_pb_custom.next + '</a></li>');
1091		}
1092
1093		function set_gallery_hash( $the_gallery ) {
1094
1095			if ( !$the_gallery.attr('id') ) {
1096				return;
1097			}
1098
1099			var this_gallery_state = [];
1100			this_gallery_state.push( $the_gallery.attr('id') );
1101
1102			if ( $the_gallery.find('.tm_pb_gallery_pagination a.active').length ) {
1103				this_gallery_state.push( $the_gallery.find('.tm_pb_gallery_pagination a.active').data('page') );
1104			} else {
1105				this_gallery_state.push( 1 );
1106			}
1107
1108			this_gallery_state = this_gallery_state.join( tm_hash_module_param_seperator );
1109
1110			tm_set_hash( this_gallery_state );
1111		}
1112
1113		$tm_pb_gallery.each(function(){
1114			var $the_gallery = $(this);
1115
1116			if ( $the_gallery.hasClass( 'tm_pb_gallery_grid' ) ) {
1117
1118				$the_gallery.show();
1119				set_gallery_grid_items( $the_gallery );
1120
1121				$the_gallery.on('tm_hashchange', function( event ){
1122					var params = event.params;
1123					$the_gallery = $( '#' + event.target.id );
1124
1125					if ( page_to = params[0] ) {
1126						if ( !$the_gallery.find('.tm_pb_gallery_pagination a.page-' + page_to ).hasClass('active') ) {
1127							$the_gallery.find('.tm_pb_gallery_pagination a.page-' + page_to ).addClass('active').click();
1128						}
1129					}
1130				});
1131			}
1132
1133		});
1134
1135		$tm_pb_gallery.data('paginating', false );
1136		$tm_pb_gallery.on('click', '.tm_pb_gallery_pagination a', function(e){
1137			e.preventDefault();
1138
1139			var to_page = $(this).data('page'),
1140				$the_gallery = $(this).parents('.tm_pb_gallery'),
1141				$the_gallery_items_container = $the_gallery.find('.tm_pb_gallery_items'),
1142				$the_gallery_items = $the_gallery_items_container.find('.tm_pb_gallery_item');
1143
1144			if ( $the_gallery.data('paginating') ) {
1145				return;
1146			}
1147
1148			$the_gallery.data('paginating', true );
1149
1150			if ( $(this).hasClass('page-prev') ) {
1151				to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) - 1;
1152			} else if ( $(this).hasClass('page-next') ) {
1153				to_page = parseInt( $(this).parents('ul').find('a.active').data('page') ) + 1;
1154			}
1155
1156			$(this).parents('ul').find('a').removeClass('active');
1157			$(this).parents('ul').find('a.page-' + to_page ).addClass('active');
1158
1159			var current_index = $(this).parents('ul').find('a.page-' + to_page ).parent().index(),
1160				total_pages = $(this).parents('ul').find('li.page').length;
1161
1162			$(this).parent().nextUntil('.page-' + ( current_index + 3 ) ).show();
1163			$(this).parent().prevUntil('.page-' + ( current_index - 3 ) ).show();
1164
1165			$(this).parents('ul').find('li.page').each(function(i){
1166				if ( !$(this).hasClass('prev') && !$(this).hasClass('next') ) {
1167					if ( i < ( current_index - 3 ) ) {
1168						$(this).hide();
1169					} else if ( i > ( current_index + 1 ) ) {
1170						$(this).hide();
1171					} else {
1172						$(this).show();
1173					}
1174
1175					if ( total_pages - current_index <= 2 && total_pages - i <= 5 ) {
1176						$(this).show();
1177					} else if ( current_index <= 3 && i <= 4 ) {
1178						$(this).show();
1179					}
1180
1181				}
1182			});
1183
1184			if ( to_page > 1 ) {
1185				$(this).parents('ul').find('li.prev').show();
1186			} else {
1187				$(this).parents('ul').find('li.prev').hide();
1188			}
1189
1190			if ( $(this).parents('ul').find('a.active').hasClass('last-page') ) {
1191				$(this).parents('ul').find('li.next').hide();
1192			} else {
1193				$(this).parents('ul').find('li.next').show();
1194			}
1195
1196			$the_gallery_items.hide();
1197			var visible_items = $the_gallery_items.filter(function( index ) {
1198				return $(this).data('page') === to_page;
1199			}).show();
1200
1201			$the_gallery.data('paginating', false );
1202
1203			setTimeout(function(){
1204				set_gallery_hash( $the_gallery );
1205			}, 100 );
1206
1207			$( 'html, body' ).animate( { scrollTop : $the_gallery.offset().top - 200 }, 200 );
1208		});
1209
1210	} /*  end if ( $tm_pb_gallery.length ) */
1211
1212	if ( $tm_pb_counter_amount.length ) {
1213		$tm_pb_counter_amount.each(function(){
1214			var $bar_item           = $(this),
1215				bar_item_width      = $bar_item.attr( 'data-width' ),
1216				bar_item_padding    = Math.ceil( parseFloat( $bar_item.css('paddingLeft') ) ) + Math.
1216ceil( parseFloat( $bar_item.css('paddingRight') ) ),
1217				$bar_item_text      = $bar_item.children( '.tm_pb_counter_amount_number' ),
1218				bar_item_text_width = $bar_item_text.width() + bar_item_padding;
1219
1220			$bar_item.css({
1221				'width' : bar_item_width,
1222				'min-width' : bar_item_text_width
1223			});
1224		});
1225	} /* $tm_pb_counter_amount.length */
1226
1227	function tm_countdown_timer( timer ) {
1228		var end_date = parseInt( timer.data( 'end-timestamp') ),
1229			current_date = new Date().getTime() / 1000,
1230			seconds_left = ( end_date - current_date );
1231
1232		days = parseInt(seconds_left / 86400);
1233		days = days > 0 ? days : 0;
1234		seconds_left = seconds_left % 86400;
1235
1236		hours = parseInt(seconds_left / 3600);
1237		hours = hours > 0 ? hours : 0;
1238
1239		seconds_left = seconds_left % 3600;
1240
1241		minutes = parseInt(seconds_left / 60);
1242		minutes = minutes > 0 ? minutes : 0;
1243
1244		seconds = parseInt(seconds_left % 60);
1245		seconds = seconds > 0 ? seconds : 0;
1246
1247		if ( days == 0 ) {
1248			if ( !timer.find('.days > .value').parent('.section').hasClass('zero') ) {
1249				timer.find('.days > .value').html( '00' ).parent('.section').addClass('zero').next().addClass('zero');
1250			}
1251		} else {
1252			days_slice = days.toString().length >= 2 ? days.toString().length : 2;
1253			timer.find('.days > .value').html( ('00' + days).slice(-days_slice) );
1254		}
1255
1256		if ( days == 0 && hours == 0 ) {
1257			if ( !timer.find('.hours > .value').parent('.section').hasClass('zero') ) {
1258				timer.find('.hours > .value').html('00').parent('.section').addClass('zero').next().addClass('zero');
1259			}
1260		} else {
1261			timer.find('.hours > .value').html( ( '0' + hours ).slice(-2) );
1262		}
1263
1264		if ( days == 0 && hours == 0 && minutes == 0 ) {
1265			if ( !timer.find('.minutes > .value').parent('.section').hasClass('zero') ) {
1266				timer.find('.minutes > .value').html('00').parent('.section').addClass('zero').next().addClass('zero');
1267			}
1268		} else {
1269			timer.find('.minutes > .value').html( ( '0' + minutes ).slice(-2) );
1270		}
1271
1272		if ( days == 0 && hours == 0 && minutes == 0 && seconds == 0 ) {
1273			if ( !timer.find('.seconds > .value').parent('.section').hasClass('zero') ) {
1274				timer.find('.seconds > .value').html('00').parent('.section').addClass('zero');
1275			}
1276		} else {
1277			timer.find('.seconds > .value').html( ( '0' + seconds ).slice(-2) );
1278		}
1279	}
1280
1281	function tm_countdown_timer_labels( timer ) {
1282		if ( timer.closest( '.tm_pb_column_3_8' ).length || timer.closest( '.tm_pb_column_1_4' ).length || timer.children('.tm_pb_countdown_timer_container').width() <= 400 ) {
1283			timer.find('.days .label').html( timer.find('.days').data('short') );
1284			timer.find('.hours .label').html( timer.find('.hours').data('short') );
1285			timer.find('.minutes .label').html( timer.find('.minutes').data('short') );
1286			timer.find('.seconds .label').html( timer.find('.seconds').data('short') );
1287		} else {
1288			timer.find('.days .label').html( timer.find('.days').data('full') );
1289			timer.find('.hours .label').html( timer.find('.hours').data('full') );
1290			timer.find('.minutes .label').html( timer.find('.minutes').data('full') );
1291			timer.find('.seconds .label').html( timer.find('.seconds').data('full') );
1292		}
1293	}
1294
1295	if ( $tm_pb_countdown_timer.length ) {
1296		$tm_pb_countdown_timer.each(function(){
1297			var timer = $(this);
1298			tm_countdown_timer_labels( timer );
1299			tm_countdown_timer( timer );
1300			setInterval(function(){
1301				tm_countdown_timer( timer );
1302			}, 1000);
1303		});
1304	}
1305
1306	if ( $tm_pb_tabs.length ) {
1307		$tm_pb_tabs.tm_pb_simple_slider( {
1308			use_controls   : false,
1309			use_arrows     : false,
1310			slide          : '.tm_pb_all_tabs > div',
1311			tabs_animation : true
1312		} ).on('tm_hashchange', function( event ){
1313			var params = event.params;
1314			var $the_tabs = $( '#' + event.target.id );
1315			var active_tab = params[0];
1316			if ( !$the_tabs.find( '.tm_pb_tabs_controls li' ).eq( active_tab ).hasClass('tm_pb_tab_active') ) {
1317				$the_tabs.find( '.tm_pb_tabs_controls li' ).eq( active_tab ).click();
1318			}
1319		});
1320
1321		$tm_pb_tabs_li.click( function() {
1322			var $this_el        = $(this),
1323				$tabs_container = $this_el.closest( '.tm_pb_tabs' ).data('tm_pb_simple_slider');
1324
1325			if ( $tabs_container.tm_animation_running ) return false;
1326
1327			$this_el.addClass( 'tm_pb_tab_active' ).siblings().removeClass( 'tm_pb_tab_active' );
1328
1329			$tabs_container.data('tm_pb_simple_slider').tm_slider_move_to( $this_el.index() );
1330
1331			if ( $this_el.closest( '.tm_pb_tabs' ).attr('id') ) {
1332				var tab_state = [];
1333				tab_state.push( $this_el.closest( '.tm_pb_tabs' ).attr('id') );
1334				tab_state.push( $this_el.index() );
1335				tab_state = tab_state.join( tm_hash_module_param_seperator );
1336				tm_set_hash( tab_state );
1337			}
1338
1339			return false;
1340		} );
1341	}
1342
1343	if ( $tm_pb_map.length ) {
1344		google.maps.event.addDomListener(window, 'load', function() {
1345			$tm_pb_map.each(function(){
1346				var $this_map_container = $(this),
1347					$this_map = $this_map_container.children('.tm_pb_map'),
1348					this_map_grayscale = $this_map_container.data( 'grayscale' ) || 0,
1349					infowindow_active,
1350					marker_icon = $this_map.data( 'marker-icon' ) || [ tm_pb_custom.builder_images_uri + '/marker.png', 34, 53, false ],
1351					map_style = $this_map.data( 'map-style' );
1352
1353					if ( this_map_grayscale !== 0 ) {
1354						this_map_grayscale = '-' + this_map_grayscale.toString();
1355					}
1356
1357					$this_map_container.data('map', new google.maps.Map( $this_map[0], {
1358						zoom: parseInt( $this_map.data('zoom') ),
1359						center: new google.maps.LatLng( parseFloat( $this_map.data('center-lat') ) , parseFloat( $this_map.data('center-lng') )),
1360						mapTypeId: google.maps.MapTypeId.ROADMAP,
1361						scrollwheel: $this_map.data('mouse-wheel') == 'on' ? true : false,
1362						panControlOptions: {
1363							position: $this_map_container.is( '.tm_beneath_transparent_nav' ) ? google.maps.ControlPosition.LEFT_BOTTOM : google.maps.ControlPosition.LEFT_TOP
1364						},
1365						zoomControlOptions: {
1366							position: $this_map_container.is( '.tm_beneath_transparent_nav' ) ? google.maps.ControlPosition.LEFT_BOTTOM : google.maps.ControlPosition.LEFT_TOP
1367						},
1368						/*styles: [ {
1369							stylers: [
1370								{ saturation: parseInt( this_map_grayscale ) }
1371							]
1372						} ],*/
1373						styles: map_style
1374					}));
1375
1376					$this_map_container.data('bounds', new google.maps.LatLngBounds() );
1377					$this_map_container.find('.tm_pb_map_pin').each(function(){
1378
1379						var $this_marker = $(this),
1380							position = new google.maps.LatLng( parseFloat( $this_marker.data('lat') ) , parseFloat( $this_marker.data('lng') ) );
1381
1382						$this_map_container.data('bounds').extend( position );
1383
1384						var marker = new google.maps.Marker({
1385							position: position,
1386							map: $this_map_container.data('map'),
1387							title: $this_marker.data('title'),
1388							icon: {
1389								url: marker_icon[0],
1390								size: new google.maps.Size( marker_icon[1], marker_icon[2] ),
1391								anchor: new google.maps.Point( marker_icon[1] / 2, marker_icon[2] )
1392							},
1393							//shape: { coord: [1, 1, marker_icon[1], marker_icon[2] ], type: 'rect' },
1394						 //anchorPoint: new google.maps.Point(0, -45),
1395							animation: google.maps.Animation.DROP
1396						});
1397
1398						if ( $this_marker.find('.infowindow').length ) {
1399							var infowindow = new google.maps.InfoWindow({
1400								content: $this_marker.html()
1401							});
1402
1403							google.maps.event.addListener( $this_map_container.data('map'), 'click', function() {
1404								infowindow.close();
1405							});
1406
1407							google.maps.event.addListener(marker, 'click', function() {
1408								if( infowindow_active ) {
1409									infowindow_active.close();
1410								}
1411								infowindow_active = infowindow;
1412
1413								infowindow.open( $this_map_container.data('map'), marker );
1414							});
1415						}
1416					});
1417
1418					google.maps.event.addListener( $this_map_container.data('map'), 'bounds_changed', function() {
1419					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
1419() ) ) {
1420						$this_map_container.data('map').fitBounds( $this_map_container.data('bounds') );
1421					}
1422				});
1423			});
1424		} );
1425	}
1426
1427	if ( $tm_pb_shop.length ) {
1428		$tm_pb_shop.each( function() {
1429			var $this_el = $(this),
1430				icon     = $this_el.data('icon') || '';
1431
1432			if ( icon === '' ) {
1433				return true;
1434			}
1435
1436			$this_el.find( '.tm_overlay' )
1437				.attr( 'data-icon', icon )
1438				.addClass( 'tm_pb_inline_icon' );
1439		} );
1440	}
1441
1442	if ( $tm_pb_circle_counter.length ) {
1443
1444		window.tm_pb_circle_counter_init = function($the_counter, animate) {
1445			if ( 0 === $the_counter.width() ) {
1446				return;
1447			}
1448
1449			$the_counter.easyPieChart({
1450				animate: {
1451					duration: 1800,
1452					enabled: true
1453				},
1454				size: 0 !== $the_counter.width() ? $the_counter.width() : 10, // set the width to 10 if actual width is 0 to avoid js errors
1455				barColor: $the_counter.data( 'bar-bg-color' ),
1456				trackColor: $the_counter.data( 'color' ) || '#000000',
1457				trackAlpha: $the_counter.data( 'alpha' ) || '0.1',
1458				lineWidth: $the_counter.data( 'circle-width' ) || '5',
1459				size: $the_counter.data( 'circle-size' ) || '110',
1460				scaleColor: false,
1461				lineCap: $the_counter.data( 'bar-type' ) || 'round',
1462				onStart: function() {
1463					$(this.el).find('.percent p').css({ 'visibility' : 'visible' });
1464				},
1465				onStep: function(from, to, percent) {
1466					$(this.el).find('.percent-value').text( Math.round( parseInt( percent ) ) );
1467				},
1468				onStop: function(from, to) {
1469					$(this.el).find('.percent-value').text( $(this.el).data('number-value') );
1470				}
1471			});
1472		}
1473
1474		window.tm_pb_reinit_circle_counters = function( $tm_pb_circle_counter ) {
1475			$tm_pb_circle_counter.each(function(){
1476				var $the_counter = $(this);
1477				window.tm_pb_circle_counter_init($the_counter, false);
1478
1479				$the_counter.on('containerWidthChanged', function( event ){
1480					$the_counter = $( event.target );
1481					$the_counter.find('canvas').remove();
1482					$the_counter.removeData('easyPieChart' );
1483					window.tm_pb_circle_counter_init($the_counter, true);
1484				});
1485
1486			});
1487		}
1488		window.tm_pb_reinit_circle_counters( $tm_pb_circle_counter );
1489	}
1490
1491	if ( $tm_pb_number_counter.length ) {
1492		window.tm_pb_reinit_number_counters = function( $tm_pb_number_counter ) {
1493
1494			if ( $.fn.fitText ) {
1495				$tm_pb_number_counter.find( '.percent' ).fitText( 0.3 );
1496			}
1497
1498			$tm_pb_number_counter.each(function(){
1499				var $this_counter = $(this);
1500				$this_counter.easyPieChart({
1501					animate: {
1502						duration: 1800,
1503						enabled: true
1504					},
1505					size: 0,
1506					trackColor: false,
1507					scaleColor: false,
1508					lineWidth: 0,
1509					onStart: function() {
1510						$(this.el).find('.percent').css({ 'visibility' : 'visible' });
1511					},
1512					onStep: function(from, to, percent) {
1513						if ( percent != to )
1514							$(this.el).find('.percent-value').text( Math.round( parseInt( percent ) ) );
1515					},
1516					onStop: function(from, to) {
1517						$(this.el).find('.percent-value').text( $(this.el).data('number-value') );
1518					}
1519				});
1520			});
1521		}
1522		window.tm_pb_reinit_number_counters( $tm_pb_number_counter );
1523	}
1524
1525	function tm_apply_parallax() {
1526		var $this = $(this),
1527			element_top = $this.offset().top,
1528			window_top = $tm_window.scrollTop(),
1529			y_pos = ( ( ( window_top + $tm_window.height() ) - element_top ) * 0.3 ),
1530			main_position;
1531
1532		main_position = 'translate(0, ' + y_pos + 'px)';
1533
1534		$this.find('.tm_parallax_bg').css( {
1535			'-webkit-transform' : main_position,
1536			'-moz-transform'    : main_position,
1537			'-ms-transform'     : main_position,
1538			'transform'         : main_position
1539		} );
1540	}
1541
1542	function tm_parallax_set_height() {
1543		var $this = $(this),
1544			bg_height;
1545
1546		bg_height = ( $tm_window.height() * 0.3 + $this.innerHeight() );
1547
1548		$this.find('.tm_parallax_bg').css( { 'height' : bg_height } );
1549	}
1550
1551	$('.tm_pb_toggle_title').click( function(){
1552		var $this_heading         = $(this),
1553			$module               = $this_heading.closest('.tm_pb_toggle'),
1554			$section              = $module.parents( '.tm_pb_section' ),
1555			$content              = $module.find('.tm_pb_toggle_content'),
1556			$accordion            = $module.closest( '.tm_pb_accordion' ),
1557			is_accordion          = $accordion.length,
1558			is_accordion_toggling = $accordion.hasClass( 'tm_pb_accordion_toggling' ),
1559			$accordion_active_toggle;
1560
1561		if ( is_accordion ) {
1562			if ( $module.hasClass('tm_pb_toggle_open') || is_accordion_toggling ) {
1563				return false;
1564			}
1565
1566			$accordion.addClass( 'tm_pb_accordion_toggling' );
1567			$accordion_active_toggle = $module.siblings('.tm_pb_toggle_open');
1568		}
1569
1570		if ( $content.is( ':animated' ) ) {
1571			return;
1572		}
1573
1574		$content.slideToggle( 700, function() {
1575			if ( $module.hasClass('tm_pb_toggle_close') ) {
1576				$module.removeClass('tm_pb_toggle_close').addClass('tm_pb_toggle_open');
1577			} else {
1578				$module.removeClass('tm_pb_toggle_open').addClass('tm_pb_toggle_close');
1579			}
1580
1581			if ( $section.hasClass( 'tm_pb_section_parallax' ) && !$section.children().hasClass( 'tm_pb_parallax_css') ) {
1582				$.proxy( tm_parallax_set_height, $section )();
1583			}
1584		} );
1585
1586		if ( is_accordion ) {
1587			$accordion_active_toggle.find('.tm_pb_toggle_content').slideToggle( 700, function() {
1588				$accordion_active_toggle.removeClass( 'tm_pb_toggle_open' ).addClass('tm_pb_toggle_close');
1589				$accordion.removeClass( 'tm_pb_accordion_toggling' );
1590			} );
1591		}
1592	} );
1593
1594	var $tm_contact_container = $( '.tm_pb_contact_form_container' );
1595
1596	if ( $tm_contact_container.length ) {
1597		$tm_contact_container.each( function() {
1598			var $this_contact_container = $( this ),
1599				$tm_contact_form = $this_contact_container.find( 'form' ),
1600				$tm_contact_submit = $this_contact_container.find( 'input.tm_pb_contact_submit' ),
1601				$tm_inputs = $tm_contact_form.find( 'input[type=text],textarea' ),
1602				tm_email_reg = /^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$/,
1603				redirect_url = typeof $this_contact_container.data( 'redirect_url' ) !== 'undefined' ? $this_contact_container.data( 'redirect_url' ) : '';
1604
1605			$tm_contact_form.on( 'submit', function( event ) {
1606				var $this_contact_form = $( this ),
1607					$this_inputs = $this_contact_form.find( '.tm_pb_contact_form_input, .tm_pb_contact_captcha' ),
1608					this_tm_contact_error = false,
1609					$tm_contact_message = $this_contact_form.closest( '.tm_pb_contact_form_container' ).find( '.tm-pb-contact-message' ),
1610					tm_message = '',
1611					tm_fields_message = '',
1612					$this_contact_container = $this_contact_form.closest( '.tm_pb_contact_form_container' ),
1613					$captcha_field = $this_contact_form.find( '.tm_pb_contact_captcha' ),
1614					form_unique_id = typeof $this_contact_container.data( 'form_unique_num' ) !== 'undefined' ? $this_contact_container.data( 'form_unique_num' ) : 0,
1615					inputs_list = [];
1616				tm_message = '<ul>';
1617
1618				$this_inputs.removeClass( 'tm_contact_error' );
1619
1620				$this_inputs.each( function(){
1621					var $this_el = $( this ),
1622						this_val = $this_el.val(),
1623						this_label = $this_el.siblings( 'label' ).text(),
1624						field_type = typeof $this_el.data( 'field_type' ) !== 'undefined' ? $this_el.data( 'field_type' ) : 'text',
1625						required_mark = typeof $this_el.data( 'required_mark' ) !== 'undefined' ? $this_el.data( 'required_mark' ) : 'not_required',
1626						original_id = typeof $this_el.data( 'original_id' ) !== 'undefined' ? $this_el.data( 'original_id' ) : '',
1627						field_name;
1628
1629					// add current field data into array of inputs
1630					if ( typeof $this_el.attr( 'id' ) !== 'undefined' ) {
1631						inputs_list.push( { 'field_id' : $this_el.attr( 'id' ), 'original_id' : original_id, 'required_mark' : required_mark, 'field_type' : field_type, 'field_label' : this_label } );
1632					}
1633
1634					// add error message for the field if it is required and empty
1635					if ( 'required' === required_mark && ( '' === this_val || this_label === this_val || null === this_val ) ) {
1636						$this_el.addClass( 'tm_contact_error' );
1637						this_tm_contact_error = true;
1638
1639						field_name = $this_el.data( 'original_title' );
1640
1641						if ( ! field_name ) {
1642							field_name = $this_el.attr( 'name' );
1643						}
1644
1645						tm_fields_message += '<li>' + field_name + '</li>';
1646					}
1647
1648					// add error message if email field is not empty and fails the email validation
1649					if ( 'email' === field_type && '' !== this_val && this_label !== this_val && ! tm_email_reg.test( this_val ) ) {
1650						$this_el.addClass( 'tm_contact_error' );
1651						this_tm_contact_error = true;
1652
1653						if ( ! tm_email_reg.test( this_val ) ) {
1654							tm_message += '<li>' + tm_pb_custom.invalid + '</li>';
1655						}
1656					}
1657				});
1658
1659				// check the captcha value if required for current form
1660				if ( $captcha_field.length && '' !== $captcha_field.val() ) {
1661					var first_digit = parseInt( $captcha_field.data( 'first_digit' ) ),
1662						second_digit = parseInt( $captcha_field.data( 'second_digit' ) );
1663
1664					if ( parseInt( $captcha_field.val() ) !== first_digit + second_digit ) {
1665
1666						tm_message += '<li>' + tm_pb_custom.wrong_captcha + '</li>';
1667						this_tm_contact_error = true;
1668
1669						// generate new digits for captcha
1670						first_digit = Math.floor( ( Math.random() * 15 ) + 1 );
1671						second_digit = Math.floor( ( Math.random() * 15 ) + 1 );
1672
1673						// set new digits for captcha
1674						$captcha_field.data( 'first_digit', first_digit );
1675						$captcha_field.data( 'second_digit', second_digit );
1676
1677						// regenerate captcha on page
1678						$this_contact_form.find( '.tm_pb_contact_captcha_question' ).empty().append( first_digit  + ' + ' + second_digit );
1679					}
1680
1681				}
1682
1683				if ( ! this_tm_contact_error ) {
1684					var $href = $( this ).attr( 'action' ),
1685						form_data = $( this ).serializeArray();
1686
1687					form_data.push( { 'name': 'tm_pb_contact_email_fields_' + form_unique_id, 'value' : JSON.stringify( inputs_list ) } );
1688
1689					$this_contact_container.fadeTo( 'fast', 0.2 ).load( $href + ' #' + $this_contact_form.closest( '.tm_pb_contact_form_container' ).attr( 'id' ), form_data, function( responseText ) {
1690						// redirect if redirect URL is not empty and no errors in contact form
1691						if ( '' !== redirect_url && ! $( responseText ).find( '.tm_pb_contact_error_text').length ) {
1692							window.location.href = redirect_url;
1693						}
1694
1695						$this_contact_container.fadeTo( 'fast', 1 );
1696					} );
1697				}
1698
1699				tm_message += '</ul>';
1700
1701				if ( '' !== tm_fields_message ) {
1702					if ( tm_message != '<ul></ul>' ) {
1703						tm_message = '<p class="tm_normal_padding">' + tm_pb_custom.contact_error_message + '</p>' + tm_message;
1704					}
1705
1706					tm_fields_message = '<ul>' + tm_fields_message + '</ul>';
1707
1708					tm_fields_message = '<p>' + tm_pb_custom.fill_message + '</p>' + tm_fields_message;
1709
1710					tm_message = tm_fields_message + tm_message;
1711				}
1712
1713				if ( tm_message != '<ul></ul>' ) {
1714					$tm_contact_message.html( tm_message );
1715				}
1716
1717				event.preventDefault();
1718			});
1719		});
1720	}
1721
1722	$( '.tm_pb_video .tm_pb_video_overlay, .tm_pb_video_wrap .tm_pb_video_overlay' ).click( function() {
1723		var $this        = $(this),
1724			$video_image = $this.closest( '.tm_pb_video_overlay' );
1725
1726		$video_image.fadeTo( 500, 0, function() {
1727			var $image = $(this);
1728
1729			$image.css( 'display', 'none' );
1730		} );
1731
1732		return false;
1733	} );
1734
1735	function tm_pb_resize_section_video_bg( $video ) {
1736		$element = typeof $video !== 'undefined' ? $video.closest( '.tm_pb_section_video_bg' ) : $( '.tm_pb_section_video_bg' );
1737
1738		$element.each( function() {
1739			var $this_el = $(this),
1740				ratio = ( typeof $this_el.attr( 'data-ratio' ) !== 'undefined' )
1741					? $this_el.attr( 'data-ratio' )
1742					: $this_el.find('video').attr( 'width' ) / $this_el.find('video').attr( 'height' ),
1743				$video_elements = $this_el.find( '.mejs-video, video, object' ).css( 'margin', 0 ),
1744				$container = $this_el.closest( '.tm_pb_section_video' ).length
1745					? $this_el.closest( '.tm_pb_section_video' )
1746					: $this_el.closest( '.tm_pb_slides' ),
1747				body_width = $container.width(),
1748				container_height = $container.innerHeight(),
1749				width, height;
1750
1751			if ( typeof $this_el.attr( 'data-ratio' ) == 'undefined' )
1752				$this_el.attr( 'data-ratio', ratio );
1753
1754			if ( body_width / container_height < ratio ) {
1755				width = container_height * ratio;
1756				height = container_height;
1757			} else {
1758				width = body_width;
1759				height = body_width / ratio;
1760			}
1761
1762			$video_elements.width( width ).height( height );
1763		} );
1764	}
1765
1766	function tm_pb_center_video( $video ) {
1767		$element = typeof $video !== 'undefined' ? $video : $( '.tm_pb_section_video_bg .mejs-video' );
1768
1769		$element.each( function() {
1770			var $video_width = $(this).width() / 2;
1771			var $video_width_negative = 0 - $video_width;
1772			$(this).css("margin-left",$video_width_negative );
1773
1774			if ( typeof $video !== 'undefined' ) {
1775				if ( $video.closest( '.tm_pb_slider' ).length && ! $video.closest( '.tm_pb_first_video' ).length )
1776					return false;
1777			}
1778		} );
1779	}
1780
1781	function tm_fix_slider_height() {
1782		if ( ! $tm_pb_slider.length ) return;
1783
1784		$tm_pb_slider.each( function() {
1785			var $slide_section = $(this).parent( '.tm_pb_section' ),
1786				$slide = $(this).find( '.tm_pb_slide' ),
1787				$slide_container = $slide.find( '.tm_pb_container' ),
1788				max_height = 0;
1789
1790			// If this is appears at the first section benath transparent nav, skip it
1791			// leave it to tm_fix_page_container_position()
1792			if ( $slide_section.is( '.tm_pb_section_first' ) ){
1793				return true;
1794			}
1795
1796			$slide_container.css( 'min-height', 0 );
1797
1798			$slide.each( function() {
1799				var $this_el = $(this),
1800					height = $this_el.innerHeight();
1801
1802				if ( max_height < height )
1803					max_height = height;
1804			} );
1805
1806			$slide_container.css( 'min-height', max_height );
1807		} );
1808	}
1809
1810	/**
1811	 * Add conditional class to prevent unwanted dropdown nav
1812	 */
1813	function tm_fix_nav_direction() {
1814		window_width = $(window).width();
1815		$('.nav li.tm-reverse-direction-nav').removeClass( 'tm-reverse-direction-nav' );
1816		$('.nav li li ul').each(function(){
1817			var $dropdown       = $(this),
1818				dropdown_width  = $dropdown.width(),
1819				dropdown_offset = $dropdown.offset(),
1820				$parents        = $dropdown.parents('.nav > li');
1821
1822			if ( dropdown_offset.left > ( window_width - dropdown_width ) ) {
1823				$parents.addClass( 'tm-reverse-direction-nav' );
1824			}
1825		});
1826	}
1827	tm_fix_nav_direction();
1828
1829	tm_pb_form_placeholders_init( $( '.tm_pb_newsletter_form' ) );
1830
1831	$('.tm_pb_fullwidth_menu ul.nav').each(function(i) {
1832		i++;
1833		tm_duplicate_menu( $(this), $(this).parents('.tm_pb_row').find('div .mobile_nav'), 'mobile_menu' + i, 'tm_mobile_menu' );
1834	});
1835
1836	window.tm_fix_testimonial_inner_width = function() {
1837		var window_width = $( window ).width();
1838
1839		if( window_width > 767 ){
1840			$( '.tm_pb_testimonial' ).each( function() {
1841				if ( ! $(this).is(':visible') ) {
1842					return;
1843				}
1844
1845				var $testimonial      = $(this),
1846					testimonial_width = $testimonial.width(),
1847					$portrait         = $testimonial.find( '.tm_pb_testimonial_portrait' ),
1848					portrait_width    = $portrait.width(),
1849					$testimonial_inner= $testimonial.find( '.tm_pb_testimonial_description_inner' ),
1850					$outer_column     = $testimonial.closest( '.tm_pb_column' ),
1851					testimonial_inner_width = testimonial_width,
1852					subtract = ! ( $outer_column.hasClass( 'tm_pb_column_1_3' ) || $outer_column.hasClass( 'tm_pb_column_1_4' ) || $outer_column.hasClass( 'tm_pb_column_3_8' ) ) ? portrait_width + 31 : 0;
1853
1854					$testimonial_inner.width( testimonial_inner_width - subtract );
1855			} );
1856		} else {
1857			$( '.tm_pb_testimonial_description_inner' ).removeAttr( 'style' );
1858		}
1859	}
1860	window.tm_fix_testimonial_inner_width();
1861
1862	window.tm_reinint_waypoint_modules = function() {
1863		if ( $.fn.waypoint ) {
1864			var $tm_pb_circle_counter = $( '.tm_pb_circle_counter_bar' ),
1865				$tm_pb_number_counter = $( '.tm_pb_number_counter' );
1866
1867			$( '.tm_pb_counter_container, .tm-waypoint' ).waypoint( {
1868				offset: '75%',
1869				handler: function() {
1870					$(this.element).addClass( 'tm-animated' );
1871				}
1872			} );
1873
1874			if ( $tm_pb_circle_counter.length ) {
1875				$tm_pb_circle_counter.each(function(){
1876					var $this_counter = $(this);
1877					if ( ! $this_counter.is( ':visible' ) ) {
1878						return;
1879					}
1880					$this_counter.waypoint({
1881						offset: '65%',
1882						handler: function() {
1883							$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
1884						}
1885					});
1886				});
1887			}
1888
1889			if ( $tm_pb_number_counter.length ) {
1890				$tm_pb_number_counter.each(function(){
1891					var $this_counter = $(this);
1892					$this_counter.waypoint({
1893						offset: '75%',
1894						handler: function() {
1895							$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
1896						}
1897					});
1898				});
1899			}
1900		}
1901	}
1902
1903	window.tm_calc_fullscreen_section = function() {
1904		var $tm_window = $(window),
1905			$body = $( 'body' ),
1906			$wpadminbar = $( '#wpadminbar' ),
1907			tm_is_vertical_nav = $body.hasClass( 'tm_vertical_nav' ),
1908			$this_section = $(this),
1909			this_section_index = $this_section.index('.tm_pb_fullwidth_header'),
1910			$header = $this_section.children('.tm_pb_fullwidth_header_container'),
1911			$header_content = $header.children('.header-content-container'),
1912			$header_image = $header.children('.header-image-container'),
1913			sectionHeight = $tm_window.height(),
1914			$wpadminbar = $('#wpadminbar'),
1915			$top_header = $('#top-header'),
1916			$main_header = $('#main-header'),
1917			tm_header_height,
1918			secondary_nav_height;
1919
1920			secondary_nav_height = $top_header.length && $top_header.is( ':visible' ) ? $top_header.innerHe
1920ight() : 0;
1921			tm_header_height = $main_header.length ? $main_header.innerHeight() + secondary_nav_height : 0;
1922
1923		var calc_header_offset = ( $wpadminbar.length ) ? tm_header_height + $wpadminbar.innerHeight() - 1 : tm_header_height - 1;
1924
1925		// Section height adjustment differs in vertical and horizontal nav
1926		if ( $body.hasClass('tm_vertical_nav') ) {
1927			if ( $tm_window.width() >= 980 && $top_header.length ) {
1928				sectionHeight -= $top_header.height();
1929			}
1930
1931			if ( $wpadminbar.length ) {
1932				sectionHeight -= $wpadminbar.height();
1933			}
1934		} else {
1935			if ( $body.hasClass('tm_hide_nav' ) ) {
1936				// If user is logged in and hide navigation is in use, adjust the section height
1937				if ( $wpadminbar.length ) {
1938					sectionHeight -= $wpadminbar.height();
1939				}
1940
1941				// In mobile, header always appears. Adjust the section height
1942				if ( $tm_window.width() < 981 && ! $body.hasClass('tm_transparent_nav') ) {
1943					sectionHeight -= $('#main-header').height();
1944				}
1945			} else {
1946				if ( $this_section.offset().top <= calc_header_offset + 3 ) {
1947					if ( tm_is_vertical_nav ) {
1948						var $top_header = $('#top-header'),
1949							top_header_height = ( $top_header.length && 0 === $this_section.index( '.tm_pb_fullscreen' ) ) ? $top_header.height() : 0,
1950							wpadminbar_height = ( $wpadminbar.length && 0 === $this_section.index( '.tm_pb_fullscreen' ) ) ? $wpadminbar.height() : 0,
1951							calc_header_offset_vertical = wpadminbar_height + top_header_height;
1952
1953						sectionHeight -= calc_header_offset_vertical;
1954					} else {
1955						sectionHeight -= calc_header_offset;
1956					}
1957				}
1958			}
1959		}
1960
1961		// If the transparent primary nav + hide nav until scroll is being used,
1962		// cancel automatic padding-top added by transparent nav mechanism
1963		if ( $body.hasClass('tm_transparent_nav') && $body.hasClass( 'tm_hide_nav' ) &&  0 === this_section_index ) {
1964			$this_section.css( 'padding-top', '' );
1965		}
1966
1967		$this_section.css('min-height', sectionHeight + 'px' );
1968		$header.css('min-height', sectionHeight + 'px' );
1969
1970		if ( $header.hasClass('center') && $header_content.hasClass('bottom') && $header_image.hasClass('bottom') ) {
1971			$header.addClass('bottom-bottom');
1972		}
1973
1974		if ( $header.hasClass('center') && $header_content.hasClass('center') && $header_image.hasClass('center') ) {
1975			$header.addClass('center-center');
1976		}
1977
1978		if ( $header.hasClass('center') && $header_content.hasClass('center') && $header_image.hasClass('bottom') ) {
1979			$header.addClass('center-bottom');
1980
1981			var contentHeight = sectionHeight - $header_image.outerHeight( true );
1982
1983			if ( contentHeight > 0 ) {
1984				$header_content.css('min-height', contentHeight + 'px' );
1985			}
1986		}
1987
1988		if ( $header.hasClass('center') && $header_content.hasClass('bottom') && $header_image.hasClass('center') ) {
1989			$header.addClass('bottom-center');
1990		}
1991
1992		if ( ( $header.hasClass('left') || $header.hasClass('right') ) && !$header_content.length && $header_image.length ) {
1993			$header.css('justify-content', 'flex-end');
1994		}
1995
1996		if ( $header.hasClass('center') && $header_content.hasClass('bottom') && !$header_image.length ) {
1997			$header_content.find('.header-content').css( 'margin-bottom', 80 + 'px' );
1998		}
1999
2000		if ( $header_content.hasClass('bottom') && $header_image.hasClass('center') ) {
2001			$header_image.find('.header-image').css( 'margin-bottom', 80 + 'px' );
2002			$header_image.css('align-self', 'flex-end');
2003		}
2004	}
2005
2006	$( window ).resize( function(){
2007		var window_width                = $tm_window.width(),
2008			tm_container_css_width      = $tm_container.css( 'width' ),
2009			tm_container_width_in_pixel = ( typeof tm_container_css_width !== 'undefined' ) ? tm_container_css_width.substr( -1, 1 ) !== '%' : '',
2010			tm_container_actual_width   = ( tm_container_width_in_pixel ) ? $tm_container.width() : ( ( $tm_container.width() / 100 ) * window_width ), // $tm_container.width() doesn't recognize pixel or percentage unit. It's our duty to understand what it returns and convert it properly
2011			containerWidthChanged       = tm_container_width !== tm_container_actual_width;
2012
2013		tm_pb_resize_section_video_bg();
2014		tm_pb_center_video();
2015		tm_fix_slider_height();
2016		tm_fix_nav_direction();
2017
2018		$tm_pb_fullwidth_portfolio.each(function(){
2019			set_container_height = $(this).hasClass('tm_pb_fullwidth_portfolio_carousel') ? true : false;
2020			set_fullwidth_portfolio_columns( $(this), set_container_height );
2021		});
2022
2023		if ( containerWidthChanged ) {
2024			$('.container-width-change-notify').trigger('containerWidthChanged');
2025
2026			setTimeout( function() {
2027				$tm_pb_filterable_portfolio.each(function(){
2028					set_filterable_grid_items( $(this) );
2029				});
2030				$tm_pb_gallery.each(function(){
2031					if ( $(this).hasClass( 'tm_pb_gallery_grid' ) ) {
2032						set_gallery_grid_items( $(this) );
2033					}
2034				});
2035			}, 100 );
2036
2037			tm_container_width = tm_container_actual_width;
2038
2039			etRecalculateOffset = true;
2040
2041			if ( $tm_pb_circle_counter.length ) {
2042				$tm_pb_circle_counter.each(function(){
2043					var $this_counter = $(this);
2044					if ( ! $this_counter.is( ':visible' ) ) {
2045						return;
2046					}
2047
2048					$this_counter.data('easyPieChart').update( $this_counter.data('number-value') );
2049				});
2050			}
2051			if ( $tm_pb_countdown_timer.length ) {
2052				$tm_pb_countdown_timer.each(function(){
2053					var timer = $(this);
2054					tm_countdown_timer_labels( timer );
2055				} );
2056			}
2057		}
2058
2059		window.tm_fix_testimonial_inner_width();
2060
2061		tm_audio_module_set();
2062	} );
2063
2064	$( window ).ready( function(){
2065		if ( $.fn.fitVids ) {
2066			$( '.tm_pb_slide_video' ).fitVids();
2067			$( '.tm_pb_module' ).fitVids( { customSelector: "iframe[src^='http://www.hulu.com'], iframe[src^='http://www.dailymotion.com'], iframe[src^='http://www.funnyordie.com'], iframe[src^='https://embed-ssl.ted.com'], iframe[src^='http://embed.revision3.com'], iframe[src^='https://flickr.com'], iframe[src^='http://blip.tv'], iframe[src^='http://www.collegehumor.com']"} );
2068		}
2069
2070		tm_fix_video_wmode('.fluid-width-video-wrapper');
2071
2072		tm_fix_slider_height();
2073	} );
2074
2075	$( window ).load( function(){
2076		tm_fix_fullscreen_section();
2077
2078		$( 'section.tm_pb_fullscreen' ).each( function(){
2079			var $this_section = $( this );
2080
2081			$.proxy( tm_calc_fullscreen_section, $this_section )();
2082
2083			$tm_window.on( 'resize', $.proxy( tm_calc_fullscreen_section, $this_section ) );
2084		});
2085
2086		$( '.tm_pb_fullwidth_header_scroll a' ).click( function( event ) {
2087			event.preventDefault();
2088
2089			var $this_section      = $(this).parents( 'section' ),
2090				is_next_fullscreen = $this_section.next().hasClass( 'tm_pb_fullscreen' ),
2091				$wpadminbar        = $('#wpadminbar'),
2092				wpadminbar_height  = ( $wpadminbar.length && ! is_next_fullscreen ) ? $wpadminbar.height() : 0,
2093				main_header_height = is_next_fullscreen || ! tm_is_fixed_nav ? 0 : $main_header.height(),
2094				top_header_height  = is_next_fullscreen || ! tm_is_fixed_nav ? 0 : $top_header.height(),
2095				section_bottom     = $this_section.offset().top + $this_section.outerHeight( true ) - ( wpadminbar_height + top_header_height + main_header_height );
2096
2097			if ( $this_section.length ) {
2098				$( 'html, body' ).animate( { scrollTop : section_bottom }, 800 );
2099
2100				if ( ! $( '#main-header' ).hasClass( 'tm-fixed-header' ) && $( 'body' ).hasClass( 'tm_fixed_nav' ) && $( window ).width() > 980 ) {
2101					setTimeout(function(){
2102						var section_offset_top = $this_section.offset().top,
2103							section_height     = $this_section.outerHeight( true ),
2104							main_header_height = is_next_fullscreen ? 0 : $main_header.height(),
2105							section_bottom     = section_offset_top + section_height - ( main_header_height + top_header_height + wpadminbar_height);
2106
2107						$( 'html, body' ).animate( { scrollTop : section_bottom }, 280, 'linear' );
2108					}, 780 );
2109				}
2110			}
2111		});
2112
2113		setTimeout( function() {
2114			$( '.tm_pb_preload' ).removeClass( 'tm_pb_preload' );
2115		}, 500 );
2116
2117		if ( $.fn.hashchange ) {
2118			$(window).hashchange( function(){
2119				var hash = window.location.hash.substring(1);
2120				process_tm_hashchange( hash );
2121			});
2122			$(window).hashchange();
2123		}
2124
2125		if ( $tm_pb_parallax.length && !tm_is_mobile_device ) {
2126			$tm_pb_parallax.each(function(){
2127				if ( $(this).hasClass('tm_pb_parallax_css') ) {
2128					return;
2129				}
2130
2131				var $this_parent = $(this).parent();
2132
2133				$.proxy( tm_parallax_set_height, $this_parent )();
2134
2135				$.proxy( tm_apply_parallax, $this_parent )();
2136
2137				$tm_window.on( 'scroll', $.proxy( tm_apply_parallax, $this_parent ) );
2138
2139				$tm_window.on( 'resize', $.proxy( tm_parallax_set_height, $this_parent ) );
2140				$tm_window.on( 'resize', $.proxy( tm_apply_parallax, $this_parent ) );
2141
2142				$this_parent.find('.tm-learn-more .heading-more').click( function() {
2143					setTimeout(function(){
2144						$.proxy( tm_parallax_set_height, $this_parent )();
2145					}, 300 );
2146				});
2147			});
2148		}
2149
2150		tm_audio_module_set();
2151
2152		window.tm_reinint_waypoint_modules();
2153	} );
2154
2155	if ( $( '.tm_section_specialty' ).length ) {
2156		$( '.tm_section_specialty' ).each( function() {
2157			var this_row = $( this ).find( '.tm_pb_row' );
2158
2159			this_row.find( '>.tm_pb_column:not(.tm_pb_specialty_column)' ).addClass( 'tm_pb_column_single' );
2160		});
2161	}
2162
2163	/**
2164	* In particular browser, map + parallax doesn't play well due the use of CSS 3D transform
2165	*/
2166	if ( $('.tm_pb_section_parallax').length && $('.tm_pb_map').length ) {
2167		$('body').addClass( 'parallax-map-support' );
2168	}
2169
2170	/**
2171	 * Add conditional class for search widget in sidebar module
2172	 */
2173	$('.tm_pb_widget_area ' + tm_pb_custom.widget_search_selector ).each( function() {
2174		var $search_wrap              = $(this),
2175			$search_input_submit      = $search_wrap.find('input[type="submit"]'),
2176			search_input_submit_text = $search_input_submit.attr( 'value' ),
2177			$search_button            = $search_wrap.find('button'),
2178			search_button_text       = $search_button.text(),
2179			has_submit_button         = $search_input_submit.length || $search_button.length ? true : false,
2180			min_column_width          = 150;
2181
2182		if ( ! $search_wrap.find( 'input[type="text"]' ).length && ! $search_wrap.find( 'input[type="search"]' ).length ) {
2183			return;
2184		}
2185
2186		// Mark no button state
2187		if ( ! has_submit_button ) {
2188			$search_wrap.addClass( 'tm-no-submit-button' );
2189		}
2190
2191		// Mark narrow state
2192		if ( $search_wrap.width() < 150 ) {
2193			$search_wrap.addClass( 'tm-narrow-wrapper' );
2194		}
2195
2196		// Fixes issue where theme's search button has no text: treat it as non-existent
2197		if ( $search_input_submit.length && ( typeof search_input_submit_text == 'undefined' || search_input_submit_text === '' ) ) {
2198			$search_input_submit.remove();
2199			$search_wrap.addClass( 'tm-no-submit-button' );
2200		}
2201
2202		if ( $search_button.length && ( typeof search_button_text == 'undefined' || search_button_text === '' ) ) {
2203			$search_button.remove();
2204			$search_wrap.addClass( 'tm-no-submit-button' );
2205		}
2206
2207	} );
2208
2209	if ( $( '.tm_pb_search' ).length ) {
2210		$( '.tm_pb_search' ).each( function() {
2211			var $this_module = $( this ),
2212				$input_field = $this_module.find( '.tm_pb_s' ),
2213				$button = $this_module.find( '.tm_pb_searchsubmit' ),
2214				input_padding = $this_module.hasClass( 'tm_pb_text_align_right' ) ? 'paddingLeft' : 'paddingRight',
2215				disabled_button = $this_module.hasClass( 'tm_pb_hide_search_button' );
2216
2217			if ( $button.innerHeight() > $input_field.innerHeight() ) {
2218				$input_field.height( $button.innerHeight() );
2219			}
2220
2221			if ( ! disabled_button ) {
2222				$input_field.css( input_padding, $button.innerWidth() + 10 );
2223			}
2224		});
2225	}
2226
2227	// apply required classes for the Reply buttons in Comments Module
2228	if ( $( '.tm_pb_comments_module' ).length ) {
2229		$( '.tm_pb_comments_module' ).each( function() {
2230			var $comments_module = $( this ),
2231				$comments_module_button = $comments_module.find( '.comment-reply-link' );
2232
2233			if ( $comments_module_button.length ) {
2234				$comments_module_button.addClass( 'tm_pb_button' );
2235
2236				if ( typeof $comments_module.data( 'icon' ) !== 'undefined' ) {
2237					$comments_module_button.attr( 'data-icon', $comments_module.data( 'icon' ) );
2238					$comments_module_button.addClass( 'tm_pb_custom_button_icon' );
2239				}
2240			}
2241		});
2242	}
2243
2244	//  Carousel Module
2245	if ( $( '.tm_pb_swiper' )[0] ) {
2246		$( '.tm_pb_swiper' ).each( function() {
2247			var $this = $( this ),
2248				settings = $this.data('settings'),
2249				pagination = ( 'on' === settings['pagination'] ) ? true : false ,
2250				navigateButton = ( 'on' === settings['navigateButton'] ) ? true : false ,
2251				autoplay = ( 'on' === settings['autoplay'] ) ? 3500 : false ,
2252				centeredSlides = ( 'on' === settings['centeredSlides'] ) ? true : false ,
2253				spaceBetweenSlides = settings['spaceBetweenSlides'] || 0 ,
2254				slidesPerView = settings['slidesPerView'],
2255				swiperContainer = $( '.swiper-container', $this ),
2256				swiper = new Swiper( swiperContainer , {
2257						slidesPerView: +slidesPerView,
2258						autoplay: autoplay,
2259						centeredSlides: centeredSlides,
2260						mousewheelControl: false,
2261						paginationClickable: true,
2262						spaceBetween: +spaceBetweenSlides,
2263						speed: 500,
2264						nextButton: $('.swiper-button-next', $this),
2265						prevButton: $('.swiper-button-prev', $this),
2266						pagination: $('.swiper-pagination', $this),
2267						onInit: function(){
2268							if ( navigateButton ) {
2269								$('.swiper-button-next, .swiper-button-prev', $this).css({ 'display': 'block' });
2270							}
2271							if ( ! pagination ) {
2272								$('.swiper-pagination', $this).css({ 'display': 'none' });
2273							}
2274						},
2275						breakpoints: {
2276							1200: {
2277								slidesPerView: Math.floor( slidesPerView * 0.75 ),
2278								spaceBetween: Math.floor( spaceBetweenSlides * 0.75 )
2279							},
2280							992: {
2281								slidesPerView: Math.floor( slidesPerView * 0.5 ),
2282								spaceBetween: Math.floor( spaceBetweenSlides * 0.5 )
2283							},
2284							769: {
2285								slidesPerView: ( 0 !== Math.floor( slidesPerView * 0.25 ) ) ? Math.floor( slidesPerView * 0.25 ) : 1
2286							},
2287						}
2288				});
2289		});
2290
2291		$( window ).on( 'load', loadHandler );
2292		function loadHandler() {
2293			$( '.tm_pb_swiper' ).css({ 'opacity': '1' });
2294		}
2295	}
2296
2297})}catch(e){console.log(e)}try{/**
2298 * Swiper 3.3.1
2299 * Most modern mobile touch slider and framework with hardware accelerated transitions
2300 * 
2301 * http://www.idangero.us/swiper/
2302 * 
2303 * Copyright 2016, Vladimir Kharlampidi
2304 * The iDangero.us
2305 * http://www.idangero.us/
2306 * 
2307 * Licensed under MIT
2308 * 
2309 * Released on: February 7, 2016
2310 */
2311(function () {
2312    'use strict';
2313    var $;
2314    /*===========================
2315    Swiper
2316    ===========================*/
2317    var Swiper = function (container, params) {
2318        if (!(this instanceof Swiper)) return new Swiper(container, params);
2319
2320        var defaults = {
2321            direction: 'horizontal',
2322            touchEventsTarget: 'container',
2323            initialSlide: 0,
2324            speed: 300,
2325            // autoplay
2326            autoplay: false,
2327            autoplayDisableOnInteraction: true,
2328            autoplayStopOnLast: false,
2329            // To support iOS's swipe-to-go-back gesture (when being used in-app, with UIWebView).
2330            iOSEdgeSwipeDetection: false,
2331            iOSEdgeSwipeThreshold: 20,
2332            // Free mode
2333            freeMode: false,
2334            freeModeMomentum: true,
2335            freeModeMomentumRatio: 1,
2336            freeModeMomentumBounce: true,
2337            freeModeMomentumBounceRatio: 1,
2338            freeModeSticky: false,
2339            freeModeMinimumVelocity: 0.02,
2340            // Autoheight
2341            autoHeight: false,
2342            // Set wrapper width
2343            setWrapperSize: false,
2344            // Virtual Translate
2345            virtualTranslate: false,
2346            // Effects
2347            effect: 'slide', // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
2348            coverflow: {
2349                rotate: 50,
2350                stretch: 0,
2351                depth: 100,
2352                modifier: 1,
2353                slideShadows : true
2354            },
2355            flip: {
2356                slideShadows : true,
2357                limitRotation: true
2358            },
2359            cube: {
2360                slideShadows: true,
2361                shadow: true,
2362                shadowOffset: 20,
2363                shadowScale: 0.94
2364            },
2365            fade: {
2366                crossFade: false
2367            },
2368            // Parallax
2369            parallax: false,
2370            // Scrollbar
2371            scrollbar: null,
2372            scrollbarHide: true,
2373            scrollbarDraggable: false,
2374            scrollbarSnapOnRelease: false,
2375            // Keyboard Mousewheel
2376            keyboardControl: false,
2377            mousewheelControl: false,
2378            mousewheelReleaseOnEdges: false,
2379            mousewheelInvert: false,
2380            mousewheelForceToAxis: false,
2381            mousewheelSensitivity: 1,
2382            // Hash Navigation
2383            hashnav: false,
2384            // Breakpoints
2385            breakpoints: undefined,
2386            // Slides grid
2387            spaceBetween: 0,
2388            slidesPerView: 1,
2389            slidesPerColumn: 1,
2390            slidesPerColumnFill: 'column',
2391            slidesPerGroup: 1,
2392            centeredSlides: false,
2393            slidesOffsetBefore: 0, // in px
2394            slidesOffsetAfter: 0, // in px
2395            // Round length
2396            roundLengths: false,
2397            // Touches
2398            touchRatio: 1,
2399            touchAngle: 45,
2400            simulateTouch: true,
2401            shortSwipes: true,
2402            longSwipes: true,
2403            longSwipesRatio: 0.5,
2404            longSwipesMs: 300,
2405            followFinger: true,
2406            onlyExternal: false,
2407            threshold: 0,
2408            touchMoveStopPropagation: true,
2409            // Unique Navigation Elements
2410            uniqueNavElements: true,
2411            // Pagination
2412            pagination: null,
2413            paginationElement: 'span',
2414            paginationClickable: false,
2415            paginationHide: false,
2416            paginationBulletRender: null,
2417            paginationProgressRender: null,
2418            paginationFractionRender: null,
2419            paginationCustomRender: null,
2420            paginationType: 'bullets', // 'bullets' or 'progress' or 'fraction' or 'custom'
2421            // Resistance
2422            resistance: true,
2423            resistanceRatio: 0.85,
2424            // Next/prev buttons
2425            nextButton: null,
2426            prevButton: null,
2427            // Progress
2428            watchSlidesProgress: false,
2429            watchSlidesVisibility: false,
2430            // Cursor
2431            grabCursor: false,
2432            // Clicks
2433            preventClicks: true,
2434            preventClicksPropagation: true,
2435            slideToClickedSlide: false,
2436            // Lazy Loading
2437            lazyLoading: false,
2438            lazyLoadingInPrevNext: false,
2439            lazyLoadingInPrevNextAmount: 1,
2440            lazyLoadingOnTransitionStart: false,
2441            // Images
2442            preloadImages: true,
2443            updateOnImagesReady: true,
2444            // loop
2445            loop: false,
2446            loopAdditionalSlides: 0,
2447            loopedSlides: null,
2448            // Control
2449            control: undefined,
2450            controlInverse: false,
2451            controlBy: 'slide', //or 'container'
2452            // Swiping/no swiping
2453            allowSwipeToPrev: true,
2454            allowSwipeToNext: true,
2455            swipeHandler: null, //'.swipe-handler',
2456            noSwiping: true,
2457            noSwipingClass: 'swiper-no-swiping',
2458            // NS
2459            slideClass: 'swiper-slide',
2460            slideActiveClass: 'swiper-slide-active',
2461            slideVisibleClass: 'swiper-slide-visible',
2462            slideDuplicateClass: 'swiper-slide-duplicate',
2463            slideNextClass: 'swiper-slide-next',
2464            slidePrevClass: 'swiper-slide-prev',
2465            wrapperClass: 'swiper-wrapper',
2466            bulletClass: 'swiper-pagination-bullet',
2467            bulletActiveClass: 'swiper-pagination-bullet-active',
2468            buttonDisabledClass: 'swiper-button-disabled',
2469            paginationCurrentClass: 'swiper-pagination-current',
2470            paginationTotalClass: 'swiper-pagination-total',
2471            paginationHiddenClass: 'swiper-pagination-hidden',
2472            paginationProgressbarClass: 'swiper-pagination-progressbar',
2473            // Observer
2474            observer: false,
2475            observeParents: false,
2476            // Accessibility
2477            a11y: false,
2478            prevSlideMessage: 'Previous slide',
2479            nextSlideMessage: 'Next slide',
2480            firstSlideMessage: 'This is the first slide',
2481            lastSlideMessage: 'This is the last slide',
2482            paginationBulletMessage: 'Go to slide {{index}}',
2483            // Callbacks
2484            runCallbacksOnInit: true
2485            /*
2486            Callbacks:
2487            onInit: function (swiper)
2488            onDestroy: function (swiper)
2489            onClick: function (swiper, e)
2490            onTap: function (swiper, e)
2491            onDoubleTap: function (swiper, e)
2492            onSliderMove: function (swiper, e)
2493            onSlideChangeStart: function (swiper)
2494            onSlideChangeEnd: function (swiper)
2495            onTransitionStart: function (swiper)
2496            onTransitionEnd: function (swiper)
2497            onImagesReady: function (swiper)
2498            onProgress: function (swiper, progress)
2499            onTouchStart: function (swiper, e)
2500            onTouchMove: function (swiper, e)
2501            onTouchMoveOpposite: function (swiper, e)
2502            onTouchEnd: function (swiper, e)
2503            onReachBeginning: function (swiper)
2504            onReachEnd: function (swiper)
2505            onSetTransition: function (swiper, duration)
2506            onSetTranslate: function (swiper, translate)
2507            onAutoplayStart: function (swiper)
2508            onAutoplayStop: function (swiper),
2509            onLazyImageLoad: function (swiper, slide, image)
2510            onLazyImageReady: function (swiper, slide, image)
2511            */
2512        
2513        };
2514        var initialVirtualTranslate = params && params.virtualTranslate;
2515        
2516        params = params || {};
2517        var originalParams = {};
2518        for (var param in params) {
2519            if (typeof params[param] === 'object' && params[param] !== null && !(params[param].nodeType || params[param] === window || params[param] === document || (typeof Dom7 !== 'undefined' && params[param] instanceof Dom7) || (typeof jQuery !== 'undefined' && params[param] instanceof jQuery))) {
2520                originalParams[param] = {};
2521                for (var deepParam in params[param]) {
2522                    originalParams[param][deepParam] = params[param][deepParam];
2523                }
2524            }
2525            else {
2526                originalParams[param] = params[param];
2527            }
2528        }
2529        for (var def in defaults) {
2530            if (typeof params[def] === 'undefined') {
2531                params[def] = defaults[def];
2532            }
2533            else if (typeof params[def] === 'object') {
2534                for (var deepDef in defaults[def]) {
2535                    if (typeof params[def][deepDef] === 'undefined') {
2536                        params[def][deepDef] = defaults[def][deepDef];
2537                    }
2538                }
2539            }
2540        }
2541        
2542        // Swiper
2543        var s = this;
2544        
2545        // Params
2546        s.params = params;
2547        s.originalParams = originalParams;
2548        
2549        // Classname
2550        s.classNames = [];
2551        /*=========================
2552          Dom Library and plugins
2553          ===========================*/
2554        if (typeof $ !== 'undefined' && typeof Dom7 !== 'undefined'){
2555            $ = Dom7;
2556        }
2557        if (typeof $ === 'undefined') {
2558            if (typeof Dom7 === 'undefined') {
2559                $ = window.Dom7 || window.Zepto || window.jQuery;
2560            }
2561            else {
2562                $ = Dom7;
2563            }
2564            if (!$) return;
2565        }
2566        // Export it to Swiper instance
2567        s.$ = $;
2568        
2569        /*=========================
2570          Breakpoints
2571          ===========================*/
2572        s.currentBreakpoint = undefined;
2573        s.getActiveBreakpoint = function () {
2574            //Get breakpoint for window width
2575            if (!s.params.breakpoints) return false;
2576            var breakpoint = false;
2577            var points = [], point;
2578            for ( point in s.params.breakpoints ) {
2579                if (s.params.breakpoints.hasOwnProperty(point)) {
2580                    points.push(point);
2581                }
2582            }
2583            points.sort(function (a, b) {
2584                return parseInt(a, 10) > parseInt(b, 10);
2585            });
2586            for (var i = 0; i < points.length; i++) {
2587                point = points[i];
2588                if (point >= window.innerWidth && !breakpoint) {
2589                    breakpoint = point;
2590                }
2591            }
2592            return breakpoint || 'max';
2593        };
2594        s.setBreakpoint = function () {
2595            //Set breakpoint for window width and update parameters
2596            var breakpoint = s.getActiveBreakpoint();
2597            if (breakpoint && s.currentBreakpoint !== breakpoint) {
2598                var breakPointsParams = breakpoint in s.params.breakpoints ? s.params.breakpoints[breakpoint] : s.originalParams;
2599                var needsReLoop = s.params.loop && (breakPointsParams.slidesPerView !== s.params.slidesPerView);
2600                for ( var param in breakPointsParams ) {
2601                    s.params[param] = breakPointsParams[param];
2602                }
2603                s.currentBreakpoint = breakpoint;
2604                if(needsReLoop && s.destroyLoop) {
2605                    s.reLoop(true);
2606                }
2607            }
2608        };
2609        // Set breakpoint on load
2610        if (s.params.breakpoints) {
2611            s.setBreakpoint();
2612        }
2613        
2614        /*=========================
2615          Preparation - Define Container, Wrapper and Pagination
2616          ===========================*/
2617        s.container = $(container);
2618        if (s.container.length === 0) return;
2619        if (s.container.length > 1) {
2620            var swipers = [];
2621            s.container.each(function () {
2622                var container = this;
2623                swipers.push(new Swiper(this, params));
2624            });
2625            return swipers;
2626        }
2627        
2628        // Save instance in container HTML Element and in data
2629        s.container[0].swiper = s;
2630        s.container.data('swiper', s);
2631        
2632        s.classNames.push('swiper-container-' + s.params.direction);
2633        
2634        if (s.params.freeMode) {
2635            s.classNames.push('swiper-container-free-mode');
2636        }
2637        if (!s.support.flexbox) {
2638            s.classNames.push('swiper-container-no-flexbox');
2639            s.params.slidesPerColumn = 1;
2640        }
2641        if (s.params.autoHeight) {
2642            s.classNames.push('swiper-container-autoheight');
2643        }
2644        // Enable slides progress when required
2645        if (s.params.parallax || s.params.watchSlidesVisibility) {
2646            s.params.watchSlidesProgress = true;
2647        }
2648        // Coverflow / 3D
2649        if (['cube', 'coverflow', 'flip'].indexOf(s.params.effect) >= 0) {
2650            if (s.support.transforms3d) {
2651                s.params.watchSlidesProgress = true;
2652                s.classNames.push('swiper-container-3d');
2653            }
2654            else {
2655                s.params.effect = 'slide';
2656            }
2657        }
2658        if (s.params.effect !== 'slide') {
2659            s.classNames.push('swiper-container-' + s.params.effect);
2660        }
2661        if (s.params.effect === 'cube') {
2662            s.params.resistanceRatio = 0;
2663            s.params.slidesPerView = 1;
2664            s.params.slidesPerColumn = 1;
2665            s.params.slidesPerGroup = 1;
2666            s.params.centeredSlides = false;
2667            s.params.spaceBetween = 0;
2668            s.params.virtualTranslate = true;
2669            s.params.setWrapperSize = false;
2670        }
2671        if (s.params.effect === 'fade' || s.params.effect === 'flip') {
2672            s.params.slidesPerView = 1;
2673            s.params.slidesPerColumn = 1;
2674            s.params.slidesPerGroup = 1;
2675            s.params.watchSlidesProgress = true;
2676            s.params.spaceBetween = 0;
2677            s.params.setWrapperSize = false;
2678            if (typeof initialVirtualTranslate === 'undefined') {
2679                s.params.virtualTranslate = true;
2680            }
2681        }
2682        
2683        // Grab Cursor
2684        if (s.params.grabCursor && s.support.touch) {
2685            s.params.grabCursor = false;
2686        }
2687        
2688        // Wrapper
2689        s.wrapper = s.container.children('.' + s.params.wrapperClass);
2690        
2691        // Pagination
2692        if (s.params.pagination) {
2693            s.paginationContainer = $(s.params.pagination);
2694            if (s.params.uniqueNavElements && typeof s.params.pagination === 'string' && s.paginationContainer.length > 1 && s.container.find(s.params.pagination).length === 1) {
2695                s.paginationContainer = s.container.find(s.params.pagination);
2696            }
2697        
2698            if (s.params.paginationType === 'bullets' && s.params.paginationClickable) {
2699                s.paginationContainer.addClass('swiper-pagination-clickable');
2700            }
2701            else {
2702                s.params.paginationClickable = false;
2703            }
2704            s.paginationContainer.addClass('swiper-pagination-' + s.params.paginationType);
2705        }
2706        // Next/Prev Buttons
2707        if (s.params.nextButton || s.params.prevButton) {
2708            if (s.params.nextButton) {
2709                s.nextButton = $(s.params.nextButton);
2710                if (s.params.uniqueNavElements && typeof s.params.nextButton === 'string' && s.nextButton.length > 1 && s.container.find(s.params.nextButton).length === 1) {
2711                    s.nextButton = s.container.find(s.params.nextButton);
2712                }
2713            }
2714            if (s.params.prevButton) {
2715                s.prevButton = $(s.params.prevButton);
2716                if (s.params.uniqueNavElements && typeof s.params.prevButton === 'string' && s.prevButton.length > 1 && s.container.find(s.params.prevButton).length === 1) {
2717                    s.prevButton = s.container.find(s.params.prevButton);
2718                }
2719            }
2720        }
2721        
2722        // Is Horizontal
2723        s.isHorizontal = function () {
2724            return s.params.direction === 'horizontal';
2725        };
2726        // s.isH = isH;
2727        
2728        // RTL
2729        s.rtl = s.isHorizontal() && (s.container[0].dir.toLowerCase() === 'rtl' || s.container.css('direction') === 'rtl');
2730        if (s.rtl) {
2731            s.classNames.push('swiper-container-rtl');
2732        }
2733        
2734        // Wrong RTL support
2735        if (s.rtl) {
2736            s.wrongRTL = s.wrapper.css('display') === '-webkit-box';
2737        }
2738        
2739        // Columns
2740        if (s.params.slidesPerColumn > 1) {
2741            s.classNames.push('swiper-container-multirow');
2742        }
2743        
2744        // Check for Android
2745        if (s.device.android) {
2746            s.classNames.push('swiper-container-android');
2747        }
2748        
2749        // Add classes
2750        s.container.addClass(s.classNames.join(' '));
2751        
2752        // Translate
2753        s.translate = 0;
2754        
2755        // Progress
2756        s.progress = 0;
2757        
2758        // Velocity
2759        s.velocity = 0;
2760        
2761        /*=========================
2762          Locks, unlocks
2763          ===========================*/
2764        s.lockSwipeToNext = function () {
2765            s.params.allowSwipeToNext = false;
2766        };
2767        s.lockSwipeToPrev = function () {
2768            s.params.allowSwipeToPrev = false;
2769        };
2770        s.lockSwipes = function () {
2771            s.params.allowSwipeToNext = s.params.allowSwipeToPrev = false;
2772        };
2773        s.unlockSwipeToNext = function () {
2774            s.params.allowSwipeToNext = true;
2775        };
2776        s.unlockSwipeToPrev = function () {
2777            s.params.allowSwipeToPrev = true;
2778        };
2779        s.unlockSwipes = function () {
2780            s.params.allowSwipeToNext = s.params.allowSwipeToPrev = true;
2781        };
2782        
2783        /*=========================
2784          Round helper
2785          ===========================*/
2786        function round(a) {
2787            return Math.floor(a);
2788        }
2789        /*=========================
2790          Set grab cursor
2791          ===========================*/
2792        if (s.params.grabCursor) {
2793            s.container[0].style.cursor = 'move';
2794            s.container[0].style.cursor = '-webkit-grab';
2795            s.container[0].style.cursor = '-moz-grab';
2796            s.container[0].style.cursor = 'grab';
2797        }
2798        /*=========================
2799          Update on Images Ready
2800          ===========================*/
2801        s.imagesToLoad = [];
2802        s.imagesLoaded = 0;
2803        
2804        s.loadImage = function (imgElement, src, srcset, checkForComplete, callback) {
2805            var image;
2806            function onReady () {
2807                if (callback) callback();
2808            }
2809            if (!imgElement.complete || !checkForComplete) {
2810                if (src) {
2811                    image = new window.Image();
2812                    image.onload = onReady;
2813                    image.onerror = onReady;
2814                    if (srcset) {
2815                        image.srcset = srcset;
2816                    }
2817                    if (src) {
2818                        image.src = src;
2819                    }
2820                } else {
2821                    onReady();
2822                }
2823        
2824            } else {//image already loaded...
2825                onReady();
2826            }
2827        };
2828        s.preloadImages = function () {
2829            s.imagesToLoad = s.container.find('img');
2830            function _onReady() {
2831                if (typeof s === 'undefined' || s === null) return;
2832                if (s.imagesLoaded !== undefined) s.imagesLoaded++;
2833                if (s.imagesLoaded === s.imagesToLoad.length) {
2834                    if (s.params.updateOnImagesReady) s.update();
2835                    s.emit('onImagesReady', s);
2836                }
2837            }
2838            for (var i = 0; i < s.imagesToLoad.length; i++) {
2839                s.loadImage(s.imagesToLoad[i], (s.imagesToLoad[i].currentSrc || s.imagesToLoad[i].getAttribute('src')), (s.imagesToLoad[i].srcset || s.imagesToLoad[i].getAttribute('srcset')), true, _onReady);
2840            }
2841        };
2842        
2843        /*=========================
2844          Autoplay
2845          ===========================*/
2846        s.autoplayTimeoutId = undefined;
2847        s.autoplaying = false;
2848        s.autoplayPaused = false;
2849        function autoplay() {
2850            s.autoplayTimeoutId = setTimeout(function () {
2851                if (s.params.loop) {
2852                    s.fixLoop();
2853                    s._slideNext();
2854                    s.emit('onAutoplay', s);
2855                }
2856                else {
2857                    if (!s.isEnd) {
2858                        s._slideNext();
2859                        s.emit('onAutoplay', s);
2860                    }
2861                    else {
2862                        if (!params.autoplayStopOnLast) {
2863                            s._slideTo(0);
2864                            s.emit('onAutoplay', s);
2865                        }
2866                        else {
2867                            s.stopAutoplay();
2868                        }
2869                    }
2870                }
2871            }, s.params.autoplay);
2872        }
2873        s.startAutoplay = function () {
2874            if (typeof s.autoplayTimeoutId !== 'undefined') return false;
2875            if (!s.params.autoplay) return false;
2876            if (s.autoplaying) return false;
2877            s.autoplaying = true;
2878            s.emit('onAutoplayStart', s);
2879            autoplay();
2880        };
2881        s.stopAutoplay = function (internal) {
2882            if (!s.autoplayTimeoutId) return;
2883            if (s.autoplayTimeoutId) clearTimeout(s.autoplayTimeoutId);
2884            s.autoplaying = false;
2885            s.autoplayTimeoutId = undefined;
2886            s.emit('onAutoplayStop', s);
2887        };
2888        s.pauseAutoplay = function (speed) {
2889            if (s.autoplayPaused) return;
2890            if (s.autoplayTimeoutId) clearTimeout(s.autoplayTimeoutId);
2891            s.autoplayPaused = true;
2892            if (speed === 0) {
2893                s.autoplayPaused = false;
2894                autoplay();
2895            }
2896            else {
2897                s.wrapper.transitionEnd(function () {
2898                    if (!s) return;
2899                    s.autoplayPaused = false;
2900                    if (!s.autoplaying) {
2901                        s.stopAutoplay();
2902                    }
2903                    else {
2904                        autoplay();
2905                    }
2906                });
2907            }
2908        };
2909        /*=========================
2910          Min/Max Translate
2911          ===========================*/
2912        s.minTranslate = function () {
2913            return (-s.snapGrid[0]);
2914        };
2915        s.maxTranslate = function () {
2916            return (-s.snapGrid[s.snapGrid.length - 1]);
2917        };
2918        /*=========================
2919          Slider/slides sizes
2920          ===========================*/
2921        s.updateAutoHeight = function () {
2922            // Update Height
2923            var slide = s.slides.eq(s.activeIndex)[0];
2924            if (typeof slide !== 'undefined') {
2925                var newHeight = slide.offsetHeight;
2926                if (newHeight) s.wrapper.css('height', newHeight + 'px');
2927            }
2928        };
2929        s.updateContainerSize = function () {
2930            var width, height;
2931            if (typeof s.params.width !== 'undefined') {
2932                width = s.params.width;
2933            }
2934            else {
2935                width = s.container[0].clientWidth;
2936            }
2937            if (typeof s.params.height !== 'undefined') {
2938                height = s.params.height;
2939            }
2940            else {
2941                height = s.container[0].clientHeight;
2942            }
2943            if (width === 0 && s.isHorizontal() || height === 0 && !s.isHorizontal()) {
2944                return;
2945            }
2946        
2947            //Subtract paddings
2948            width = width - parseInt(s.container.css('padding-left'), 10) - parseInt(s.container.css('padding-right'), 10);
2949            height = height - parseInt(s.container.css('padding-top'), 10) - parseInt(s.container.css('padding-bottom'), 10);
2950        
2951            // Store values
2952            s.width = width;
2953            s.height = height;
2954            s.size = s.isHorizontal() ? s.width : s.height;
2955        };
2956        
2957        s.updateSlidesSize = function () {
2958            s.slides = s.wrapper.children('.' + s.params.slideClass);
2959            s.snapGrid = [];
2960            s.slidesGrid = [];
2961            s.slidesSizesGrid = [];
2962        
2963            var spaceBetween = s.params.spaceBetween,
2964                slidePosition = -s.params.slidesOffsetBefore,
2965                i,
2966                prevSlideSize = 0,
2967                index = 0;
2968            if (typeof s.size === 'undefined') return;
2969            if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
2970                spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * s.size;
2971            }
2972        
2973            s.virtualSize = -spaceBetween;
2974            // reset margins
2975            if (s.rtl) s.slides.css({marginLeft: '', marginTop: ''});
2976            else s.slides.css({marginRight: '', marginBottom: ''});
2977        
2978            var slidesNumberEvenToRows;
2979            if (s.params.slidesPerColumn > 1) {
2980                if (Math.floor(s.slides.length / s.params.slidesPerColumn) === s.slides.length / s.params.slidesPerColumn) {
2981                    slidesNumberEvenToRows = s.slides.length;
2982                }
2983                else {
2984                    slidesNumberEvenToRows = Math.ceil(s.slides.length / s.params.slidesPerColumn) * s.params.slidesPerColumn;
2985                }
2986                if (s.params.slidesPerView !== 'auto' && s.params.slidesPerColumnFill === 'row') {
2987                    slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, s.params.slidesPerView * s.params.slidesPerColumn);
2988                }
2989            }
2990        
2991            // Calc slides
2992            var slideSize;
2993            var slidesPerColumn = s.params.slidesPerColumn;
2994            var slidesPerRow = slidesNumberEvenToRows / slidesPerColumn;
2995            var numFullColumns = slidesPerRow - (s.params.slidesPerColumn * slidesPerRow - s.slides.length);
2996            for (i = 0; i < s.slides.length; i++) {
2997                slideSize = 0;
2998                var slide = s.slides.eq(i);
2999                if (s.params.slidesPerColumn > 1) {
3000                    // Set slides order
3001                    var newSlideOrderIndex;
3002                    var column, row;
3003                    if (s.params.slidesPerColumnFill === 'column') {
3004                        column = Math.floor(i / slidesPerColumn);
3005                        row = i - column * slidesPerColumn;
3006                        if (column > numFullColumns || (column === numFullColumns && row === slidesPerColumn-1)) {
3007                            if (++row >= slidesPerColumn) {
3008                                row = 0;
3009                                column++;
3010                            }
3011                        }
3012                        newSlideOrderIndex = column + row * slidesNumberEvenToRows / slidesPerColumn;
3013                        slide
3014                            .css({
3015                                '-webkit-box-ordinal-group': newSlideOrderIndex,
3016                                '-moz-box-ordinal-group': newSlideOrderIndex,
3017                                '-ms-flex-order': newSlideOrderIndex,
3018                                '-webkit-order': newSlideOrderIndex,
3019                                'order': newSlideOrderIndex
3020                            });
3021                    }
3022                    else {
3023                        row = Math.floor(i / slidesPerRow);
3024                        column = i - row * slidesPerRow;
3025                    }
3026                    slide
3027                        .css({
3028                            'margin-top': (row !== 0 && s.params.spaceBetween) && (s.params.spaceBetween + 'px')
3029                        })
3030                        .attr('data-swiper-column', column)
3031                        .attr('data-swiper-row', row);
3032        
3033                }
3034                if (slide.css('display') === 'none') continue;
3035                if (s.params.slidesPerView === 'auto') {
3036                    slideSize = s.isHorizontal() ? slide.outerWidth(true) : slide.outerHeight(true);
3037                    if (s.params.roundLengths) slideSize = round(slideSize);
3038                }
3039                else {
3040                    slideSize = (s.size - (s.params.slidesPerView - 1) * spaceBetween) / s.params.slidesPerView;
3041                    if (s.params.roundLengths) slideSize = round(slideSize);
3042        
3043                    if (s.isHorizontal()) {
3044                        s.slides[i].style.width = slideSize + 'px';
3045                    }
3046                    else {
3047                        s.slides[i].style.height = slideSize + 'px';
3048                    }
3049                }
3050                s.slides[i].swiperSlideSize = slideSize;
3051                s.slidesSizesGrid.push(slideSize);
3052        
3053        
3054                if (s.params.centeredSlides) {
3055                    slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
3056                    if (i === 0) slidePosition = slidePosition - s.size / 2 - spaceBetween;
3057                    if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
3058                    if ((index) % s.params.slidesPerGroup === 0) s.snapGrid.push(slidePosition);
3059                    s.slidesGrid.push(slidePosition);
3060                }
3061                else {
3062                    if ((index) % s.params.slidesPerGroup === 0) s.snapGrid.push(slidePosition);
3063                    s.slidesGrid.push(slidePosition);
3064                    slidePosition = slidePosition + slideSize + spaceBetween;
3065                }
3066        
3067                s.virtualSize += slideSize + spaceBetween;
3068        
3069                prevSlideSize = slideSize;
3070        
3071                index ++;
3072            }
3073            s.virtualSize = Math.max(s.virtualSize, s.size) + s.params.slidesOffsetAfter;
3074            var newSlidesGrid;
3075        
3076            if (
3077                s.rtl && s.wrongRTL && (s.params.effect === 'slide' || s.params.effect === 'coverflow')) {
3078                s.wrapper.css({width: s.virtualSize + s.params.spaceBetween + 'px'});
3079            }
3080            if (!s.support.flexbox || s.params.setWrapperSize) {
3081                if (s.isHorizontal()) s.wrapper.css({width: s.virtualSize + s.params.spaceBetween + 'px'});
3082                else s.wrapper.css({height: s.virtualSize + s.params.spaceBetween + 'px'});
3083            }
3084        
3085            if (s.params.slidesPerColumn > 1) {
3086                s.virtualSize = (slideSize + s.params.spaceBetween) * slidesNumber
3086EvenToRows;
3087                s.virtualSize = Math.ceil(s.virtualSize / s.params.slidesPerColumn) - s.params.spaceBetween;
3088                s.wrapper.css({width: s.virtualSize + s.params.spaceBetween + 'px'});
3089                if (s.params.centeredSlides) {
3090                    newSlidesGrid = [];
3091                    for (i = 0; i < s.snapGrid.length; i++) {
3092                        if (s.snapGrid[i] < s.virtualSize + s.snapGrid[0]) newSlidesGrid.push(s.snapGrid[i]);
3093                    }
3094                    s.snapGrid = newSlidesGrid;
3095                }
3096            }
3097        
3098            // Remove last grid elements depending on width
3099            if (!s.params.centeredSlides) {
3100                newSlidesGrid = [];
3101                for (i = 0; i < s.snapGrid.length; i++) {
3102                    if (s.snapGrid[i] <= s.virtualSize - s.size) {
3103                        newSlidesGrid.push(s.snapGrid[i]);
3104                    }
3105                }
3106                s.snapGrid = newSlidesGrid;
3107                if (Math.floor(s.virtualSize - s.size) - Math.floor(s.snapGrid[s.snapGrid.length - 1]) > 1) {
3108                    s.snapGrid.push(s.virtualSize - s.size);
3109                }
3110            }
3111            if (s.snapGrid.length === 0) s.snapGrid = [0];
3112        
3113            if (s.params.spaceBetween !== 0) {
3114                if (s.isHorizontal()) {
3115                    if (s.rtl) s.slides.css({marginLeft: spaceBetween + 'px'});
3116                    else s.slides.css({marginRight: spaceBetween + 'px'});
3117                }
3118                else s.slides.css({marginBottom: spaceBetween + 'px'});
3119            }
3120            if (s.params.watchSlidesProgress) {
3121                s.updateSlidesOffset();
3122            }
3123        };
3124        s.updateSlidesOffset = function () {
3125            for (var i = 0; i < s.slides.length; i++) {
3126                s.slides[i].swiperSlideOffset = s.isHorizontal() ? s.slides[i].offsetLeft : s.slides[i].offsetTop;
3127            }
3128        };
3129        
3130        /*=========================
3131          Slider/slides progress
3132          ===========================*/
3133        s.updateSlidesProgress = function (translate) {
3134            if (typeof translate === 'undefined') {
3135                translate = s.translate || 0;
3136            }
3137            if (s.slides.length === 0) return;
3138            if (typeof s.slides[0].swiperSlideOffset === 'undefined') s.updateSlidesOffset();
3139        
3140            var offsetCenter = -translate;
3141            if (s.rtl) offsetCenter = translate;
3142        
3143            // Visible Slides
3144            s.slides.removeClass(s.params.slideVisibleClass);
3145            for (var i = 0; i < s.slides.length; i++) {
3146                var slide = s.slides[i];
3147                var slideProgress = (offsetCenter - slide.swiperSlideOffset) / (slide.swiperSlideSize + s.params.spaceBetween);
3148                if (s.params.watchSlidesVisibility) {
3149                    var slideBefore = -(offsetCenter - slide.swiperSlideOffset);
3150                    var slideAfter = slideBefore + s.slidesSizesGrid[i];
3151                    var isVisible =
3152                        (slideBefore >= 0 && slideBefore < s.size) ||
3153                        (slideAfter > 0 && slideAfter <= s.size) ||
3154                        (slideBefore <= 0 && slideAfter >= s.size);
3155                    if (isVisible) {
3156                        s.slides.eq(i).addClass(s.params.slideVisibleClass);
3157                    }
3158                }
3159                slide.progress = s.rtl ? -slideProgress : slideProgress;
3160            }
3161        };
3162        s.updateProgress = function (translate) {
3163            if (typeof translate === 'undefined') {
3164                translate = s.translate || 0;
3165            }
3166            var translatesDiff = s.maxTranslate() - s.minTranslate();
3167            var wasBeginning = s.isBeginning;
3168            var wasEnd = s.isEnd;
3169            if (translatesDiff === 0) {
3170                s.progress = 0;
3171                s.isBeginning = s.isEnd = true;
3172            }
3173            else {
3174                s.progress = (translate - s.minTranslate()) / (translatesDiff);
3175                s.isBeginning = s.progress <= 0;
3176                s.isEnd = s.progress >= 1;
3177            }
3178            if (s.isBeginning && !wasBeginning) s.emit('onReachBeginning', s);
3179            if (s.isEnd && !wasEnd) s.emit('onReachEnd', s);
3180        
3181            if (s.params.watchSlidesProgress) s.updateSlidesProgress(translate);
3182            s.emit('onProgress', s, s.progress);
3183        };
3184        s.updateActiveIndex = function () {
3185            var translate = s.rtl ? s.translate : -s.translate;
3186            var newActiveIndex, i, snapIndex;
3187            for (i = 0; i < s.slidesGrid.length; i ++) {
3188                if (typeof s.slidesGrid[i + 1] !== 'undefined') {
3189                    if (translate >= s.slidesGrid[i] && translate < s.slidesGrid[i + 1] - (s.slidesGrid[i + 1] - s.slidesGrid[i]) / 2) {
3190                        newActiveIndex = i;
3191                    }
3192                    else if (translate >= s.slidesGrid[i] && translate < s.slidesGrid[i + 1]) {
3193                        newActiveIndex = i + 1;
3194                    }
3195                }
3196                else {
3197                    if (translate >= s.slidesGrid[i]) {
3198                        newActiveIndex = i;
3199                    }
3200                }
3201            }
3202            // Normalize slideIndex
3203            if (newActiveIndex < 0 || typeof newActiveIndex === 'undefined') newActiveIndex = 0;
3204            // for (i = 0; i < s.slidesGrid.length; i++) {
3205                // if (- translate >= s.slidesGrid[i]) {
3206                    // newActiveIndex = i;
3207                // }
3208            // }
3209            snapIndex = Math.floor(newActiveIndex / s.params.slidesPerGroup);
3210            if (snapIndex >= s.snapGrid.length) snapIndex = s.snapGrid.length - 1;
3211        
3212            if (newActiveIndex === s.activeIndex) {
3213                return;
3214            }
3215            s.snapIndex = snapIndex;
3216            s.previousIndex = s.activeIndex;
3217            s.activeIndex = newActiveIndex;
3218            s.updateClasses();
3219        };
3220        
3221        /*=========================
3222          Classes
3223          ===========================*/
3224        s.updateClasses = function () {
3225            s.slides.removeClass(s.params.slideActiveClass + ' ' + s.params.slideNextClass + ' ' + s.params.slidePrevClass);
3226            var activeSlide = s.slides.eq(s.activeIndex);
3227            // Active classes
3228            activeSlide.addClass(s.params.slideActiveClass);
3229            // Next Slide
3230            var nextSlide = activeSlide.next('.' + s.params.slideClass).addClass(s.params.slideNextClass);
3231            if (s.params.loop && nextSlide.length === 0) {
3232                s.slides.eq(0).addClass(s.params.slideNextClass);
3233            }
3234            // Prev Slide
3235            var prevSlide = activeSlide.prev('.' + s.params.slideClass).addClass(s.params.slidePrevClass);
3236            if (s.params.loop && prevSlide.length === 0) {
3237                s.slides.eq(-1).addClass(s.params.slidePrevClass);
3238            }
3239        
3240            // Pagination
3241            if (s.paginationContainer && s.paginationContainer.length > 0) {
3242                // Current/Total
3243                var current,
3244                    total = s.params.loop ? Math.ceil((s.slides.length - s.loopedSlides * 2) / s.params.slidesPerGroup) : s.snapGrid.length;
3245                if (s.params.loop) {
3246                    current = Math.ceil((s.activeIndex - s.loopedSlides)/s.params.slidesPerGroup);
3247                    if (current > s.slides.length - 1 - s.loopedSlides * 2) {
3248                        current = current - (s.slides.length - s.loopedSlides * 2);
3249                    }
3250                    if (current > total - 1) current = current - total;
3251                    if (current < 0 && s.params.paginationType !== 'bullets') current = total + current;
3252                }
3253                else {
3254                    if (typeof s.snapIndex !== 'undefined') {
3255                        current = s.snapIndex;
3256                    }
3257                    else {
3258                        current = s.activeIndex || 0;
3259                    }
3260                }
3261                // Types
3262                if (s.params.paginationType === 'bullets' && s.bullets && s.bullets.length > 0) {
3263                    s.bullets.removeClass(s.params.bulletActiveClass);
3264                    if (s.paginationContainer.length > 1) {
3265                        s.bullets.each(function () {
3266                            if ($(this).index() === current) $(this).addClass(s.params.bulletActiveClass);
3267                        });
3268                    }
3269                    else {
3270                        s.bullets.eq(current).addClass(s.params.bulletActiveClass);
3271                    }
3272                }
3273                if (s.params.paginationType === 'fraction') {
3274                    s.paginationContainer.find('.' + s.params.paginationCurrentClass).text(current + 1);
3275                    s.paginationContainer.find('.' + s.params.paginationTotalClass).text(total);
3276                }
3277                if (s.params.paginationType === 'progress') {
3278                    var scale = (current + 1) / total,
3279                        scaleX = scale,
3280                        scaleY = 1;
3281                    if (!s.isHorizontal()) {
3282                        scaleY = scale;
3283                        scaleX = 1;
3284                    }
3285                    s.paginationContainer.find('.' + s.params.paginationProgressbarClass).transform('translate3d(0,0,0) scaleX(' + scaleX + ') scaleY(' + scaleY + ')').transition(s.params.speed);
3286                }
3287                if (s.params.paginationType === 'custom' && s.params.paginationCustomRender) {
3288                    s.paginationContainer.html(s.params.paginationCustomRender(s, current + 1, total));
3289                    s.emit('onPaginationRendered', s, s.paginationContainer[0]);
3290                }
3291            }
3292        
3293            // Next/active buttons
3294            if (!s.params.loop) {
3295                if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
3296                    if (s.isBeginning) {
3297                        s.prevButton.addClass(s.params.buttonDisabledClass);
3298                        if (s.params.a11y && s.a11y) s.a11y.disable(s.prevButton);
3299                    }
3300                    else {
3301                        s.prevButton.removeClass(s.params.buttonDisabledClass);
3302                        if (s.params.a11y && s.a11y) s.a11y.enable(s.prevButton);
3303                    }
3304                }
3305                if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
3306                    if (s.isEnd) {
3307                        s.nextButton.addClass(s.params.buttonDisabledClass);
3308                        if (s.params.a11y && s.a11y) s.a11y.disable(s.nextButton);
3309                    }
3310                    else {
3311                        s.nextButton.removeClass(s.params.buttonDisabledClass);
3312                        if (s.params.a11y && s.a11y) s.a11y.enable(s.nextButton);
3313                    }
3314                }
3315            }
3316        };
3317        
3318        /*=========================
3319          Pagination
3320          ===========================*/
3321        s.updatePagination = function () {
3322            if (!s.params.pagination) return;
3323            if (s.paginationContainer && s.paginationContainer.length > 0) {
3324                var paginationHTML = '';
3325                if (s.params.paginationType === 'bullets') {
3326                    var numberOfBullets = s.params.loop ? Math.ceil((s.slides.length - s.loopedSlides * 2) / s.params.slidesPerGroup) : s.snapGrid.length;
3327                    for (var i = 0; i < numberOfBullets; i++) {
3328                        if (s.params.paginationBulletRender) {
3329                            paginationHTML += s.params.paginationBulletRender(i, s.params.bulletClass);
3330                        }
3331                        else {
3332                            paginationHTML += '<' + s.params.paginationElement+' class="' + s.params.bulletClass + '"></' + s.params.paginationElement + '>';
3333                        }
3334                    }
3335                    s.paginationContainer.html(paginationHTML);
3336                    s.bullets = s.paginationContainer.find('.' + s.params.bulletClass);
3337                    if (s.params.paginationClickable && s.params.a11y && s.a11y) {
3338                        s.a11y.initPagination();
3339                    }
3340                }
3341                if (s.params.paginationType === 'fraction') {
3342                    if (s.params.paginationFractionRender) {
3343                        paginationHTML = s.params.paginationFractionRender(s, s.params.paginationCurrentClass, s.params.paginationTotalClass);
3344                    }
3345                    else {
3346                        paginationHTML =
3347                            '<span class="' + s.params.paginationCurrentClass + '"></span>' +
3348                            ' / ' +
3349                            '<span class="' + s.params.paginationTotalClass+'"></span>';
3350                    }
3351                    s.paginationContainer.html(paginationHTML);
3352                }
3353                if (s.params.paginationType === 'progress') {
3354                    if (s.params.paginationProgressRender) {
3355                        paginationHTML = s.params.paginationProgressRender(s, s.params.paginationProgressbarClass);
3356                    }
3357                    else {
3358                        paginationHTML = '<span class="' + s.params.paginationProgressbarClass + '"></span>';
3359                    }
3360                    s.paginationContainer.html(paginationHTML);
3361                }
3362                if (s.params.paginationType !== 'custom') {
3363                    s.emit('onPaginationRendered', s, s.paginationContainer[0]);
3364                }
3365            }
3366        };
3367        /*=========================
3368          Common update method
3369          ===========================*/
3370        s.update = function (updateTranslate) {
3371            s.updateContainerSize();
3372            s.updateSlidesSize();
3373            s.updateProgress();
3374            s.updatePagination();
3375            s.updateClasses();
3376            if (s.params.scrollbar && s.scrollbar) {
3377                s.scrollbar.set();
3378            }
3379            function forceSetTranslate() {
3380                newTranslate = Math.min(Math.max(s.translate, s.maxTranslate()), s.minTranslate());
3381                s.setWrapperTranslate(newTranslate);
3382                s.updateActiveIndex();
3383                s.updateClasses();
3384            }
3385            if (updateTranslate) {
3386                var translated, newTranslate;
3387                if (s.controller && s.controller.spline) {
3388                    s.controller.spline = undefined;
3389                }
3390                if (s.params.freeMode) {
3391                    forceSetTranslate();
3392                    if (s.params.autoHeight) {
3393                        s.updateAutoHeight();
3394                    }
3395                }
3396                else {
3397                    if ((s.params.slidesPerView === 'auto' || s.params.slidesPerView > 1) && s.isEnd && !s.params.centeredSlides) {
3398                        translated = s.slideTo(s.slides.length - 1, 0, false, true);
3399                    }
3400                    else {
3401                        translated = s.slideTo(s.activeIndex, 0, false, true);
3402                    }
3403                    if (!translated) {
3404                        forceSetTranslate();
3405                    }
3406                }
3407            }
3408            else if (s.params.autoHeight) {
3409                s.updateAutoHeight();
3410            }
3411        };
3412        
3413        /*=========================
3414          Resize Handler
3415          ===========================*/
3416        s.onResize = function (forceUpdatePagination) {
3417            //Breakpoints
3418            if (s.params.breakpoints) {
3419                s.setBreakpoint();
3420            }
3421        
3422            // Disable locks on resize
3423            var allowSwipeToPrev = s.params.allowSwipeToPrev;
3424            var allowSwipeToNext = s.params.allowSwipeToNext;
3425            s.params.allowSwipeToPrev = s.params.allowSwipeToNext = true;
3426        
3427            s.updateContainerSize();
3428            s.updateSlidesSize();
3429            if (s.params.slidesPerView === 'auto' || s.params.freeMode || force
3429UpdatePagination) s.updatePagination();
3430            if (s.params.scrollbar && s.scrollbar) {
3431                s.scrollbar.set();
3432            }
3433            if (s.controller && s.controller.spline) {
3434                s.controller.spline = undefined;
3435            }
3436            var slideChangedBySlideTo = false;
3437            if (s.params.freeMode) {
3438                var newTranslate = Math.min(Math.max(s.translate, s.maxTranslate()), s.minTranslate());
3439                s.setWrapperTranslate(newTranslate);
3440                s.updateActiveIndex();
3441                s.updateClasses();
3442        
3443                if (s.params.autoHeight) {
3444                    s.updateAutoHeight();
3445                }
3446            }
3447            else {
3448                s.updateClasses();
3449                if ((s.params.slidesPerView === 'auto' || s.params.slidesPerView > 1) && s.isEnd && !s.params.centeredSlides) {
3450                    slideChangedBySlideTo = s.slideTo(s.slides.length - 1, 0, false, true);
3451                }
3452                else {
3453                    slideChangedBySlideTo = s.slideTo(s.activeIndex, 0, false, true);
3454                }
3455            }
3456            if (s.params.lazyLoading && !slideChangedBySlideTo && s.lazy) {
3457                s.lazy.load();
3458            }
3459            // Return locks after resize
3460            s.params.allowSwipeToPrev = allowSwipeToPrev;
3461            s.params.allowSwipeToNext = allowSwipeToNext;
3462        };
3463        
3464        /*=========================
3465          Events
3466          ===========================*/
3467        
3468        //Define Touch Events
3469        var desktopEvents = ['mousedown', 'mousemove', 'mouseup'];
3470        if (window.navigator.pointerEnabled) desktopEvents = ['pointerdown', 'pointermove', 'pointerup'];
3471        else if (window.navigator.msPointerEnabled) desktopEvents = ['MSPointerDown', 'MSPointerMove', 'MSPointerUp'];
3472        s.touchEvents = {
3473            start : s.support.touch || !s.params.simulateTouch  ? 'touchstart' : desktopEvents[0],
3474            move : s.support.touch || !s.params.simulateTouch ? 'touchmove' : desktopEvents[1],
3475            end : s.support.touch || !s.params.simulateTouch ? 'touchend' : desktopEvents[2]
3476        };
3477        
3478        
3479        // WP8 Touch Events Fix
3480        if (window.navigator.pointerEnabled || window.navigator.msPointerEnabled) {
3481            (s.params.touchEventsTarget === 'container' ? s.container : s.wrapper).addClass('swiper-wp8-' + s.params.direction);
3482        }
3483        
3484        // Attach/detach events
3485        s.initEvents = function (detach) {
3486            var actionDom = detach ? 'off' : 'on';
3487            var action = detach ? 'removeEventListener' : 'addEventListener';
3488            var touchEventsTarget = s.params.touchEventsTarget === 'container' ? s.container[0] : s.wrapper[0];
3489            var target = s.support.touch ? touchEventsTarget : document;
3490        
3491            var moveCapture = s.params.nested ? true : false;
3492        
3493            //Touch Events
3494            if (s.browser.ie) {
3495                touchEventsTarget[action](s.touchEvents.start, s.onTouchStart, false);
3496                target[action](s.touchEvents.move, s.onTouchMove, moveCapture);
3497                target[action](s.touchEvents.end, s.onTouchEnd, false);
3498            }
3499            else {
3500                if (s.support.touch) {
3501                    touchEventsTarget[action](s.touchEvents.start, s.onTouchStart, false);
3502                    touchEventsTarget[action](s.touchEvents.move, s.onTouchMove, moveCapture);
3503                    touchEventsTarget[action](s.touchEvents.end, s.onTouchEnd, false);
3504                }
3505                if (params.simulateTouch && !s.device.ios && !s.device.android) {
3506                    touchEventsTarget[action]('mousedown', s.onTouchStart, false);
3507                    document[action]('mousemove', s.onTouchMove, moveCapture);
3508                    document[action]('mouseup', s.onTouchEnd, false);
3509                }
3510            }
3511            window[action]('resize', s.onResize);
3512        
3513            // Next, Prev, Index
3514            if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
3515                s.nextButton[actionDom]('click', s.onClickNext);
3516                if (s.params.a11y && s.a11y) s.nextButton[actionDom]('keydown', s.a11y.onEnterKey);
3517            }
3518            if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
3519                s.prevButton[actionDom]('click', s.onClickPrev);
3520                if (s.params.a11y && s.a11y) s.prevButton[actionDom]('keydown', s.a11y.onEnterKey);
3521            }
3522            if (s.params.pagination && s.params.paginationClickable) {
3523                s.paginationContainer[actionDom]('click', '.' + s.params.bulletClass, s.onClickIndex);
3524                if (s.params.a11y && s.a11y) s.paginationContainer[actionDom]('keydown', '.' + s.params.bulletClass, s.a11y.onEnterKey);
3525            }
3526        
3527            // Prevent Links Clicks
3528            if (s.params.preventClicks || s.params.preventClicksPropagation) touchEventsTarget[action]('click', s.preventClicks, true);
3529        };
3530        s.attachEvents = function () {
3531            s.initEvents();
3532        };
3533        s.detachEvents = function () {
3534            s.initEvents(true);
3535        };
3536        
3537        /*=========================
3538          Handle Clicks
3539          ===========================*/
3540        // Prevent Clicks
3541        s.allowClick = true;
3542        s.preventClicks = function (e) {
3543            if (!s.allowClick) {
3544                if (s.params.preventClicks) e.preventDefault();
3545                if (s.params.preventClicksPropagation && s.animating) {
3546                    e.stopPropagation();
3547                    e.stopImmediatePropagation();
3548                }
3549            }
3550        };
3551        // Clicks
3552        s.onClickNext = function (e) {
3553            e.preventDefault();
3554            if (s.isEnd && !s.params.loop) return;
3555            s.slideNext();
3556        };
3557        s.onClickPrev = function (e) {
3558            e.preventDefault();
3559            if (s.isBeginning && !s.params.loop) return;
3560            s.slidePrev();
3561        };
3562        s.onClickIndex = function (e) {
3563            e.preventDefault();
3564            var index = $(this).index() * s.params.slidesPerGroup;
3565            if (s.params.loop) index = index + s.loopedSlides;
3566            s.slideTo(index);
3567        };
3568        
3569        /*=========================
3570          Handle Touches
3571          ===========================*/
3572        function findElementInEvent(e, selector) {
3573            var el = $(e.target);
3574            if (!el.is(selector)) {
3575                if (typeof selector === 'string') {
3576                    el = el.parents(selector);
3577                }
3578                else if (selector.nodeType) {
3579                    var found;
3580                    el.parents().each(function (index, _el) {
3581                        if (_el === selector) found = selector;
3582                    });
3583                    if (!found) return undefined;
3584                    else return selector;
3585                }
3586            }
3587            if (el.length === 0) {
3588                return undefined;
3589            }
3590            return el[0];
3591        }
3592        s.updateClickedSlide = function (e) {
3593            var slide = findElementInEvent(e, '.' + s.params.slideClass);
3594            var slideFound = false;
3595            if (slide) {
3596                for (var i = 0; i < s.slides.length; i++) {
3597                    if (s.slides[i] === slide) slideFound = true;
3598                }
3599            }
3600        
3601            if (slide && slideFound) {
3602                s.clickedSlide = slide;
3603                s.clickedIndex = $(slide).index();
3604            }
3605            else {
3606                s.clickedSlide = undefined;
3607                s.clickedIndex = undefined;
3608                return;
3609            }
3610            if (s.params.slideToClickedSlide && s.clickedIndex !== undefined && s.clickedIndex !== s.activeIndex) {
3611                var slideToIndex = s.clickedIndex,
3612                    realIndex,
3613                    duplicatedSlides;
3614                if (s.params.loop) {
3615                    if (s.animating) return;
3616                    realIndex = $(s.clickedSlide).attr('data-swiper-slide-index');
3617                    if (s.params.centeredSlides) {
3618                        if ((slideToIndex < s.loopedSlides - s.params.slidesPerView/2) || (slideToIndex > s.slides.length - s.loopedSlides + s.params.slidesPerView/2)) {
3619                            s.fixLoop();
3620                            slideToIndex = s.wrapper.children('.' + s.params.slideClass + '[data-swiper-slide-index="' + realIndex + '"]:not(.swiper-slide-duplicate)').eq(0).index();
3621                            setTimeout(function () {
3622                                s.slideTo(slideToIndex);
3623                            }, 0);
3624                        }
3625                        else {
3626                            s.slideTo(slideToIndex);
3627                        }
3628                    }
3629                    else {
3630                        if (slideToIndex > s.slides.length - s.params.slidesPerView) {
3631                            s.fixLoop();
3632                            slideToIndex = s.wrapper.children('.' + s.params.slideClass + '[data-swiper-slide-index="' + realIndex + '"]:not(.swiper-slide-duplicate)').eq(0).index();
3633                            setTimeout(function () {
3634                                s.slideTo(slideToIndex);
3635                            }, 0);
3636                        }
3637                        else {
3638                            s.slideTo(slideToIndex);
3639                        }
3640                    }
3641                }
3642                else {
3643                    s.slideTo(slideToIndex);
3644                }
3645            }
3646        };
3647        
3648        var isTouched,
3649            isMoved,
3650            allowTouchCallbacks,
3651            touchStartTime,
3652            isScrolling,
3653            currentTranslate,
3654            startTranslate,
3655            allowThresholdMove,
3656            // Form elements to match
3657            formElements = 'input, select, textarea, button',
3658            // Last click time
3659            lastClickTime = Date.now(), clickTimeout,
3660            //Velocities
3661            velocities = [],
3662            allowMomentumBounce;
3663        
3664        // Animating Flag
3665        s.animating = false;
3666        
3667        // Touches information
3668        s.touches = {
3669            startX: 0,
3670            startY: 0,
3671            currentX: 0,
3672            currentY: 0,
3673            diff: 0
3674        };
3675        
3676        // Touch handlers
3677        var isTouchEvent, startMoving;
3678        s.onTouchStart = function (e) {
3679            if (e.originalEvent) e = e.originalEvent;
3680            isTouchEvent = e.type === 'touchstart';
3681            if (!isTouchEvent && 'which' in e && e.which === 3) return;
3682            if (s.params.noSwiping && findElementInEvent(e, '.' + s.params.noSwipingClass)) {
3683                s.allowClick = true;
3684                return;
3685            }
3686            if (s.params.swipeHandler) {
3687                if (!findElementInEvent(e, s.params.swipeHandler)) return;
3688            }
3689        
3690            var startX = s.touches.currentX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
3691            var startY = s.touches.currentY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
3692        
3693            // Do NOT start if iOS edge swipe is detected. Otherwise iOS app (UIWebView) cannot swipe-to-go-back anymore
3694            if(s.device.ios && s.params.iOSEdgeSwipeDetection && startX <= s.params.iOSEdgeSwipeThreshold) {
3695                return;
3696            }
3697        
3698            isTouched = true;
3699            isMoved = false;
3700            allowTouchCallbacks = true;
3701            isScrolling = undefined;
3702            startMoving = undefined;
3703            s.touches.startX = startX;
3704            s.touches.startY = startY;
3705            touchStartTime = Date.now();
3706            s.allowClick = true;
3707            s.updateContainerSize();
3708            s.swipeDirection = undefined;
3709            if (s.params.threshold > 0) allowThresholdMove = false;
3710            if (e.type !== 'touchstart') {
3711                var preventDefault = true;
3712                if ($(e.target).is(formElements)) preventDefault = false;
3713                if (document.activeElement && $(document.activeElement).is(formElements)) {
3714                    document.activeElement.blur();
3715                }
3716                if (preventDefault) {
3717                    e.preventDefault();
3718                }
3719            }
3720            s.emit('onTouchStart', s, e);
3721        };
3722        
3723        s.onTouchMove = function (e) {
3724            if (e.originalEvent) e = e.originalEvent;
3725            if (isTouchEvent && e.type === 'mousemove') return;
3726            if (e.preventedByNestedSwiper) {
3727                s.touches.startX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
3728                s.touches.startY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
3729                return;
3730            }
3731            if (s.params.onlyExternal) {
3732                // isMoved = true;
3733                s.allowClick = false;
3734                if (isTouched) {
3735                    s.touches.startX = s.touches.currentX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
3736                    s.touches.startY = s.touches.currentY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
3737                    touchStartTime = Date.now();
3738                }
3739                return;
3740            }
3741            if (isTouchEvent && document.activeElement) {
3742                if (e.target === document.activeElement && $(e.target).is(formElements)) {
3743                    isMoved = true;
3744                    s.allowClick = false;
3745                    return;
3746                }
3747            }
3748            if (allowTouchCallbacks) {
3749                s.emit('onTouchMove', s, e);
3750            }
3751            if (e.targetTouches && e.targetTouches.length > 1) return;
3752        
3753            s.touches.currentX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
3754            s.touches.currentY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
3755        
3756            if (typeof isScrolling === 'undefined') {
3757                var touchAngle = Math.atan2(Math.abs(s.touches.currentY - s.touches.startY), Math.abs(s.touches.currentX - s.touches.startX)) * 180 / Math.PI;
3758                isScrolling = s.isHorizontal() ? touchAngle > s.params.touchAngle : (90 - touchAngle > s.params.touchAngle);
3759            }
3760            if (isScrolling) {
3761                s.emit('onTouchMoveOpposite', s, e);
3762            }
3763            if (typeof startMoving === 'undefined' && s.browser.ieTouch) {
3764                if (s.touches.currentX !== s.touches.startX || s.touches.currentY !== s.touches.startY) {
3765                    startMoving = true;
3766                }
3767            }
3768            if (!isTouched) return;
3769            if (isScrolling)  {
3770                isTouched = false;
3771                return;
3772            }
3773            if (!startMoving && s.browser.ieTouch) {
3774                return;
3775            }
3776            s.allowClick = false;
3777            s.emit('onSliderMove', s, e);
3778            e.preventDefault();
3779            if (s.params.touchMoveStopPropagation && !s.params.nested) {
3780                e.stopPropagation();
3781            }
3782        
3783            if (!isMoved) {
3784                if (params.loop) {
3785                    s.fixLoop();
3786                }
3787                startTranslate = s.getWrapperTranslate();
3788                s.setWrapperTransition(0);
3789                if (s.animating) {
3790                    s.wrapper.trigger('webkitTransitionEnd transitionend oTransitionEnd MSTransitionEnd msTransitionEnd');
3791                }
3792                if (s.params.autoplay && s.autoplaying) {
3793                    if (s.params.autoplayDisableOnInteraction) {
3794                        s.stopAutoplay();
3795                    }
3796                    else {
3797                        s.pauseAutoplay();
3798                    }
3799                }
3800                allowMomentumBounce = false;
3801                //Grab Cursor
3802                if (s.params.grabCursor) {
3803                    s.container[0].style.cursor = 'move';
3804                    s.container[0].style.cursor = '-webkit-grabbing';
3805                    s.container[0].style.cursor = '-moz-grabbin';
3806                    s.container[0].style.cursor = 'grabbing';
3807                }
3808            }
3809            isMoved = true;
3810        
3811            var diff = s.touches.diff = s.isHorizontal() ? s.touches.currentX - s.touches.startX : s.touches.currentY - s.touches.startY;
3812        
3813            diff = diff * s.params.touchRatio;
3814            if (s.rtl) diff = -diff;
3815        
3816            s.swipeDirection = diff > 0 ? 'prev' : 'next';
3817            currentTranslate = diff + startTranslate;
3818        
3819            var disableParentSwiper = true;
3820            if ((diff > 0 && currentTranslate > s.minTranslate())) {
3821                disableParentSwiper = false;
3822                if (s.params.resistance) currentTranslate = s.minTranslate() - 1 + Math.pow(-s.minTranslate() + startTranslate + diff, s.params.resistanceRatio);
3823            }
3824            else if (diff < 0 && currentTranslate < s.maxTranslate()) {
3825                disableParentSwiper = false;
3826                if (s.params.resistance) currentTranslate = s.maxTranslate() + 1 - Math.pow(s.maxTranslate() - startTranslate - diff, s.params.resistanceRatio);
3827            }
3828        
3829            if (disableParentSwiper) {
3830                e.preventedByNestedSwiper = true;
3831            }
3832        
3833            // Directions locks
3834            if (!s.params.allowSwipeToNext && s.swipeDirection === 'next' && currentTranslate < startTranslate) {
3835                currentTranslate = startTranslate;
3836            }
3837            if (!s.params.allowSwipeToPrev && s.swipeDirection === 'prev' && currentTranslate > startTranslate) {
3838                currentTranslate = startTranslate;
3839            }
3840        
3841            if (!s.params.followFinger) return;
3842        
3843            // Threshold
3844            if (s.params.threshold > 0) {
3845                if (Math.abs(diff) > s.params.threshold || allowThresholdMove) {
3846                    if (!allowThresholdMove) {
3847                        allowThresholdMove = true;
3848                        s.touches.startX = s.touches.currentX;
3849                        s.touches.startY = s.touches.currentY;
3850                        currentTranslate = startTranslate;
3851                        s.touches.diff = s.isHorizontal() ? s.touches.currentX - s.touches.startX : s.touches.currentY - s.touches.startY;
3852                        return;
3853                    }
3854                }
3855                else {
3856                    currentTranslate = startTranslate;
3857                    return;
3858                }
3859            }
3860            // Update active index in free mode
3861            if (s.params.freeMode || s.params.watchSlidesProgress) {
3862                s.updateActiveIndex();
3863            }
3864            if (s.params.freeMode) {
3865                //Velocity
3866                if (velocities.length === 0) {
3867                    velocities.push({
3868                        position: s.touches[s.isHorizontal() ? 'startX' : 'startY'],
3869                        time: touchStartTime
3870                    });
3871                }
3872                velocities.push({
3873                    position: s.touches[s.isHorizontal() ? 'currentX' : 'currentY'],
3874                    time: (new window.Date()).getTime()
3875                });
3876            }
3877            // Update progress
3878            s.updateProgress(currentTranslate);
3879            // Update translate
3880            s.setWrapperTranslate(currentTranslate);
3881        };
3882        s.onTouchEnd = function (e) {
3883            if (e.originalEvent) e = e.originalEvent;
3884            if (allowTouchCallbacks) {
3885                s.emit('onTouchEnd', s, e);
3886            }
3887            allowTouchCallbacks = false;
3888            if (!isTouched) return;
3889            //Return Grab Cursor
3890            if (s.params.grabCursor && isMoved && isTouched) {
3891                s.container[0].style.cursor = 'move';
3892                s.container[0].style.cursor = '-webkit-grab';
3893                s.container[0].style.cursor = '-moz-grab';
3894                s.container[0].style.cursor = 'grab';
3895            }
3896        
3897            // Time diff
3898            var touchEndTime = Date.now();
3899            var timeDiff = touchEndTime - touchStartTime;
3900        
3901            // Tap, doubleTap, Click
3902            if (s.allowClick) {
3903                s.updateClickedSlide(e);
3904                s.emit('onTap', s, e);
3905                if (timeDiff < 300 && (touchEndTime - lastClickTime) > 300) {
3906                    if (clickTimeout) clearTimeout(clickTimeout);
3907                    clickTimeout = setTimeout(function () {
3908                        if (!s) return;
3909                        if (s.params.paginationHide && s.paginationContainer.length > 0 && !$(e.target).hasClass(s.params.bulletClass)) {
3910                            s.paginationContainer.toggleClass(s.params.paginationHiddenClass);
3911                        }
3912                        s.emit('onClick', s, e);
3913                    }, 300);
3914        
3915                }
3916                if (timeDiff < 300 && (touchEndTime - lastClickTime) < 300) {
3917                    if (clickTimeout) clearTimeout(clickTimeout);
3918                    s.emit('onDoubleTap', s, e);
3919                }
3920            }
3921        
3922            lastClickTime = Date.now();
3923            setTimeout(function () {
3924                if (s) s.allowClick = true;
3925            }, 0);
3926        
3927            if (!isTouched || !isMoved || !s.swipeDirection || s.touches.diff === 0 || currentTranslate === startTranslate) {
3928                isTouched = isMoved = false;
3929                return;
3930            }
3931            isTouched = isMoved = false;
3932        
3933            var currentPos;
3934            if (s.params.followFinger) {
3935                currentPos = s.rtl ? s.translate : -s.translate;
3936            }
3937            else {
3938                currentPos = -currentTranslate;
3939            }
3940            if (s.params.freeMode) {
3941                if (currentPos < -s.minTranslate()) {
3942                    s.slideTo(s.activeIndex);
3943                    return;
3944                }
3945                else if (currentPos > -s.maxTranslate()) {
3946                    if (s.slides.length < s.snapGrid.length) {
3947                        s.slideTo(s.snapGrid.length - 1);
3948                    }
3949                    else {
3950                        s.slideTo(s.slides.length - 1);
3951                    }
3952                    return;
3953                }
3954        
3955                if (s.params.freeModeMomentum) {
3956                    if (velocities.length > 1) {
3957                        var lastMoveEvent = velocities.pop(), velocityEvent = velocities.pop();
3958        
3959                        var distance = lastMoveEvent.position - velocityEvent.position;
3960                        var time = lastMoveEvent.time - velocityEvent.time;
3961                        s.velocity = distance / time;
3962                        s.velocity = s.velocity / 2;
3963                        if (Math.abs(s.velocity) < s.params.freeModeMinimumVelocity) {
3964                            s.velocity = 0;
3965                        }
3966                        // this implies that the user stopped moving a finger then released.
3967                        // There would be no events with distance zero, so the last event is stale.
3968                        if (time > 150 || (new window.Date().getTime() - lastMoveEvent.time) > 300) {
3969                            s.velocity = 0;
3970                        }
3971                    } else {
3972                        s.velocity = 0;
3973                    }
3974        
3975                    velocities.length = 0;
3976                    var momentumDuration = 1000 * s.params.freeModeMomentumRatio;
3977                    var momentumDistance = s.velocity * momentumDuration;
3978        
3979                    var newPosition = s.translate + momentumDistance;
3980                    if (s.rtl) newPosition = - newPosition;
3981                    var doBounce = false;
3982                    var afterBouncePosition;
3983                    var bounceAmount = Math.abs(s.velocity) * 20 * s.params.freeModeMomentumBounceRatio;
3984                    if (newPosition < s.maxTranslate()) {
3985                        if (s.params.freeModeMomentumBounce) {
3986                            if (newPosition + s.maxTranslate() < -bounceAmount) {
3987                                newPosition = s.maxTranslate() - bounceAmount;
3988                            }
3989                            afterBouncePosition = s.maxTranslate();
3990                            doBounce = true;
3991                            allowMomentumBounce = true;
3992                        }
3993                        else {
3994                            newPosition = s.maxTranslate();
3995                        }
3996                    }
3997                    else if (newPosition > s.minTranslate()) {
3998                        if (s.params.freeModeMomentumBounce) {
3999                            if (newPosition - s.minTranslate() > bounceAmount) {
4000                                newPosition = s.minTranslate() + bounceAmount;
4001                            }
4002                            afterBouncePosition = s.minTranslate();
4003                            doBounce = true;
4004                            allowMomentumBounce = true;
4005                        }
4006                        else {
4007                            newPosition = s.minTranslate();
4008                        }
4009                    }
4010                    else if (s.params.freeModeSticky) {
4011                        var j = 0,
4012                            nextSlide;
4013                        for (j = 0; j < s.snapGrid.length; j += 1) {
4014                            if (s.snapGrid[j] > -newPosition) {
4015                                nextSlide = j;
4016                                break;
4017                            }
4018        
4019                        }
4020                        if (Math.abs(s.snapGrid[nextSlide] - newPosition) < Math.abs(s.snapGrid[nextSlide - 1] - newPosition) || s.swipeDirection === 'next') {
4021                            newPosition = s.snapGrid[nextSlide];
4022                        } else {
4023                            newPosition = s.snapGrid[nextSlide - 1];
4024                        }
4025                        if (!s.rtl) newPosition = - newPosition;
4026                    }
4027                    //Fix duration
4028                    if (s.velocity !== 0) {
4029                        if (s.rtl) {
4030                            momentumDuration = Math.abs((-newPosition - s.translate) / s.velocity);
4031                        }
4032                        else {
4033                            momentumDuration = Math.abs((newPosition - s.translate) / s.velocity);
4034                        }
4035                    }
4036                    else if (s.params.freeModeSticky) {
4037                        s.slideReset();
4038                        return;
4039                    }
4040        
4041                    if (s.params.freeModeMomentumBounce && doBounce) {
4042                        s.updateProgress(afterBouncePosition);
4043                        s.setWrapperTransition(momentumDuration);
4044                        s.setWrapperTranslate(newPosition);
4045                        s.onTransitionStart();
4046                        s.animating = true;
4047                        s.wrapper.transitionEnd(function () {
4048                            if (!s || !allowMomentumBounce) return;
4049                            s.emit('onMomentumBounce', s);
4050        
4051                            s.setWrapperTransition(s.params.speed);
4052                            s.setWrapperTranslate(afterBouncePosition);
4053                            s.wrapper.transitionEnd(function () {
4054                                if (!s) return;
4055                                s.onTransitionEnd();
4056                            });
4057                        });
4058                    } else if (s.velocity) {
4059                        s.updateProgress(newPosition);
4060                        s.setWrapperTransition(momentumDuration);
4061                        s.setWrapperTranslate(newPosition);
4062                        s.onTransitionStart();
4063                        if (!s.animating) {
4064                            s.animating = true;
4065                            s.wrapper.transitionEnd(function () {
4066                                if (!s) return;
4067                                s.onTransitionEnd();
4068                            });
4069                        }
4070        
4071                    } else {
4072                        s.updateProgress(newPosition);
4073                    }
4074        
4075                    s.updateActiveIndex();
4076                }
4077                if (!s.params.freeModeMomentum || timeDiff >= s.params.longSwipesMs) {
4078                    s.updateProgress();
4079                    s.updateActiveIndex();
4080                }
4081                return;
4082            }
4083        
4084            // Find current slide
4085            var i, stopIndex = 0, groupSize = s.slidesSizesGrid[0];
4086            for (i = 0; i < s.slidesGrid.length; i += s.params.slidesPerGroup) {
4087                if (typeof s.slidesGrid[i + s.params.slidesPerGroup] !== 'undefined') {
4088                    if (currentPos >= s.slidesGrid[i] && currentPos < s.slidesGrid[i + s.params.slidesPerGroup]) {
4089                        stopIndex = i;
4090                        groupSize = s.slidesGrid[i + s.params.slidesPerGroup] - s.slidesGrid[i];
4091                    }
4092                }
4093                else {
4094                    if (currentPos >= s.slidesGrid[i]) {
4095                        stopIndex = i;
4096                        groupSize = s.slidesGrid[s.slidesGrid.length - 1] - s.slidesGrid[s.slidesGrid.length - 2];
4097                    }
4098                }
4099            }
4100        
4101            // Find current slide size
4102            var ratio = (currentPos - s.slidesGrid[stopIndex]) / groupSize;
4103        
4104            if (timeDiff > s.params.longSwipesMs) {
4105                // Long touches
4106                if (!s.params.longSwipes) {
4107                    s.slideTo(s.activeIndex);
4108                    return;
4109                }
4110                if (s.swipeDirection === 'next') {
4111                    if (ratio >= s.params.longSwipesRatio) s.slideTo(stopIndex + s.params.slidesPerGroup);
4112                    else s.slideTo(stopIndex);
4113        
4114                }
4115                if (s.swipeDirection === 'prev') {
4116                    if (ratio > (1 - s.params.longSwipesRatio)) s.slideTo(stopIndex + s.params.slidesPerGroup);
4117                    else s.slideTo(stopIndex);
4118                }
4119            }
4120            else {
4121                // Short swipes
4122                if (!s.params.shortSwipes) {
4123                    s.slideTo(s.activeIndex);
4124                    return;
4125                }
4126                if (s.swipeDirection === 'next') {
4127                    s.slideTo(stopIndex + s.params.slidesPerGroup);
4128        
4129                }
4130                if (s.swipeDirection === 'prev') {
4131                    s.slideTo(stopIndex);
4132                }
4133            }
4134        };
4135        /*=========================
4136          Transitions
4137          ===========================*/
4138        s._slideTo = function (slideIndex, speed) {
4139            return s.slideTo(slideIndex, speed, true, true);
4140        };
4141        s.slideTo = function (slideIndex, speed, runCallbacks, internal) {
4142            if (typeof runCallbacks === 'undefined') runCallbacks = true;
4143            if (typeof slideIndex === 'undefined') slideIndex = 0;
4144            if (slideIndex < 0) slideIndex = 0;
4145            s.snapIndex = Math.floor(slideIndex / s.params.slidesPerGroup);
4146            if (s.snapIndex >= s.snapGrid.length) s.snapIndex = s.snapGrid.length - 1;
4147        
4148            var translate = - s.snapGrid[s.snapIndex];
4149            // Stop autoplay
4150            if (s.params.autoplay && s.autoplaying) {
4151                if (internal || !s.params.autoplayDisableOnInteraction) {
4152                    s.pauseAutoplay(speed);
4153                }
4154                else {
4155                    s.stopAutoplay();
4156                }
4157            }
4158            // Update progress
4159            s.updateProgress(translate);
4160        
4161            // Normalize slideIndex
4162            for (var i = 0; i < s.slidesGrid.length; i++) {
4163                if (- Math.floor(translate * 100) >= Math.floor(s.slidesGrid[i] * 100)) {
4164                    slideIndex = i;
4165                }
4166            }
4167        
4168            // Directions locks
4169            if (!s.params.allowSwipeToNext && translate < s.translate && translate < s.minTranslate()) {
4170                return false;
4171            }
4172            if (!s.params.allowSwipeToPrev && translate > s.translate && translate > s.maxTranslate()) {
4173                if ((s.activeIndex || 0) !== slideIndex ) return false;
4174            }
4175        
4176            // Update Index
4177            if (typeof speed === 'undefined') speed = s.params.speed;
4178            s.previousIndex = s.activeIndex || 0;
4179            s.activeIndex = slideIndex;
4180        
4181            if ((s.rtl && -translate === s.translate) || (!s.rtl && translate === s.translate)) {
4182                // Update Height
4183                if (s.params.autoHeight) {
4184                    s.updateAutoHeight();
4185                }
4186                s.updateClasses();
4187                if (s.params.effect !== 'slide') {
4188                    s.setWrapperTranslate(translate);
4189                }
4190                return false;
4191            }
4192            s.updateClasses();
4193            s.onTransitionStart(runCallbacks);
4194        
4195            if (speed === 0) {
4196                s.setWrapperTranslate(translate);
4197                s.setWrapperTransition(0);
4198                s.onTransitionEnd(runCallbacks);
4199            }
4200            else {
4201                s.setWrapperTranslate(translate);
4202                s.setWrapperTransition(speed);
4203                if (!s.animating) {
4204                    s.animating = true;
4205                    s.wrapper.transitionEnd(function () {
4206                        if (!s) return;
4207                        s.onTransitionEnd(runCallbacks);
4208                    });
4209                }
4210        
4211            }
4212        
4213            return true;
4214        };
4215        
4216        s.onTransitionStart = function (runCallbacks) {
4217            if (typeof runCallbacks === 'undefined') runCallbacks = true;
4218            if (s.params.autoHeight) {
4219                s.updateAutoHeight();
4220            }
4221            if (s.lazy) s.lazy.onTransitionStart();
4222            if (runCallbacks) {
4223                s.emit('onTransitionStart', s);
4224                if (s.activeIndex !== s.previousIndex) {
4225                    s.emit('onSlideChangeStart', s);
4226                    if (s.activeIndex > s.previousIndex) {
4227                        s.emit('onSlideNextStart', s);
4228                    }
4229                    else {
4230                        s.emit('onSlidePrevStart', s);
4231                    }
4232                }
4233        
4234            }
4235        };
4236        s.onTransitionEnd = function (runCallbacks) {
4237            s.animating = false;
4238            s.setWrapperTransition(0);
4239            if (typeof runCallbacks === 'undefined') runCallbacks = true;
4240            if (s.lazy) s.lazy.onTransitionEnd();
4241            if (runCallbacks) {
4242                s.emit('onTransitionEnd', s);
4243                if (s.activeIndex !== s.previousIndex) {
4244                    s.emit('onSlideChangeEnd', s);
4245                    if (s.activeIndex > s.previousIndex) {
4246                        s.emit('onSlideNextEnd', s);
4247                    }
4248                    else {
4249                        s.emit('onSlidePrevEnd', s);
4250                    }
4251                }
4252            }
4253            if (s.params.hashnav && s.hashnav) {
4254                s.hashnav.setHash();
4255            }
4256        
4257        };
4258        s.slideNext = function (runCallbacks, speed, internal) {
4259            if (s.params.loop) {
4260                if (s.animating) return false;
4261                s.fixLoop();
4262                var clientLeft = s.container[0].clientLeft;
4263                return s.slideTo(s.activeIndex + s.params.slidesPerGroup, speed, runCallbacks, internal);
4264            }
4265            else return s.slideTo(s.activeIndex + s.params.slidesPerGroup, speed, runCallbacks, internal);
4266        };
4267        s._slideNext = function (speed) {
4268            return s.slideNext(true, speed, true);
4269        };
4270        s.slidePrev = function (runCallbacks, speed, internal) {
4271            if (s.params.loop) {
4272                if (s.animating) return false;
4273                s.fixLoop();
4274                var clientLeft = s.container[0].clientLeft;
4275                return s.slideTo(s.activeIndex - 1, speed, runCallbacks, internal);
4276            }
4277            else return s.slideTo(s.activeIndex - 1, speed, runCallbacks, internal);
4278        };
4279        s._slidePrev = function (speed) {
4280            return s.slidePrev(true, speed, true);
4281        };
4282        s.slideReset = function (runCallbacks, speed, internal) {
4283            return s.slideTo(s.activeIndex, speed, runCallbacks);
4284        };
4285        
4286        /*=========================
4287          Translate/transition helpers
4288          ===========================*/
4289        s.setWrapperTransition = function (duration, byController) {
4290            s.wrapper.transition(duration);
4291            if (s.params.effect !== 'slide' && s.effects[s.params.effect]) {
4292                s.effects[s.params.effect].setTransition(duration);
4293            }
4294            if (s.params.parallax && s.parallax) {
4295                s.parallax.setTransition(duration);
4296            }
4297            if (s.params.scrollbar && s.scrollbar) {
4298                s.scrollbar.setTransition(duration);
4299            }
4300            if (s.params.control && s.controller) {
4301                s.controller.setTransition(duration, byController);
4302            }
4303            s.emit('onSetTransition', s, duration);
4304        };
4305        s.setWrapperTranslate = function (translate, updateActiveIndex, byController) {
4306            var x = 0, y = 0, z = 0;
4307            if (s.isHorizontal()) {
4308                x = s.rtl ? -translate : translate;
4309            }
4310            else {
4311                y = translate;
4312            }
4313        
4314            if (s.params.roundLengths) {
4315                x = round(x);
4316                y = round(y);
4317            }
4318        
4319            if (!s.params.virtualTranslate) {
4320                if (s.support.transforms3d) s.wrapper.transform('translate3d(' + x + 'px, ' + y + 'px, ' + z + 'px)');
4321                else s.wrapper.transform('translate(' + x + 'px, ' + y + 'px)');
4322            }
4323        
4324            s.translate = s.isHorizontal() ? x : y;
4325        
4326            // Check if we need to update progress
4327            var progress;
4328            var translatesDiff = s.maxTranslate() - s.minTranslate();
4329            if (translatesDiff === 0) {
4330                progress = 0;
4331            }
4332            else {
4333                progress = (translate - s.minTranslate()) / (translatesDiff);
4334            }
4335            if (progress !== s.progress) {
4336                s.updateProgress(translate);
4337            }
4338        
4339            if (updateActiveIndex) s.updateActiveIndex();
4340            if (s.params.effect !== 'slide' && s.effects[s.params.effect]) {
4341                s.effects[s.params.effect].setTranslate(s.translate);
4342            }
4343            if (s.params.parallax && s.parallax) {
4344                s.parallax.setTranslate(s.translate);
4345            }
4346            if (s.params.scrollbar && s.scrollbar) {
4347                s.scrollbar.setTranslate(s.translate);
4348            }
4349            if (s.params.control && s.controller) {
4350                s.controller.setTranslate(s.translate, byController);
4351            }
4352            s.emit('onSetTranslate', s, s.translate);
4353        };
4354        
4355        s.getTranslate = function (el, axis) {
4356            var matrix, curTransform, curStyle, transformMatrix;
4357        
4358            // automatic axis detection
4359            if (typeof axis === 'undefined') {
4360                axis = 'x';
4361            }
4362        
4363            if (s.params.virtualTranslate) {
4364                return s.rtl ? -s.translate : s.translate;
4365            }
4366        
4367            curStyle = window.getComputedStyle(el, null);
4368            if (window.WebKitCSSMatrix) {
4369                curTransform = curStyle.transform || curStyle.webkitTransform;
4370                if (curTransform.split(',').length > 6) {
4371                    curTransform = curTransform.split(', ').map(function(a){
4372                        return a.replace(',','.');
4373                    }).join(', ');
4374                }
4375                // Some old versions of Webkit choke when 'none' is passed; pass
4376                // empty string instead in this case
4377                transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
4378            }
4379            else {
4380                transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform  || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
4381                matrix = transformMatrix.toString().split(',');
4382            }
4383        
4384            if (axis === 'x') {
4385                //Latest Chrome and webkits Fix
4386                if (window.WebKitCSSMatrix)
4387                    curTransform = transformMatrix.m41;
4388                //Crazy IE10 Matrix
4389                else if (matrix.length === 16)
4390                    curTransform = parseFloat(matrix[12]);
4391                //Normal Browsers
4392                else
4393                    curTransform = parseFloat(matrix[4]);
4394            }
4395            if (axis === 'y') {
4396                //Latest Chrome and webkits Fix
4397                if (window.WebKitCSSMatrix)
4398                    curTransform = transformMatrix.m42;
4399                //Crazy IE10 Matrix
4400                else if (matrix.length === 16)
4401                    curTransform = parseFloat(matrix[13]);
4402                //Normal Browsers
4403                else
4404                    curTransform = parseFloat(matrix[5]);
4405            }
4406            if (s.rtl && curTransform) curTransform = -curTransform;
4407            return curTransform || 0;
4408        };
4409        s.getWrapperTranslate = function (axis) {
4410            if (typeof axis === 'undefined') {
4411                axis = s.isHorizontal() ? 'x' : 'y';
4412            }
4413            return s.getTranslate(s.wrapper[0], axis);
4414        };
4415        
4416        /*=========================
4417          Observer
4418          ===========================*/
4419        s.observers = [];
4420        function initObserver(target, options) {
4421            options = options || {};
4422            // create an observer instance
4423            var ObserverFunc = window.MutationObserver || window.WebkitMutationObserver;
4424            var observer = new ObserverFunc(function (mutations) {
4425                mutations.forEach(function (mutation) {
4426                    s.onResize(true);
4427                    s.emit('onObserverUpdate', s, mutation);
4428                });
4429            });
4430        
4431            observer.observe(target, {
4432                attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
4433                childList: typeof options.childList === 'undefined' ? true : options.childList,
4434                characterData: typeof options.characterData === 'undefined' ? true : options.characterData
4435            });
4436        
4437            s.observers.push(observer);
4438        }
4439        s.initObservers = function () {
4440            if (s.params.observeParents) {
4441                var containerParents = s.container.parents();
4442                for (var i = 0; i < containerParents.length; i++) {
4443                    initObserver(containerParents[i]);
4444                }
4445            }
4446        
4447            // Observe container
4448            initObserver(s.container[0], {childList: false});
4449        
4450            // Observe wrapper
4451            initObserver(s.wrapper[0], {attributes: false});
4452        };
4453        s.disconnectObservers = function () {
4454            for (var i = 0; i < s.observers.length; i++) {
4455                s.observers[i].disconnect();
4456            }
4457            s.observers = [];
4458        };
4459        /*=========================
4460          Loop
4461          ===========================*/
4462        // Create looped slides
4463        s.createLoop = function () {
4464            // Remove duplicated slides
4465            s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove();
4466        
4467            var slides = s.wrapper.children('.' + s.params.slideClass);
4468        
4469            if(s.params.slidesPerView === 'auto' && !s.params.loopedSlides) s.params.loopedSlides = slides.length;
4470        
4471            s.loopedSlides = parseInt(s.params.loopedSlides || s.params.slidesPerView, 10);
4472            s.loopedSlides = s.loopedSlides + s.params.loopAdditionalSlides;
4473            if (s.loopedSlides > slides.length) {
4474                s.loopedSlides = slides.length;
4475            }
4476        
4477            var prependSlides = [], appendSlides = [], i;
4478            slides.each(function (index, el) {
4479                var slide = $(this);
4480                if (index < s.loopedSlides) appendSlides.push(el);
4481                if (index < slides.length && index >= slides.length - s.loopedSlides) prependSlides.push(el);
4482                slide.attr('data-swiper-slide-index', index);
4483            });
4484            for (i = 0; i < appendSlides.length; i++) {
4485                s.wrapper.append($(appendSlides[i].cloneNode(true)).addClass(s.params.slideDuplicateClass));
4486            }
4487            for (i = prependSlides.length - 1; i >= 0; i--) {
4488                s.wrapper.prepend($(prependSlides[i].cloneNode(true)).addClass(s.params.slideDuplicateClass));
4489            }
4490        };
4491        s.destroyLoop = function () {
4492            s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove();
4493            s.slides.removeAttr('data-swiper-slide-index');
4494        };
4495        s.reLoop = function (updatePosition) {
4496            var oldIndex = s.activeIndex - s.loopedSlides;
4497            s.destroyLoop();
4498            s.createLoop();
4499            s.updateSlidesSize();
4500            if (updatePosition) {
4501                s.slideTo(oldIndex + s.loopedSlides, 0, false);
4502            }
4503        
4504        };
4505        s.fixLoop = function () {
4506            var newIndex;
4507            //Fix For Negative Oversliding
4508            if (s.activeIndex < s.loopedSlides) {
4509                newIndex = s.slides.length - s.loopedSlides * 3 + s.activeIndex;
4510                newIndex = newIndex + s.loopedSlides;
4511                s.slideTo(newIndex, 0, false, true);
4512            }
4513            //Fix For Positive Oversliding
4514            else if ((s.params.slidesPerView === 'auto' && s.activeIndex >= s.loopedSlides * 2) || (s.activeIndex > s.slides.length - s.params.slidesPerView * 2)) {
4515                newIndex = -s.slides.length + s.activeIndex + s.loopedSlides;
4516                newIndex = newIndex + s.loopedSlides;
4517                s.slideTo(newIndex, 0, false, true);
4518            }
4519        };
4520        /*=========================
4521          Append/Prepend/Remove Slides
4522          ===========================*/
4523        s.appendSlide = function (slides) {
4524            if (s.params.loop) {
4525                s.destroyLoop();
4526            }
4527            if (typeof slides === 'object' && slides.length) {
4528                for (var i = 0; i < slides.length; i++) {
4529                    if (slides[i]) s.wrapper.append(slides[i]);
4530                }
4531            }
4532            else {
4533                s.wrapper.append(slides);
4534            }
4535            if (s.params.loop) {
4536                s.createLoop();
4537            }
4538            if (!(s.params.observer && s.support.observer)) {
4539                s.update(true);
4540            }
4541        };
4542        s.prependSlide = function (slides) {
4543            if (s.params.loop) {
4544                s.destroyLoop();
4545            }
4546            var newActiveIndex = s.activeIndex + 1;
4547            if (typeof slides === 'object' && slides.length) {
4548                for (var i = 0; i < slides.length; i++) {
4549                    if (slides[i]) s.wrapper.prepend(slides[i]);
4550                }
4551                newActiveIndex = s.activeIndex + slides.length;
4552            }
4553            else {
4554                s.wrapper.prepend(slides);
4555            }
4556            if (s.params.loop) {
4557                s.createLoop();
4558            }
4559            if (!(s.params.observer && s.support.observer)) {
4560                s.update(true);
4561            }
4562            s.slideTo(newActiveIndex, 0, false);
4563        };
4564        s.removeSlide = function (slidesIndexes) {
4565            if (s.params.loop) {
4566                s.destroyLoop();
4567                s.slides = s.wrapper.children('.' + s.params.slideClass);
4568            }
4569            var newActiveIndex = s.activeIndex,
4570                indexToRemove;
4571            if (typeof slidesIndexes === 'object' && slidesIndexes.length) {
4572                for (var i = 0; i < slidesIndexes.length; i++) {
4573                    indexToRemove = slidesIndexes[i];
4574                    if (s.slides[indexToRemove]) s.slides.eq(indexToRemove).remove();
4575                    if (indexToRemove < newActiveIndex) newActiveIndex--;
4576                }
4577                newActiveIndex = Math.max(newActiveIndex, 0);
4578            }
4579            else {
4580                indexToRemove = slidesIndexes;
4581                if (s.slides[indexToRemove]) s.slides.eq(indexToRemove).remove();
4582                if (indexToRemove < newActiveIndex) newActiveIndex--;
4583                newActiveIndex = Math.max(newActiveIndex, 0);
4584            }
4585        
4586            if (s.params.loop) {
4587                s.createLoop();
4588            }
4589        
4590            if (!(s.params.observer && s.support.observer)) {
4591                s.update(true);
4592            }
4593            if (s.params.loop) {
4594                s.slideTo(newActiveIndex + s.loopedSlides, 0, false);
4595            }
4596            else {
4597                s.slideTo(newActiveIndex, 0, false);
4598            }
4599        
4600        };
4601        s.removeAllSlides = function () {
4602            var slidesIndexes = [];
4603            for (var i = 0; i < s.slides.length; i++) {
4604                slidesIndexes.push(i);
4605            }
4606            s.removeSlide(slidesIndexes);
4607        };
4608        
4609
4610        /*=========================
4611          Effects
4612          ===========================*/
4613        s.effects = {
4614            fade: {
4615                setTranslate: function () {
4616                    for (var i = 0; i < s.slides.length; i++) {
4617                        var slide = s.slides.eq(i);
4618                        var offset = slide[0].swiperSlideOffset;
4619                        var tx = -offset;
4620                        if (!s.params.virtualTranslate) tx = tx - s.translate;
4621                        var ty = 0;
4622                        if (!s.isHorizontal()) {
4623                            ty = tx;
4624                            tx = 0;
4625                        }
4626                        var slideOpacity = s.params.fade.crossFade ?
4627                                Math.max(1 - Math.abs(slide[0].progress), 0) :
4628                                1 + Math.min(Math.max(slide[0].progress, -1), 0);
4629                        slide
4630                            .css({
4631                                opacity: slideOpacity
4632                            })
4633                            .transform('translate3d(' + tx + 'px, ' + ty + 'px, 0px)');
4634        
4635                    }
4636        
4637                },
4638                setTransition: function (duration) {
4639                    s.slides.transition(duration);
4640                    if (s.params.virtualTranslate && duration !== 0) {
4641                        var eventTriggered = false;
4642                        s.slides.transitionEnd(function () {
4643                            if (eventTriggered) return;
4644                            if (!s) return;
4645                            eventTriggered = true;
4646                            s.animating = false;
4647                            var triggerEvents = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'];
4648                            for (var i = 0; i < triggerEvents.length; i++) {
4649                                s.wrapper.trigger(triggerEvents[i]);
4650                            }
4651                        });
4652                    }
4653                }
4654            },
4655            flip: {
4656                setTranslate: function () {
4657                    for (var i = 0; i < s.slides.length; i++) {
4658                        var slide = s.slides.eq(i);
4659                        var progress = slide[0].progress;
4660                        if (s.params.flip.limitRotation) {
4661                            progress = Math.max(Math.min(slide[0].progress, 1), -1);
4662                        }
4663                        var offset = slide[0].swiperSlideOffset;
4664                        var rotate = -180 * progress,
4665                            rotateY = rotate,
4666                            rotateX = 0,
4667                            tx = -offset,
4668                            ty = 0;
4669                        if (!s.isHorizontal()) {
4670                            ty = tx;
4671                            tx = 0;
4672                            rotateX = -rotateY;
4673                            rotateY = 0;
4674                        }
4675                        else if (s.rtl) {
4676                            rotateY = -rotateY;
4677                        }
4678        
4679                        slide[0].style.zIndex = -Math.abs(Math.round(progress)) + s.slides.length;
4680        
4681                        if (s.params.flip.slideShadows) {
4682                            //Set shadows
4683                            var shadowBefore = s.isHorizontal() ? slide.find('.swiper-slide-shadow-left') : slide.find('.swiper-slide-shadow-top');
4684                            var shadowAfter = s.isHorizontal() ? slide.find('.swiper-slide-shadow-right') : slide.find('.swiper-slide-shadow-bottom');
4685                            if (shadowBefore.length === 0) {
4686                                shadowBefore = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'left' : 'top') + '"></div>');
4687                                slide.append(shadowBefore);
4688                            }
4689                            if (shadowAfter.length === 0) {
4690                                shadowAfter = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'right' : 'bottom') + '"></div>');
4691                                slide.append(shadowAfter);
4692                            }
4693                            if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0);
4694                            if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0);
4695                        }
4696        
4697                        slide
4698                            .transform('translate3d(' + tx + 'px, ' + ty + 'px, 0px) rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg)');
4699                    }
4700                },
4701                setTransition: function (duration) {
4702                    s.slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
4703                    if (s.params.virtualTranslate && duration !== 0) {
4704                        var eventTriggered = false;
4705                        s.slides.eq(s.activeIndex).transitionEnd(function () {
4706                            if (eventTriggered) return;
4707                            if (!s) return;
4708                            if (!$(this).hasClass(s.params.slideActiveClass)) return;
4709                            eventTriggered = true;
4710                            s.animating = false;
4711                            var triggerEvents = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'];
4712                            for (var i = 0; i < triggerEvents.length; i++) {
4713                                s.wrapper.trigger(triggerEvents[i]);
4714                            }
4715                        });
4716                    }
4717                }
4718            },
4719            cube: {
4720                setTranslate: function () {
4721                    var wrapperRotate = 0, cubeShadow;
4722                    if (s.params.cube.shadow) {
4723                        if (s.isHorizontal()) {
4724                            cubeShadow = s.wrapper.find('.swiper-cube-shadow');
4725                            if (cubeShadow.length === 0) {
4726                                cubeShadow = $('<div class="swiper-cube-shadow"></div>');
4727                                s.wrapper.append(cubeShadow);
4728                            }
4729                            cubeShadow.css({height: s.width + 'px'});
4730                        }
4731                        else {
4732                            cubeShadow = s.container.find('.swiper-cube-shadow');
4733                            if (cubeShadow.length === 0) {
4734                                cubeShadow = $('<div class="swiper-cube-shadow"></div>');
4735                                s.container.append(cubeShadow);
4736                            }
4737                        }
4738                    }
4739                    for (var i = 0; i < s.slides.length; i++) {
4740                        var slide = s.slides.eq(i);
4741                        var slideAngle = i * 90;
4742                        var round = Math.floor(slideAngle / 360);
4743                        if (s.rtl) {
4744                            slideAngle = -slideAngle;
4745                            round = Math.floor(-slideAngle / 360);
4746                        }
4747                        var progress = Math.max(Math.min(slide[0].progress, 1), -1);
4748                        var tx = 0, ty = 0, tz = 0;
4749                        if (i % 4 === 0) {
4750                            tx = - round * 4 * s.size;
4751                            tz = 0;
4752                        }
4753                        else if ((i - 1) % 4 === 0) {
4754                            tx = 0;
4755                            tz = - round * 4 * s.size;
4756                        }
4757                        else if ((i - 2) % 4 === 0) {
4758                            tx = s.size + round * 4 * s.size;
4759                            tz = s.size;
4760                        }
4761                        else if ((i - 3) % 4 === 0) {
4762                            tx = - s.size;
4763                            tz = 3 * s.size + s.size * 4 * round;
4764                        }
4765                        if (s.rtl) {
4766                            tx = -tx;
4767                        }
4768        
4769                        if (!s.isHorizontal()) {
4770                            ty = tx;
4771                            tx = 0;
4772                        }
4773        
4774                        var transform = 'rotateX(' + (s.isHorizontal() ? 0 : -slideAngle) + 'deg) rotateY(' + (s.isHorizontal() ? slideAngle : 0) + 'deg) translate3d(' + tx + 'px, ' + ty + 'px, ' + tz + 'px)';
4775                        if (progress <= 1 && progress > -1) {
4776                            wrapperRotate = i * 90 + progress * 90;
4777                            if (s.rtl) wrapperRotate = -i * 90 - progress * 90;
4778                        }
4779                        slide.transform(transform);
4780                        if (s.params.cube.slideShadows) {
4781                            //Set shadows
4782                            var shadowBefore = s.isHorizontal() ? slide.find('.swiper-slide-shadow-left') : slide.find('.swiper-slide-shadow-top');
4783                            var shadowAfter = s.isHorizontal() ? slide.find('.swiper-slide-shadow-right') : slide.find('.swiper-slide-shadow-bottom');
4784                            if (shadowBefore.length === 0) {
4785                                shadowBefore = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'left' : 'top') + '"></div>');
4786                                slide.append(shadowBefore);
4787                            }
4788                            if (shadowAfter.length === 0) {
4789                                shadowAfter = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'right' : 'bottom') + '"></div>');
4790                                slide.append(shadowAfter);
4791                            }
4792                            if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0);
4793                            if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0);
4794                        }
4795                    }
4796                    s.wrapper.css({
4797                        '-webkit-transform-origin': '50% 50% -' + (s.size / 2) + 'px',
4798                        '-moz-transform-origin': '50% 50% -' + (s.size / 2) + 'px',
4799                        '-ms-transform-origin': '50% 50% -' + (s.size / 2) + 'px',
4800                        'transform-origin': '50% 50% -' + (s.size / 2) + 'px'
4801                    });
4802        
4803                    if (s.params.cube.shadow) {
4804                        if (s.isHorizontal()) {
4805                            cubeShadow.transform('translate3d(0px, ' + (s.width / 2 + s.params.cube.shadowOffset) + 'px, ' + (-s.width / 2) + 'px) rotateX(90deg) rotateZ(0deg) scale(' + (s.params.cube.shadowScale) + ')');
4806                        }
4807                        else {
4808                            var shadowAngle = Math.abs(wrapperRotate) - Math.floor(Math.abs(wrapperRotate) / 90) * 90;
4809                            var multiplier = 1.5 - (Math.sin(shadowAngle * 2 * Math.PI / 360) / 2 + Math.cos(shadowAngle * 2 * Math.PI / 360) / 2);
4810                            var scale1 = s.params.cube.shadowScale,
4811                                scale2 = s.params.cube.shadowScale / multiplier,
4812                                offset = s.params.cube.shadowOffset;
4813                            cubeShadow.transform('scale3d(' + scale1 + ', 1, ' + scale2 + ') translate3d(0px, ' + (s.height / 2 + offset) + 'px, ' + (-s.height / 2 / scale2) + 'px) rotateX(-90deg)');
4814                        }
4815                    }
4816                    var zFactor = (s.isSafari || s.isUiWebView) ? (-s.size / 2) : 0;
4817                    s.wrapper.transform('translate3d(0px,0,' + zFactor + 'px) rotateX(' + (s.isHorizontal() ? 0 : wrapperRotate) + 'deg) rotateY(' + (s.isHorizontal() ? -wrapperRotate : 0) + 'deg)');
4818                },
4819                setTransition: function (duration) {
4820                    s.slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
4821                    if (s.params.cube.shadow && !s.isHorizontal()) {
4822                        s.container.find('.swiper-cube-shadow').transition(duration);
4823                    }
4824                }
4825            },
4826            coverflow: {
4827                setTranslate: function () {
4828                    var transform = s.translate;
4829                    var center = s.isHorizontal() ? -transform + s.width / 2 : -transform + s.height / 2;
4830                    var rotate = s.isHorizontal() ? s.params.coverflow.rotate: -s.params.coverflow.rotate;
4831                    var translate = s.params.coverflow.depth;
4832                    //Each slide offset from center
4833                    for (var i = 0, length = s.slides.length; i < length; i++) {
4834                        var slide = s.slides.eq(i);
4835                        var slideSize = s.slidesSizesGrid[i];
4836                        var slideOffset = slide[0].swiperSlideOffset;
4837                        var offsetMultiplier = (center - slideOffset - slideSize / 2) / slideSize * s.params.coverflow.modifier;
4838        
4839                        var rotateY = s.isHorizontal() ? rotate * offsetMultiplier : 0;
4840                        var rotateX = s.isHorizontal() ? 0 : rotate * offsetMultiplier;
4841                        // var rotateZ = 0
4842                        var translateZ = -translate * Math.abs(offsetMultiplier);
4843        
4844                        var translateY = s.isHorizontal() ? 0 : s.params.coverflow.stretch * (offsetMultiplier);
4845                        var translateX = s.isHorizontal() ? s.params.coverflow.stretch * (offsetMultiplier) : 0;
4846        
4847                        //Fix for ultra small values
4848                        if (Math.abs(translateX) < 0.001) translateX = 0;
4849                        if (Math.abs(translateY) < 0.001) translateY = 0;
4850                        if (Math.abs(translateZ) < 0.001) translateZ = 0;
4851                        if (Math.abs(rotateY) < 0.001) rotateY = 0;
4852                        if (Math.abs(rotateX) < 0.001) rotateX = 0;
4853        
4854                        var slideTransform = 'translate3d(' + translateX + 'px,' + translateY + 'px,' + translateZ + 'px)  rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg)';
4855        
4856                        slide.transform(slideTransform);
4857                        slide[0].style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1;
4858                        if (s.params.coverflow.slideShadows) {
4859                            //Set shadows
4860                            var shadowBefore = s.isHorizontal() ? slide.find('.swiper-slide-shadow-left') : slide.find('.swiper-slide-shadow-top');
4861                            var shadowAfter = s.isHorizontal() ? slide.find('.swiper-slide-shadow-right') : slide.find('.swiper-slide-shadow-bottom');
4862                            if (shadowBefore.length === 0) {
4863                                shadowBefore = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'left' : 'top') + '"></div>');
4864                                slide.append(shadowBefore);
4865                            }
4866                            if (shadowAfter.length === 0) {
4867                                shadowAfter = $('<div class="swiper-slide-shadow-' + (s.isHorizontal() ? 'right' : 'bottom') + '"></div>');
4868                                slide.append(shadowAfter);
4869                            }
4870                            if (shadowBefore.length) shadowBefore[0].style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0;
4871                            if (shadowAfter.length) shadowAfter[0].style.opacity = (-offsetMultiplier) > 0 ? -offsetMultiplier : 0;
4872                        }
4873                    }
4874        
4875                    //Set correct perspective for IE10
4876                    if (s.browser.ie) {
4877                        var ws = s.wrapper[0].style;
4878                        ws.perspectiveOrigin = center + 'px 50%';
4879                    }
4880                },
4881                setTransition: function (duration) {
4882                    s.slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
4883                }
4884            }
4885        };
4886
4887        /*=========================
4888          Images Lazy Loading
4889          ===========================*/
4890        s.lazy = {
4891            initialImageLoaded: false,
4892            loadImageInSlide: function (index, loadInDuplicate) {
4893                if (typeof index === 'undefined') return;
4894                if (typeof loadInDuplicate === 'undefined') loadInDuplicate = true;
4895                if (s.slides.length === 0) return;
4896        
4897                var slide = s.slides.eq(index);
4898                var img = slide.find('.swiper-lazy:not(.swiper-lazy-loaded):not(.swiper-lazy-loading)');
4899                if (slide.hasClass('swiper-lazy') && !slide.hasClass('swiper-lazy-loaded') && !slide.hasClass('swiper-lazy-loading')) {
4900                    img = img.add(slide[0]);
4901                }
4902                if (img.length === 0) return;
4903        
4904                img.each(function () {
4905                    var _img = $(this);
4906                    _img.addClass('swiper-lazy-loading');
4907                    var background = _img.attr('data-background');
4908                    var src = _img.attr('data-src'),
4909                        srcset = _img.attr('data-srcset');
4910                    s.loadImage(_img[0], (src || background), srcset, false, function () {
4911                        if (background) {
4912                            _img.css('background-image', 'url("' + background + '")');
4913                            _img.removeAttr('data-background');
4914                        }
4915                        else {
4916                            if (srcset) {
4917                                _img.attr('srcset', srcset);
4918                                _img.removeAttr('data-srcset');
4919                            }
4920                            if (src) {
4921                                _img.attr('src', src);
4922                                _img.removeAttr('data-src');
4923                            }
4924        
4925                        }
4926        
4927                        _img.addClass('swiper-lazy-loaded').removeClass('swiper-lazy-loading');
4928                        slide.find('.swiper-lazy-preloader, .preloader').remove();
4929                        if (s.params.loop && loadInDuplicate) {
4930                            var slideOriginalIndex = slide.attr('data-swiper-slide-index');
4931                            if (slide.hasClass(s.params.slideDuplicateClass)) {
4932                                var originalSlide = s.wrapper.children('[data-swiper-slide-index="' + slideOriginalIndex + '"]:not(.' + s.params.slideDuplicateClass + ')');
4933                                s.lazy.loadImageInSlide(originalSlide.index(), false);
4934                            }
4935                            else {
4936                                var duplicatedSlide = s.wrapper.children('.' + s.params.slideDuplicateClass + '[data-swiper-slide-index="' + slideOriginalIndex + '"]');
4937                                s.lazy.loadImageInSlide(duplicatedSlide.index(), false);
4938                            }
4939                        }
4940                        s.emit('onLazyImageReady', s, slide[0], _img[0]);
4941                    });
4942        
4943                    s.emit('onLazyImageLoad', s, slide[0], _img[0]);
4944                });
4945        
4946            },
4947            load: function () {
4948                var i;
4949                if (s.params.watchSlidesVisibility) {
4950                    s.wrapper.children('.' + s.params.slideVisibleClass).each(function () {
4951                        s.lazy.loadImageInSlide($(this).index());
4952                    });
4953                }
4954                else {
4955                    if (s.params.slidesPerView > 1) {
4956                        for (i = s.activeIndex; i < s.activeIndex + s.params.slidesPerView ; i++) {
4957                            if (s.slides[i]) s.lazy.loadImageInSlide(i);
4958                        }
4959                    }
4960                    else {
4961                        s.lazy.loadImageInSlide(s.activeIndex);
4962                    }
4963                }
4964                if (s.params.lazyLoadingInPrevNext) {
4965                    if (s.params.slidesPerView > 1 || (s.params.lazyLoadingInPrevNextAmount && s.params.lazyLoadingInPrevNextAmount > 1)) {
4966                        var amount = s.params.lazyLoadingInPrevNextAmount;
4967                        var spv = s.params.slidesPerView;
4968                        var maxIndex = Math.min(s.activeIndex + spv + Math.max(amount, spv), s.slides.length);
4969                        var minIndex = Math.max(s.activeIndex - Math.max(spv, amount), 0);
4970                        // Next Slides
4971                        for (i = s.activeIndex + s.params.slidesPerView; i < maxIndex; i++) {
4972                            if (s.slides[i]) s.lazy.loadImageInSlide(i);
4973                        }
4974                        // Prev Slides
4975                        for (i = minIndex; i < s.activeIndex ; i++) {
4976                            if (s.slides[i]) s.lazy.loadImageInSlide(i);
4977                        }
4978                    }
4979                    else {
4980                        var nextSlide = s.wrapper.children('.' + s.params.slideNextClass);
4981                        if (nextSlide.length > 0) s.lazy.loadImageInSlide(nextSlide.index());
4982        
4983                        var prevSlide = s.wrapper.children('.' + s.params.slidePrevClass);
4984                        if (prevSlide.length > 0) s.lazy.loadImageInSlide(prevSlide.index());
4985                    }
4986                }
4987            },
4988            onTransitionStart: function () {
4989                if (s.params.lazyLoading) {
4990                    if (s.params.lazyLoadingOnTransitionStart || (!s.params.lazyLoadingOnTransitionStart && !s.lazy.initialImageLoaded)) {
4991                        s.lazy.load();
4992                    }
4993                }
4994            },
4995            onTransitionEnd: function () {
4996                if (s.params.lazyLoading && !s.params.lazyLoadingOnTransitionStart) {
4997                    s.lazy.load();
4998                }
4999            }
5000        };
5001        
5002
5003        /*=========================
5004          Scrollbar
5005          ===========================*/
5006        s.scrollbar = {
5007            isTouched: false,
5008            setDragPosition: function (e) {
5009                var sb = s.scrollbar;
5010                var x = 0, y = 0;
5011                var translate;
5012                var pointerPosition = s.isHorizontal() ?
5013                    ((e.type === 'touchstart' || e.type === 'touchmove') ? e.targetTouches[0].pageX : e.pageX || e.clientX) :
5014                    ((e.type === 'touchstart' || e.type === 'touchmove') ? e.targetTouches[0].pageY : e.pageY || e.clientY) ;
5015                var position = (pointerPosition) - sb.track.offset()[s.isHorizontal() ? 'left' : 'top'] - sb.dragSize / 2;
5016                var positionMin = -s.minTranslate() * sb.moveDivider;
5017                var positionMax = -s.maxTranslate() * sb.moveDivider;
5018                if (position < positionMin) {
5019                    position = positionMin;
5020                }
5021                else if (position > positionMax) {
5022                    position = positionMax;
5023                }
5024                position = -position / sb.moveDivider;
5025                s.updateProgress(position);
5026                s.setWrapperTranslate(position, true);
5027            },
5028            dragStart: function (e) {
5029                var sb = s.scrollbar;
5030                sb.isTouched = true;
5031                e.preventDefault();
5032                e.stopPropagation();
5033        
5034                sb.setDragPosition(e);
5035                clearTimeout(sb.dragTimeout);
5036        
5037                sb.track.transition(0);
5038                if (s.params.scrollbarHide) {
5039                    sb.track.css('opacity', 1);
5040                }
5041                s.wrapper.transition(100);
5042                sb.drag.transition(100);
5043                s.emit('onScrollbarDragStart', s);
5044            },
5045            dragMove: function (e) {
5046                var sb = s.scrollbar;
5047                if (!sb.isTouched) return;
5048                if (e.preventDefault) e.preventDefault();
5049                else e.returnValue = false;
5050                sb.setDragPosition(e);
5051                s.wrapper.transition(0);
5052                sb.track.transition(0);
5053                sb.drag.transition(0);
5054                s.emit('onScrollbarDragMove', s);
5055            },
5056            dragEnd: function (e) {
5057                var sb = s.scrollbar;
5058                if (!sb.isTouched) return;
5059                sb.isTouched = false;
5060                if (s.params.scrollbarHide) {
5061                    clearTimeout(sb.dragTimeout);
5062                    sb.dragTimeout = setTimeout(function () {
5063                        sb.track.css('opacity', 0);
5064                        sb.track.transition(400);
5065                    }, 1000);
5066        
5067                }
5068                s.emit('onScrollbarDragEnd', s);
5069                if (s.params.scrollbarSnapOnRelease) {
5070                    s.slideReset();
5071                }
5072            },
5073            enableDraggable: function () {
5074                var sb = s.scrollbar;
5075                var target = s.support.touch ? sb.track : document;
5076                $(sb.track).on(s.touchEvents.start, sb.dragStart);
5077                $(target).on(s.touchEvents.move, sb.dragMove);
5078                $(target).on(s.touchEvents.end, sb.dragEnd);
5079            },
5080            disableDraggable: function () {
5081                var sb = s.scrollbar;
5082                var target = s.support.touch ? sb.track : document;
5083                $(sb.track).off(s.touchEvents.start, sb.dragStart);
5084                $(target).off(s.touchEvents.move, sb.dragMove);
5085                $(target).off(s.touchEvents.end, sb.dragEnd);
5086            },
5087            set: function () {
5088                if (!s.params.scrollbar) return;
5089                var sb = s.scrollbar;
5090                sb.track = $(s.params.scrollbar);
5091                if (s.params.uniqueNavElements && typeof s.params.scrollbar === 'string' && sb.track.length > 1 && s.container.find(s.params.scrollbar).length === 1) {
5092                    sb.track = s.container.find(s.params.scrollbar);
5093                }
5094                sb.drag = sb.track.find('.swiper-scrollbar-drag');
5095                if (sb.drag.length === 0) {
5096                    sb.drag = $('<div class="swiper-scrollbar-drag"></div>');
5097                    sb.track.append(sb.drag);
5098                }
5099                sb.drag[0].style.width = '';
5100                sb.drag[0].style.height = '';
5101                sb.trackSize = s.isHorizontal() ? sb.track[0].offsetWidth : sb.track[0].offsetHeight;
5102        
5103                sb.divider = s.size / s.virtualSize;
5104                sb.moveDivider = sb.divider * (sb.trackSize / s.size);
5105                sb.dragSize = sb.trackSize * sb.divider;
5106        
5107                if (s.isHorizontal()) {
5108                    sb.drag[0].style.width = sb.dragSize + 'px';
5109                }
5110                else {
5111                    sb.drag[0].style.height = sb.dragSize + 'px';
5112                }
5113        
5114                if (sb.divider >= 1) {
5115                    sb.track[0].style.display = 'none';
5116                }
5117                else {
5118                    sb.track[0].style.display = '';
5119                }
5120                if (s.params.scrollbarHide) {
5121                    sb.track[0].style.opacity = 0;
5122                }
5123            },
5124            setTranslate: function () {
5125                if (!s.params.scrollbar) return;
5126                var diff;
5127                var sb = s.scrollbar;
5128                var translate = s.translate || 0;
5129                var newPos;
5130        
5131                var newSize = sb.dragSize;
5132                newPos = (sb.trackSize - sb.dragSize) * s.progress;
5133                if (s.rtl && s.isHorizontal()) {
5134                    newPos = -newPos;
5135                    if (newPos > 0) {
5136                        newSize = sb.dragSize - newPos;
5137                        newPos = 0;
5138                    }
5139                    else if (-newPos + sb.dragSize > sb.trackSize) {
5140                        newSize = sb.trackSize + newPos;
5141                    }
5142                }
5143                else {
5144                    if (newPos < 0) {
5145                        newSize = sb.dragSize + newPos;
5146                        newPos = 0;
5147                    }
5148                    else if (newPos + sb.dragSize > sb.trackSize) {
5149                        newSize = sb.trackSize - newPos;
5150                    }
5151                }
5152                if (s.isHorizontal()) {
5153                    if (s.support.transforms3d) {
5154                        sb.drag.transform('translate3d(' + (newPos) + 'px, 0, 0)');
5155                    }
5156                    else {
5157                        sb.drag.transform('translateX(' + (newPos) + 'px)');
5158                    }
5159                    sb.drag[0].style.width = newSize + 'px';
5160                }
5161                else {
5162                    if (s.support.transforms3d) {
5163                        sb.drag.transform('translate3d(0px, ' + (newPos) + 'px, 0)');
5164                    }
5165                    else {
5166                        sb.drag.transform('translateY(' + (newPos) + 'px)');
5167                    }
5168                    sb.drag[0].style.height = newSize + 'px';
5169                }
5170                if (s.params.scrollbarHide) {
5171                    clearTimeout(sb.timeout);
5172                    sb.track[0].style.opacity = 1;
5173                    sb.timeout = setTimeout(function () {
5174                        sb.track[0].style.opacity = 0;
5175                        sb.track.transition(400);
5176                    }, 1000);
5177                }
5178            },
5179            setTransition: function (duration) {
5180                if (!s.params.scrollbar) return;
5181                s.scrollbar.drag.transition(duration);
5182            }
5183        };
5184
5185        /*=========================
5186          Controller
5187          ===========================*/
5188        s.controller = {
5189            LinearSpline: function (x, y) {
5190                this.x = x;
5191                this.y = y;
5192                this.lastIndex = x.length - 1;
5193                // Given an x value (x2), return the expected y2 value:
5194                // (x1,y1) is the known point before given value,
5195                // (x3,y3) is the known point after given value.
5196                var i1, i3;
5197                var l = this.x.length;
5198        
5199                this.interpolate = function (x2) {
5200                    if (!x2) return 0;
5201        
5202                    // Get the indexes of x1 and x3 (the array indexes before and after given x2):
5203                    i3 = binarySearch(this.x, x2);
5204                    i1 = i3 - 1;
5205        
5206                    // We have our indexes i1 & i3, so we can calculate already:
5207                    // y2 := ((x2−x1) × (y3−y1)) ÷ (x3−x1) + y1
5208                    return ((x2 - this.x[i1]) * (this.y[i3] - this.y[i1])) / (this.x[i3] - this.x[i1]) + this.y[i1];
5209                };
5210        
5211                var binarySearch = (function() {
5212                    var maxIndex, minIndex, guess;
5213                    return function(array, val) {
5214                        minIndex = -1;
5215                        maxIndex = array.length;
5216                        while (maxIndex - minIndex > 1)
5217                            if (array[guess = maxIndex + minIndex >> 1] <= val) {
5218                                minIndex = guess;
5219                            } else {
5220                                maxIndex = guess;
5221                            }
5222                        return maxIndex;
5223                    };
5224                })();
5225            },
5226            //xxx: for now i will just save one spline function to to
5227            getInterpolateFunction: function(c){
5228                if(!s.controller.spline) s.controller.spline = s.params.loop ?
5229                    new s.controller.LinearSpline(s.slidesGrid, c.slidesGrid) :
5230                    new s.controller.LinearSpline(s.snapGrid, c.snapGrid);
5231            },
5232            setTranslate: function (translate, byController) {
5233               var controlled = s.params.control;
5234               var multiplier, controlledTranslate;
5235               function setControlledTranslate(c) {
5236                    // this will create an Interpolate function based on the snapGrids
5237                    // x is the Grid of the scrolled scroller and y will be the controlled scroller
5238                    // it makes sense to create this only once and recall it for the interpolation
5239                    // the function does a lot of value caching for performance
5240                    translate = c.rtl && c.params.direction === 'horizontal' ? -s.translate : s.translate;
5241                    if (s.params.controlBy === 'slide') {
5242                        s.controller.getInterpolateFunction(c);
5243                        // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid
5244                        // but it did not work out
5245                        controlledTranslate = -s.controller.spline.interpolate(-translate);
5246                    }
5247        
5248                    if(!controlledTranslate || s.params.controlBy === 'container'){
5249                        multiplier = (c.maxTranslate() - c.minTranslate()) / (s.maxTranslate() - s.minTranslate());
5250                        controlledTranslate = (translate - s.minTranslate()) * multiplier + c.minTranslate();
5251                    }
5252        
5253                    if (s.params.controlInverse) {
5254                        controlledTranslate = c.maxTranslate() - controlledTranslate;
5255                    }
5256                    c.updateProgress(controlledTranslate);
5257                    c.setWrapperTranslate(controlledTranslate, false, s);
5258                    c.updateActiveIndex();
5259               }
5260               if (s.isArray(controlled)) {
5261                   for (var i = 0; i < controlled.length; i++) {
5262                       if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
5263                           setControlledTranslate(controlled[i]);
5264                       }
5265                   }
5266               }
5267               else if (controlled instanceof Swiper && byController !== controlled) {
5268        
5269                   setControlledTranslate(controlled);
5270               }
5271            },
5272            setTransition: function (duration, byController) {
5273                var controlled = s.params.control;
5274                var i;
5275                function setControlledTransition(c) {
5276                    c.setWrapperTransition(duration, s);
5277                    if (duration !== 0) {
5278                        c.onTransitionStart();
5279                        c.wrapper.transitionEnd(function(){
5280                            if (!controlled) return;
5281                            if (c.params.loop && s.params.controlBy === 'slide') {
5282                                c.fixLoop();
5283                            }
5284                            c.onTransitionEnd();
5285        
5286                        });
5287                    }
5288                }
5289                if (s.isArray(controlled)) {
5290                    for (i = 0; i < controlled.length; i++) {
5291                        if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
5292                            setControlledTransition(controlled[i]);
5293                        }
5294                    }
5295                }
5296                else if (controlled instanceof Swiper && byController !== controlled) {
5297                    setControlledTransition(controlled);
5298                }
5299            }
5300        };
5301
5302        /*=========================
5303          Hash Navigation
5304          ===========================*/
5305        s.hashnav = {
5306            init: function () {
5307                if (!s.params.hashnav) return;
5308                s.hashnav.initialized = true;
5309                var hash = document.location.hash.replace('#', '');
5310                if (!hash) return;
5311                var speed = 0;
5312                for (var i = 0, length = s.slides.length; i < length; i++) {
5313                    var slide = s.slides.eq(i);
5314                    var slideHash = slide.attr('data-hash');
5315                    if (slideHash === hash && !slide.hasClass(s.params.slideDuplicateClass)) {
5316                        var index = slide.index();
5317                        s.slideTo(index, speed, s.params.runCallbacksOnInit, true);
5318                    }
5319                }
5320            },
5321            setHash: function () {
5322                if (!s.hashnav.initialized || !s.params.hashnav) return;
5323                document.location.hash = s.slides.eq(s.activeIndex).attr('data-hash') || '';
5324            }
5325        };
5326
5327        /*=========================
5328          Keyboard Control
5329          ===========================*/
5330        function handleKeyboard(e) {
5331            if (e.originalEvent) e = e.originalEvent; //jquery fix
5332            var kc = e.keyCode || e.charCode;
5333            // Directions locks
5334            if (!s.params.allowSwipeToNext && (s.isHorizontal() && kc === 39 || !s.isHorizontal() && kc === 40)) {
5335                return false;
5336            }
5337            if (!s.params.allowSwipeToPrev && (s.isHorizontal() && kc === 37 || !s.isHorizontal() && kc === 38)) {
5338                return false;
5339            }
5340            if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) {
5341                return;
5342            }
5343            if (document.activeElement && document.activeElement.nodeName && (document.activeElement.nodeName.toLowerCase() === 'input' || document.activeElement.nodeName.toLowerCase() === 'textarea')) {
5344                return;
5345            }
5346            if (kc === 37 || kc === 39 || kc === 38 || kc === 40) {
5347                var inView = false;
5348                //Check that swiper should be inside of visible area of window
5349                if (s.container.parents('.swiper-slide').length > 0 && s.container.parents('.swiper-slide-active').length === 0) {
5350                    return;
5351                }
5352                var windowScroll = {
5353                    left: window.pageXOffset,
5354                    top: window.pageYOffset
5355                };
5356                var windowWidth = window.innerWidth;
5357                var windowHeight = window.innerHeight;
5358                var swiperOffset = s.container.offset();
5359                if (s.rtl) swiperOffset.left = swiperOffset.left - s.container[0].scrollLeft;
5360                var swiperCoord = [
5361                    [swiperOffset.left, swiperOffset.top],
5362                    [swiperOffset.left + s.width, swiperOffset.top],
5363                    [swiperOffset.left, swiperOffset.top + s.height],
5364                    [swiperOffset.left + s.width, swiperOffset.top + s.height]
5365                ];
5366                for (var i = 0; i < swiperCoord.length; i++) {
5367                    var point = swiperCoord[i];
5368                    if (
5369                        point[0] >= windowScroll.left && point[0] <= windowScroll.left + windowWidth &&
5370                        point[1] >= windowScroll.top && point[1] <= windowScroll.top + windowHeight
5371                    ) {
5372                        inView = true;
5373                    }
5374        
5375                }
5376                if (!inView) return;
5377            }
5378            if (s.isHorizontal()) {
5379                if (kc === 37 || kc === 39) {
5380                    if (e.preventDefault) e.preventDefault();
5381                    else e.returnValue = false;
5382                }
5383                if ((kc === 39 && !s.rtl) || (kc === 37 && s.rtl)) s.slideNext();
5384                if ((kc === 37 && !s.rtl) || (kc === 39 && s.rtl)) s.slidePrev();
5385            }
5386            else {
5387                if (kc === 38 || kc === 40) {
5388                    if (e.preventDefault) e.preventDefault();
5389                    else e.returnValue = false;
5390                }
5391                if (kc === 40) s.slideNext();
5392                if (kc === 38) s.slidePrev();
5393            }
5394        }
5395        s.disableKeyboardControl = function () {
5396            s.params.keyboardControl = false;
5397            $(document).off('keydown', handleKeyboard);
5398        };
5399        s.enableKeyboardControl = function () {
5400            s.params.keyboardControl = true;
5401            $(document).on('keydown', handleKeyboard);
5402        };
5403        
5404
5405        /*=========================
5406          Mousewheel Control
5407          ===========================*/
5408        s.mousewheel = {
5409            event: false,
5410            lastScrollTime: (new window.Date()).getTime()
5411        };
5412        if (s.params.mousewheelControl) {
5413            try {
5414                new window.WheelEvent('wheel');
5415                s.mousewheel.event = 'wheel';
5416            } catch (e) {
5417                if (window.WheelEvent || (s.container[0] && 'wheel' in s.container[0])) {
5418                    s.mousewheel.event = 'wheel';
5419                }
5420            }
5421            if (!s.mousewheel.event && window.WheelEvent) {
5422        
5423            }
5424            if (!s.mousewheel.event && document.onmousewheel !== undefined) {
5425                s.mousewheel.event = 'mousewheel';
5426            }
5427            if (!s.mousewheel.event) {
5428                s.mousewheel.event = 'DOMMouseScroll';
5429            }
5430        }
5431        function handleMousewheel(e) {
5432            if (e.originalEvent) e = e.originalEvent; //jquery fix
5433            var we = s.mousewheel.event;
5434            var delta = 0;
5435            var rtlFactor = s.rtl ? -1 : 1;
5436        
5437            //WebKits
5438            if (we === 'mousewheel') {
5439                if (s.params.mousewheelForceToAxis) {
5440                    if (s.isHorizontal()) {
5441                        if (Math.abs(e.wheelDeltaX) > Math.abs(e.wheelDeltaY)) delta = e.wheelDeltaX * rtlFactor;
5442                        else return;
5443                    }
5444                    else {
5445                        if (Math.abs(e.wheelDeltaY) > Math.abs(e.wheelDeltaX)) delta = e.wheelDeltaY;
5446                        else return;
5447                    }
5448                }
5449                else {
5450                    delta = Math.abs(e.wheelDeltaX) > Math.abs(e.wheelDeltaY) ? - e.wheelDeltaX * rtlFactor : - e.wheelDeltaY;
5451                }
5452            }
5453            //Old FireFox
5454            else if (we === 'DOMMouseScroll') delta = -e.detail;
5455            //New FireFox
5456            else if (we === 'wheel') {
5457                if (s.params.mousewheelForceToAxis) {
5458                    if (s.isHorizontal()) {
5459                        if (Math.abs(e.deltaX) > Math.abs(e.deltaY)) delta = -e.deltaX * rtlFactor;
5460                        else return;
5461                    }
5462                    else {
5463                        if (Math.abs(e.deltaY) > Math.abs(e.deltaX)) delta = -e.deltaY;
5464                        else return;
5465                    }
5466                }
5467                else {
5468                    delta = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? - e.deltaX * rtlFactor : - e.deltaY;
5469                }
5470            }
5471            if (delta === 0) return;
5472        
5473            if (s.params.mousewheelInvert) delta = -delta;
5474        
5475            if (!s.params.freeMode) {
5476                if ((new window.Date()).getTime() - s.mousewheel.lastScrollTime > 60) {
5477                    if (delta < 0) {
5478                        if ((!s.isEnd || s.params.loop) && !s.animating) s.slideNext();
5479                        else if (s.params.mousewheelReleaseOnEdges) return true;
5480                    }
5481                    else {
5482                        if ((!s.isBeginning || s.params.loop) && !s.animating) s.slidePrev();
5483                        else if (s.params.mousewheelReleaseOnEdges) return true;
5484                    }
5485                }
5486                s.mousewheel.lastScrollTime = (new window.Date()).getTime();
5487        
5488            }
5489            else {
5490                //Freemode or scrollContainer:
5491                var position = s.getWrapperTranslate() + delta * s.params.mousewheelSensitivity;
5492                var wasBeginning = s.isBeginning,
5493                    wasEnd = s.isEnd;
5494        
5495                if (position >= s.minTranslate()) position = s.minTranslate();
5496                if (position <= s.maxTranslate()) position = s.maxTranslate();
5497        
5498                s.setWrapperTransition(0);
5499                s.setWrapperTranslate(position);
5500                s.updateProgress();
5501                s.updateActiveIndex();
5502        
5503                if (!wasBeginning && s.isBeginning || !wasEnd && s.isEnd) {
5504                    s.updateClasses();
5505                }
5506        
5507                if (s.params.freeModeSticky) {
5508                    clearTimeout(s.mousewheel.timeout);
5509                    s.mousewheel.timeout = setTimeout(function () {
5510                        s.slideReset();
5511                    }, 300);
5512                }
5513                else {
5514                    if (s.params.lazyLoading && s.lazy) {
5515                        s.lazy.load();
5516                    }
5517                }
5518        
5519                // Return page scroll on edge positions
5520                if (position === 0 || position === s.maxTranslate()) return;
5521            }
5522            if (s.params.autoplay) s.stopAutoplay();
5523        
5524            if (e.preventDefault) e.preventDefault();
5525            else e.returnValue = false;
5526            return false;
5527        }
5528        s.disableMousewheelControl = function () {
5529            if (!s.mousewheel.event) return false;
5530            s.container.off(s.mousewheel.event, handleMousewheel);
5531            return true;
5532        };
5533        
5534        s.enableMousewheelControl = function () {
5535            if (!s.mousewheel.event) return false;
5536            s.container.on(s.mousewheel.event, handleMousewheel);
5537            return true;
5538        };
5539        
5540
5541        /*=========================
5542          Parallax
5543          ===========================*/
5544        function setParallaxTransform(el, progress) {
5545            el = $(el);
5546            var p, pX, pY;
5547            var rtlFactor = s.rtl ? -1 : 1;
5548        
5549            p = el.attr('data-swiper-parallax') || '0';
5550            pX = el.attr('data-swiper-parallax-x');
5551            pY = el.attr('data-swiper-parallax-y');
5552            if (pX || pY) {
5553                pX = pX || '0';
5554                pY = pY || '0';
5555            }
5556            else {
5557                if (s.isHorizontal()) {
5558                    pX = p;
5559                    pY = '0';
5560                }
5561                else {
5562                    pY = p;
5563                    pX = '0';
5564                }
5565            }
5566        
5567            if ((pX).indexOf('%') >= 0) {
5568                pX = parseInt(pX, 10) * progress * rtlFactor + '%';
5569            }
5570            else {
5571                pX = pX * progress * rtlFactor + 'px' ;
5572            }
5573            if ((pY).indexOf('%') >= 0) {
5574                pY = parseInt(pY, 10) * progress + '%';
5575            }
5576            else {
5577                pY = pY * progress + 'px' ;
5578            }
5579        
5580            el.transform('translate3d(' + pX + ', ' + pY + ',0px)');
5581        }
5582        s.parallax = {
5583            setTranslate: function () {
5584                s.container.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]').each(function(){
5585                    setParallaxTransform(this, s.progress);
5586        
5587                });
5588                s.slides.each(function () {
5589                    var slide = $(this);
5590                    slide.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]').each(function () {
5591                        var progress = Math.min(Math.max(slide[0].progress, -1), 1);
5592                        setParallaxTransform(this, progress);
5593                    });
5594                });
5595            },
5596            setTransition: function (duration) {
5597                if (typeof duration === 'undefined') duration = s.params.speed;
5598                s.container.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]').each(function(){
5599                    var el = $(this);
5600                    var parallaxDuration = parseInt(el.attr('data-swiper-parallax-duration'), 10) || duration;
5601                    if (duration === 0) parallaxDuration = 0;
5602                    el.transition(parallaxDuration);
5603                });
5604            }
5605        };
5606        
5607
5608        /*=========================
5609          Plugins API. Collect all and init all plugins
5610          ===========================*/
5611        s._plugins = [];
5612        for (var plugin in s.plugins) {
5613            var p = s.plugins[plugin](s, s.params[plugin]);
5614            if (p) s._plugins.push(p);
5615        }
5616        // Method to call all plugins event/method
5617        s.callPlugins = function (eventName) {
5618            for (var i = 0; i < s._plugins.length; i++) {
5619                if (eventName in s._plugins[i]) {
5620                    s._plugins[i][eventName](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
5621                }
5622            }
5623        };
5624
5625        /*=========================
5626          Events/Callbacks/Plugins Emitter
5627          ===========================*/
5628        function normalizeEventName (eventName) {
5629            if (eventName.indexOf('on') !== 0) {
5630                if (eventName[0] !== eventName[0].toUpperCase()) {
5631                    eventName = 'on' + eventName[0].toUpperCase() + eventName.substring(1);
5632                }
5633                else {
5634                    eventName = 'on' + eventName;
5635                }
5636            }
5637            return eventName;
5638        }
5639        s.emitterEventListeners = {
5640        
5641        };
5642        s.emit = function (eventName) {
5643            // Trigger callbacks
5644            if (s.params[eventName]) {
5645                s.params[eventName](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
5646            }
5647            var i;
5648            // Trigger events
5649            if (s.emitterEventListeners[eventName]) {
5650                for (i = 0; i < s.emitterEventListeners[eventName].length; i++) {
5651                    s.emitterEventListeners[eventName][i](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
5652                }
5653            }
5654            // Trigger plugins
5655            if (s.callPlugins) s.callPlugins(eventName, arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
5656        };
5657        s.on = function (eventName, handler) {
5658            eventName = normalizeEventName(eventName);
5659            if (!s.emitterEventListeners[eventName]) s.emitterEventListeners[eventName] = [];
5660            s.emitterEventListeners[eventName].push(handler);
5661            return s;
5662        };
5663        s.off = function (eventName, handler) {
5664            var i;
5665            eventName = normalizeEventName(eventName);
5666            if (typeof handler === 'undefined') {
5667                // Remove all handlers for such event
5668                s.emitterEventListeners[eventName] = [];
5669                return s;
5670            }
5671            if (!s.emitterEventListeners[eventName] || s.emitterEventListeners[eventName].length === 0) return;
5672            for (i = 0; i < s.emitterEventListeners[eventName].length; i++) {
5673                if(s.emitterEventListeners[eventName][i] === handler) s.emitterEventListeners[eventName].splice(i, 1);
5674            }
5675            return s;
5676        };
5677        s.once = function (eventName, handler) {
5678            eventName = normalizeEventName(eventName);
5679            var _handler = function () {
5680                handler(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]);
5681                s.off(eventName, _handler);
5682            };
5683            s.on(eventName, _handler);
5684            return s;
5685        };
5686
5687        // Accessibility tools
5688        s.a11y = {
5689            makeFocusable: function ($el) {
5690                $el.attr('tabIndex', '0');
5691                return $el;
5692            },
5693            addRole: function ($el, role) {
5694                $el.attr('role', role);
5695                return $el;
5696            },
5697        
5698            addLabel: function ($el, label) {
5699                $el.attr('aria-label', label);
5700                return $el;
5701            },
5702        
5703            disable: function ($el) {
5704                $el.attr('aria-disabled', true);
5705                return $el;
5706            },
5707        
5708            enable: function ($el) {
5709                $el.attr('aria-disabled', false);
5710                return $el;
5711            },
5712        
5713            onEnterKey: function (event) {
5714                if (event.keyCode !== 13) return;
5715                if ($(event.target).is(s.params.nextButton)) {
5716                    s.onClickNext(event);
5717                    if (s.isEnd) {
5718                        s.a11y.notify(s.params.lastSlideMessage);
5719                    }
5720                    else {
5721                        s.a11y.notify(s.params.nextSlideMessage);
5722                    }
5723                }
5724                else if ($(event.target).is(s.params.prevButton)) {
5725                    s.onClickPrev(event);
5726                    if (s.isBeginning) {
5727                        s.a11y.notify(s.params.firstSlideMessage);
5728                    }
5729                    else {
5730                        s.a11y.notify(s.params.prevSlideMessage);
5731                    }
5732                }
5733                if ($(event.target).is('.' + s.params.bulletClass)) {
5734                    $(event.target)[0].click();
5735                }
5736            },
5737        
5738            liveRegion: $('<span class="swiper-notification" aria-l
5738ive="assertive" aria-atomic="true"></span>'),
5739        
5740            notify: function (message) {
5741                var notification = s.a11y.liveRegion;
5742                if (notification.length === 0) return;
5743                notification.html('');
5744                notification.html(message);
5745            },
5746            init: function () {
5747                // Setup accessibility
5748                if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
5749                    s.a11y.makeFocusable(s.nextButton);
5750                    s.a11y.addRole(s.nextButton, 'button');
5751                    s.a11y.addLabel(s.nextButton, s.params.nextSlideMessage);
5752                }
5753                if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
5754                    s.a11y.makeFocusable(s.prevButton);
5755                    s.a11y.addRole(s.prevButton, 'button');
5756                    s.a11y.addLabel(s.prevButton, s.params.prevSlideMessage);
5757                }
5758        
5759                $(s.container).append(s.a11y.liveRegion);
5760            },
5761            initPagination: function () {
5762                if (s.params.pagination && s.params.paginationClickable && s.bullets && s.bullets.length) {
5763                    s.bullets.each(function () {
5764                        var bullet = $(this);
5765                        s.a11y.makeFocusable(bullet);
5766                        s.a11y.addRole(bullet, 'button');
5767                        s.a11y.addLabel(bullet, s.params.paginationBulletMessage.replace(/{{index}}/, bullet.index() + 1));
5768                    });
5769                }
5770            },
5771            destroy: function () {
5772                if (s.a11y.liveRegion && s.a11y.liveRegion.length > 0) s.a11y.liveRegion.remove();
5773            }
5774        };
5775        
5776
5777        /*=========================
5778          Init/Destroy
5779          ===========================*/
5780        s.init = function () {
5781            if (s.params.loop) s.createLoop();
5782            s.updateContainerSize();
5783            s.updateSlidesSize();
5784            s.updatePagination();
5785            if (s.params.scrollbar && s.scrollbar) {
5786                s.scrollbar.set();
5787                if (s.params.scrollbarDraggable) {
5788                    s.scrollbar.enableDraggable();
5789                }
5790            }
5791            if (s.params.effect !== 'slide' && s.effects[s.params.effect]) {
5792                if (!s.params.loop) s.updateProgress();
5793                s.effects[s.params.effect].setTranslate();
5794            }
5795            if (s.params.loop) {
5796                s.slideTo(s.params.initialSlide + s.loopedSlides, 0, s.params.runCallbacksOnInit);
5797            }
5798            else {
5799                s.slideTo(s.params.initialSlide, 0, s.params.runCallbacksOnInit);
5800                if (s.params.initialSlide === 0) {
5801                    if (s.parallax && s.params.parallax) s.parallax.setTranslate();
5802                    if (s.lazy && s.params.lazyLoading) {
5803                        s.lazy.load();
5804                        s.lazy.initialImageLoaded = true;
5805                    }
5806                }
5807            }
5808            s.attachEvents();
5809            if (s.params.observer && s.support.observer) {
5810                s.initObservers();
5811            }
5812            if (s.params.preloadImages && !s.params.lazyLoading) {
5813                s.preloadImages();
5814            }
5815            if (s.params.autoplay) {
5816                s.startAutoplay();
5817            }
5818            if (s.params.keyboardControl) {
5819                if (s.enableKeyboardControl) s.enableKeyboardControl();
5820            }
5821            if (s.params.mousewheelControl) {
5822                if (s.enableMousewheelControl) s.enableMousewheelControl();
5823            }
5824            if (s.params.hashnav) {
5825                if (s.hashnav) s.hashnav.init();
5826            }
5827            if (s.params.a11y && s.a11y) s.a11y.init();
5828            s.emit('onInit', s);
5829        };
5830        
5831        // Cleanup dynamic styles
5832        s.cleanupStyles = function () {
5833            // Container
5834            s.container.removeClass(s.classNames.join(' ')).removeAttr('style');
5835        
5836            // Wrapper
5837            s.wrapper.removeAttr('style');
5838        
5839            // Slides
5840            if (s.slides && s.slides.length) {
5841                s.slides
5842                    .removeClass([
5843                      s.params.slideVisibleClass,
5844                      s.params.slideActiveClass,
5845                      s.params.slideNextClass,
5846                      s.params.slidePrevClass
5847                    ].join(' '))
5848                    .removeAttr('style')
5849                    .removeAttr('data-swiper-column')
5850                    .removeAttr('data-swiper-row');
5851            }
5852        
5853            // Pagination/Bullets
5854            if (s.paginationContainer && s.paginationContainer.length) {
5855                s.paginationContainer.removeClass(s.params.paginationHiddenClass);
5856            }
5857            if (s.bullets && s.bullets.length) {
5858                s.bullets.removeClass(s.params.bulletActiveClass);
5859            }
5860        
5861            // Buttons
5862            if (s.params.prevButton) $(s.params.prevButton).removeClass(s.params.buttonDisabledClass);
5863            if (s.params.nextButton) $(s.params.nextButton).removeClass(s.params.buttonDisabledClass);
5864        
5865            // Scrollbar
5866            if (s.params.scrollbar && s.scrollbar) {
5867                if (s.scrollbar.track && s.scrollbar.track.length) s.scrollbar.track.removeAttr('style');
5868                if (s.scrollbar.drag && s.scrollbar.drag.length) s.scrollbar.drag.removeAttr('style');
5869            }
5870        };
5871        
5872        // Destroy
5873        s.destroy = function (deleteInstance, cleanupStyles) {
5874            // Detach evebts
5875            s.detachEvents();
5876            // Stop autoplay
5877            s.stopAutoplay();
5878            // Disable draggable
5879            if (s.params.scrollbar && s.scrollbar) {
5880                if (s.params.scrollbarDraggable) {
5881                    s.scrollbar.disableDraggable();
5882                }
5883            }
5884            // Destroy loop
5885            if (s.params.loop) {
5886                s.destroyLoop();
5887            }
5888            // Cleanup styles
5889            if (cleanupStyles) {
5890                s.cleanupStyles();
5891            }
5892            // Disconnect observer
5893            s.disconnectObservers();
5894            // Disable keyboard/mousewheel
5895            if (s.params.keyboardControl) {
5896                if (s.disableKeyboardControl) s.disableKeyboardControl();
5897            }
5898            if (s.params.mousewheelControl) {
5899                if (s.disableMousewheelControl) s.disableMousewheelControl();
5900            }
5901            // Disable a11y
5902            if (s.params.a11y && s.a11y) s.a11y.destroy();
5903            // Destroy callback
5904            s.emit('onDestroy');
5905            // Delete instance
5906            if (deleteInstance !== false) s = null;
5907        };
5908        
5909        s.init();
5910        
5911
5912    
5913        // Return swiper instance
5914        return s;
5915    };
5916    
5917
5918    /*==================================================
5919        Prototype
5920    ====================================================*/
5921    Swiper.prototype = {
5922        isSafari: (function () {
5923            var ua = navigator.userAgent.toLowerCase();
5924            return (ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0);
5925        })(),
5926        isUiWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent),
5927        isArray: function (arr) {
5928            return Object.prototype.toString.apply(arr) === '[object Array]';
5929        },
5930        /*==================================================
5931        Browser
5932        ====================================================*/
5933        browser: {
5934            ie: window.navigator.pointerEnabled || window.navigator.msPointerEnabled,
5935            ieTouch: (window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints > 1) || (window.navigator.pointerEnabled && window.navigator.maxTouchPoints > 1)
5936        },
5937        /*==================================================
5938        Devices
5939        ====================================================*/
5940        device: (function () {
5941            var ua = navigator.userAgent;
5942            var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
5943            var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
5944            var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
5945            var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);
5946            return {
5947                ios: ipad || iphone || ipod,
5948                android: android
5949            };
5950        })(),
5951        /*==================================================
5952        Feature Detection
5953        ====================================================*/
5954        support: {
5955            touch : (window.Modernizr && Modernizr.touch === true) || (function () {
5956                return !!(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch);
5957            })(),
5958    
5959            transforms3d : (window.Modernizr && Modernizr.csstransforms3d === true) || (function () {
5960                var div = document.createElement('div').style;
5961                return ('webkitPerspective' in div || 'MozPerspective' in div || 'OPerspective' in div || 'MsPerspective' in div || 'perspective' in div);
5962            })(),
5963    
5964            flexbox: (function () {
5965                var div = document.createElement('div').style;
5966                var styles = ('alignItems webkitAlignItems webkitBoxAlign msFlexAlign mozBoxAlign webkitFlexDirection msFlexDirection mozBoxDirection mozBoxOrient webkitBoxDirection webkitBoxOrient').split(' ');
5967                for (var i = 0; i < styles.length; i++) {
5968                    if (styles[i] in div) return true;
5969                }
5970            })(),
5971    
5972            observer: (function () {
5973                return ('MutationObserver' in window || 'WebkitMutationObserver' in window);
5974            })()
5975        },
5976        /*==================================================
5977        Plugins
5978        ====================================================*/
5979        plugins: {}
5980    };
5981    
5982
5983    /*===========================
5984     Get Dom libraries
5985     ===========================*/
5986    var swiperDomPlugins = ['jQuery', 'Zepto', 'Dom7'];
5987    for (var i = 0; i < swiperDomPlugins.length; i++) {
5988    	if (window[swiperDomPlugins[i]]) {
5989    		addLibraryPlugin(window[swiperDomPlugins[i]]);
5990    	}
5991    }
5992    // Required DOM Plugins
5993    var domLib;
5994    if (typeof Dom7 === 'undefined') {
5995    	domLib = window.Dom7 || window.Zepto || window.jQuery;
5996    }
5997    else {
5998    	domLib = Dom7;
5999    }
6000
6001    /*===========================
6002    Add .swiper plugin from Dom libraries
6003    ===========================*/
6004    function addLibraryPlugin(lib) {
6005        lib.fn.swiper = function (params) {
6006            var firstInstance;
6007            lib(this).each(function () {
6008                var s = new Swiper(this, params);
6009                if (!firstInstance) firstInstance = s;
6010            });
6011            return firstInstance;
6012        };
6013    }
6014    
6015    if (domLib) {
6016        if (!('transitionEnd' in domLib.fn)) {
6017            domLib.fn.transitionEnd = function (callback) {
6018                var events = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'],
6019                    i, j, dom = this;
6020                function fireCallBack(e) {
6021                    /*jshint validthis:true */
6022                    if (e.target !== this) return;
6023                    callback.call(this, e);
6024                    for (i = 0; i < events.length; i++) {
6025                        dom.off(events[i], fireCallBack);
6026                    }
6027                }
6028                if (callback) {
6029                    for (i = 0; i < events.length; i++) {
6030                        dom.on(events[i], fireCallBack);
6031                    }
6032                }
6033                return this;
6034            };
6035        }
6036        if (!('transform' in domLib.fn)) {
6037            domLib.fn.transform = function (transform) {
6038                for (var i = 0; i < this.length; i++) {
6039                    var elStyle = this[i].style;
6040                    elStyle.webkitTransform = elStyle.MsTransform = elStyle.msTransform = elStyle.MozTransform = elStyle.OTransform = elStyle.transform = transform;
6041                }
6042                return this;
6043            };
6044        }
6045        if (!('transition' in domLib.fn)) {
6046            domLib.fn.transition = function (duration) {
6047                if (typeof duration !== 'string') {
6048                    duration = duration + 'ms';
6049                }
6050                for (var i = 0; i < this.length; i++) {
6051                    var elStyle = this[i].style;
6052                    elStyle.webkitTransitionDuration = elStyle.MsTransitionDuration = elStyle.msTransitionDuration = elStyle.MozTransitionDuration = elStyle.OTransitionDuration = elStyle.transitionDuration = duration;
6053                }
6054                return this;
6055            };
6056        }
6057    }
6058
6059    window.Swiper = Swiper;
6060})();
6061/*===========================
6062Swiper AMD Export
6063===========================*/
6064if (typeof(module) !== 'undefined')
6065{
6066    module.exports = window.Swiper;
6067}
6068else if (typeof define === 'function' && define.amd) {
6069    define([], function () {
6070        'use strict';
6071        return window.Swiper;
6072    });
6073}
6074//# sourceMappingURL=maps/swiper.jquery.js.map;
6075}catch(e){console.log(e)}try{/*global jQuery */
6076/*!
6077* FitText.js 1.2
6078*
6079* Copyright 2011, Dave Rupert http://daverupert.com
6080* Released under the WTFPL license
6081* http://sam.zoy.org/wtfpl/
6082*
6083* Date: Thu May 05 14:23:00 2011 -0600
6084*/
6085
6086(function( $ ){
6087
6088  $.fn.fitText = function( kompressor, options ) {
6089
6090    // Setup options
6091    var compressor = kompressor || 1,
6092        settings = $.extend({
6093          'minFontSize' : Number.NEGATIVE_INFINITY,
6094          'maxFontSize' : $(this).css('font-size')
6095        }, options);
6096
6097    return this.each(function(){
6098
6099      // Store the object
6100      var $this = $(this);
6101
6102      // Resizer() resizes items based on the object width divided by the compressor * 10
6103      var resizer = function () {
6104        $this.css('font-size', Math.max(Math.min($this.width() / (compressor*10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize)));
6105      };
6106
6107      // Call once to set.
6108      resizer();
6109
6110      // Call on resize. Opera debounces their resize by default.
6111      $(window).on('resize.fittext orientationchange.fittext', resizer);
6112
6113    });
6114
6115  };
6116
6117})( jQuery )}catch(e){console.log(e)}try{!function(d,l){"use strict";var e=!1,n=!1;if(l.querySelector)if(d.addEventListener)e=!0;if(d.wp=d.wp||{},!d.wp.receiveEmbedMessage)if(d.wp.receiveEmbedMessage=function(e){var t=e.data;if(t.secret||t.message||t.value)if(!/[^a-zA-Z0-9]/.test(t.secret)){for(var r,a,i,s=l.querySelectorAll('iframe[data-secret="'+t.secret+'"]'),n=l.querySelectorAll('blockquote[data-secret="'+t.secret+'"]'),o=new RegExp("^https?:$","i"),c=0;c<n.length;c++)n[c].style.display="none";for(c=0;c<s.length;c++)if(r=s[c],e.source===r.contentWindow){if(r.removeAttribute("style"),"height"===t.message){if(1e3<(i=parseInt(t.value,10)))i=1e3;else if(~~i<200)i=200;r.height=i}if("link"===t.message)if(a=l.createElement("a"),i=l.createElement("a"),a.href=r.getAttribute("src"),i.href=t.value,o.test(i.protocol))if(i.host===a.host)if(l.activeElement===r)d.top.location.href=t.value}}},e)d.addEventListener("message",d.wp.receiveEmbedMessage,!1),l.addEventListener("DOMContentLoaded",t,!1),d.addEventListener("load",t,!1);function t(){if(!n){n=!0;for(var e,t,r=-1!==navigator.appVersion.indexOf("MSIE 10"),a=!!navigator.userAgent.match(/Trident.*rv:11\./),i=l.querySelectorAll("iframe.wp-embedded-content"),s=0;s<i.length;s++){if(!(e=i[s]).getAttribute("data-secret"))t=Math.random().toString(36).substr(2,10),e.src+="#?secret="+t,e.setAttribute("data-secret",t);if(r||a)(t=e.cloneNode(!0)).removeAttribute("security"),e.parentNode.replaceChild(t,e)}}}}(window,document)}catch(e){console.log(e)}try{function vc_js(){vc_toggleBehaviour(),vc_tabsBehaviour(),vc_accordionBehaviour(),vc_teaserGrid(),vc_carouselBehaviour(),vc_slidersBehaviour(),vc_prettyPhoto(),vc_googleplus(),vc_pinterest(),vc_progress_bar(),vc_plugin_flexslider(),vc_google_fonts(),vc_gridBehaviour(),vc_rowBehaviour(),vc_googleMapsPointer(),vc_ttaActivation(),jQuery(document).trigger("vc_js"),window.setTimeout(vc_waypoints,500)}function getSizeName(){var screen_w=jQuery(window).width();return screen_w>1170?"desktop_wide":screen_w>960&&1169>screen_w?"desktop":screen_w>768&&959>screen_w?"tablet":screen_w>300&&767>screen_w?"mobile":300>screen_w?"mobile_portrait":""}function loadScript(url,$obj,callback){var script=document.createElement("script");script.type="text/javascript",script.readyState&&(script.onreadystatechange=function(){("loaded"===script.readyState||"complete"===script.readyState)&&(script.onreadystatechange=null,callback())}),script.src=url,$obj.get(0).appendChild(script)}function vc_ttaActivation(){jQuery("[data-vc-accordion]").on("show.vc.accordion",function(e){var $=window.jQuery,ui={};ui.newPanel=$(this).data("vc.accordion").getTarget(),window.wpb_prepare_tab_content(e,ui)})}function vc_accordionActivate(event,ui){if(ui.newPanel.length&&ui.newHeader.length){var $pie_charts=ui.newPanel.find(".vc_pie_chart:not(.vc_ready)"),$round_charts=ui.newPanel.find(".vc_round-chart"),$line_charts=ui.newPanel.find(".vc_line-chart"),$carousel=ui.newPanel.find('[data-ride="vc_carousel"]');
6117"undefined"!=typeof jQuery.fn.isotope&&ui.newPanel.find(".isotope, .wpb_image_grid_ul").isotope("layout"),ui.newPanel.find(".vc_masonry_media_grid, .vc_masonry_grid").length&&ui.newPanel.find(".vc_masonry_media_grid, .vc_masonry_grid").each(function(){var grid=jQuery(this).data("vcGrid");grid&&grid.gridBuilder&&grid.gridBuilder.setMasonry&&grid.gridBuilder.setMasonry()}),vc_carouselBehaviour(ui.newPanel),vc_plugin_flexslider(ui.newPanel),$pie_charts.length&&jQuery.fn.vcChat&&$pie_charts.vcChat(),$round_charts.length&&jQuery.fn.vcRoundChart&&$round_charts.vcRoundChart({reload:!1}),$line_charts.length&&jQuery.fn.vcLineChart&&$line_charts.vcLineChart({reload:!1}),$carousel.length&&jQuery.fn.carousel&&$carousel.carousel("resizeAction"),ui.newPanel.parents(".isotope").length&&ui.newPanel.parents(".isotope").each(function(){jQuery(this).isotope("layout")})}}function initVideoBackgrounds(){return window.console&&window.console.warn&&window.console.warn("this function is deprecated use vc_initVideoBackgrounds"),vc_initVideoBackgrounds()}function vc_initVideoBackgrounds(){jQuery(".vc_row").each(function(){var youtubeUrl,youtubeId,$row=jQuery(this);$row.data("vcVideoBg")?(youtubeUrl=$row.data("vcVideoBg"),youtubeId=vcExtractYoutubeId(youtubeUrl),youtubeId&&($row.find(".vc_video-bg").remove(),insertYoutubeVideoAsBackground($row,youtubeId)),jQuery(window).on("grid:items:added",function(event,$grid){$row.has($grid).length&&vcResizeVideoBackground($row)})):$row.find(".vc_video-bg").remove()})}function insertYoutubeVideoAsBackground($element,youtubeId,counter){if("undefined"==typeof YT.Player)return counter="undefined"==typeof counter?0:counter,counter>100?void console.warn("Too many attempts to load YouTube api"):void setTimeout(function(){insertYoutubeVideoAsBackground($element,youtubeId,counter++)},100);var $container=$element.prepend('<div class="vc_video-bg vc_hidden-xs"><div class="inner"></div></div>').find(".inner");new YT.Player($container[0],{width:"100%",height:"100%",videoId:youtubeId,playerVars:{playlist:youtubeId,iv_load_policy:3,enablejsapi:1,disablekb:1,autoplay:1,controls:0,showinfo:0,rel:0,loop:1,wmode:"transparent"},events:{onReady:function(event){event.target.mute().setLoop(!0)}}}),vcResizeVideoBackground($element),jQuery(window).bind("resize",function(){vcResizeVideoBackground($element)})}function vcResizeVideoBackground($element){var iframeW,iframeH,marginLeft,marginTop,containerW=$element.innerWidth(),containerH=$element.innerHeight(),ratio1=16,ratio2=9;ratio1/ratio2>containerW/containerH?(iframeW=containerH*(ratio1/ratio2),iframeH=containerH,marginLeft=-Math.round((iframeW-containerW)/2)+"px",marginTop=-Math.round((iframeH-containerH)/2)+"px",iframeW+="px",iframeH+="px"):(iframeW=containerW,iframeH=containerW*(ratio2/ratio1),marginTop=-Math.round((iframeH-containerH)/2)+"px",marginLeft=-Math.round((iframeW-containerW)/2)+"px",iframeW+="px",iframeH+="px"),$element.find(".vc_video-bg iframe").css({maxWidth:"1000%",marginLeft:marginLeft,marginTop:marginTop,width:iframeW,height:iframeH})}function vcExtractYoutubeId(url){if("undefined"==typeof url)return!1;var id=url.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/);return null!==id?id[1]:!1}function vc_googleMapsPointer(){var $=window.jQuery,$wpbGmapsWidget=$(".wpb_gmaps_widget");$wpbGmapsWidget.click(function(){$("iframe",this).css("pointer-events","auto")}),$wpbGmapsWidget.mouseleave(function(){$("iframe",this).css("pointer-events","none")}),$(".wpb_gmaps_widget iframe").css("pointer-events","none")}document.documentElement.className+=" js_active ",document.documentElement.className+="ontouchstart"in document.documentElement?" vc_mobile ":" vc_desktop ",function(){for(var prefix=["-webkit-","-moz-","-ms-","-o-",""],i=0;i<prefix.length;i++)prefix[i]+"transform"in document.documentElement.style&&(document.documentElement.className+=" vc_transform ")}(),"function"!=typeof window.vc_plugin_flexslider&&(window.vc_plugin_flexslider=function($parent){var $slider=$parent?$parent.find(".wpb_flexslider"):jQuery(".wpb_flexslider");$slider.each(function(){var this_element=jQuery(this),sliderSpeed=800,sliderTimeout=1e3*parseInt(this_element.attr("data-interval")),sliderFx=this_element.attr("data-flex_fx"),slideshow=!0;0===sliderTimeout&&(slideshow=!1),this_element.is(":visible")&&this_element.flexslider({animation:sliderFx,slideshow:slideshow,slideshowSpeed:sliderTimeout,sliderSpeed:sliderSpeed,smoothHeight:!0})})}),"function"!=typeof window.vc_googleplus&&(window.vc_googleplus=function(){0<jQuery(".wpb_googleplus").length&&!function(){var po=document.createElement("script");po.type="text/javascript",po.async=!0,po.src="//apis.google.com/js/plusone.js";var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(po,s)}()}),"function"!=typeof window.vc_pinterest&&(window.vc_pinterest=function(){0<jQuery(".wpb_pinterest").length&&!function(){var po=document.createElement("script");po.type="text/javascript",po.async=!0,po.src="//assets.pinterest.com/js/pinit.js";var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(po,s)}()}),"function"!=typeof window.vc_progress_bar&&(window.vc_progress_bar=function(){"undefined"!=typeof jQuery.fn.waypoint&&jQuery(".vc_progress_bar").waypoint(function(){jQuery(this).find(".vc_single_bar").each(function(index){var $this=jQuery(this),bar=$this.find(".vc_bar"),val=bar.data("percentage-value");setTimeout(function(){bar.css({width:val+"%"})},200*index)})},{offset:"85%"})}),"function"!=typeof window.vc_waypoints&&(window.vc_waypoints=function(){"undefined"!=typeof jQuery.fn.waypoint&&jQuery(".wpb_animate_when_almost_visible:not(.wpb_start_animation)").waypoint(function(){jQuery(this).addClass("wpb_start_animation")},{offset:"85%"})}),"function"!=typeof window.vc_toggleBehaviour&&(window.vc_toggleBehaviour=function($el){function event(e){e&&e.preventDefault&&e.preventDefault();var title=jQuery(this),element=title.closest(".vc_toggle"),content=element.find(".vc_toggle_content");element.hasClass("vc_toggle_active")?content.slideUp({duration:300,complete:function(){element.removeClass("vc_toggle_active")}}):content.slideDown({duration:300,complete:function(){element.addClass("vc_toggle_active")}})}$el?$el.hasClass("vc_toggle_title")?$el.unbind("click").click(event):$el.find(".vc_toggle_title").unbind("click").click(event):jQuery(".vc_toggle_title").unbind("click").on("click",event)}),"function"!=typeof window.vc_tabsBehaviour&&(window.vc_tabsBehaviour=function($tab){if(jQuery.ui){var $call=$tab||jQuery(".wpb_tabs, .wpb_tour"),ver=jQuery.ui&&jQuery.ui.version?jQuery.ui.version.split("."):"1.10",old_version=1===parseInt(ver[0])&&9>parseInt(ver[1]);$call.each(function(index){var $tabs,interval=jQuery(this).attr("data-interval"),tabs_array=[];if($tabs=jQuery(this).find(".wpb_tour_tabs_wrapper").tabs({show:function(event,ui){wpb_prepare_tab_content(event,ui)},beforeActivate:function(event,ui){1!==ui.newPanel.index()&&ui.newPanel.find(".vc_pie_chart:not(.vc_ready)")},activate:function(event,ui){wpb_prepare_tab_content(event,ui)}}),interval&&interval>0)try{$tabs.tabs("rotate",1e3*interval)}catch(e){window.console&&window.console.log&&console.log(e)}jQuery(this).find(".wpb_tab").each(function(){tabs_array.push(this.id)}),jQuery(this).find(".wpb_tabs_nav li").click(function(e){return e.preventDefault(),old_version?$tabs.tabs("select",jQuery("a",this).attr("href")):$tabs.tabs("option","active",jQuery(this).index()),!1}),jQuery(this).find(".wpb_prev_slide a, .wpb_next_slide a").click(function(e){if(e.preventDefault(),old_version){var index=$tabs.tabs("option","selected");jQuery(this).parent().hasClass("wpb_next_slide")?index++:index--,0>index?index=$tabs.tabs("length")-1:index>=$tabs.tabs("length")&&(index=0),$tabs.tabs("select",index)}else{var index=$tabs.tabs("option","active"),length=$tabs.find(".wpb_tab").length;index=jQuery(this).parent().hasClass("wpb_next_slide")?index+1>=length?0:index+1:0>index-1?length-1:index-1,$tabs.tabs("option","active",index)}})})}}),"function"!=typeof window.vc_accordionBehaviour&&(window.vc_accordionBehaviour=function(){jQuery(".wpb_accordion").each(function(index){var $tabs,$this=jQuery(this),active_tab=($this.attr("data-interval"),!isNaN(jQuery(this).data("active-tab"))&&0<parseInt($this.data("active-tab"))?parseInt($this.data("active-tab"))-1:!1),collapsible=!1===active_tab||"yes"===$this.data("c
6117ollapsible");$tabs=$this.find(".wpb_accordion_wrapper").accordion({header:"> div > h3",autoHeight:!1,heightStyle:"content",active:active_tab,collapsible:collapsible,navigation:!0,activate:vc_accordionActivate,change:function(event,ui){"undefined"!=typeof jQuery.fn.isotope&&ui.newContent.find(".isotope").isotope("layout"),vc_carouselBehaviour(ui.newPanel)}}),!0===$this.data("vcDisableKeydown")&&($tabs.data("uiAccordion")._keydown=function(){})})}),"function"!=typeof window.vc_teaserGrid&&(window.vc_teaserGrid=function(){var layout_modes={fitrows:"fitRows",masonry:"masonry"};jQuery(".wpb_grid .teaser_grid_container:not(.wpb_carousel), .wpb_filtered_grid .teaser_grid_container:not(.wpb_carousel)").each(function(){var $container=jQuery(this),$thumbs=$container.find(".wpb_thumbnails"),layout_mode=$thumbs.attr("data-layout-mode");$thumbs.isotope({itemSelector:".isotope-item",layoutMode:"undefined"==typeof layout_modes[layout_mode]?"fitRows":layout_modes[layout_mode]}),$container.find(".categories_filter a").data("isotope",$thumbs).click(function(e){e.preventDefault();var $thumbs=jQuery(this).data("isotope");jQuery(this).parent().parent().find(".active").removeClass("active"),jQuery(this).parent().addClass("active"),$thumbs.isotope({filter:jQuery(this).attr("data-filter")})}),jQuery(window).bind("load resize",function(){$thumbs.isotope("layout")})})}),"function"!=typeof window.vc_carouselBehaviour&&(window.vc_carouselBehaviour=function($parent){var $carousel=$parent?$parent.find(".wpb_carousel"):jQuery(".wpb_carousel");$carousel.each(function(){var $this=jQuery(this);if(!0!==$this.data("carousel_enabled")&&$this.is(":visible")){$this.data("carousel_enabled",!0);var carousel_speed=(getColumnsCount(jQuery(this)),500);jQuery(this).hasClass("columns_count_1")&&(carousel_speed=900);var carousele_li=jQuery(this).find(".wpb_thumbnails-fluid li");carousele_li.css({"margin-right":carousele_li.css("margin-left"),"margin-left":0});var fluid_ul=jQuery(this).find("ul.wpb_thumbnails-fluid");fluid_ul.width(fluid_ul.width()+300),jQuery(window).resize(function(){var before_resize=screen_size;screen_size=getSizeName(),before_resize!=screen_size&&window.setTimeout("location.reload()",20)})}})}),"function"!=typeof window.vc_slidersBehaviour&&(window.vc_slidersBehaviour=function(){jQuery(".wpb_gallery_slides").each(function(index){var $imagesGrid,this_element=jQuery(this);if(this_element.hasClass("wpb_slider_nivo")){var sliderSpeed=800,sliderTimeout=1e3*this_element.attr("data-interval");0===sliderTimeout&&(sliderTimeout=9999999999),this_element.find(".nivoSlider").nivoSlider({effect:"boxRainGrow,boxRain,boxRainReverse,boxRainGrowReverse",slices:15,boxCols:8,boxRows:4,animSpeed:sliderSpeed,pauseTime:sliderTimeout,startSlide:0,directionNav:!0,directionNavHide:!0,controlNav:!0,keyboardNav:!1,pauseOnHover:!0,manualAdvance:!1,prevText:"Prev",nextText:"Next"})}else this_element.hasClass("wpb_image_grid")&&(jQuery.fn.imagesLoaded?$imagesGrid=this_element.find(".wpb_image_grid_ul").imagesLoaded(function(){$imagesGrid.isotope({itemSelector:".isotope-item",layoutMode:"fitRows"})}):this_element.find(".wpb_image_grid_ul").isotope({itemSelector:".isotope-item",layoutMode:"fitRows"}))})}),"function"!=typeof window.vc_prettyPhoto&&(window.vc_prettyPhoto=function(){try{jQuery&&jQuery.fn&&jQuery.fn.prettyPhoto&&jQuery('a.prettyphoto, .gallery-icon a[href*=".jpg"]').prettyPhoto({animationSpeed:"normal",hook:"data-rel",padding:15,opacity:.7,showTitle:!0,allowresize:!0,counter_separator_label:"/",hideflash:!1,deeplinking:!1,modal:!1,callback:function(){var url=location.href,hashtag=url.indexOf("#!prettyPhoto")?!0:!1;hashtag&&(location.hash="")},social_tools:""})}catch(err){window.console&&window.console.log&&console.log(err)}}),"function"!=typeof window.vc_google_fonts&&(window.vc_google_fonts=function(){return!1}),window.vcParallaxSkroll=!1,"function"!=typeof window.vc_rowBehaviour&&(window.vc_rowBehaviour=function(){function fullWidthRow(){var $elements=$('[data-vc-full-width="true"]');$.each($elements,function(key,item){var $el=$(this);$el.addClass("vc_hidden");var $el_full=$el.next(".vc_row-full-width");if($el_full.length||($el_full=$el.parent().next(".vc_row-full-width")),$el_full.length){var el_margin_left=parseInt($el.css("margin-left"),10),el_margin_right=parseInt($el.css("margin-right"),10),offset=0-$el_full.offset().left-el_margin_left,width=$(window).width();if($el.css({position:"relative",left:offset,"box-sizing":"border-box",width:$(window).width()}),!$el.data("vcStretchContent")){var padding=-1*offset;0>padding&&(padding=0);var paddingRight=width-padding-$el_full.width()+el_margin_left+el_margin_right;0>paddingRight&&(paddingRight=0),$el.css({"padding-left":padding+"px","padding-right":paddingRight+"px"})}$el.attr("data-vc-full-width-init","true"),$el.removeClass("vc_hidden")}}),$(document).trigger("vc-full-width-row",$elements)}
6117function parallaxRow(){var vcSkrollrOptions,callSkrollInit=!1;return window.vcParallaxSkroll&&window.vcParallaxSkroll.destroy(),$(".vc_parallax-inner").remove(),$("[data-5p-top-bottom]").removeAttr("data-5p-top-bottom data-30p-top-bottom"),$("[data-vc-parallax]").each(function(){var skrollrSpeed,skrollrSize,skrollrStart,skrollrEnd,$parallaxElement,parallaxImage,youtubeId;callSkrollInit=!0,"on"===$(this).data("vcParallaxOFade")&&$(this).children().attr("data-5p-top-bottom","opacity:0;").attr("data-30p-top-bottom","opacity:1;"),skrollrSize=100*$(this).data("vcParallax"),$parallaxElement=$("<div />").addClass("vc_parallax-inner").appendTo($(this)),$parallaxElement.height(skrollrSize+"%"),parallaxImage=$(this).data("vcParallaxImage"),youtubeId=vcExtractYoutubeId(parallaxImage),youtubeId?insertYoutubeVideoAsBackground($parallaxElement,youtubeId):"undefined"!=typeof parallaxImage&&$parallaxElement.css("background-image","url("+parallaxImage+")"),skrollrSpeed=skrollrSize-100,skrollrStart=-skrollrSpeed,skrollrEnd=0,$parallaxElement.attr("data-bottom-top","top: "+skrollrStart+"%;").attr("data-top-bottom","top: "+skrollrEnd+"%;")}),callSkrollInit&&window.skrollr?(vcSkrollrOptions={forceHeight:!1,smoothScrolling:!1,mobileCheck:function(){return!1}},window.vcParallaxSkroll=skrollr.init(vcSkrollrOptions),window.vcParallaxSkroll):!1}function fullHeightRow(){var $element=$(".vc_row-o-full-height:first");if($element.length){var $window,windowHeight,offsetTop,fullHeight;$window=$(window),windowHeight=$window.height(),offsetTop=$element.offset().top,windowHeight>offsetTop&&(fullHeight=100-offsetTop/(windowHeight/100),$element.css("min-height",fullHeight+"vh"))}$(document).trigger("vc-full-height-row",$element)}function fixIeFlexbox(){var ua=window.navigator.userAgent,msie=ua.indexOf("MSIE ");(msie>0||navigator.userAgent.match(/Trident.*rv\:11\./))&&$(".vc_row-o-full-height").each(function(){"flex"===$(this).css("display")&&$(this).wrap('<div class="vc_ie-flexbox-fixer"></div>')})}var $=window.jQuery;$(window).off("resize.vcRowBehaviour").on("resize.vcRowBehaviour",fullWidthRow).on("resize.vcRowBehaviour",fullHeightRow),fullWidthRow(),fullHeightRow(),fixIeFlexbox(),vc_initVideoBackgrounds(),parallaxRow()}),"function"!=typeof window.vc_gridBehaviour&&(window.vc_gridBehaviour=function(){jQuery.fn.vcGrid&&jQuery("[data-vc-grid]").vcGrid()}),"function"!=typeof window.getColumnsCount&&(window.getColumnsCount=function(el){for(var find=!1,i=1;!1===find;){if(el.hasClass("columns_count_"+i))return find=!0,i;i++}});var screen_size=getSizeName();"function"!=typeof window.wpb_prepare_tab_content&&(window.wpb_prepare_tab_content=function(event,ui){var $ui_panel,$google_maps,panel=ui.panel||ui.newPanel,$pie_charts=panel.find(".vc_pie_chart:not(.vc_ready)"),$round_charts=panel.find(".vc_round-chart"),$line_charts=panel.find(".vc_line-chart"),$carousel=panel.find('[data-ride="vc_carousel"]');if(vc_carouselBehaviour(),vc_plugin_flexslider(panel),ui.newPanel.find(".vc_masonry_media_grid, .vc_masonry_grid").length&&ui.newPanel.find(".vc_masonry_media_grid, .vc_masonry_grid").each(function(){var grid=jQuery(this).data("vcGrid");grid&&grid.gridBuilder&&grid.gridBuilder.setMasonry&&grid.gridBuilder.setMasonry()}),panel.find(".vc_masonry_media_grid, .vc_masonry_grid").length&&panel.find(".vc_masonry_media_grid, .vc_masonry_grid").each(function(){var grid=jQuery(this).data("vcGrid");grid&&grid.gridBuilder&&grid.gridBuilder.setMasonry&&grid.gridBuilder.setMasonry()}),$pie_charts.length&&jQuery.fn.vcChat&&$pie_charts.vcChat(),$round_charts.length&&jQuery.fn.vcRoundChart&&$round_charts.vcRoundChart({reload:!1}),$line_charts.length&&jQuery.fn.vcLineChart&&$line_charts.vcLineChart({reload:!1}),$carousel.length&&jQuery.fn.carousel&&$carousel.carousel("resizeAction"),$ui_panel=panel.find(".isotope, .wpb_image_grid_ul"),$google_maps=panel.find(".wpb_gmaps_widget"),0<$ui_panel.length&&$ui_panel.isotope("layout"),$google_maps.length&&!$google_maps.is(".map_ready")){var $frame=$google_maps.find("iframe");$frame.attr("src",$frame.attr("src")),$google_maps.addClass("map_ready")}panel.parents(".isotope").length&&panel.parents(".isotope").each(function(){jQuery(this).isotope("layout")})}),"function"!=typeof window.vc_googleMapsPointer,jQuery(document).ready(function($){window.vc_js()});
6118}catch(e){console.log(e)}

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.