PageSourceSearch

https://first-class-leadership.com/wp-content/themes/enfold/js/shortcodes.js?ver=3

js first-class-leadership.com collected 2026-10-08 08:52:40 UTC 156,046 bytes, 5,538 lines download raw bytes

1(function($)
2{	
3    "use strict";
4
5    $(document).ready(function()
6    {	
7    	//global variables that are used on several ocassions
8    	$.avia_utilities = $.avia_utilities || {};
9    	
10    	if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && 'ontouchstart' in document.documentElement)
11    	{
12    		$.avia_utilities.isMobile =  true;
13    	}
14    	else
15    	{
16    		$.avia_utilities.isMobile =  false;
17    	}
18    
19    	//activate fixed bg fallback for mobile
20    	if($.fn.avia_mobile_fixed)
21		$('.avia-bg-style-fixed').avia_mobile_fixed();
22    	
23    	//activate parallax scrolling for backgrounds.
24    	if($.fn.avia_parallax)
25		$('.av-parallax').avia_parallax();
26    	
27    	//calculate the browser height and append a css rule to the head
28		if($.fn.avia_browser_height)
29		$('.av-minimum-height, .avia-fullscreen-slider, .av-cell-min-height').avia_browser_height();
30		
31		//calculate the height of each video section
32		if($.fn.avia_video_section)
33		 $('.av-section-with-video-bg').avia_video_section();
34		
35		//creates team social icon tooltip
36        new $.AviaTooltip({'class': "avia-tooltip", data: "avia-tooltip", delay:0, scope: "body"});
37		
38		//creates icon element tooltip
39		new $.AviaTooltip({'class': "avia-tooltip avia-icon-tooltip", data: "avia-icon-tooltip", delay:0, scope: "body"});
40
41        activate_shortcode_scripts();
42        
43        //layer slider height helper
44        $('.avia-layerslider').layer_slider_height_helper();
45        
46        //"ajax" portfolio
47        $('.grid-links-ajax').avia_portfolio_preview();
48        
49        // actiavte the masonry script: sorting/loading/etc
50		if($.fn.avia_masonry)
51		$('.av-masonry').avia_masonry();
52		
53		//activate the accordion
54		if($.fn.aviaccordion)
55		$('.aviaccordion').aviaccordion();
56		
57		
58		//activate the accordion
59		if($.fn.avia_textrotator)
60		$('.av-rotator-container').avia_textrotator();
61		
62		//activates the tab section shortcode
63		if($.fn.avia_sc_tab_section)
64		{
65			$('.av-tab-section-container').avia_sc_tab_section();
66		}
67		
68		//activates the hor gallery  shortcode
69		if($.fn.avia_hor_gallery)
70		{
71			$('.av-horizontal-gallery').avia_hor_gallery();
72		}
73		
74		
75		if($.fn.avia_delayed_animation_in_container)
76		{
77			$('.av-animation-delay-container').avia_delayed_animation_in_container();
78		}
79		
80		
81    });
82
83
84
85
86
87// -------------------------------------------------------------------------------------------
88// ACTIVATE ALL SHORTCODES
89// -------------------------------------------------------------------------------------------
90
91	function activate_waypoints(container)
92	{
93		//activates simple css animations of the content once the user scrolls to an elements
94		if($.fn.avia_waypoints)
95		{
96			if(typeof container == 'undefined'){ container = 'body';};
97
98			$('.avia_animate_when_visible', container).avia_waypoints();
99			$('.avia_animate_when_almost_visible', container).avia_waypoints({ offset: '80%'});
100			
101			if(container == 'body') container = '.avia_desktop body';
102			$('.av-animated-generic', container).avia_waypoints({ offset: '95%'});
103		}
104	}
105
106
107    function activate_shortcode_scripts(container)
108	{
109		if(typeof container == 'undefined'){ container = 'body';}
110		
111		//activates the form shortcode
112		if($.fn.avia_ajax_form)
113		{
114			$('.avia_ajax_form:not( .avia-disable-default-ajax )', container).avia_ajax_form();
115		}
116		
117		activate_waypoints(container);
118		
119		//activate the video api
120		if($.fn.aviaVideoApi)
121		{
122			$('.avia-slideshow iframe[src*="youtube.com"], .av_youtube_frame, .avia-slideshow iframe[src*="vimeo.com"], .avia-slideshow video').aviaVideoApi({}, 'li');
123		}
124		
125	    //activates the toggle shortcode
126		if($.fn.avia_sc_toggle)
127		{
128			$('.togglecontainer', container).avia_sc_toggle();
129		}
130		
131		//activates the tabs shortcode
132		if($.fn.avia_sc_tabs)
133		{
134			$('.top_tab', container).avia_sc_tabs();
135			$('.sidebar_tab', container).avia_sc_tabs({sidebar:true});
136		}
137		
138		//activates behavior and animation for gallery
139		if($.fn.avia_sc_gallery)
140		{
141			$('.avia-gallery', container).avia_sc_gallery();
142		}
143		
144		//activates animated number shortcode
145		if($.fn.avia_sc_animated_number)
146		{
147			$('.avia-animated-number', container).avia_sc_animated_number();
148		}
149		
150		//animation for elements that are not connected like icon shortcode
151		if($.fn.avia_sc_animation_delayed)
152		{
153			$('.av_font_icon', container).avia_sc_animation_delayed({delay:100});
154			$('.avia-image-container', container).avia_sc_animation_delayed({delay:100});
155			$('.av-hotspot-image-container', container).avia_sc_animation_delayed({delay:100});
156			$('.av-animated-generic', container).avia_sc_animation_delayed({delay:100});
157		}
158
159		//activates animation for iconlist
160		if($.fn.avia_sc_iconlist)
161		{
162			$('.avia-icon-list.av-iconlist-big', container).avia_sc_iconlist();
163		}
164
165		//activates animation for progress bar
166		if($.fn.avia_sc_progressbar)
167		{
168			$('.avia-progress-bar-container', container).avia_sc_progressbar();
169		}
170
171		//activates animation for testimonial
172		if($.fn.avia_sc_testimonial)
173		{
174			$('.avia-testimonial-wrapper', container).avia_sc_testimonial();
175		}
176		
177		//activate the fullscreen slider
178		$('.avia-slideshow.av_fullscreen', container).aviaFullscreenSlider();
179		
180		//activate the aviaslider
181		$('.avia-slideshow:not(.av_fullscreen)', container).aviaSlider();
182		
183        //content slider
184        $('.avia-content-slider-active', container).aviaSlider({wrapElement: '.avia-content-slider-inner', slideElement:'.slide-entry-wrap', fullfade:true});
185
186        //testimonial slider
187        $('.avia-slider-testimonials', container).aviaSlider({wrapElement: '.avia-testimonial-row', slideElement:'.avia-testimonial', fullfade:true});
188        
189        //load and activate maps
190        if($.fn.aviaMaps)
191        {
192        	$('.avia-google-map-container', container).aviaMaps();
193    	}
194    	
195    	 //load magazine sorting
196        if($.fn.aviaMagazine)
197        {
198        	$('.av-magazine-tabs-active', container).aviaMagazine();
199    	}
200    	
201    	 //load image hotspot
202        if($.fn.aviaHotspots)
203        {
204        	$('.av-hotspot-image-container', container).aviaHotspots();
205    	}
206    	
207    	 //load countdown
208        if($.fn.aviaCountdown)
209        {
210        	$('.av-countdown-timer', container).aviaCountdown();
211    	}
212    	
213    	
214    	
215    }
216
217
218
219// -------------------------------------------------------------------------------------------
220// 
221// AVIA Countdown
222// 
223// -------------------------------------------------------------------------------------------
224(function($)
225{ 
226	"use strict";
227	
228	var _units	= ['weeks','days','hours','minutes','seconds'],
229		_second = 1000,
230		_minute = _second * 60,
231		_hour 	= _minute * 60,
232		_day 	= _hour * 24,
233		_week	= _day * 7,	
234		ticker	= function(_self)
235		{
236			var _time		= {},
237				_now 		= new Date(),
238				_timestamp  = _self.end - _now;
239			
240			if(_timestamp <= 0)
241			{
242				clearInterval(_self.countdown);
243				return;
244			}	
245			
246			_self.time.weeks   	= Math.floor( _timestamp / _week);
247			_self.time.days 	= Math.floor((_timestamp % _week) / _day);
248			_self.time.hours	= Math.floor((_timestamp % _day) / _hour); 
249			_self.time.minutes 	= Math.floor((_timestamp % _hour) / _minute); 
250			_self.time.seconds 	= Math.floor((_timestamp % _minute) / _second); 
251			
252			switch(_self.data.maximum)
253			{
254				case 1: _self.time.seconds 	= Math.floor(_timestamp / _second); break;
255				case 2: _self.time.minutes 	= Math.floor(_timestamp / _minute); break;
256				case 3: _self.time.hours	= Math.floor(_timestamp / _hour); 	break;
257				case 4: _self.time.days 	= Math.floor(_timestamp / _day); 	break;
258			}
259			
260			for (var i in _self.time)
261			{	
262				if(typeof _self.update[i] == "object")
263				{
264					if(_self.firstrun || _self.oldtime[i] != _self.time[i])
265					{
266						var labelkey = ( _self.time[i] === 1 ) ? "single" : "multi"; 
267					
268						_self.update[i].time_container.text(_self.time[i]);
269						_self.update[i].label_container.text(_self.update[i][labelkey]);
270					}
271				}
272			}
273			
274			//show ticker
275			if(_self.firstrun) _self.container.addClass('av-countdown-active')
276			
277			_self.oldtime 	= $.extend( {}, _self.time );
278			_self.firstrun	= false;
279		};
280		
281	
282	$.fn.aviaCountdown = function( options )
283	{	
284		if(!this.length) return; 
285
286		return this.each(function()
287		{
288			var _self 			= {};
289			_self.update		= {};
290			_self.time			= {};			
291			_self.oldtime		= {};			
292			_self.firstrun		= true;			
293			
294			_self.container		= $(this);
295			_self.data			= _self.container.data();
296			_self.end			= new Date(_self.data.year, _self.data.month, _self.data.day, _self.data.hour, _self.data.minute );
297			
298			for (var i in _units)
299			{
300				_self.update[_units[i]] = {
301					time_container:  _self.container.find('.av-countdown-' + _units[i] + ' .av-countdown-time'),
302					label_container: _self.container.find('.av-countdown-' + _units[i] + ' .av-countdown-time-label'),
303				};
304				
305				if(_self.update[_units[i]].label_container.length)
306				{
307					_self.update[_units[i]].single = _self.update[_units[i]].label_container.data('label');
308					_self.update[_units[i]].multi  = _self.update[_units[i]].label_container.data('label-multi');
309				}
310			}
311			
312			ticker(_self);
313			_self.countdown 	= setInterval(function(){ ticker(_self); }, 1000);
314
315			
316		});
317	}
318	
319}(jQuery));
320
321
322
323// -------------------------------------------------------------------------------------------
324// 
325// AVIA Image Hotspots
326// 
327// -------------------------------------------------------------------------------------------
328(function($)
329{ 
330	"use strict";
331
332	$.fn.aviaHotspots = function( options )
333	{
334		if(!this.length) return; 
335
336		return this.each(function()
337		{
338			var _self = {};
339			
340			_self.container	= $(this);
341			_self.hotspots	= _self.container.find('.av-image-hotspot');
342			
343				_self.container.on('avia_start_animation', function()
344				{
345					setTimeout(function()
346					{
347						_self.hotspots.each(function(i)
348						{
349							var current = $(this);
350							setTimeout(function(){ current.addClass('av-display-hotspot'); },300 * i);
351						});
352					},400);
353				});
354
355		});
356	}
357	
358}(jQuery));
359
360
361
362
363// -------------------------------------------------------------------------------------------
364// 
365// AVIA Magazine function for magazine sorting
366// 
367// -------------------------------------------------------------------------------------------
368(function($)
369{ 
370	"use strict";
371	
372	var animating = false,
373		methods = {
374		
375		switchMag: function(clicked, _self)
376		{
377			var current 		= $(clicked)
378			
379			if(current.is('.active_sort') || animating) return;
380			
381			var filter			= current.data('filter'),
382				oldContainer	= _self.container.filter(':visible'),
383				newContainer	= _self.container.filter('.' + filter);
384			
385			//switch Class
386			animating = true;
387			_self.sort_buttons.removeClass('active_sort');
388			current.addClass('active_sort');
389			
390			//apply fixed heiht for transition
391			_self.magazine.height(_self.magazine.outerHeight());
392			
393			//switch items
394			oldContainer.avia_animate({opacity:0}
394, 200, function()
395			{
396				oldContainer.css({display:'none'});
397				newContainer.css({opacity:0, display:'block'}).avia_animate({opacity:1}, 150, function()
398				{
399					_self.magazine.avia_animate({height: (newContainer.outerHeight() + _self.sort_bar.outerHeight())}, 150, function()
400					{
401						_self.magazine.height('auto');
402						animating = false;
403					});
404					
405				});
406			});
407		}
408	};
409	
410	
411	$.fn.aviaMagazine = function( options )
412	{
413		if(!this.length) return; 
414
415		return this.each(function()
416		{
417			var _self = {};
418			 
419			_self.magazine		= $(this),
420			_self.sort_buttons 	= _self.magazine.find('.av-magazine-sort a');
421			_self.container		= _self.magazine.find('.av-magazine-group');
422			_self.sort_bar		= _self.magazine.find('.av-magazine-top-bar');
423			
424			_self.sort_buttons.on('click', function(e){ e.preventDefault(); methods.switchMag(this, _self);  } );
425		});
426	}
427	
428}(jQuery));
429
430// -------------------------------------------------------------------------------------------
431// 
432// AVIA MAPS API - loads the google maps api asynchronously 
433// 
434// afterwards applies the map to the container
435// 
436// -------------------------------------------------------------------------------------------
437
438
439(function($)
440{
441    "use strict";
442
443	$.AviaMapsAPI  =  function(options, container)
444	{
445		if(typeof window.av_google_map == 'undefined')
446		{
447			$.avia_utilities.log('Map creation stopped, var av_google_map not found'); return
448		}
449	
450		// gatehr container and map data
451		this.container	= container;
452		this.$container	= $( container );
453		this.$body  	= $('body');
454		this.$mapid		= this.$container.data('mapid') - 1; 
455		this.$data		= window.av_google_map[this.$mapid];
456		this.retina 	= window.devicePixelRatio > 1;
457		
458		// set up the whole api object
459		this._init( options );
460	}
461	
462	$.AviaMapsAPI.apiFiles = 
463	{
464		loading: false, 
465		finished: false, 
466		src: 'https://maps.googleapis.com/maps/api/js?v=3.27&callback=aviaOnGoogleMapsLoaded' 
467	}
468	
469  	$.AviaMapsAPI.prototype =
470    {
471    	_init: function()
472    	{
473    		this._bind_execution();
474    		this._getAPI();
475    	},
476    	
477    	_getAPI: function( )
478		{	
479			//make sure the api file is loaded only once
480			if((typeof window.google == 'undefined' || typeof window.google.maps == 'undefined') && $.AviaMapsAPI.apiFiles.loading == false)
481			{	
482				$.AviaMapsAPI.apiFiles.loading = true;
483				var script 	= document.createElement('script');
484				script.type = 'text/javascript';	
485				script.src 	= $.AviaMapsAPI.apiFiles.src;
486				
487				if(avia_framework_globals.gmap_api != 'undefined' && avia_framework_globals.gmap_api != "")
488				{
489					script.src 	+= "&key=" + avia_framework_globals.gmap_api;
490				}
491				
492      			document.body.appendChild(script);
493			}
494			else if((typeof window.google != 'undefined' && typeof window.google.maps != 'undefined') || $.AviaMapsAPI.apiFiles.loading == false)
495			//else if($.AviaMapsAPI.apiFiles.finished === true)
496			{
497				this._applyMap();
498			}
499		},
500		
501		_bind_execution: function()
502		{
503			this.$body.on('av-google-maps-api-loaded', $.proxy( this._applyMap, this) );
504		},
505		
506		_applyMap: function()
507		{
508			if(typeof this.map != 'undefined') return;
509			if(!this.$data.marker || !this.$data.marker[0] || !this.$data.marker[0].long || !this.$data.marker[0].long)
510			{
511				$.avia_utilities.log('Latitude or Longitude missing', 'map-error'); 
512				return;
513			}
514			
515			var _self = this,
516				mobile_drag = $.avia_utilities.isMobile ? this.$data.mobile_drag_control : true,
517				zoomValue 	= this.$data.zoom == "auto" ? 10 : this.$data.zoom;
518			
519			this.mapVars = {
520				mapMaker: false, //mapmaker tiles are user generated content maps. might hold more info but also be inaccurate
521				mapTypeControl: false,
522				backgroundColor:'transparent',
523				streetViewControl: false,
524				panControl: this.$data.pan_control,
525				zoomControl: this.$data.zoom_control,
526				//draggable: mobile_drag,
527				gestureHandling: 'cooperative',
528				scrollwheel: false,
529				zoom: zoomValue,
530				mapTypeId:google.maps.MapTypeId.ROADMAP,
531				center: new google.maps.LatLng(this.$data.marker[0].lat, this.$data.marker[0].long),
532				styles:[{featureType: "poi", elementType: "labels", stylers: [ { visibility: "off" }] }]
533			};
534			
535
536			this.map = new google.maps.Map(this.container, this.mapVars);
537		
538			this._applyMapStyle();
539			
540			if(this.$data.zoom == "auto")
541			{
542				this._setAutoZoom();
543			}
544			
545			google.maps.event.addListenerOnce(this.map, 'tilesloaded', function() {	
546				_self._addMarkers();
547			});
548		},
549		
550		_setAutoZoom: function()
551		{
552			var bounds = new google.maps.LatLngBounds();
553			
554			for (var key in this.$data.marker) 
555			{
556				bounds.extend( new google.maps.LatLng (this.$data.marker[key].lat , this.$data.marker[key].long) );
557			}
558			
559			this.map.fitBounds(bounds);
560		},
561		
562		_applyMapStyle: function()
563		{
564			var stylers = [], style = [], mapType, style_color = "";
565			
566			if(this.$data.hue != "") stylers.push({hue: this.$data.hue});
567			if(this.$data.saturation != "") stylers.push({saturation: this.$data.saturation});
568			
569			if(stylers.length)
570			{
571				style = [{
572					      featureType: "all",
573					      elementType: "all",
574					      stylers: stylers
575					    }, {
576					      featureType: "poi",
577					      stylers: [
578						  	{ visibility: "off" }
579					      ]
580					    }];
581					    
582				
583				if(this.$data.saturation == "fill")
584				{
585					   
586					style_color = this.$data.hue || "#242424";
587					
588					var c = style_color.substring(1);      // strip #
589					var rgb = parseInt(c, 16);   // convert rrggbb to decimal
590					var r = (rgb >> 16) & 0xff;  // extract red
591					var g = (rgb >>  8) & 0xff;  // extract green
592					var b = (rgb >>  0) & 0xff;  // extract blue
593					
594					var luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; // per ITU-R BT.709
595					var lightness = 1;
596					var street_light = 2;
597					
598					if (luma > 60) {
599					    lightness = -1;
600					    street_light = 3;
601					}
602					if (luma > 220) {
603					    lightness = -2;
604					    street_light = -2;
605					}
606					
607				style = [
608{"featureType":"all","elementType":"all","stylers":[{"color":style_color},{"lightness":0}]},
609{"featureType":"all","elementType":"labels.text.fill","stylers":[{"color":style_color},{"lightness":(25 * street_light)}]},
610{"featureType":"all","elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":style_color},{"lightness":3}]},
611{"featureType":"all","elementType":"labels.icon","stylers":[{"visibility":"off"}]},
612{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":style_color},{"lightness":30}]},
613{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":style_color},{"lightness":30},{"weight":1.2}]},
614{"featureType":"landscape","elementType":"geometry","stylers":[{visibility: 'simplified'},{"color":style_color},{"lightness":3}]},
615{"featureType":"poi","elementType":"geometry","stylers":[{ "visibility": "off" }]},
616{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":style_color},{"lightness":-3}]},
617{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":style_color},{"lightness":2},{"weight":0.2}]},
618{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":style_color},{"lightness":-3}]},
619{"featureType":"road.local","elementType":"geometry","stylers":[{"color":style_color},{"lightness":-3}]},
620{"featureType":"transit","elementType":"geometry","stylers":[{"color":style_color},{"lightness":-3}]},
621{"featureType":"water","elementType":"geometry","stylers":[{"color":style_color},{"lightness":-20}]}
622						];
623				}	
624				
625				mapType = new google.maps.StyledMapType(style, { name:"av_map_style" });
626				this.map.mapTypes.set('av_styled_map', mapType);
627				this.map.setMapTypeId('av_styled_map');
628			}
629		},
630		
631		_addMarkers: function()
632		{
633			for (var key in this.$data.marker) 
634			{	
635				var _self = this;
636				
637				(function(key, _self) 
638				{
639					setTimeout(function()
640					{
641							var marker = "";
642							
643							if(!_self.$data.marker[key] || !_self.$data.marker[key].long || !_self.$data.marker[key].long)
644							{
645								$.avia_utilities.log('Latitude or Longitude for single marker missing', 'map-error'); 
646								return;
647							}
648							
649							_self.$data.LatLng = new google.maps.LatLng(_self.$data.marker[key].lat, _self.$data.marker[key].long);
650							
651							var markerArgs = {
652			        		  flat: false,
653						      position: _self.$data.LatLng,
654						      animation: google.maps.Animation.BOUNCE,
655						      map: _self.map,
656						      title: _self.$data.marker[key].address,
657						      optimized: false
658						    };
659						    
660						    //set a custom marker image if available. also set the size and reduce the marker on retina size so its sharp
661						    if(_self.$data.marker[key].icon && _self.$data.marker[key].imagesize)
662						    { 
663						    	var size = _self.$data.marker[key].imagesize, half = "", full = "";
664						    	
665						    	if(_self.retina && size > 40) size = 40;			//retina downsize to at least half the px size
666						    	half = new google.maps.Point(size / 2, size ) ; 	//used to position the marker
667						    	full = new google.maps.Size(size , size ) ; 		//marker size
668						    	markerArgs.icon = new google.maps.MarkerImage(_self.$data.marker[key].icon, null, null, half, full);
669						    }
670							
671			        		marker = new google.maps.Marker(markerArgs);
672			        		
673			        		setTimeout(function(){ marker.setAnimation(null); _self._infoWindow(_self.map, marker, _self.$data.marker[key]); },500);
674			        		
675		        	},200 * (parseInt(key,10) + 1));
676		        		
677		        }(key, _self));
678    		}
679		},
680		
681		_infoWindow: function(map, marker, data)
682		{
683			var info = $.trim(data.content);
684			
685			if(info != "")
686			{
687				var infowindow = new google.maps.InfoWindow({
688					content: info
689				});
690				
691				google.maps.event.addListener(marker, 'click', function() {
692				    infowindow.open(map,marker);
693				});
694				
695				if(data.tooltip_display) infowindow.open(map,marker);
696			}
697		}
698		
699    	
700    }
701
702    //simple wrapper to call the api. makes sure that the api data is not applied twice
703    $.fn.aviaMaps = function( options )
704    {
705    	return this.each(function()
706    	{	
707    		var self = $.data( this, 'aviaMapsApi' );
708    		
709    		if(!self)
710    		{
711    			self = $.data( this, 'aviaMapsApi', new $.AviaMapsAPI( options, this ) );
712    		}
713    	});
714    }
715    
716})( jQuery );
717
718//this function is executed once the api file is loaded
719window.aviaOnGoogleMapsLoaded = function(){ $('body').trigger('av-google-maps-api-loaded'); $.AviaMapsAPI.apiFiles.finished = true; };
720
721
722// -------------------------------------------------------------------------------------------
723// 
724// AVIA VIDEO API - make sure that youtube, vimeo and html 5 use the same interface
725// 
726// requires froogaloop vimeo library and youtube iframe api (yt can be loaded async)
727// 
728// -------------------------------------------------------------------------------------------
729
730
731(function($)
732{
733    "use strict";
734
735	$.AviaVideoAPI  =  function(options, video, option_container)
736	{	
737		// actual video element. either iframe or video
738		this.$video	= $( video );
739		
740		// container where the AviaVideoAPI object will be stored as data, and that can receive events like play, pause etc 
741		// also the container that allows to overwrite javacript options by adding html data- attributes
742		this.$option_container = option_container ? $( option_container ) : this.$video; 
743		
744		//mobile device?
745		this.isMobile 	= $.avia_utilities.isMobile;
746		
747		//iamge fallback use
748		this.fallback = this.isMobile ? this.$option_container.is('.av-mobile-fallback-image') : false;
749		
750		if(this.fallback) return;
751		
752		// set up the whole api object
753		this._init( options );
754		
755	}
756
757	$.AviaVideoAPI.defaults  = {
758	
759		loop: false,
760		mute: false,
761		controls: false,
762		events: 'play pause mute unmute loop toggle reset unload'
763
764	};
765	
766	$.AviaVideoAPI.apiFiles =
767    {
768    	youtube : {loaded: false, src: 'https://www.youtube.com/iframe_api' }
769    }
770	
771  	$.AviaVideoAPI.prototype =
772    {
773    	_init: function( options )
774    	{	
775			// set slider options
776			this.options = this._setOptions(options);
777			
778			// info which video service we are using: html5, vimeo or youtube
779			this.type = this._getPlayerType();
780			
781			// store the player object to the this.player variable created by one of the APIs (mediaelement, youtube, vimeo)
782			this._setPlayer();			
783			
784			// set to true once the events are bound so it doesnt happen a second time by accident or racing condition
785			this.eventsBound = false;
786			
787			// info if the video is playing
788			this.playing = false;
789			
790			//set css class that video is currently not playing
791			this.$option_container.addClass('av-video-paused');
792			
793			//play pause indicator
794			this.pp = $.avia_utilities.playpause(this.$option_container);
795    	},
796		
797		
798    	//set the video options by first merging the default options and the passed options, then checking the video element if any data attributes overwrite the option set
799    	_setOptions: function(options)
800		{	
801			var newOptions 	= $.extend( true, {}, $.AviaVideoAPI.defaults, options ),
802				htmlData 	= this.$option_container.data(),
803				i 			= "";
804
805			//overwritte passed option set with any data properties on the html element
806			for (i in htmlData)
807			{
808				if (htmlData.hasOwnProperty(i) && (typeof htmlData[i] === "string" || typeof htmlData[i] === "number" || typeof htmlData[i] === "boolean"))
809				{
810					newOptions[i] = htmlData[i]; 
811				}
812			}
813		
814			return newOptions;
815		},
816		
817		
818		//get the player type
819		_getPlayerType: function()
820		{
821			var vid_src = this.$video.get(0).src || this.$video.data('src');
822			
823			
824			if(this.$video.is('video')) 				return 'html5';
825			if(this.$video.is('.av_youtube_frame')) 	return 'youtube';
826			if(vid_src.indexOf('vimeo.com') != -1 ) 	return 'vimeo';
827			if(vid_src.indexOf('youtube.com') != -1) 	return 'youtube';
828		},
829		
830		//get the player object
831		_setPlayer: function()
832		{
833			var _self = this;
834			
835			switch(this.type)
836			{
837				case "html5": 	
838				
839					this.player = this.$video.data('mediaelementplayer');  
840					this._playerReady(); 
841					
842				break; 
843					
844				case "vimeo": 	
845					
846					this.player = Froogaloop(this.$video.get(0)); 
847					this._playerReady(); 
848					
849				break;
850					
851				case "youtube": 
852				
853					this._getAPI(this.type);
854					$('body').on('av-youtube-iframe-api-loaded', function(){ _self._playerReady(); });
855					
856				break;
857			}
858		},
859		
860		_getAPI: function( api )
861		{	
862			//make sure the api file is loaded only once
863			if($.AviaVideoAPI.apiFiles[api].loaded === false)
864			{	
865				$.AviaVideoAPI.apiFiles[api].loaded = true;
866				//load the file async
867				var tag		= document.createElement('script'),
868					first	= document.getElementsByTagName('script')[0];
869					
870				tag.src = $.AviaVideoAPI.apiFiles[api].src;
871      			first.parentNode.insertBefore(tag, first);
872			}
873		},
874		
875		
876		
877		//wait for player to be ready, then bind events
878		_playerReady: function()
879		{	
880			var _self = this;
881			
882			this.$option_container.on('av-video-loaded', function(){ _self._bindEvents(); });
883			
884			switch(this.type)
885			{
886				case "html5": 
887						
888					this.$video.on('av-mediajs-loaded', function(){ _self.$option_container.trigger('av-video-loaded'); });
889					this.$video.on('av-mediajs-ended' , function(){ _self.$option_container.trigger('av-video-ended');  });
890					
891				break;
892				case "vimeo": 	
893					
894					//finish event must be applied after ready event for firefox
895					_self.player.addEvent('ready',  function(){ _self.$option_container.trigger('av-video-loaded'); 
896					_self.player.addEvent('finish', function(){ _self.$option_container.trigger('av-video-ended');  });
897					}); 
898					
899					// vimeo sometimes does not fire. fallback jquery load event should fix this
900					// currently not used because it causes firefox problems
901					/*
902					this.$video.load(function()
903					{ 	
904						if(_self.eventsBound == true || typeof _self.eventsBound == 'undefined') return;
905				        _self.$option_container.trigger('av-video-loaded');
906						$.avia_utilities.log('VIMEO Fallback Trigger');
907				    });
908					*/
909					
910				
911				break;
912				
913				case "youtube": 
914					
915					var params = _self.$video.data();
916					
917					if(_self._supports_video()) params.html5 = 1;
918					
919					_self.player = new YT.Player(_self.$video.attr('id'), {
920						videoId: params.videoid,
921						height: _self.$video.attr('height'),
922						width: _self.$video.attr('width'),
923						playerVars: params,
924						events: {
925						'onReady': function(){ _self.$option_container.trigger('av-video-loaded'); },
926						'onError': function(player){ $.avia_utilities.log('YOUTUBE ERROR:', 'error', player); },
927						'onStateChange': function(event){ 
928							if (event.data === YT.PlayerState.ENDED)
929							{	
930								var command = _self.options.loop != false ? 'loop' : 'av-video-ended';
931								_self.$option_container.trigger(command); 
932							} 
933						  }
934						}
935					});
936					
937					
938				break;
939			}
940			
941			//fallback always trigger after 2 seconds
942			setTimeout(function()
943			{ 	
944				if(_self.eventsBound == true || typeof _self.eventsBound == 'undefined' || _self.type == 'youtube' ) { return; }
945				$.avia_utilities.log('Fallback Video Trigger "'+_self.type+'":', 'log', _self);
946				
947				_self.$option_container.trigger('av-video-loaded'); 
948				
949			},2000);
950			
951		},
952		
953		//bind events we should listen to, to the player
954		_bindEvents: function()
955		{	
956			if(this.eventsBound == true || typeof this.eventsBound == 'undefined')
957			{
958				return;
959			}
960			
961			var _self = this, volume = 'unmute';
962			
963			this.eventsBound = true;
964			
965			this.$option_container.on(this.options.events, function(e)
966			{
967				_self.api(e.type);
968			});
969			
970			if(!_self.isMobile)
971			{
972				//set up initial options
973				if(this.options.mute != false) { volume = "mute"; 	 }
974				if(this.options.loop != false) { _self.api('loop'); }
975				
976				_self.api(volume);
977			}
978			
979			//set timeout to prevent racing conditions with other scripts
980			setTimeout(function()
981			{
982				_self.$option_container.trigger('av-video-events-bound').addClass('av-video-events-bound');
983			},50);
984		},
985		
986		
987		_supports_video: function() {
988		  return !!document.createElement('video').canPlayType;
989		},
990		
991		
992		/************************************************************************
993		PUBLIC Methods
994		*************************************************************************/
995		
996		api: function( action )
997		{	
998			//commands on mobile can not be executed if the player was not started manually 
999			if(this.isMobile && !this.was_started()) return;
1000			
1001			// prevent calling of unbound function
1002			if(this.options.events.indexOf(action) === -1) return;
1003			
1004			// broadcast that the command was executed
1005			this.$option_container.trigger('av-video-'+action+'-executed');
1006			
1007			// calls the function based on action. eg: _html5_play()
1008			if(typeof this[ '_' + this.type + '_' + action] == 'function')
1009			{
1010				this[ '_' + this.type + '_' + action].call(this);
1011			}
1012			
1013			//call generic function eg: _toggle() or _play()
1014			if(typeof this[ '_' + action] == 'function')
1015			{
1016				this[ '_' + action].call(this);
1017			}
1018			
1019		},
1020		
1021		was_started: function()
1022		{
1023			if(!this.player) return false;
1024		
1025			switch(this.type)
1026			{
1027				case "html5": 
1028					if(this.player.getCurrentTime() > 0) return true; 
1029				break; 
1030					
1031				case "vimeo": 	
1032					if(this.player.api('getCurrentTime') > 0) return true; 
1033				break;
1034					
1035				case "youtube": 
1036					if(this.player.getPlayerState() !== -1) return true; 
1037				break;
1038			}
1039			
1040			return false;
1041		},
1042		
1043		/************************************************************************
1044		Generic Methods, are always executed and usually set variables
1045		*************************************************************************/
1046		_play: function()
1047		{
1048			this.playing = true;
1049			this.$option_container.addClass('av-video-playing').removeClass('av-video-paused');
1050		},
1051		
1052		_pause: function()
1053		{
1054			this.playing = false;
1055			this.$option_container.removeClass('av-video-playing').addClass('av-video-paused');
1056		},
1057		
1058		_loop: function()
1059		{
1060			this.options.loop = true;
1061		},
1062		
1063		_toggle: function( )
1064		{
1065			var command = this.playing == true ? 'pause' : 'play';
1066			
1067			this.api(command);
1068			this.pp.set(command);
1069		},
1070		
1071		
1072		/************************************************************************
1073		VIMEO Methods
1074		*************************************************************************/
1075		
1076		_vimeo_play: function( )
1077		{	
1078			this.player.api('play');
1079		},
1080		
1081		_vimeo_pause: function( )
1082		{
1083			this.player.api('pause');	
1084		},
1085		
1086		_vimeo_mute: function( )
1087		{
1088			this.player.api('setVolume', 0);
1089		},
1090		
1091		_vimeo_unmute: function( )
1092		{
1093			this.player.api('setVolume', 0.7);
1094		},
1095		
1096		_vimeo_loop: function( )
1097		{
1098			// currently throws error, must be set in iframe
1099			// this.player.api('setLoop', true);
1100		},
1101		
1102		_vimeo_reset: function( )
1103		{
1104			this.player.api('seekTo',0);
1105		},
1106		
1107		_vimeo_unload: function()
1108		{
1109			this.player.api('unload');
1110		},
1111		
1112		/************************************************************************
1113		YOUTUBE Methods
1114		*************************************************************************/		
1115		
1116		_youtube_play: function( )
1117		{
1118			this.player.playVideo();
1119		},
1120		
1121		_youtube_pause: function( )
1122		{
1123			this.player.pauseVideo()
1124		},
1125		
1126		_youtube_mute: function( )
1127		{
1128			this.player.mute();
1129		},
1130		
1131		_youtube_unmute: function( )
1132		{
1133			this.player.unMute();
1134		},
1135		
1136		_youtube_loop: function( )
1137		{	
1138			// does not work properly with iframe api. needs to manual loop on "end" event
1139			// this.player.setLoop(true); 
1140			if(this.playing == true) this.player.seekTo(0);
1141		},
1142		
1143		_youtube_reset: function( )
1144		{
1145			this.player.stopVideo();
1146		},
1147		
1148		_youtube_unload: function()
1149		{
1150			this.player.clearVideo();
1151		},
1152		
1153		/************************************************************************
1154		HTML5 Methods
1155		*************************************************************************/
1156		
1157		_html5_play: function( )
1158		{
1159			//disable stoping of other videos in case the user wants to run section bgs
1160			this.player.options.pauseOtherPlayers = false;
1161			this.player.play();
1162		},
1163		
1164		_html5_pause: function( )
1165		{
1166			this.player.pause();
1167		},
1168		
1169		_html5_mute: function( )
1170		{
1171			this.player.setMuted(true);
1172		},
1173		
1174		_html5_unmute: function( )
1175		{
1176			this.player.setVolume(0.7);
1177		},
1178		
1179		_html5_loop: function( )
1180		{
1181			this.player.options.loop = true;
1182		},
1183		
1184		_html5_reset: function( )
1185		{	
1186			this.player.setCurrentTime(0);	
1187		},
1188		
1189		_html5_unload: function()
1190		{
1191			this._html5_pause();
1192			this._html5_reset();
1193		}
1194    }
1195
1196    //simple wrapper to call the api. makes sure that the api data is not applied twice
1197    $.fn.aviaVideoApi = function( options , apply_to_parent)
1198    {
1199    	return this.each(function()
1200    	{	
1201    		// by default save the object as data to the initial video. 
1202    		// in the case of slideshows its more benefitial to save it to a parent element (eg: the slide)
1203    		var applyTo = this;
1204    		
1205    		if(apply_to_parent)
1206    		{
1207    			applyTo = $(this).parents(apply_to_parent).get(0);
1208    		}
1209    		
1210    		var self = $.data( applyTo, 'aviaVideoApi' );
1211    		
1212    		if(!self)
1213    		{
1214    			self = $.data( applyTo, 'aviaVideoApi', new $.AviaVideoAPI( options, this, applyTo ) );
1215    		}
1216    	});
1217    }
1218    
1219})( jQuery );
1220
1221window.onYouTubeIframeAPIReady = function(){ $('body').trigger('av-youtube-iframe-api-loaded'); };
1222
1223
1224
1225// -------------------------------------------------------------------------------------------
1226// Masonry
1227// -------------------------------------------------------------------------------------------
1228
1229$.fn.avia_masonry = function(options)
1230{
1231	//return if we didnt find anything
1232	if(!this.length) return this;
1233	
1234	var the_body = $('body'),
1235		the_win	 = $(window),
1236		isMobile = $.avia_utilities.isMobile,
1237		loading = false,
1238		methods = {
1239	
1240		
1241		masonry_filter: function()
1242		{
1243			var current		= $(this),
1244				linktext	= current.html(),
1245		  		selector	= current.data('filter'),
1246		  		masonry 	= current.parents('.av-masonry:eq(0)'),
1247		  		container 	= masonry.find('.av-masonry-container:eq(0)'),
1248		  		links		= masonry.find('.av-masonry-sort a'),
1249		  		activeCat	= masonry.find('.av-current-sort-title');
1250				
1251				links.removeClass('active_sort');
1252				current.addClass('active_sort');
1253				container.attr('id', 'masonry_id_'+selector);
1254				
1255				if(activeCat.length) activeCat.html(linktext);
1256				
1257				methods.applyMasonry(container, selector, function()
1258				{
1259					container.css({overflow:'visible'});
1260				});
1261				
1262				return false;
1263		},
1264		
1265		applyMasonry: function(container, selector, callback)
1266		{
1267			var filters = selector ? {filter: '.'+selector} : {};
1268			
1269			filters['layoutMode'] = 'packery';
1270			filters['packery'] = {gutter:0};
1271			filters['percentPosition'] = true;
1272			filters['itemSelector'] = "a.isotope-item";
1273			
1274			container.isotope(filters, function()
1275			{
1276				the_win.trigger('av-height-change');
1277			});
1278			
1279			if(typeof callback == 'function')
1280			{
1281				setTimeout(callback, 0);
1282			}
1283		},
1284		
1285		show_bricks: function(bricks, callback)
1286		{
1287			bricks.each(function(i)
1288			{
1289				var currentLink 	= $(this),
1290					browserPrefix 	= $.avia_utilities.supports('transition'),
1291					multiplier		= isMobile ? 0 : 100;
1292				
1293				setTimeout(function()
1294				{
1295					if(browserPrefix === false)
1296					{
1297						currentLink.css({visibility:"visible", opacity:0}).animate({opacity:1},1500);
1298					}
1299					else
1300					{
1301						currentLink.addClass('av-masonry-item-loaded');
1302					}
1303					
1304					if(i == bricks.length - 1 && typeof callback == 'function')
1305					{
1306						callback.call();
1307						the_win.trigger('av-height-change');
1308					}
1309					
1310				}, (multiplier * i));
1311			});
1312		},
1313		
1314		loadMore: function(e)
1315		{
1316			e.preventDefault();
1317			
1318			if(loading) return false;
1319			
1320			loading = true;
1321		
1322			var current		= $(this),
1323		  		data		= current.data(),
1324		  		masonry 	= current.parents('.av-masonry:eq(0)'),
1325		  		container	= masonry.find('.av-masonry-container'),
1326		  		items		= masonry.find('.av-masonry-entry'),
1327		  		loader		= $.avia_utilities.loading(),
1328		  		finished	= function(){ loading = false; loader.hide(); the_body.trigger('av_resize_finished'); };
1329		  			  	
1330		  	//calculate a new offset	
1331		  	if(!data.offset){ data.offset = 0; }	
1332		  	data.offset += data.items;
1333		  	data.action = 'avia_ajax_masonry_more';
1334		  	data.loaded = []; //prevents duplicate entries from beeing loaded when randomized is active
1335		  	
1336		  	items.each(function(){
1337			  	var item_id = $(this).data('av-masonry-item');
1338			  	if(item_id) data.loaded.push( item_id );
1339		  	});
1340		  	
1341		  	 $.ajax({
1342				url: avia_framework_globals.ajaxurl,
1343				type: "POST",
1344				data:data,
1345				beforeSend: function()
1346				{
1347					loader.show();
1348				},
1349				success: function(response)
1350				{
1351					if(response.indexOf("{av-masonry-loaded}") !== -1)
1352					{
1353						//fetch the response. if any php warnings were displayed before rendering of the items the are removed by the string split
1354						var response  = response.split('{av-masonry-loaded}'),
1355							new_items = $(response.pop()).filter('.isotope-item');
1356							
1357							//check if we got more items than we need. if not we have reached the end of items
1358							if(new_items.length > data.items)
1359							{
1360								new_items = new_items.not(':last');
1361							}
1362							else
1363							{
1364								current.addClass('av-masonry-no-more-items');
1365							}
1366							
1367							var load_container = $('<div class="loadcontainer"></div>').append(new_items);
1368							
1369							
1370							
1371							$.avia_utilities.preload({container: load_container, single_callback:  function()
1372							{
1373								var links = masonry.find('.av-masonry-sort a'),
1374									filter_container = masonry.find('.av-sort-by-term'),
1375									allowed_filters = filter_container.data("av-allowed-sort");
1376								
1377								filter_container.hide();
1378								
1379								loader.hide();
1380								container.isotope( 'insert', new_items); 
1381								$.avia_utilities.avia_ajax_call(masonry);
1382								setTimeout( function(){ methods.show_bricks( new_items , finished); },150);
1383								setTimeout(function(){ the_win.trigger('av-height-change'); }, 550);
1384								if(links)
1385								{
1386									$(links).each(function(filterlinkindex)
1387									{
1388										var filterlink = $(this),
1389										sort = filterlink.data('filter');
1390
1391										if(new_items)
1392										{
1393										    $(new_items).each(function(itemindex){
1394										        var item = $(this);
1395												
1396										        if(item.hasClass(sort) && allowed_filters.indexOf(sort) !== -1)
1397										        {
1398										            var term_count = filterlink.find('.avia-term-count').text();
1399										            filterlink.find('.avia-term-count').text(' ' + (parseInt(term_count) + 1) + ' ');
1400										
1401										            if(filterlink.hasClass('avia_hide_sort'))
1402										            {
1403										                filterlink.removeClass('avia_hide_sort').addClass('avia_show_sort');
1404										                masonry.find('.av-masonry-sort .'+sort+'_sep').removeClass('avia_hide_sort').addClass('avia_show_sort');
1405										                masonry.find('.av-masonry-sort .av-sort-by-term').removeClass('hidden');
1406										            }
1407										        }
1408										    });
1409										}
1410									});
1411
1412								}
1413
1414                                				filter_container.fadeIn();
1415							}
1416						});
1417					}
1418					else
1419					{
1420						finished();
1421					}
1422				},
1423				error: finished,
1424				complete: function()
1425				{
1426				    
1427				}
1428			});
1429		}
1430
1431	};
1432
1433	return this.each(function()
1434	{	
1435		var masonry			= $(this),
1436			container 		= masonry.find('.av-masonry-container'),
1437			bricks			= masonry.find('.isotope-item'), 
1438			filter			= masonry.find('.av-masonry-sort').css({visibility:"visible", opacity:0}).on('click', 'a',  methods.masonry_filter),
1439			load_more		= masonry.find('.av-masonry-load-more').css({visibility:"visible", opacity:0});
1440			
1441		$.avia_utilities.preload({container: container, single_callback:  function()
1442		{
1443			var start_animation = function()
1444			{ 
1445				filter.animate({opacity:1}, 400);
1446				
1447				//fix for non aligned elements because of scrollbar
1448				if(container.outerHeight() + container.offset().top + $('#footer').outerHeight() > $(window).height())
1449				{
1450					$('html').css({'overflow-y':'scroll'});
1451				}
1452				
1453				methods.applyMasonry(container, false, function()
1454				{
1455					masonry.addClass('avia_sortable_active');
1456					container.removeClass('av-js-disabled '); 
1457				});
1458				
1459				methods.show_bricks(bricks, function()
1460				{
1461					load_more.css({opacity:1}).on('click',  methods.loadMore);
1462				});
1463				
1464				//container.isotope( 'reLayout' );
1465
1466			};
1467			
1468			if(isMobile)
1469			{
1470				start_animation();
1471			}
1472			else
1473			{
1474				masonry.waypoint(start_animation , { offset: '80%'} );
1475			}
1476					
1477			// update columnWidth on window resize
1478			$(window).on( 'debouncedresize', function()
1479			{
1480			  	methods.applyMasonry(container, false, function()
1481				{
1482					masonry.addClass('avia_sortable_active');
1483				});
1484			});
1485		}
1486	});
1487		
1488		
1489	});
1490};
1491
1492
1493
1494
1495	
1496// -------------------------------------------------------------------------------------------
1497// Avia AJAX Portfolio
1498// -------------------------------------------------------------------------------------------
1499
1500(function($)
1501{ 
1502	"use strict";
1503	$.avia_utilities = $.avia_utilities || {};
1504	
1505	$.fn.avia_portfolio_preview = function(passed_options) 
1506	{	
1507		var win  = $(window),
1508		the_body = $('body'),
1509		isMobile = $.avia_utilities.isMobile,
1510		defaults = 
1511		{
1512			open_in:	'.portfolio-details-inner',
1513			easing:		'easeOutQuint',
1514			timing:		800,
1515			transition:	'slide' // 'fade' or 'slide'
1516		},
1517		
1518		options = $.extend({}, defaults, passed_options);
1519	
1520		return this.each(function()
1521		{	
1522			var container			= $(this),
1523				portfolio_id		= container.data('portfolio-id'),
1524				target_wrap			= $('.portfolio_preview_container[data-portfolio-id="' + portfolio_id + '"]'),
1525				target_container	= target_wrap.find(options.open_in),
1526				items				= container.find('.grid-entry'),
1527				content_retrieved	= {},
1528				is_open				= false,
1529				animating			= false,
1530				index_open			= false,
1531				ajax_call			= false,
1532				methods,
1533				controls,
1534				loader				= $.avia_utilities.loading();
1535				
1536			methods = 
1537			{
1538				load_item: function(e)
1539				{
1540					e.preventDefault();
1541
1542					var link			= $(this),
1543						post_container	= link.parents('.post-entry:eq(0)'),
1544						post_id			= "ID_" + post_container.data('ajax-id'),
1545						clickedIndex	= items.index(post_container);
1546					
1547					//check if current item is the clicked item or if we are currently animating
1548					if(post_id === is_open || animating == true) 
1549					{
1550						return false;
1551					}
1552					
1553					animating = true;
1554					
1555					container.find('.active_portfolio_item').removeClass('active_portfolio_item');
1556					post_container.addClass('active_portfolio_item');
1557					loader.show();
1558					
1559					methods.ajax_get_contents(post_id, clickedIndex);
1560				},
1561				
1562				scroll_top: function()
1563				{
1564					setTimeout(function()
1565					{
1566						var target_offset = target_wrap.offset().top - 175,
1567							window_offset = win.scrollTop();
1568											
1569						if(window_offset > target_offset || target_offset - window_offset > 100  )
1570						{
1571							$('html:not(:animated),body:not(:animated)').animate({ scrollTop: target_offset }, options.timing, options.easing);
1572						}
1573					},10);
1574				},
1575				
1576				attach_item: function(post_id)
1577				{
1578					content_retrieved[post_id] = $(content_retrieved[post_id]).appendTo(target_container);
1579					ajax_call = true;
1580				},
1581				
1582				remove_video: function()
1583				{
1584					var del = target_wrap.find('iframe, .avia-video').parents('.ajax_slide:not(.open_slide)');	
1585					
1586						if(del.length > 0)
1587						{
1588							del.remove();
1589							content_retrieved["ID_" + del.data('slideId')] = undefined;
1590						}
1591				},
1592				
1593				show_item: function(post_id, clickedIndex)
1594				{
1595				
1596					//check if current item is the clicked item or if we are currently animating
1597					if(post_id === is_open) 
1598					{
1599						return false;
1600					}
1601					animating = true;
1602					
1603					
1604					loader.hide();
1605					
1606					if(false === is_open)
1607					{
1608						target_wrap.addClass('open_container');
1609						content_retrieved[post_id].addClass('open_slide');
1610						
1611						methods.scroll_top();
1612						
1613						target_wrap.css({display:'none'}).slideDown(options.timing, options.easing, function()
1614						{
1615							if(ajax_call)
1616							{ 
1617								activate_shortcode_scripts(content_retrieved[post_id]); 
1618								$.avia_utilities.avia_ajax_call(content_retrieved[post_id]);
1619								the_body.trigger('av_resize_finished');
1620								ajax_call = false; 
1621							}
1622							
1623							methods.remove_video();
1624							the_body.trigger('av_resize_finished');
1625						});
1626						
1627							index_open	= clickedIndex;
1628							is_open		= post_id;
1629							animating	= false;
1630						
1631						
1632						
1633					}
1634					else
1635					{
1636						methods.scroll_top();
1637					
1638						var initCSS = { zIndex:3 },
1639							easing	= options.easing;
1640							
1641						if(index_open > clickedIndex) { initCSS.left = '-110%'; }
1642						if(options.transition === 'fade'){ initCSS.left = '0%'; initCSS.opacity = 0; easing = 'easeOutQuad'; }
1643						
1644						//fixate height for container during animation
1645						target_container.height(target_container.height()); //outerHeight = border problems?
1646						
1647						content_retrieved[post_id].css(initCSS).avia_animate({'left':"0%", opacity:1}, options.timing, easing);
1648						content_retrieved[is_open].avia_animate({opacity:0}
1648, options.timing, easing, function()
1649						{
1650							content_retrieved[is_open].attr({'style':""}).removeClass('open_slide');
1651							content_retrieved[post_id].addClass('open_slide');
1652																										  //+ 2 fixes border problem (slides move up and down 2 px on transition)
1653							target_container.avia_animate({height: content_retrieved[post_id].outerHeight() + 2}, options.timing/2, options.easing, function()
1654							{
1655								target_container.attr({'style':""});
1656								is_open		= post_id;
1657								index_open	= clickedIndex;
1658								animating	= false;
1659								
1660								methods.remove_video();
1661								if(ajax_call)
1662								{ 
1663									the_body.trigger('av_resize_finished');
1664									activate_shortcode_scripts(content_retrieved[post_id]); 
1665									$.avia_utilities.avia_ajax_call(content_retrieved[post_id]);
1666									ajax_call = false; 
1667								}
1668	
1669							});
1670							
1671						});		
1672					}
1673				},
1674				
1675				ajax_get_contents: function(post_id, clickedIndex)
1676				{
1677					if(content_retrieved[post_id] !== undefined)
1678					{
1679						methods.show_item(post_id, clickedIndex);
1680						return;
1681					}
1682					
1683					content_retrieved[post_id] = $('#avia-tmpl-portfolio-preview-' + post_id.replace(/ID_/,"")).html();
1684					
1685					//this line is necessary to prevent w3 total cache from messing up the portfolio if inline js is compressed
1686					content_retrieved[post_id] = content_retrieved[post_id].replace('/*<![CDATA[*/','').replace('*]]>','');
1687					
1688					methods.attach_item(post_id);
1689					
1690					$.avia_utilities.preload({container: content_retrieved[post_id] , single_callback:  function(){ methods.show_item(post_id, clickedIndex); }});
1691				},
1692				
1693				add_controls: function()
1694				{
1695					controls = target_wrap.find('.ajax_controlls');
1696
1697					target_wrap.avia_keyboard_controls({27:'.avia_close', 37:'.ajax_previous', 39:'.ajax_next'});
1698					//target_wrap.avia_swipe_trigger({prev:'.ajax_previous', next:'.ajax_next'});
1699					
1700					items.each(function(){
1701					
1702						var current = $(this), overlay;
1703						
1704						current.addClass('no_combo').bind('click', function(event)
1705						{
1706							overlay = current.find('.slideshow_overlay');
1707							
1708							if(overlay.length)
1709							{
1710								event.stopPropagation();
1711								methods.load_item.apply(current.find('a:eq(0)'));
1712								return false;
1713							}
1714						});
1715						
1716						
1717					});
1718				},
1719				
1720				control_click: function()
1721				{
1722					var showItem,
1723						activeID = container.find('.active_portfolio_item').data('ajax-id'),
1724						active   = container.find('.post-entry-'+activeID);
1725				
1726					switch(this.hash)
1727					{
1728						case '#next': 
1729						
1730							showItem = active.nextAll('.post-entry:visible:eq(0)').find('a:eq(0)');
1731							if(!showItem.length) { showItem = $('.post-entry:visible:eq(0)', container).find('a:eq(0)'); }
1732							showItem.trigger('click');
1733					
1734						break;
1735						case '#prev': 
1736							
1737							showItem = active.prevAll('.post-entry:visible:eq(0)').find('a:eq(0)');
1738							if(!showItem.length) { showItem = $('.post-entry:visible:last', container).find('a:eq(0)'); }
1739							showItem.trigger('click');
1740						
1741						break;
1742						case '#close':
1743						
1744							animating = true;
1745							
1746							target_wrap.slideUp( options.timing, options.easing, function()
1747							{ 
1748								container.find('.active_portfolio_item').removeClass('active_portfolio_item');
1749								content_retrieved[is_open].attr({'style':""}).removeClass('open_slide');
1750								target_wrap.removeClass('open_container');
1751								animating = is_open = index_open = false;
1752								methods.remove_video();
1753								the_body.trigger('av_resize_finished');
1754							});
1755							
1756						break;
1757					}
1758					return false;
1759				},
1760				
1761				
1762				resize_reset: function()
1763				{
1764					if(is_open === false)
1765					{
1766						target_container.html('');
1767						content_retrieved	= [];
1768					}
1769				}
1770			};
1771			
1772			methods.add_controls();
1773			
1774			container.on("click", "a", methods.load_item);
1775			controls.on("click", "a", methods.control_click);
1776			if(jQuery.support.leadingWhitespace) { win.bind('debouncedresize', methods.resize_reset); }
1777			
1778		});
1779	};
1780}(jQuery));	
1781
1782
1783
1784// -------------------------------------------------------------------------------------------
1785// Fullscreen Slideshow 
1786// 
1787// extends avia slideshow script with a more sophisticated preloader and fixed size for slider
1788// -------------------------------------------------------------------------------------------
1789
1790
1791	$.AviaFullscreenSlider  =  function(options, slider)
1792	{
1793	    this.$slider  	= $( slider ); 
1794	    this.$inner	  	= this.$slider.find('.avia-slideshow-inner');
1795	    this.$innerLi	= this.$inner.find('>li');
1796	    this.$caption 	= this.$inner.find('.avia-slide-wrap .caption_container');
1797	    this.$win	  	= $( window );
1798	    this.isMobile 	= $.avia_utilities.isMobile;
1799	    this.property 	= {};
1800	    this.scrollPos	= "0";
1801	    this.transform3d= document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
1802	    this.ticking 	= false; 
1803	    
1804	    
1805	    if($.avia_utilities.supported.transition === undefined)
1806		{
1807			$.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
1808		}
1809		
1810	    this._init( options );
1811	}
1812
1813	$.AviaFullscreenSlider.defaults  = {
1814
1815		//height of the slider in percent
1816		height: 100,
1817		
1818		//subtract elements from the height
1819		subtract: '#wpadminbar, #header, #main>.title_container'
1820		
1821		
1822	};
1823
1824  	$.AviaFullscreenSlider.prototype =
1825    {
1826    	_init: function( options )
1827    	{
1828    		var _self = this;
1829    		//set the default options
1830    		this.options = $.extend( true, {}, $.AviaFullscreenSlider.defaults, options );
1831    		
1832    		if(this.$slider.data('slide_height')) this.options.height = this.$slider.data('slide_height');
1833    		
1834    		//if background attachment is set to fixed or scroll disable the parallax effect
1835    		this.options.parallax_enabled = this.$slider.data('image_attachment') == "" ? true : false;
1836    		
1837    		//elements that get subtracted from the image height
1838    		this.$subtract = $(this.options.subtract);
1839    		
1840    		
1841			// set the slideshow size
1842			this._setSize(); 
1843    		
1844			// set resizing script on window resize
1845			this.$win.on( 'debouncedresize',  $.proxy( this._setSize, this) );
1846    		
1847    		//parallax scroll if element if leaving viewport
1848			setTimeout(function()
1849			{
1850				if(!_self.isMobile && _self.options.parallax_enabled) //disable parallax scrolling on mobile
1851    			{
1852	    			_self.$win.on( 'scroll', $.proxy( _self._on_scroll, _self) );
1853    			}
1854    			
1855    		},100);
1856			/**/
1857    		
1858			//activate the defaule slider
1859			this.$slider.aviaSlider({bg_slider:true});
1860			
1861			
1862    	},
1863    	
1864    	_on_scroll: function(e)
1865    	{
1866	    	var _self = this;
1867	    	
1868	    	if(!_self.ticking) {
1869		     _self.ticking = true;
1870		      window.requestAnimationFrame( $.proxy( _self._parallax_scroll, _self) );
1871		    }
1872    	},
1873    	
1874    	
1875    	_fetch_properties: function(slide_height)
1876		{
1877			this.property.offset 	= this.$slider.offset().top;
1878			this.property.wh 		= this.$win.height();
1879			this.property.height 	= slide_height || this.$slider.outerHeight();
1880			
1881			//re-position the slider
1882			this._parallax_scroll();
1883		},
1884    	
1885    	_setSize: function( )
1886    	{	
1887    		if(!$.fn.avia_browser_height)
1888    		{
1889    	
1890    		var viewport		= this.$win.height(),
1891    			slide_height	= Math.ceil( (viewport / 100) * this.options.height );
1892			
1893			if(this.$subtract.length && this.options.height == 100)
1894			{
1895	    		this.$subtract.each(function()
1896	    		{
1897	    			slide_height -= this.offsetHeight - 0.5;
1898	    		});
1899    		}
1900    		else
1901    		{
1902    			slide_height -= 1;
1903    		}
1904    		this.$slider.height(slide_height).removeClass('av-default-height-applied');
1905    		this.$inner.css('padding',0);
1906    		}
1907    		
1908    		
1909    		this._fetch_properties(slide_height);
1910    	},
1911    	
1912    	_parallax_scroll: function(e)
1913    	{
1914    		if(this.isMobile || ! this.options.parallax_enabled) return; //disable parallax scrolling on mobile
1915    	
1916    		var winTop 		= this.$win.scrollTop(),
1917    			winBottom	=  winTop + this.property.wh,
1918    			scrollPos 	= "0", 
1919    			prop 		= {}, prop2 = {};
1920    		
1921    		if(this.property.offset < winTop && winTop <= this.property.offset + this.property.height)
1922    		{	
1923    			scrollPos = Math.round( (winTop - this.property.offset) * 0.3 );
1924    		}
1925    		
1926    		if(this.scrollPos != scrollPos)
1927    		{	
1928    			//slide background parallax
1929    			this.scrollPos = scrollPos;
1930    			
1931    			//currently no 3d transform, because of browser quirks
1932    			//this.transform3d = false;
1933    			
1934    			if(this.transform3d)
1935    			{
1936    				prop[$.avia_utilities.supported.transition+"transform"] = "translate3d(0px,"+ scrollPos +"px,0px)";
1937    			}
1938    			else
1939    			{
1940    				prop[$.avia_utilities.supported.transition+"transform"] = "translate(0px,"+ scrollPos +"px)";
1941    			}
1942    			
1943    			
1944    			this.$inner.css(prop);
1945    			
1946    			
1947    			
1948    			//slider caption parallax
1949    			
1950				// prop2[$.avia_utilities.supported.transition+"transform"] = "translate(0px,-"+ ( scrollPos * 1) +"px)";
1951				/*
1952	    		prop2['opacity'] = Math.ceil((this.$slider.height() - (scrollPos * 2)) / 100)/ 10;
1953	    		prop2['opacity'] = prop2['opacity'] < 0 ? 0 : prop2['opacity'];
1954	    		this.$caption.css(prop2);
1955				*/
1956    		}
1957    		
1958    		this.ticking = false;
1959    	}
1960    };
1961
1962
1963
1964$.fn.aviaFullscreenSlider = function( options )
1965{
1966	return this.each(function()
1967	{
1968		var active = $.data( this, 'aviaFullscreenSlider' );
1969
1970		if(!active)
1971		{
1972			//make sure that the function doesnt get aplied a second time
1973			$.data( this, 'aviaFullscreenSlider', 1 );
1974			
1975			//create the preparations for fullscreen slider
1976			new $.AviaFullscreenSlider( options, this );
1977		}
1978	});
1979}
1980	
1981// -------------------------------------------------------------------------------------------
1982// makes sure that the fixed container height is removed once the layerslider is loaded, so it adapts to the screen resolution
1983// -------------------------------------------------------------------------------------------
1984
1985	$.AviaParallaxElement  =  function(options, element)
1986	{
1987	    this.$el  	  	= $( element ).addClass('active-parallax');
1988	    this.$win	  	= $( window );
1989	    this.$body	  	= $( 'body' );
1990	    this.$parent  	= this.$el.parent();
1991	    this.property	= {};
1992	    this.isMobile 	= $.avia_utilities.isMobile;
1993	    this.ratio		= this.$el.data('avia-parallax-ratio') || 0.5;
1994	    this.transform  = document.documentElement.className.indexOf('avia_transform') !== -1 ? true : false;
1995	    this.transform3d= document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
1996	    this.ticking	= false;
1997	    
1998	    if($.avia_utilities.supported.transition === undefined)
1999		{
2000			$.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
2001		}
2002	    
2003	    this._init( options );
2004	}
2005	
2006	$.AviaParallaxElement.prototype = {
2007	
2008		_init: function( options )
2009    	{
2010    		var _self = this;
2011			if(_self.isMobile)
2012			{
2013				return; //disable parallax scrolling on mobile
2014			}
2015			
2016			//fetch window constants
2017			setTimeout(function()
2018			{
2019    			_self._fetch_properties();
2020    		},30);
2021			
2022			this.$win.on("debouncedresize av-height-change",  $.proxy( _self._fetch_properties, _self));
2023			this.$body.on("av_resize_finished",  $.proxy( _self._fetch_properties, _self));
2024			
2025			
2026			
2027			//activate the scrolling
2028			setTimeout(function()
2029			{
2030				_self.$win.on( 'scroll', $.proxy( _self._on_scroll, _self) );
2031    			
2032    		},100);
2033		},
2034		
2035		_fetch_properties: function()
2036		{
2037			this.property.offset 	= this.$parent.offset().top;
2038			this.property.wh 		= this.$win.height();
2039			this.property.height 	= this.$parent.outerHeight();
2040			
2041			//set the height of the element based on the windows height, offset ratio and parent height
2042			this.$el.height(Math.ceil((this.property.wh * this.ratio) + this.property.height));
2043			
2044			//re-position the element
2045			this._parallax_scroll();
2046		},
2047		
2048		_on_scroll: function(e)
2049    	{
2050	    	var _self = this;
2051	    	
2052	    	if(!_self.ticking) {
2053		     _self.ticking = true;
2054		      window.requestAnimationFrame( $.proxy( _self._parallax_scroll, _self) );
2055		    }
2056    	},
2057		
2058		_parallax_scroll: function(e)
2059    	{
2060    		var winTop		=  this.$win.scrollTop(),
2061    			winBottom	=  winTop + this.property.wh,
2062    			scrollPos 	= "0", 
2063    			prop = {};
2064    		
2065    		//shift element when it moves into viewport
2066    		if(this.property.offset < winBottom && winTop <= this.property.offset + this.property.height)
2067    		{	
2068    			scrollPos = Math.ceil( (winBottom - this.property.offset) * this.ratio );
2069    			
2070    			//parallax movement via backround position change, although
2071    			if(this.transform3d)
2072    			{
2073    				prop[$.avia_utilities.supported.transition+"transform"] = "translate3d(0px,"+ scrollPos +"px, 0px)";
2074    			}
2075    			else if(this.transform)
2076    			{
2077    				prop[$.avia_utilities.supported.transition+"transform"] = "translate(0px,"+ scrollPos +"px)";
2078    			}
2079    			else
2080    			{
2081    				prop["background-position"] = "0px "+ scrollPos +"px";
2082    			}
2083	    		
2084	    		this.$el.css(prop);
2085    		}
2086    		
2087    		this.ticking = false;
2088    	}
2089	};
2090
2091
2092$.fn.avia_parallax = function(options)
2093{
2094	return this.each(function()
2095    	{
2096    		var self = $.data( this, 'aviaParallax' );
2097
2098    		if(!self)
2099    		{
2100    			self = $.data( this, 'aviaParallax', new $.AviaParallaxElement( options, this ) );
2101    		}
2102    	});
2103}
2104
2105
2106// -------------------------------------------------------------------------------------------
2107// Helper to allow fixed bgs on mobile
2108// -------------------------------------------------------------------------------------------
2109
2110$.fn.avia_mobile_fixed = function(options)
2111{
2112	var isMobile = $.avia_utilities.isMobile;
2113	if(!isMobile) return;
2114	
2115	return this.each(function()
2116	{
2117		var current				= $(this).addClass('av-parallax-section'),
2118			$background 		= current.attr('style'),
2119			$attachment_class 	= current.data('section-bg-repeat'),
2120			template			= "";
2121			
2122			if($attachment_class == 'stretch' || $attachment_class == 'no-repeat' )
2123			{
2124				$attachment_class = " avia-full-stretch"; 
2125			}
2126			else
2127			{
2128				$attachment_class = ""; 
2129			}
2130			
2131			template = "<div class='av-parallax " + $attachment_class + "' data-avia-parallax-ratio='0.0' style = '" + $background + "' ></div>";
2132			
2133			current.prepend(template);
2134			current.attr('style','');
2135	});
2136}
2137
2138
2139
2140
2141	
2142// -------------------------------------------------------------------------------------------
2143// makes sure that the fixed container height is removed once the layerslider is loaded, so it adapts to the screen resolution
2144// -------------------------------------------------------------------------------------------
2145
2146$.fn.layer_slider_height_helper = function(options)
2147{
2148	return this.each(function()
2149	{
2150		var container 	= $(this),
2151			first_div 	= container.find('>div:first'),
2152			timeout 	= false,
2153			counter 	= 0,
2154			reset_size 	= function()
2155			{
2156				if(first_div.height() > 0 || counter > 5)
2157				{
2158					container.height('auto');
2159				}
2160				else
2161				{
2162					timeout = setTimeout(reset_size, 500);
2163					counter++;
2164				}
2165			};
2166
2167		if(!first_div.length) return;
2168
2169		timeout = setTimeout(reset_size, 0);
2170	});
2171}
2172
2173// -------------------------------------------------------------------------------------------
2174// testimonial shortcode javascript
2175// -------------------------------------------------------------------------------------------
2176
2177$.fn.avia_sc_testimonial = function(options)
2178{
2179	return this.each(function()
2180	{
2181		var container = $(this), elements = container.find('.avia-testimonial');
2182
2183
2184		//trigger displaying of thumbnails
2185		container.on('avia_start_animation', function()
2186		{
2187			elements.each(function(i)
2188			{
2189				var element = $(this);
2190				setTimeout(function(){ element.addClass('avia_start_animation') }, (i * 150));
2191			});
2192		});
2193	});
2194}
2195
2196
2197// -------------------------------------------------------------------------------------------
2198// Progress bar shortcode javascript
2199// -------------------------------------------------------------------------------------------
2200
2201$.fn.avia_sc_progressbar = function(options)
2202{
2203	return this.each(function()
2204	{
2205		var container = $(this), elements = container.find('.avia-progress-bar');
2206		
2207		
2208		//trigger displaying of progress bar
2209		container.on('avia_start_animation', function()
2210		{
2211			elements.each(function(i)
2212			{
2213				var element = $(this)
2214				
2215				setTimeout(function()
2216				{ 
2217					element.find('.progress').addClass('avia_start_animation') 
2218					element.find('.progressbar-percent').avia_sc_animated_number(
2219					{
2220						instant_start:true, simple_up:true, start_timer: 10
2221					});
2222					
2223				}, (i * 250));
2224			});
2225		});
2226	});
2227}
2228
2229// -------------------------------------------------------------------------------------------
2230// Iconlist shortcode javascript
2231// -------------------------------------------------------------------------------------------
2232
2233$.fn.avia_sc_iconlist = function(options)
2234{
2235	return this.each(function()
2236	{
2237		var iconlist = $(this), elements = iconlist.find('>li');
2238
2239
2240		//trigger displaying of thumbnails
2241		iconlist.on('avia_start_animation', function()
2242		{
2243			elements.each(function(i)
2244			{
2245				var element = $(this);
2246				setTimeout(function(){ element.addClass('avia_start_animation') }, (i * 350));
2247			});
2248		});
2249	});
2250}
2251
2252
2253// -------------------------------------------------------------------------------------------
2254//  shortcode javascript for delayed animation even when non connected elements are used
2255// -------------------------------------------------------------------------------------------
2256
2257$.fn.avia_sc_animation_delayed = function(options)
2258{
2259	var global_timer = 0,
2260		delay = options.delay || 50,
2261		max_timer = 10,
2262		new_max = setTimeout(function(){ max_timer = 20; }, 500);
2263	
2264	return this.each(function()
2265	{
2266		var elements = $(this);
2267
2268		//trigger displaying of thumbnails
2269		elements.on('avia_start_animation', function()
2270		{
2271			var element = $(this);
2272			 
2273			if(global_timer < max_timer) global_timer ++;
2274			
2275			setTimeout(function()
2276			{ 
2277				element.addClass('avia_start_delayed_animation'); 
2278				if(global_timer > 0) global_timer --; 
2279			
2280			}, (global_timer * delay));
2281			
2282		});
2283	});
2284}
2285
2286/*delayd animations when used within tab sections or similar elements. this way they get animated each new time a tab is shown*/
2287$.fn.avia_delayed_animation_in_container = function(options)
2288{
2289	return this.each(function()
2290	{
2291		var elements = $(this);
2292		
2293		elements.on('avia_start_animation_if_current_slide_is_active', function()
2294		{
2295			var current = $(this),
2296				animate = current.find('.avia_start_animation_when_active');
2297				
2298				animate.addClass('avia_start_animation').trigger('avia_start_animation');
2299		});
2300		
2301		elements.on('avia_remove_animation', function()
2302		{
2303			var current = $(this),
2304				animate = current.find('.avia_start_animation_when_active, .avia_start_animation');
2305				animate.removeClass('avia_start_animation avia_start_delayed_animation');
2306		});
2307	});
2308}
2309
2310
2311
2312
2313
2314// -------------------------------------------------------------------------------------------
2315// Section Height Helper
2316// -------------------------------------------------------------------------------------------
2317
2318$.fn.avia_browser_height = function()
2319{
2320	if(!this.length) return;
2321	
2322	var win			= $(window),
2323		html_el		= $('html'),
2324		subtract	= $('#wpadminbar, #header.av_header_top:not(.html_header_transparency #header), #main>.title_container'),
2325		css_block	= $("<style type='text/css' id='av-browser-height'></style>").appendTo('head:first'), 
2326		sidebar_menu= $('.html_header_sidebar #top #header_main'),
2327		full_slider	= $('.html_header_sidebar .avia-fullscreen-slider.avia-builder-el-0.avia-builder-el-no-sibling').addClass('av-solo-full'),
2328		calc_height = function()
2329		{
2330			var css			= "",
2331				wh100 		= win.height(),
2332				ww100 		= win.width(),
2333				wh100_mod 	= wh100,
2334				whCover		= (wh100 / 9) * 16,
2335				wwCover		= (ww100 / 16) * 9,
2336				wh75		= Math.round( wh100 * 0.75 ),
2337				wh50		= Math.round( wh100 * 0.5  ),
2338				wh25		= Math.round( wh100 * 0.25 ),
2339				solo		= 0;
2340			
2341			if(sidebar_menu.length) solo = sidebar_menu.height();
2342			
2343			subtract.each(function(){ wh100_mod -= this.offsetHeight - 1; });	
2344			
2345			var whCoverMod	= (wh100_mod / 9) * 16;
2346			
2347			//fade in of section content with minimum height once the height has been calculated
2348			css += ".avia-section.av-minimum-height .container{opacity: 1; }\n";
2349			
2350			//various section heights (100-25% as well as 100% - header/adminbar in case its the first builder element)
2351			css += ".av-minimum-height-100 .container, .avia-fullscreen-slider .avia-slideshow, #top.avia-blank .av-minimum-height-100 .container, .av-cell-min-height-100 > .flex_cell{height:"+wh100+"px;}\n";
2352			css += ".av-minimum-height-75 .container, .av-cell-min-height-75 > .flex_cell	{height:"+wh75+"px;}\n";
2353			css += ".av-minimum-height-50 .container, .av-cell-min-height-50 > .flex_cell	{height:"+wh50+"px;}\n";
2354			css += ".av-minimum-height-25 .container, .av-cell-min-height-25 > .flex_cell	{height:"+wh25+"px;}\n";
2355			css += ".avia-builder-el-0.av-minimum-height-100 .container, .avia-builder-el-0.avia-fullscreen-slider .avia-slideshow, .avia-builder-el-0.av-cell-min-height-100 > .flex_cell{height:"+wh100_mod+"px;}\n";
2356			
2357			css += "#top .av-solo-full .avia-slideshow {min-height:"+solo+"px;}\n";
2358			
2359			//fullscreen video calculations
2360			if(ww100/wh100 < 16/9)
2361			{
2362				css += "#top .av-element-cover iframe, #top .av-element-cover embed, #top .av-element-cover object, #top .av-element-cover video{width:"+whCover+"px; left: -"+(whCover - ww100)/2+"px;}\n";
2363			}
2364			else
2365			{
2366				css += "#top .av-element-cover iframe, #top .av-element-cover embed, #top .av-element-cover object, #top .av-element-cover video{height:"+wwCover+"px; top: -"+(wwCover - wh100)/2+"px;}\n";
2367			}
2368			
2369			if(ww100/wh100_mod < 16/9)
2370			{
2371				css += "#top .avia-builder-el-0 .av-element-cover iframe, #top .avia-builder-el-0 .av-element-cover embed, #top .avia-builder-el-0 .av-element-cover object, #top .avia-builder-el-0 .av-element-cover video{width:"+whCoverMod+"px; left: -"+(whCoverMod - ww100)/2+"px;}\n";
2372			}
2373			else
2374			{
2375				css += "#top .avia-builder-el-0 .av-element-cover iframe, #top .avia-builder-el-0 .av-element-cover embed, #top .avia-builder-el-0 .av-element-cover object, #top .avia-builder-el-0 .av-element-cover video{height:"+wwCover+"px; top: -"+(wwCover - wh100_mod)/2+"px;}\n";
2376			}
2377			
2378			//ie8 needs different insert method
2379			try{
2380				css_block.text(css); 
2381			}
2382			catch(err){
2383				css_block.remove();
2384				css_block = $("<style type='text/css' id='av-browser-height'>"+css+"</style>").appendTo('head:first');
2385			}
2386			
2387			
2388			setTimeout(function(){ win.trigger('av-height-change'); /*broadcast the height change*/ },100);
2389		};
2390	
2391	win.on( 'debouncedresize', calc_height);
2392	calc_height();
2393}
2394
2395// -------------------------------------------------------------------------------------------
2396// Video Section helper
2397// -------------------------------------------------------------------------------------------
2398
2399$.fn.avia_video_section = function()
2400{
2401	if(!this.length) return;
2402	
2403	var elements	= this.length, content = "",
2404		win			= $(window),
2405		css_block	= $("<style type='text/css' id='av-section-height'></style>").appendTo('head:first'), 
2406		calc_height = function(section, counter)
2407		{
2408			if(counter === 0) { content = "";}
2409		
2410			var css			= "",
2411				the_id		= '#' +section.attr('id'),
2412				wh100 		= section.height(),
2413				ww100 		= section.width(),
2414				aspect		= section.data('sectionVideoRatio').split(':'),
2415				video_w		= aspect[0],
2416				video_h		= aspect[1],
2417				whCover		= (wh100 / video_h ) * video_w,
2418				wwCover		= (ww100 / video_w ) * video_h;
2419			
2420			//fullscreen video calculations
2421			if(ww100/wh100 < video_w/video_h)
2422			{
2423				css += "#top "+the_id+" .av-section-video-bg iframe, #top "+the_id+" .av-section-video-bg embed, #top "+the_id+" .av-section-video-bg object, #top "+the_id+" .av-section-video-bg video{width:"+whCover+"px; left: -"+(whCover - ww100)/2+"px;}\n";
2424			}
2425			else
2426			{
2427				css += "#top "+the_id+" .av-section-video-bg iframe, #top "+the_id+" .av-section-video-bg embed, #top "+the_id+" .av-section-video-bg object, #top "+the_id+" .av-section-video-bg video{height:"+wwCover+"px; top: -"+(wwCover - wh100)/2+"px;}\n";
2428			}
2429			
2430			content = content + css;
2431			
2432			if(elements == counter + 1)
2433			{
2434				//ie8 needs different insert method
2435				try{
2436					css_block.text(content);
2437				}
2438				catch(err){
2439					css_block.remove();
2440					css_block = $("<style type='text/css' id='av-section-height'>"+content+"</style>").appendTo('head:first');
2441				}
2442			}
2443		};
2444		
2445		
2446	return this.each(function(i)
2447	{
2448		var self = $(this);
2449		
2450		win.on( 'debouncedresize', function(){ calc_height(self, i); });
2451		calc_height(self, i);
2452	});
2453	
2454}
2455
2456
2457
2458
2459
2460
2461
2462
2463// -------------------------------------------------------------------------------------------
2464// Gallery shortcode javascript
2465// -------------------------------------------------------------------------------------------
2466
2467$.fn.avia_sc_gallery = function(options)
2468{
2469	return this.each(function()
2470	{
2471		var gallery = $(this), images = gallery.find('img'), big_prev = gallery.find('.avia-gallery-big');
2472
2473
2474		//trigger displaying of thumbnails
2475		gallery.on('avia_start_animation', function()
2476		{
2477			images.each(function(i)
2478			{
2479				var image = $(this);
2480				setTimeout(function(){ image.addClass('avia_start_animation') }, (i * 110));
2481			});
2482		});
2483		
2484		if(gallery.hasClass('deactivate_avia_lazyload')) gallery.trigger('avia_start_animation');
2485
2486		//trigger thumbnail hover and big prev image change
2487		if(big_prev.length)
2488		{
2489			gallery.on('mouseenter','.avia-gallery-thumb a', function()
2490			{
2491				var _self = this;
2492
2493				big_prev.attr('data-onclick', _self.getAttribute("data-onclick"));
2494				big_prev.height(big_prev.height());
2495				big_prev.attr('href', _self.href)
2496
2497				var newImg 		= _self.getAttribute("data-prev-img"),
2498					oldImg 		= big_prev.find('img'),
2499					oldImgSrc 	= oldImg.attr('src');
2500
2501				if(newImg != oldImgSrc)
2502				{
2503					var next_img = new Image();
2504					next_img.src = newImg;
2505					
2506					var $next = $(next_img);
2507					
2508					if(big_prev.hasClass('avia-gallery-big-no-crop-thumb'))
2509					{
2510						$next.css({'height':big_prev.height(),'width':'auto'});
2511					}
2512					
2513					big_prev.stop().animate({opacity:0}
2513, function()
2514					{
2515						$next.insertAfter(oldImg);
2516						oldImg.remove();
2517						big_prev.animate({opacity:1});
2518						
2519						big_prev.attr('title',$(_self).attr('title'));
2520						
2521					});
2522				}
2523			});
2524
2525			big_prev.on('click', function()
2526			{
2527				var imagelink = gallery.find('.avia-gallery-thumb a').eq(this.getAttribute("data-onclick") - 1);
2528
2529				if(imagelink && !imagelink.hasClass('aviaopeninbrowser'))
2530				{
2531					imagelink.trigger('click');
2532				}
2533				else if(imagelink)
2534				{
2535					var imgurl = imagelink.attr("href");
2536
2537					if(imagelink.hasClass('aviablank') && imgurl != '' )
2538					{
2539						window.open(imgurl, '_blank');
2540					}
2541					else if( imgurl != '' )
2542					{
2543						window.open(imgurl, '_self');
2544					}
2545				}
2546				return false;
2547			});
2548
2549
2550			$(window).on("debouncedresize", function()
2551			{
2552			  	big_prev.height('auto');
2553			});
2554
2555		}
2556	});
2557}
2558
2559// -------------------------------------------------------------------------------------------
2560// Toggle shortcode javascript
2561// -------------------------------------------------------------------------------------------
2562
2563$.fn.avia_sc_toggle = function(options)
2564{
2565	var defaults =
2566	{
2567		single: '.single_toggle',
2568		heading: '.toggler',
2569		content: '.toggle_wrap',
2570		sortContainer:'.taglist'
2571	};
2572
2573	var win = $(window),
2574		options = $.extend(defaults, options);
2575
2576	return this.each(function()
2577	{
2578		var container 	= $(this).addClass('enable_toggles'),
2579			toggles		= $(options.single, container),
2580			heading 	= $(options.heading, container),
2581			allContent 	= $(options.content, container),
2582			sortLinks	= $(options.sortContainer + " a", container);
2583
2584		heading.each(function(i)
2585		{
2586			var thisheading =  $(this), content = thisheading.next(options.content, container);
2587
2588			function scroll_to_viewport()
2589			{
2590			    //check if toggle title is in viewport. if not scroll up
2591			    var el_offset = content.offset().top,
2592			        scoll_target = el_offset - 50 - parseInt($('html').css('margin-top'),10);
2593
2594			    if(win.scrollTop() > el_offset)
2595			    {
2596			        $('html:not(:animated),body:not(:animated)').animate({scrollTop: scoll_target},200);
2597			    }
2598			}
2599
2600			if(content.css('visibility') != "hidden")
2601			{
2602				thisheading.addClass('activeTitle');
2603			}
2604
2605			thisheading.on('click', function()
2606			{
2607				if(content.css('visibility') != "hidden")
2608				{
2609					content.slideUp(200, function()
2610					{
2611						content.removeClass('active_tc').attr({style:''});
2612						win.trigger('av-height-change');
2613					});
2614					thisheading.removeClass('activeTitle');
2615
2616				}
2617				else
2618				{
2619					if(container.is('.toggle_close_all'))
2620					{
2621						allContent.not(content).slideUp(200, function()
2622						{
2623							$(this).removeClass('active_tc').attr({style:''});
2624							scroll_to_viewport();
2625						});
2626						heading.removeClass('activeTitle');
2627					}
2628					content.addClass('active_tc').slideDown(200,
2629					
2630					function()
2631					{
2632                        if(!container.is('.toggle_close_all'))
2633                        {
2634                            scroll_to_viewport();
2635                        }
2636                        
2637                        win.trigger('av-height-change');
2638					}
2639					
2640					);
2641					thisheading.addClass('activeTitle');
2642					location.replace(thisheading.data('fake-id'));
2643				}
2644				
2645				
2646				
2647			});
2648		});
2649
2650
2651		sortLinks.click(function(e){
2652
2653			e.preventDefault();
2654			var show = toggles.filter('[data-tags~="'+$(this).data('tag')+'"]'),
2655				hide = toggles.not('[data-tags~="'+$(this).data('tag')+'"]');
2656
2657				sortLinks.removeClass('activeFilter');
2658				$(this).addClass('activeFilter');
2659				heading.filter('.activeTitle').trigger('click');
2660				show.slideDown();
2661				hide.slideUp();
2662		});
2663
2664
2665		function trigger_default_open(hash)
2666		{
2667			if(!hash && window.location.hash) hash = window.location.hash;
2668			if(!hash) return;
2669			
2670			var open = heading.filter('[data-fake-id="'+hash+'"]');
2671
2672			if(open.length)
2673			{
2674				if(!open.is('.activeTitle')) open.trigger('click');
2675				window.scrollTo(0, container.offset().top - 70);
2676			}
2677		}
2678		trigger_default_open(false);
2679		
2680		$('a').on('click',function(){
2681            var hash = $(this).attr('href');
2682            if(typeof hash != "undefined" && hash)
2683            {
2684                hash = hash.replace(/^.*?#/,'');
2685                trigger_default_open('#'+hash);
2686            }
2687        });
2688
2689	});
2690};
2691
2692
2693
2694
2695// -------------------------------------------------------------------------------------------
2696// Tab Shortcode
2697// -------------------------------------------------------------------------------------------
2698
2699$.fn.avia_sc_tabs= function(options)
2700{
2701	var defaults =
2702	{
2703		heading: '.tab',
2704		content:'.tab_content',
2705		active:'active_tab',
2706		sidebar: false
2707	};
2708
2709	var win = $(window),
2710		options = $.extend(defaults, options);
2711
2712	return this.each(function()
2713	{
2714		var container 	= $(this),
2715			tab_titles 	= $('<div class="tab_titles"></div>').prependTo(container),
2716			tabs 		= $(options.heading, container),
2717			content 	= $(options.content, container),
2718			newtabs 	= false,
2719			oldtabs 	= false;
2720
2721		newtabs = tabs.clone();
2722		oldtabs = tabs.addClass('fullsize-tab');
2723		tabs = newtabs;
2724
2725		tabs.prependTo(tab_titles).each(function(i)
2726		{
2727			var tab = $(this), the_oldtab = false;
2728
2729			if(newtabs) the_oldtab = oldtabs.filter(':eq('+i+')');
2730
2731			tab.addClass('tab_counter_'+i).bind('click', function()
2732			{
2733				open_content(tab, i, the_oldtab);
2734				return false;
2735			});
2736
2737			if(newtabs)
2738			{
2739				the_oldtab.bind('click', function()
2740				{
2741					open_content(the_oldtab, i, tab);
2742					return false;
2743				});
2744			}
2745		});
2746
2747		set_size();
2748		trigger_default_open(false);
2749		win.on("debouncedresize", set_size);
2750		
2751        $('a').on('click',function(){
2752            var hash = $(this).attr('href');
2753            if(typeof hash != "undefined" && hash)
2754            {
2755                hash = hash.replace(/^.*?#/,'');
2756                trigger_default_open('#'+hash);
2757            }
2758        });
2759
2760		function set_size()
2761		{
2762			if(!options.sidebar) return;
2763			content.css({'min-height': tab_titles.outerHeight() + 1});
2764		}
2765
2766		function open_content(tab, i, alternate_tab)
2767		{
2768			if(!tab.is('.'+options.active))
2769			{
2770				$('.'+options.active, container).removeClass(options.active);
2771				$('.'+options.active+'_content', container).removeClass(options.active+'_content');
2772
2773				tab.addClass(options.active);
2774
2775				var new_loc = tab.data('fake-id');
2776				if(typeof new_loc == 'string') location.replace(new_loc);
2777
2778				if(alternate_tab) alternate_tab.addClass(options.active);
2779				var active_c = content.filter(':eq('+i+')').addClass(options.active+'_content');
2780
2781				if(typeof click_container != 'undefined' && click_container.length)
2782				{
2783					sidebar_shadow.height(active_c.outerHeight());
2784				}
2785				
2786				//check if tab title is in viewport. if not scroll up
2787				var el_offset = active_c.offset().top,
2788					scoll_target = el_offset - 50 - parseInt($('html').css('margin-top'),10);
2789				
2790				if(win.scrollTop() > el_offset)
2791				{
2792					$('html:not(:animated),body:not(:animated)').scrollTop(scoll_target);
2793				}
2794			}
2795		}
2796
2797		function trigger_default_open(hash)
2798		{
2799			if(!hash && window.location.hash) hash = window.location.hash;
2800            		if(!hash) return;
2801            		
2802			var open = tabs.filter('[data-fake-id="'+hash+'"]');
2803
2804			if(open.length)
2805			{
2806				if(!open.is('.active_tab')) open.trigger('click');
2807				window.scrollTo(0, container.offset().top - 70);
2808			}
2809		}
2810
2811	});
2812};
2813
2814
2815
2816
2817// -------------------------------------------------------------------------------------------
2818// Tab Section
2819// -------------------------------------------------------------------------------------------
2820
2821$.fn.avia_sc_tab_section= function()
2822{
2823	var win 			= $(window),
2824		browserPrefix 	= $.avia_utilities.supports('transition'),
2825		cssActive 		= this.browserPrefix !== false ? true : false,
2826		isMobile 		= $.avia_utilities.isMobile,
2827		transform3d		= document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false,
2828		transition		= {};
2829		
2830	return this.each(function()
2831	{
2832		var container 		= $(this),
2833			tabs			= container.find('.av-section-tab-title'),
2834			tab_wrap		= container.find('.av-tab-section-tab-title-container'),
2835			tab_nav			= container.find('.av_tab_navigation'), 
2836			content_wrap	= container.find('.av-tab-section-inner-container'),
2837			single_tabs		= container.find('.av-animation-delay-container'), //for elements inside the tab that receive waypoint animation
2838			min_width		= 0,
2839			change_tab 		= function(e)
2840			{
2841				e.preventDefault();
2842				
2843				var current_tab 	= $(e.currentTarget),
2844					current_arrow	= current_tab.find('.av-tab-arrow-container span'),
2845					tab_nr			= current_tab.data('av-tab-section-title'),
2846					current_content = container.find('[data-av-tab-section-content="'+tab_nr+'"]'),
2847					new_bg			= current_content.data('av-tab-bg-color'),
2848					new_font		= current_content.data('av-tab-color');
2849
2850				tabs.attr('style','').removeClass('av-active-tab-title');
2851				current_tab.addClass('av-active-tab-title');
2852				
2853				if(new_bg != "") current_arrow.css('background-color', new_bg);
2854				if(new_font != "") current_tab.css('color', new_font);
2855				
2856				var new_pos = ((parseInt(tab_nr,10) - 1) * -100 );
2857				
2858				if(cssActive)
2859				{
2860					//move the slides
2861					new_pos = new_pos / tabs.length;
2862					transition['transform']  = transform3d ? "translate3d(" + new_pos  + "%, 0, 0)" : "translate(" + new_pos + "%,0)"; //3d or 2d transform?
2863					transition['left'] = "0%";
2864					content_wrap.css(transition);
2865				}
2866				else
2867				{
2868					content_wrap.css('left',  new_pos + "%");
2869				}
2870				
2871				set_tab_titlte_pos();
2872				
2873				setTimeout(function()
2874				{
2875					current_content.trigger('avia_start_animation_if_current_slide_is_active');
2876					single_tabs.not(current_content).trigger('avia_remove_animation');
2877				}, 600);				
2878			},
2879			set_min_width = function()
2880			{
2881				min_width = 0;
2882				tabs.each(function()
2883				{ 
2884					min_width += $(this).outerWidth(); 
2885				});
2886				
2887				tab_wrap.css('min-width',min_width);
2888			},
2889			set_tab_titlte_pos = function()
2890			{
2891				//scroll the tabs if there is not enough room to display them all
2892				var current_tab = container.find('.av-active-tab-title'),
2893					viewport	= container.width(),
2894					left_pos	= viewport < min_width ? (current_tab.position().left * - 1) - (current_tab.outerWidth() / 2) + (viewport / 2): 0;
2895				
2896				if(left_pos + min_width < viewport) left_pos = (min_width - viewport) * -1;
2897				if(left_pos > 0) left_pos = 0;
2898				
2899				tab_wrap.css('left',left_pos );
2900			},
2901			switch_to_next_prev = function(e)
2902			{
2903				if(!isMobile) return;
2904				
2905				var clicked 		= $(e.currentTarget),
2906					current_tab 	= container.find('.av-active-tab-title');
2907					
2908					if(clicked.is('.av_prev_tab_section'))
2909					{
2910						current_tab.prev('.av-section-tab-title').trigger('click');
2911					}
2912					else
2913					{
2914						current_tab.next('.av-section-tab-title').trigger('click');
2915					}
2916			}
2917			
2918			
2919		tabs.on('click', change_tab);
2920		
2921		tab_nav.on('click', switch_to_next_prev);
2922		
2923		win.on('debouncedresize', set_tab_titlte_pos);	
2924		
2925		set_min_width();
2926		
2927		//force a click on page load to properly set the tab color
2928		container.find('.av-active-tab-title').trigger('click');	
2929		
2930		content_wrap.avia_swipe_trigger({prev:'.av_prev_tab_section', next:'.av_next_tab_section'});
2931			
2932	});
2933};
2934
2935
2936
2937
2938// -------------------------------------------------------------------------------------------
2939// Horizontal Gallery
2940// -------------------------------------------------------------------------------------------
2941
2942$.fn.avia_hor_gallery= function(options)
2943{
2944	var defaults =
2945		{
2946			slide_container	: '.av-horizontal-gallery-inner', //element with max width
2947			slide_element	: '.av-horizontal-gallery-slider', //element that gets moved
2948			slide_content	: '.av-horizontal-gallery-wrap',
2949			active			: 'av-active-gal-item',				// must be a class string without the . in front
2950			prev			: '.av-horizontal-gallery-prev',
2951			next			: '.av-horizontal-gallery-next'
2952		};
2953
2954	var options = $.extend(defaults, options);
2955	
2956	var win 			= $(window),
2957		browserPrefix 	= $.avia_utilities.supports('transition'),
2958		cssActive 		= this.browserPrefix !== false ? true : false,
2959		isMobile 		= $.avia_utilities.isMobile,
2960		transform3d		= document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false,
2961		transition		= {};
2962		
2963	return this.each(function()
2964	{
2965		var container 			= $(this),
2966			slide_container 	= container.find(options.slide_container),
2967			slide_element		= container.find(options.slide_element),
2968			slide_content		= container.find(options.slide_content),
2969			prev				= container.find(options.prev),
2970			next				= container.find(options.next),
2971			imgs				= container.find('img'),
2972			
2973			all_elements_width 	= 0,
2974			currentIndex		= false,
2975			initial				= container.data('av-initial'),
2976			
2977			set_up = function( init )
2978			{
2979				var sl_height = (slide_container.width() / 100 ) * slide_container.data('av-height');
2980				
2981				slide_container.css({'padding':0}).height(sl_height);
2982				
2983				//fixes img distortion when resizing browser:
2984				imgs.css('display','inline-block');
2985				setTimeout(function(){ imgs.css('display','block'); }, 10);
2986				
2987				//calculate the slidelement width based on the elements inside
2988				all_elements_width = 0;
2989				
2990				slide_content.each(function()
2991				{ 
2992					all_elements_width += $(this).outerWidth( true ); 
2993				});
2994				
2995				slide_element.css( 'min-width' , all_elements_width );
2996				
2997				if(currentIndex !== false )
2998				{
2999					change_active(currentIndex);
3000				}
3001			},
3002			change_active = function(index)
3003			{
3004				//scroll the tabs if there is not enough room to display them all
3005				var current 	= slide_element.find(options.slide_content).eq(index),
3006					viewport	= slide_container.width(),
3007					modifier	= container.data('av-enlarge') > 1  && currentIndex == index ? container.data('av-enlarge') : 1,
3008					outerWidth	= current.outerWidth( true ) * modifier,
3009					margin_right= parseInt( current.css('margin-right') , 10 ) / 2,
3010					left_pos	= viewport < all_elements_width ? (current.position().left * - 1) - (outerWidth / 2) + (viewport / 2): 0;
3011				
3012				//center properly
3013				left_pos = left_pos + margin_right;
3014				
3015				//out of bounce right side
3016				if(left_pos + all_elements_width < viewport) left_pos = (all_elements_width - viewport - parseInt(current.css('margin-right'),10) ) * -1;
3017				
3018				//out of bounce left side
3019				if(left_pos > 0) left_pos = 0;
3020				
3021				//set pos
3022				slide_element.css('left',left_pos );
3023				
3024				slide_container.find("." +options.active).removeClass(options.active);
3025				current.addClass(options.active);
3026				currentIndex = index;
3027				
3028			};
3029
3030			
3031		 $.avia_utilities.preload({container: container , global_callback:  function()
3032		 {
3033			 // activate behavior
3034			set_up( 'init' );
3035			win.on('debouncedresize', set_up);
3036			if(initial) change_active(initial - 1);
3037			
3038			setTimeout(function(){
3039				container.addClass('av-horizontal-gallery-animated');
3040			},10); 
3041		
3042		  }});
3043			
3044		
3045		
3046		
3047		
3048		
3049		
3050		//swipe on mobile
3051		slide_element.avia_swipe_trigger({prev:options.prev, next:options.next});
3052		
3053		//element click
3054		slide_content.on('click', function(e)
3055		{
3056			var current = $(this);
3057			var index = slide_content.index(current);
3058			
3059			if(currentIndex === index)
3060			{
3061				if(container.data('av-enlarge') > 1 && !$(e.target).is('a') )
3062				{
3063					slide_container.find("." +options.active).removeClass(options.active);
3064					currentIndex = false;	
3065				}
3066				return;
3067			}
3068			
3069			change_active(index);
3070		});
3071		
3072		prev.on('click', function(e)
3073		{
3074			if(currentIndex === false) currentIndex = 1;
3075			var index = currentIndex - 1;
3076			if(index < 0) index = 0;
3077			
3078			change_active(index);
3079		});
3080		
3081		next.on('click', function(e)
3082		{
3083			if(currentIndex === false) currentIndex = -1;
3084			var index = currentIndex + 1;
3085			if(index > slide_content.length - 1) index = slide_content.length - 1;
3086			
3087			change_active(index);
3088		});
3089		
3090		//if its a desktop browser add arrow navigation, otherwise add touch nav
3091		if(!isMobile)
3092		{
3093			container.avia_keyboard_controls({ 37: options.prev, 39: options.next });
3094		}
3095		else
3096		{
3097			container.avia_swipe_trigger({next: options.next, prev: options.prev});
3098		}
3099		
3100		
3101	
3102	});
3103};
3104
3105// -------------------------------------------------------------------------------------------
3106// Big Number animation shortcode javascript
3107// -------------------------------------------------------------------------------------------
3108
3109(function($)
3110{
3111	// options.simple_up = dont prepend leading zeros, options.instant_start = trigger counting instantly, options.start_timer = delay when to start counting
3112	$.fn.avia_sc_animated_number = function(options) 
3113	{
3114		if(!this.length) return;
3115		if(this.is('.avia_sc_animated_number_active')) return;
3116		
3117		this.addClass('avia_sc_animated_number_active');
3118	
3119		var skipStep = false,
3120			simple_upcount 	= (options && options.simple_up) ? true : false,
3121			start_timer 	= (options && options.start_timer) ? options.start_timer : 300,
3122		start_count = function(element, countTo, increment, current, fakeCountTo)
3123		{
3124			
3125			
3126			//calculate the new number
3127			var newCount = current + increment;
3128			
3129			//if the number is bigger than our final number set the number and finish
3130			if(newCount >= fakeCountTo) 
3131			{
3132				element.text(countTo); //exit
3133				
3134			}
3135			else
3136			{
3137				var prepend = "", addZeros = countTo.toString().length - newCount.toString().length
3138				
3139				//if the number has less digits than the final number some zeros where omitted. add them to the front
3140				for(var i = addZeros; i > 0; i--){ prepend += "0"; }
3141				
3142				if(simple_upcount) prepend = 0;
3143				element.text(prepend + newCount);
3144				
3145				window.requestAnimationFrame(function(){ start_count(element, countTo, increment, newCount, fakeCountTo) });
3146			}
3147		};
3148	
3149		return this.each(function()
3150		{
3151			var number_container = $(this), elements = number_container.find('.__av-single-number'), countTimer = number_container.data('timer') || 3000;
3152			
3153			//prepare elements
3154			elements.each(function(i)
3155			{
3156				var element = $(this), text = element.text();
3157				if(window.addEventListener) element.text( text.replace(/./g, "0")); /*https://github.com/AviaThemes/wp-themes/issues/812*/
3158			});
3159			
3160			//trigger number animation
3161			number_container.addClass('number_prepared').on('avia_start_animation', function()
3162			{
3163				if(number_container.is('.avia_animation_done')) return;
3164				number_container.addClass('avia_animation_done');
3165				
3166				elements.each(function(i)
3167				{
3168					var element = $(this), countTo = element.data('number'), fakeCountTo = countTo, current = parseInt(element.text(),10), zeroOnly = /^0+$/.test(countTo), increment = 0;
3169					
3170					//fallback for decimals like 00 or 000
3171					if(zeroOnly && countTo !== 0) fakeCountTo = countTo.replace(/0/g, '9');
3172					
3173					increment = Math.round( fakeCountTo * 32 / countTimer);
3174					if(increment == 0 || increment % 10 == 0) increment += 1;
3175					
3176					setTimeout(function(){ start_count(element, countTo, increment, current, fakeCountTo);}, start_timer);
3177				});
3178			});
3179			
3180			if(options && options.instant_start == true)
3181			{
3182				number_container.trigger('avia_start_animation');
3183			}
3184			
3185			
3186		});
3187	}
3188})(jQuery);
3189
3190
3191
3192
3193// -------------------------------------------------------------------------------------------
3194// contact form ajax
3195// -------------------------------------------------------------------------------------------
3196
3197(function($)
3198{
3199	$.fn.avia_ajax_form = function(variables)
3200	{	
3201		var defaults =
3202		{
3203			sendPath: 'send.php',
3204			responseContainer: '.ajaxresponse'
3205		};
3206
3207		var options = $.extend(defaults, variables);
3208
3209		return this.each(function()
3210		{
3211			var form = $(this),
3212				form_sent = false,
3213				send =
3214				{
3215					formElements: form.find('textarea, select, input[type=text], input[type=checkbox], input[type=hidden]'),
3216					validationError:false,
3217					button : form.find('input:submit'),
3218					dataObj : {}
3219				},
3220
3221				responseContainer = form.next(options.responseContainer+":eq(0)");
3222
3223				send.button.bind('click', checkElements);
3224				
3225				
3226				//change type of email forms on mobile so the e-mail keyboard with @ sign is used
3227				if($.avia_utilities.isMobile)
3228				{
3229					send.formElements.each(function(i)
3230					{
3231						var currentElement = $(this), is_email = currentElement.hasClass('is_email');
3232						if(is_email) currentElement.attr('type','email');
3233					});
3234				}
3235			
3236
3237			function checkElements( e )
3238			{
3239				// reset validation var and send data
3240				send.validationError = false;
3241				send.datastring = 'ajax=true';
3242
3243				send.formElements.each(function(i)
3244				{
3245					var currentElement = $(this),
3246						surroundingElement = currentElement.parent(),
3247						value = currentElement.val(),
3248						name = currentElement.attr('name'),
3249					 	classes = currentElement.attr('class'),
3250					 	nomatch = true;
3251
3252					 	if(currentElement.is(':checkbox'))
3253					 	{
3254					 		if(currentElement.is(':checked')) { value = true } else {value = ''}
3255					 	}
3256					 	
3257					 	send.dataObj[name] = encodeURIComponent(value);
3258
3259					 	if(classes && classes.match(/is_empty/))
3260						{
3261							if(value == '' || value == null)
3262							{
3263								surroundingElement.removeClass("valid error ajax_alert").addClass("error");
3264								send.validationError = true;
3265							}
3266							else
3267							{
3268								surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
3269							}
3270							nomatch = false;
3271						}
3272
3273						if(classes && classes.match(/is_email/))
3274						{
3275							if(!value.match(/^[\w|\.|\-]+@\w[\w|\.|\-]*\.[a-zA-Z]{2,20}$/))
3276							{
3277								surroundingElement.removeClass("valid error ajax_alert").addClass("error");
3278								send.validationError = true;
3279							}
3280							else
3281							{
3282								surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
3283							}
3284							nomatch = false;
3285						}
3286
3287						if(classes && classes.match(/is_phone/))
3288						{
3289							if(!value.match(/^(\d|\s|\-|\/|\(|\)|\[|\]|e|x|t|ension|\.|\+|\_|\,|\:|\;){3,}$/))
3290							{
3291								surroundingElement.removeClass("valid error ajax_alert").addClass("error");
3292								send.validationError = true;
3293							}
3294							else
3295							{
3296								surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
3297							}
3298							nomatch = false;
3299						}
3300
3301						if(classes && classes.match(/is_number/))
3302						{
3303							if(!($.isNumeric(value)) || value == "")
3304							{
3305								surroundingElement.removeClass("valid error ajax_alert").addClass("error");
3306								send.validationError = true;
3307							}
3308							else
3309							{
3310								surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
3311							}
3312							nomatch = false;
3313						}
3314
3315						if(classes && classes.match(/captcha/))
3316						{
3317							var verifier 	= form.find("#" + name + "_verifier").val(),
3318								lastVer		= verifier.charAt(verifier.length-1),
3319								finalVer	= verifier.charAt(lastVer);
3320
3321							if(value != finalVer)
3322							{
3323								surroundingElement.removeClass("valid error ajax_alert").addClass("error");
3324								send.validationError = true;
3325							}
3326							else
3327							{
3328								surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
3329							}
3330							nomatch = false;
3331						}
3332
3333						if(nomatch && value != '')
3334						{
3335							surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
3336						}
3337				});
3338
3339				if(send.validationError == false)
3340				{
3341					if(form.data('av-custom-send'))
3342					{
3343						mailchimp_send();	
3344					}
3345					else
3346					{
3347						send_ajax_form();
3348					}
3349				}
3350				
3351				return false;
3352			}
3353			
3354			
3355			function send_ajax_form()
3356			{
3357				if(form_sent){ return false; }
3358
3359				form_sent = true;
3360				send.button.addClass('av-sending-button');
3361				send.button.val(send.button.data('sending-label'));
3362				
3363				var redirect_to = form.data('avia-redirect') || false,
3364					action		= form.attr('action');
3365				
3366				responseContainer.load(action+' '+options.responseContainer, send.dataObj, function()
3367				{
3368					if(redirect_to && action != redirect_to)
3369					{
3370						form.attr('action', redirect_to);
3371						location.href = redirect_to;
3372						// form.submit();
3373					}
3374					else
3375					{
3376						responseContainer.removeClass('hidden').css({display:"block"});
3377						form.slideUp(400, function(){responseContainer.slideDown(400, function(){ $('body').trigger('av_resize_finished'); }); send.formElements.val('');});
3378					}
3379				});
3380			}
3381			
3382			
3383			function mailchimp_send()
3384			{
3385				if(form_sent){ return false; }
3386
3387				form_sent = true;
3388				
3389				var original_label = send.button.val();
3390
3391				send.button.addClass('av-sending-button');
3392				send.button.val(send.button.data('sending-label'));
3393				send.dataObj.ajax_mailchimp = true;
3394				
3395				var redirect_to 		= form.data('avia-redirect') || false,
3396					action				= form.attr('action'),
3397					error_msg_container = form.find('.av-form-error-container'),
3398					form_id 			= form.data('avia-form-id'); 
3399				
3400				$.ajax({
3401					url: action,
3402					type: "POST",
3403					data:send.dataObj,
3404					beforeSend: function()
3405					{
3406						if(error_msg_container.length)
3407						{
3408							error_msg_container.slideUp(400, function()
3409							{
3410								error_msg_container.remove();
3411								$('body').trigger('av_resize_finished');
3412							});
3413						}
3414					},
3415					success: function(responseText)
3416					{
3417						var response	= jQuery("<div>").append(jQuery.parseHTML(responseText)),
3418							error		= response.find('.av-form-error-container');	
3419						
3420						if(error.length)
3421						{
3422							form_sent = false;
3423							form.prepend(error);
3424							error.css({display:"none"}).slideDown(400, function()
3425							{
3426								$('body').trigger('av_resize_finished');
3427							});
3428
3429							send.button.removeClass('av-sending-button');
3430							send.button.val(original_label);
3431						}
3432						else
3433						{
3434							if(redirect_to && action != redirect_to)
3435							{
3436								form.attr('action', redirect_to);
3437								location.href = redirect_to;
3438								// form.submit();
3439							}
3440							else
3441							{
3442								var success_text = response.find(options.responseContainer + "_" + form_id);
3443								
3444								responseContainer.html(success_text).removeClass('hidden').css({display:"block"});
3445								
3446								form.slideUp(400, function()
3447								{
3448									responseContainer.slideDown(400, function()
3449									{ 
3450										$('body').trigger('av_resize_finished'); 
3451									});
3452									
3453								send.formElements.val('');
3454							});
3455							}
3456						}
3457						
3458					},
3459					error: function()
3460					{
3461						
3462					},
3463					complete: function()
3464					{
3465					    
3466					}
3467				});
3468
3469			}
3470			
3471			
3472		});
3473	};
3474})(jQuery);
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487// -------------------------------------------------------------------------------------------
3488// Aviaccordion Slideshow 
3489// 
3490// accordion slider script
3491// -------------------------------------------------------------------------------------------
3492
3493	$.AviaccordionSlider  =  function(options, slider)
3494	{
3495	    this.$slider  	= $( slider );
3496	    this.$inner	  	= this.$slider.find('.aviaccordion-inner');
3497	    this.$slides	= this.$inner.find('.aviaccordion-slide');
3498	    this.$images	= this.$inner.find('.aviaccordion-image');
3499	    this.$last		= this.$slides.filter(':last');
3500	    this.$titles  	= this.$slider.find('.aviaccordion-preview');
3501	    this.$titlePos  = this.$slider.find('.aviaccordion-preview-title-pos');
3502	    this.$titleWrap = this.$slider.find('.aviaccordion-preview-title-wrap');
3503	    this.$win	  	= $( window );
3504	    
3505	    if($.avia_utilities.supported.transition === undefined)
3506		{
3507			$.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
3508		}
3509		
3510		this.browserPrefix 	= $.avia_utilities.supported.transition;
3511	    this.cssActive 		= this.browserPrefix !== false ? true : false;
3512	    this.transform3d	= document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
3513		this.isMobile 		= $.avia_utilities.isMobile;
3514		this.property		= this.browserPrefix + 'transform',
3515		this.count			= this.$slides.length;
3516		this.open			= false;
3517		this.autoplay		= false;
3518		this.increaseTitle  = this.$slider.is(".aviaccordion-title-on-hover");
3519		// this.cssActive    = false; //testing no css3 browser
3520		
3521	    this._init( options );
3522	}
3523
3524  	$.AviaccordionSlider.prototype =
3525    {
3526    	_init: function( options )
3527    	{
3528    		var _self = this;
3529    		_self.options = $.extend({}, options, this.$slider.data());
3530			 $.avia_utilities.preload({container: this.$slider , single_c
3530allback:  function(){ _self._kickOff(); }});
3531    	},
3532    	
3533    	_kickOff: function()
3534    	{
3535    		var _self = this;
3536    		
3537    		_self._calcMovement();
3538    		_self._bindEvents();
3539    		_self._showImages();
3540    		_self._autoplay();
3541    	},
3542    	
3543    	_autoplay: function()
3544    	{
3545    		var _self = this;
3546    		
3547    		if(_self.options.autoplay)
3548    		{
3549    			_self.autoplay = setInterval(function()
3550    			{
3551    				_self.open = _self.open === false ? 0 : _self.open + 1;
3552    				if(_self.open >= _self.count) _self.open = 0;
3553    				_self._move({}, _self.open);
3554    				
3555    			}, _self.options.interval * 1000)
3556    		}
3557    	},
3558    	
3559    	_showImages: function()
3560    	{
3561    		var _self = this, counter = 0, delay = 300, title_delay = this.count * delay;
3562    		
3563    		if(this.cssActive)
3564    		{
3565    			setTimeout(function(){ _self.$slider.addClass('av-animation-active'); } , 10);
3566    		}
3567    		
3568    		this.$images.each(function(i)
3569    		{
3570    			var current = $(this), timer = delay * (i + 1);
3571    				
3572    			setTimeout(function()
3573    			{ 
3574    				current.avia_animate({opacity:1}, 400, function()
3575    				{
3576    					current.css($.avia_utilities.supported.transition + "transform", "none");
3577    				}); 
3578    			},timer);
3579    		});
3580    		
3581    		if(_self.increaseTitle) title_delay = 0;
3582    		
3583    		this.$titlePos.each(function(i)
3584    		{
3585    			var current = $(this), new_timer = title_delay + 100 * (i + 1);
3586    					
3587    			setTimeout(function()
3588    			{ 
3589    				current.avia_animate({opacity:1}, 200, function()
3590    				{
3591    					current.css($.avia_utilities.supported.transition + "transform", "none");
3592    				}); 
3593    			},new_timer);
3594    		});
3595    	},
3596    	
3597    	_bindEvents: function()
3598    	{
3599    		var trigger = this.isMobile ? "click" : "mouseenter";
3600    	
3601    		this.$slider.on(trigger,'.aviaccordion-slide', $.proxy( this._move, this));
3602    		this.$slider.on('mouseleave','.aviaccordion-inner', $.proxy( this._move, this));
3603    		this.$win.on('debouncedresize', $.proxy( this._calcMovement, this));
3604    		this.$slider.on('av-prev av-next', $.proxy( this._moveTo, this));
3605    		
3606    		if(this.isMobile)
3607    		{
3608    			this.$slider.avia_swipe_trigger({next: this.$slider, prev: this.$slider, event:{prev: 'av-prev', next: 'av-next'}});
3609    		}
3610    		
3611    	},
3612    	
3613    	_titleHeight: function()
3614    	{
3615    		var th = 0;
3616    		
3617    		this.$titleWrap.css({'height':'auto'}).each(function()
3618    		{
3619    			var new_h = $(this).outerHeight();
3620    			if( new_h > th) th = new_h;
3621    		
3622    		}).css({'height':th + 2});
3623    		
3624    	},
3625    	
3626    	_calcMovement: function(event, allow_repeat)
3627    	{ 
3628    		var _self			= this,
3629    			containerWidth	= this.$slider.width(),
3630    			defaultPos		= this.$last.data('av-left'),
3631    			imgWidth		= this.$images.filter(':last').width() || containerWidth,
3632    			imgWidthPercent = Math.floor((100 / containerWidth) * imgWidth),
3633    			allImageWidth	= imgWidthPercent * _self.count,
3634    			modifier		= 3, // 10 - _self.count,
3635    			tempMinLeft		= 100 - imgWidthPercent,
3636    			minLeft 		= tempMinLeft > defaultPos / modifier ? tempMinLeft : 0,
3637    			oneLeft			= minLeft / (_self.count -1 ),
3638    			titleWidth		= imgWidth;
3639    		
3640    		
3641    		
3642    		if(allImageWidth < 110 && allow_repeat !== false)
3643    		{
3644    			//set height if necessary	
3645    			var slideHeight = this.$slider.height(), 
3646    				maxHeight 	= (slideHeight / allImageWidth) * 110 ;
3647    			
3648    			this.$slider.css({'max-height': maxHeight});
3649    			_self._calcMovement(event, false);
3650    			return;
3651    		}
3652    		
3653    		//backup so the minimized slides dont get too small
3654    		if(oneLeft < 2) minLeft = 0;
3655    		
3656			this.$slides.each(function(i)
3657			{
3658				var current = $(this), newLeft = 0, newRight = 0, defaultLeft = current.data('av-left');
3659					
3660				if( minLeft !== 0)
3661				{
3662					newLeft  = oneLeft * i;
3663					newRight = imgWidthPercent + newLeft - oneLeft;
3664				}
3665				else
3666				{
3667					newLeft  = defaultLeft / Math.abs(modifier);
3668					newRight = 100 - ((newLeft / i) * (_self.count - i));
3669				}
3670				
3671				if(i == 1 && _self.increaseTitle) { titleWidth = newRight + 1; } 
3672				
3673				if(_self.cssActive)
3674				{	
3675					//if we are not animating based on the css left value but on css transform we need to subtract the left value
3676					newLeft = newLeft - defaultLeft;
3677					newRight = newRight - defaultLeft;
3678					defaultLeft = 0;
3679				}
3680				
3681				current.data('av-calc-default', defaultLeft);
3682				current.data('av-calc-left', newLeft);
3683				current.data('av-calc-right', newRight);
3684				
3685			});
3686			
3687			if(_self.increaseTitle) { _self.$titles.css({width: titleWidth + "%"});} 
3688    	},
3689    	
3690    	_moveTo: function(event)
3691    	{
3692    		var direction 	= event.type == "av-next" ? 1 : -1,
3693    			nextSlide 	= this.open === false ? 0 : this.open + direction;
3694    			
3695    		if(nextSlide >= 0 && nextSlide < this.$slides.length) this._move(event, nextSlide);
3696    	},
3697    	
3698    	_move: function(event, direct_open)
3699    	{
3700    		var _self  = this,
3701    			slide  = event.currentTarget,
3702    			itemNo = typeof direct_open != "undefined" ? direct_open : this.$slides.index(slide);
3703    			
3704    		this.open = itemNo;
3705    		
3706    		if(_self.autoplay && typeof slide != "undefined") { clearInterval(_self.autoplay); _self.autoplay = false; }
3707    		
3708    		this.$slides.removeClass('aviaccordion-active-slide').each(function(i)
3709    		{
3710    			var current 	= $(this),
3711    				dataSet 	= current.data(),
3712    				trans_val	= i <= itemNo ? dataSet.avCalcLeft : dataSet.avCalcRight,
3713					transition 	= {},
3714					reset		= event.type == 'mouseleave' ? 1 : 0,
3715					active 		= itemNo === i ? _self.$titleWrap.eq(i) : false;
3716    			
3717    			if(active) current.addClass('aviaccordion-active-slide');
3718    				
3719    			if(reset)
3720    			{
3721    				trans_val = dataSet.avCalcDefault; 
3722    				this.open = false;
3723    			}
3724    				
3725				if(_self.cssActive) //do a css3 animation
3726				{
3727					//move the slides
3728					transition[_self.property]  = _self.transform3d ? "translate3d(" + trans_val  + "%, 0, 0)" : "translate(" + trans_val + "%,0)"; //3d or 2d transform?
3729					current.css(transition);
3730				}
3731				else
3732				{
3733					transition.left =  trans_val + "%";
3734					current.stop().animate(transition, 700, 'easeOutQuint');
3735				}	
3736    		});
3737    	}
3738    };
3739
3740
3741$.fn.aviaccordion = function( options )
3742{
3743	return this.each(function()
3744	{
3745		var active = $.data( this, 'AviaccordionSlider' );
3746
3747		if(!active)
3748		{
3749			//make sure that the function doesnt get aplied a second time
3750			$.data( this, 'AviaccordionSlider', 1 );
3751			
3752			//create the preparations for fullscreen slider
3753			new $.AviaccordionSlider( options, this );
3754		}
3755	});
3756}
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768// -------------------------------------------------------------------------------------------
3769// Aviaccordion Slideshow 
3770// 
3771// accordion slider script
3772// -------------------------------------------------------------------------------------------
3773
3774	$.AviaTextRotator  =  function(options, slider)
3775	{
3776	    this.$win	  	= $( window );
3777	    this.$slider  	= $( slider );
3778	    this.$inner	  	= this.$slider.find('.av-rotator-text');
3779	    this.$slides	= this.$inner.find('.av-rotator-text-single');
3780	    this.$current   = this.$slides.eq(0);
3781	    this.open		= 0;
3782	    this.count		= this.$slides.length;
3783	    
3784	    if($.avia_utilities.supported.transition === undefined)
3785		{
3786			$.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
3787		}
3788		
3789		this.browserPrefix 	= $.avia_utilities.supported.transition;
3790	    this.cssActive 		= this.browserPrefix !== false ? true : false;
3791		this.property		= this.browserPrefix + 'transform',
3792		
3793		//this.cssActive    = false; //testing no css3 browser
3794		
3795	    this._init( options );
3796	}
3797
3798  	$.AviaTextRotator.prototype =
3799    {
3800    	_init: function( options )
3801    	{
3802    		var _self = this;
3803    		
3804    		if(this.count <= 1) return;
3805    		
3806    		_self.options = $.extend({}, options, this.$slider.data());
3807			_self.$inner.addClass('av-rotation-active');
3808			//if(_self.options.fixwidth == 1) this.$inner.width(this.$current.width());
3809			_self._autoplay();
3810    	},
3811    	
3812    	_autoplay: function()
3813    	{
3814    		var _self = this;
3815    		
3816			_self.autoplay = setInterval(function()
3817			{
3818				_self.open = _self.open === false ? 0 : _self.open + 1;
3819				if(_self.open >= _self.count) _self.open = 0;
3820				_self._move({}, _self.open);
3821				
3822			}, _self.options.interval * 1000)
3823    	},
3824    	    	
3825    	_move: function(event)
3826    	{
3827	    	var _self 		= this, 
3828	    		modifier 	= 30 * _self.options.animation, 
3829	    		fade_out 	= {opacity:0}, 
3830	    		fade_start  = {display:'inline-block', opacity:0},
3831	    		fade_in		= {opacity:1};
3832	    		
3833    		this.$next = _self.$slides.eq(this.open);
3834    		
3835    		if(this.cssActive)
3836    		{
3837	    		fade_out[_self.property] 	= "translate(0px," + modifier +"px)";
3838	    		fade_start[_self.property] 	= "translate(0px," + (modifier * -1) +"px)";
3839	    		fade_in[_self.property] 	= "translate(0px,0px)";
3840    		}
3841    		else
3842    		{
3843	    		fade_out['top'] 	= modifier;
3844	    		fade_start['top'] 	= (modifier * -1);
3845	    		fade_in['top'] 		= 0;
3846    		}
3847    		
3848    		
3849    		_self.$current.avia_animate(fade_out, function()
3850    		{
3851	    		_self.$current.css({display:'none'});
3852	    		_self.$next.css(fade_start).avia_animate(fade_in, function()
3853	    		{
3854		    		_self.$current = _self.$slides.eq(_self.open);
3855	    		});
3856    		});
3857    	}
3858    };
3859
3860
3861$.fn.avia_textrotator = function( options )
3862{
3863	return this.each(function()
3864	{
3865		var active = $.data( this, 'AviaTextRotator' );
3866
3867		if(!active)
3868		{
3869			//make sure that the function doesnt get aplied a second time
3870			$.data( this, 'AviaTextRotator', 1 );
3871			
3872			//create the preparations for fullscreen slider
3873			new $.AviaTextRotator( options, this );
3874		}
3875	});
3876}
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892// -------------------------------------------------------------------------------------------
3893// HELPER FUNCTIONS
3894// -------------------------------------------------------------------------------------------
3895
3896
3897//waipoint script when something comes into viewport
3898 $.fn.avia_waypoints = function(options_passed)
3899	{
3900		if(! $('html').is('.avia_transform')) return;
3901
3902		var defaults = { offset: 'bottom-in-view' , triggerOnce: true},
3903			options  = $.extend({}, defaults, options_passed),
3904			isMobile = $.avia_utilities.isMobile;
3905
3906		return this.each(function()
3907		{
3908			var element = $(this);
3909			
3910			setTimeout(function()
3911			{
3912				if(isMobile)
3913				{
3914					element.addClass('avia_start_animation').trigger('avia_start_animation');
3915				}
3916				else
3917				{
3918					element.waypoint(function(direction)
3919					{
3920					 	var current 	= $(this.element),
3921					 		parent  	= current.parents('.av-animation-delay-container:eq(0)');
3922					 	
3923					 	if(parent.length)
3924					 	{
3925						 	current.addClass('avia_start_animation_when_active').trigger('avia_start_animation_when_active');
3926					 	}
3927					 	
3928					 	if(!parent.length || (parent.length && parent.is('.__av_init_open')))
3929					 	{
3930						 	current.addClass('avia_start_animation').trigger('avia_start_animation');
3931					 	}
3932					 	
3933					 	
3934					 	
3935					}, options );
3936				}
3937			},100)
3938			
3939		});
3940	};
3941
3942
3943
3944
3945
3946
3947
3948// window resize script
3949var $event = $.event, $special, resizeTimeout;
3950
3951$special = $event.special.debouncedresize = {
3952	setup: function() {
3953		$( this ).on( "resize", $special.handler );
3954	},
3955	teardown: function() {
3956		$( this ).off( "resize", $special.handler );
3957	},
3958	handler: function( event, execAsap ) {
3959		// Save the context
3960		var context = this,
3961			args = arguments,
3962			dispatch = function() {
3963				// set correct event type
3964				event.type = "debouncedresize";
3965				$event.dispatch.apply( context, args );
3966			};
3967
3968		if ( resizeTimeout ) {
3969			clearTimeout( resizeTimeout );
3970		}
3971
3972		execAsap ?
3973			dispatch() :
3974			resizeTimeout = setTimeout( dispatch, $special.threshold );
3975	},
3976	threshold: 150
3977};
3978
3979
3980
3981
3982
3983$.easing['jswing'] = $.easing['swing'];
3984
3985$.extend( $.easing,
3986{
3987	def: 'easeOutQuad',
3988	swing: function (x, t, b, c, d) { return $.easing[$.easing.def](x, t, b, c, d); },
3989	easeInQuad: function (x, t, b, c, d) { return c*(t/=d)*t + b; },
3990	easeOutQuad: function (x, t, b, c, d) { return -c *(t/=d)*(t-2) + b; },
3991	easeInOutQuad: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t + b; return -c/2 * ((--t)*(t-2) - 1) + b; },
vendor: 4,549 bytes, lines 3992-4097
3992	easeInCubic: function (x, t, b, c, d) { return c*(t/=d)*t*t + b; },
3993	easeOutCubic: function (x, t, b, c, d) { return c*((t=t/d-1)*t*t + 1) + b; },
3994	easeInOutCubic: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t + b; return c/2*((t-=2)*t*t + 2) + b;	},
3995	easeInQuart: function (x, t, b, c, d) { return c*(t/=d)*t*t*t + b;	},
3996	easeOutQuart: function (x, t, b, c, d) { return -c * ((t=t/d-1)*t*t*t - 1) + b; },
3997	easeInOutQuart: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t*t + b; return -c/2 * ((t-=2)*t*t*t - 2) + b;	},
3998	easeInQuint: function (x, t, b, c, d) { return c*(t/=d)*t*t*t*t + b;	},
3999	easeOutQuint: function (x, t, b, c, d) { return c*((t=t/d-1)*t*t*t*t + 1) + b;	},
4000	easeInOutQuint: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; return c/2*((t-=2)*t*t*t*t + 2) + b;	},
4001	easeInSine: function (x, t, b, c, d) {	return -c * Math.cos(t/d * (Math.PI/2)) + c + b;	},
4002	easeOutSine: function (x, t, b, c, d) { return c * Math.sin(t/d * (Math.PI/2)) + b;	},
4003	easeInOutSine: function (x, t, b, c, d) { return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;	},
4004	easeInExpo: function (x, t, b, c, d) { return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;	},
4005	easeOutExpo: function (x, t, b, c, d) { return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;	},
4006	easeInOutExpo: function (x, t, b, c, d) {
4007		if (t==0) return b;
4008		if (t==d) return b+c;
4009		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
4010		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
4011	},
4012	easeInCirc: function (x, t, b, c, d) { return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;	},
4013	easeOutCirc: function (x, t, b, c, d) {return c * Math.sqrt(1 - (t=t/d-1)*t) + b;	},
4014	easeInOutCirc: function (x, t, b, c, d) { if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;	return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;	},
4015	easeInElastic: function (x, t, b, c, d) {
4016		var s=1.70158;var p=0;var a=c;
4017		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
4018		if (a < Math.abs(c)) { a=c; var s=p/4; }
4019		else var s = p/(2*Math.PI) * Math.asin (c/a);
4020		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
4021	},
4022	easeOutElastic: function (x, t, b, c, d) {
4023		var s=1.70158;var p=0;var a=c;
4024		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
4025		if (a < Math.abs(c)) { a=c; var s=p/4; }
4026		else var s = p/(2*Math.PI) * Math.asin (c/a);
4027		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
4028	},
4029	easeInOutElastic: function (x, t, b, c, d) {
4030		var s=1.70158;var p=0;var a=c;
4031		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
4032		if (a < Math.abs(c)) { a=c; var s=p/4; }
4033		else var s = p/(2*Math.PI) * Math.asin (c/a);
4034		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
4035		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
4036	},
4037	easeInBack: function (x, t, b, c, d, s) {
4038		if (s == undefined) s = 1.70158;
4039		return c*(t/=d)*t*((s+1)*t - s) + b;
4040	},
4041	easeOutBack: function (x, t, b, c, d, s) {
4042		if (s == undefined) s = 1.70158;
4043		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
4044	},
4045	easeInOutBack: function (x, t, b, c, d, s) {
4046		if (s == undefined) s = 1.70158;
4047		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
4048		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
4049	},
4050	easeInBounce: function (x, t, b, c, d) {
4051		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
4052	},
4053	easeOutBounce: function (x, t, b, c, d) {
4054		if ((t/=d) < (1/2.75)) {
4055			return c*(7.5625*t*t) + b;
4056		} else if (t < (2/2.75)) {
4057			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
4058		} else if (t < (2.5/2.75)) {
4059			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
4060		} else {
4061			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
4062		}
4063	},
4064	easeInOutBounce: function (x, t, b, c, d) {
4065		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
4066		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
4067	}
4068});
4069
4070})( jQuery );
4071
4072
4073
4074/*utility functions*/
4075
4076
4077(function($)
4078{
4079	"use strict";
4080
4081	$.avia_utilities = $.avia_utilities || {};
4082
4083	/************************************************************************
4084	gloabl loading function
4085	*************************************************************************/
4086	$.avia_utilities.loading = function(attach_to, delay){
4087
4088		var loader = {
4089
4090			active: false,
4091
4092			show: function()
4093			{
4094				if(loader.active === false)
4095				{
4096					loader.active = true;
4097					loader.loading_item.css({display:'block', opacity:0}
4097);
4098				}
4099
4100				loader.loading_item.stop().animate({opacity:1});
4101			},
4102
4103			hide: function()
4104			{	
4105				if(typeof delay === 'undefined'){ delay = 600; }
4106
4107				loader.loading_item.stop().delay( delay ).animate({opacity:0}, function()
4108				{
4109					loader.loading_item.css({display:'none'});
4110					loader.active = false;
4111				});
4112			},
4113
4114			attach: function()
4115			{
4116				if(typeof attach_to === 'undefined'){ attach_to = 'body';}
4117
4118				loader.loading_item = $('<div class="avia_loading_icon"><div class="av-siteloader"></div></div>').css({display:"none"}).appendTo(attach_to);
4119			}
4120		}
4121
4122		loader.attach();
4123		return loader;
4124	};
4125	
4126	/************************************************************************
4127	gloabl play/pause visualizer function
4128	*************************************************************************/
4129	$.avia_utilities.playpause = function(attach_to, delay){
4130
4131		var pp = {
4132
4133			active: false,
4134			to1: "", 
4135			to2: "", 
4136			set: function(status)
4137			{	
4138				pp.loading_item.removeClass('av-play av-pause');
4139				pp.to1 = setTimeout(function(){ pp.loading_item.addClass('av-' + status); },10);
4140				pp.to2 = setTimeout(function(){ pp.loading_item.removeClass('av-' + status); },1500);
4141			},
4142
4143			attach: function()
4144			{
4145				if(typeof attach_to === 'undefined'){ attach_to = 'body';}
4146
4147				pp.loading_item = $('<div class="avia_playpause_icon"></div>').css({display:"none"}).appendTo(attach_to);
4148			}
4149		}
4150
4151		pp.attach();
4152		return pp;
4153	};
4154	
4155	
4156
4157	/************************************************************************
4158	preload images, as soon as all are loaded trigger a special load ready event
4159	*************************************************************************/
4160	$.avia_utilities.preload = function(options_passed)
4161	{
4162		new $.AviaPreloader(options_passed);
4163	}
4164	
4165	$.AviaPreloader  =  function(options)
4166	{
4167	    this.win 		= $(window);
4168	    this.defaults	=
4169		{
4170			container:			'body',
4171			maxLoops:			10,
4172			trigger_single:		true,
4173			single_callback:	function(){},
4174			global_callback:	function(){}
4175
4176		};
4177		this.options 	= $.extend({}, this.defaults, options);
4178		this.preload_images = 0;
4179		
4180		this.load_images();
4181	}
4182	
4183	$.AviaPreloader.prototype  = 
4184	{
4185		load_images: function()
4186		{	
4187			var _self = this;
4188			
4189			if(typeof _self.options.container === 'string'){ _self.options.container = $(_self.options.container); }
4190
4191			_self.options.container.each(function()
4192			{
4193				var container		= $(this);
4194	
4195				container.images	= container.find('img');
4196				container.allImages	= container.images;
4197	
4198				_self.preload_images += container.images.length;
4199				setTimeout(function(){ _self.checkImage(container); }, 10);
4200			});	
4201		},
4202		
4203		checkImage: function(container)
4204		{	
4205			var _self = this;
4206			
4207			container.images.each(function()
4208			{
4209				if(this.complete === true)
4210				{
4211					container.images = container.images.not(this);
4212					_self.preload_images -= 1;
4213				}
4214			});
4215
4216			if(container.images.length && _self.options.maxLoops >= 0)
4217			{
4218				_self.options.maxLoops-=1;
4219				setTimeout(function(){ _self.checkImage(container); }, 500);
4220			}
4221			else
4222			{
4223				_self.preload_images = _self.preload_images - container.images.length;
4224				_self.trigger_loaded(container);
4225			}
4226		},
4227
4228		trigger_loaded: function(container)
4229		{
4230			var _self = this;
4231			
4232			if(_self.options.trigger_single !== false)
4233			{
4234				_self.win.trigger('avia_images_loaded_single', [container]);
4235				_self.options.single_callback.call(container);
4236			}
4237
4238			if(_self.preload_images === 0)
4239			{
4240				_self.win.trigger('avia_images_loaded');
4241				_self.options.global_callback.call();
4242			}
4243
4244		}
4245	}
4246
4247
4248	/************************************************************************
4249	CSS Easing transformation table
4250	*************************************************************************/
4251	/*
4252	Easing transform table from jquery.animate-enhanced plugin
4253	http://github.com/benbarnett/jQuery-Animate-Enhanced
4254	*/
4255	$.avia_utilities.css_easings = {
4256			linear:			'linear',
4257			swing:			'ease-in-out',
4258			bounce:			'cubic-bezier(0.0, 0.35, .5, 1.3)',
4259			easeInQuad:     'cubic-bezier(0.550, 0.085, 0.680, 0.530)' ,
4260			easeInCubic:    'cubic-bezier(0.550, 0.055, 0.675, 0.190)' ,
4261			easeInQuart:    'cubic-bezier(0.895, 0.030, 0.685, 0.220)' ,
4262			easeInQuint:    'cubic-bezier(0.755, 0.050, 0.855, 0.060)' ,
4263			easeInSine:     'cubic-bezier(0.470, 0.000, 0.745, 0.715)' ,
4264			easeInExpo:     'cubic-bezier(0.950, 0.050, 0.795, 0.035)' ,
4265			easeInCirc:     'cubic-bezier(0.600, 0.040, 0.980, 0.335)' ,
4266			easeInBack:     'cubic-bezier(0.600, -0.280, 0.735, 0.04)' ,
4267			easeOutQuad:    'cubic-bezier(0.250, 0.460, 0.450, 0.940)' ,
4268			easeOutCubic:   'cubic-bezier(0.215, 0.610, 0.355, 1.000)' ,
4269			easeOutQuart:   'cubic-bezier(0.165, 0.840, 0.440, 1.000)' ,
4270			easeOutQuint:   'cubic-bezier(0.230, 1.000, 0.320, 1.000)' ,
4271			easeOutSine:    'cubic-bezier(0.390, 0.575, 0.565, 1.000)' ,
4272			easeOutExpo:    'cubic-bezier(0.190, 1.000, 0.220, 1.000)' ,
4273			easeOutCirc:    'cubic-bezier(0.075, 0.820, 0.165, 1.000)' ,
4274			easeOutBack:    'cubic-bezier(0.175, 0.885, 0.320, 1.275)' ,
4275			easeInOutQuad:  'cubic-bezier(0.455, 0.030, 0.515, 0.955)' ,
4276			easeInOutCubic: 'cubic-bezier(0.645, 0.045, 0.355, 1.000)' ,
4277			easeInOutQuart: 'cubic-bezier(0.770, 0.000, 0.175, 1.000)' ,
4278			easeInOutQuint: 'cubic-bezier(0.860, 0.000, 0.070, 1.000)' ,
4279			easeInOutSine:  'cubic-bezier(0.445, 0.050, 0.550, 0.950)' ,
4280			easeInOutExpo:  'cubic-bezier(1.000, 0.000, 0.000, 1.000)' ,
4281			easeInOutCirc:  'cubic-bezier(0.785, 0.135, 0.150, 0.860)' ,
4282			easeInOutBack:  'cubic-bezier(0.680, -0.550, 0.265, 1.55)' ,
4283			easeInOutBounce:'cubic-bezier(0.580, -0.365, 0.490, 1.365)',
4284			easeOutBounce:	'cubic-bezier(0.760, 0.085, 0.490, 1.365)' 
4285		};
4286
4287	/************************************************************************
4288	check if a css feature is supported and save it to the supported array
4289	*************************************************************************/
4290	$.avia_utilities.supported	= {};
4291	$.avia_utilities.supports	= (function()
4292	{
4293		var div		= document.createElement('div'),
4294			vendors	= ['Khtml', 'Ms','Moz','Webkit'];  // vendors	= ['Khtml', 'Ms','Moz','Webkit','O']; 
4295
4296		return function(prop, vendor_overwrite)
4297		{
4298			if ( div.style[prop] !== undefined  ) { return ""; }
4299			if (vendor_overwrite !== undefined) { vendors = vendor_overwrite; }
4300
4301			prop = prop.replace(/^[a-z]/, function(val)
4302			{
4303				return val.toUpperCase();
4304			});
4305
4306			var len	= vendors.length;
4307			while(len--)
4308			{
4309				if ( div.style[vendors[len] + prop] !== undefined )
4310				{
4311					return "-" + vendors[len].toLowerCase() + "-";
4312				}
4313			}
4314
4315			return false;
4316		};
4317
4318	}());
4319
4320	/************************************************************************
4321	animation function
4322	*************************************************************************/
4323	$.fn.avia_animate = function(prop, speed, easing, callback)
4324	{
4325		if(typeof speed === 'function') {callback = speed; speed = false; }
4326		if(typeof easing === 'function'){callback = easing; easing = false;}
4327		if(typeof speed === 'string'){easing = speed; speed = false;}
4328
4329		if(callback === undefined || callback === false){ callback = function(){}; }
4330		if(easing === undefined || easing === false)	{ easing = 'easeInQuad'; }
4331		if(speed === undefined || speed === false)		{ speed = 400; }
4332
4333		if($.avia_utilities.supported.transition === undefined)
4334		{
4335			$.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
4336		}
4337		
4338		
4339
4340		if($.avia_utilities.supported.transition !== false )
4341		{
4342			var prefix		= $.avia_utilities.supported.transition + 'transition',
4343				cssRule		= {},
4344				cssProp		= {},
4345				thisStyle	= document.body.style,
4346				end			= (thisStyle.WebkitTransition !== undefined) ? 'webkitTransitionEnd' : (thisStyle.OTransition !== undefined) ? 'oTransitionEnd' : 'transitionend';
4347
4348			//translate easing into css easing
4349			easing = $.avia_utilities.css_easings[easing];
4350
4351			//create css transformation rule
4352			cssRule[prefix]	=  'all '+(speed/1000)+'s '+easing;
4353			//add namespace to the transition end trigger
4354			end = end + ".avia_animate";
4355			
4356			//since jquery 1.10 the items passed need to be {} and not [] so make sure they are converted properly
4357			for (var rule in prop)
4358			{
4359				if (prop.hasOwnProperty(rule)) { cssProp[rule] = prop[rule]; }
4360			}
4361			prop = cssProp;
4362			
4363			
4364			
4365			this.each(function()
4366			{
4367				var element	= $(this), css_difference = false, rule, current_css;
4368
4369				for (rule in prop)
4370				{
4371					if (prop.hasOwnProperty(rule))
4372					{
4373						current_css = element.css(rule);
4374
4375						if(prop[rule] != current_css && prop[rule] != current_css.replace(/px|%/g,""))
4376						{
4377							css_difference = true;
4378							break;
4379						}
4380					}
4381				}
4382
4383				if(css_difference)
4384				{
4385					//if no transform property is set set a 3d translate to enable hardware acceleration
4386					if(!($.avia_utilities.supported.transition+"transform" in prop))
4387					{
4388						prop[$.avia_utilities.supported.transition+"transform"] = "translateZ(0)";
4389					}
4390					
4391					var endTriggered = false;
4392					
4393					element.on(end,  function(event)
4394					{
4395						if(event.target != event.currentTarget) return false;
4396						
4397						if(endTriggered == true) return false;
4398						endTriggered = true;
4399
4400						cssRule[prefix] = "none";
4401
4402						element.off(end);
4403						element.css(cssRule);
4404						setTimeout(function(){ callback.call(element); });
4405					});
4406					
4407					
4408					//desktop safari fallback if we are in another tab to trigger the end event
4409					setTimeout(function(){ 
4410						if(!endTriggered && !avia_is_mobile && $('html').is('.avia-safari') ) { 
4411							element.trigger(end); 
4412							$.avia_utilities.log('Safari Fallback '+end+' trigger'); 
4413						}
4414					}, speed + 100);
4415					
4416					setTimeout(function(){ element.css(cssRule);},10);
4417					setTimeout(function(){ element.css(prop);	},20);
4418				}
4419				else
4420				{
4421					setTimeout(function(){ callback.call(element); });
4422				}
4423
4424			});
4425		}
4426		else // if css animation is not available use default JS animation
4427		{
4428			this.animate(prop, speed, easing, callback);
4429		}
4430
4431		return this;
4432	};
4433
4434})( jQuery );
4435
4436
4437/* ======================================================================================================================================================
4438Avia Slideshow
4439====================================================================================================================================================== */
4440
4441(function($)
4442{
4443    "use strict";
4444
4445	$.AviaSlider  =  function(options, slider)
4446	{
4447		var self = this;
4448		
4449		this.$win	 = $( window );
4450		
4451	    this.$slider = $( slider );
4452	    
4453		this.isMobile = $.avia_utilities.isMobile;
4454	    
4455	    this._prepareSlides(options);
4456	    
4457		//default preload images then init slideshow
4458	    $.avia_utilities.preload({container: this.$slider , single_callback:  function(){ self._init( options ); }});
4459	}
4460
4461	$.AviaSlider.defaults  = {
4462
4463		//interval between autorotation switches
4464		interval:5,
4465
4466		//autorotation active or not
4467		autoplay:false,
4468		
4469		//set if the loop will stop at the last/first slide or if the slides will loop infinite
4470		//set to false for infinite loop, "last" to stop at the last slide or "first" to stop at the first slide
4471		stopinfiniteloop: false,
4472
4473		//fade or slide animation
4474		animation:'slide',
4475
4476		//transition speed when switching slide
4477		transitionSpeed:900,
4478
4479		//easing method for the transition
4480		easing:'easeInOutQuart',
4481
4482		//slide wrapper
4483		wrapElement: '>ul',
4484
4485		//slide element
4486		slideElement: '>li',
4487
4488		//pause if mouse cursor is above item
4489		hoverpause: false,
4490		
4491		//attach images as background
4492		bg_slider: false,
4493		
4494		//delay of miliseconds to wait before showing the next slide
4495		show_slide_delay: 0,
4496		
4497		//if slider animation is set to "fade" the fullfade property sets the crossfade behaviour
4498		fullfade: false
4499
4500	};
4501
4502  	$.AviaSlider.prototype =
4503    {
4504    	_init: function( options )
4505    	{
4506			// set slider options
4507			this.options = this._setOptions(options);
4508
4509			//slidewrap
4510			this.$sliderUl  = this.$slider.find(this.options.wrapElement);
4511
4512			// slide elements
4513			this.$slides = this.$sliderUl.find(this.options.slideElement);
4514
4515			// goto dots
4516			this.gotoButtons = this.$slider.find('.avia-slideshow-dots a');
4517			
4518			//perma caption
4519			this.permaCaption =  this.$slider.find('>.av-slideshow-caption');
4520
4521			// slide count
4522			this.itemsCount = this.$slides.length;
4523
4524			// current image index
4525			this.current = 0;
4526
4527			//loop count
4528			this.loopCount = 0;
4529
4530			// control if the slicebox is animating
4531			this.isAnimating = false;
4532
4533			// css browser prefix like -webkit-, -moz-
4534			this.browserPrefix = $.avia_utilities.supports('transition');
4535			
4536			// css3 animation?
4537			this.cssActive = this.browserPrefix !== false ? true : false;
4538			
4539			// css3D animation?
4540			this.css3DActive = document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
4541			
4542			//store the aviaVideoApi object for the current slide if available
4543			this.video	= false;
4544			
4545			//if we have a bg slider no images were preloaded yet. in that case start preloading and attaching images
4546			if(this.options.bg_slider == true)
4547			{
4548				//create array that holds all image urls to preload
4549				this.imageUrls = [];
4550				
4551				//create a preloader icon to indicate loading
4552				this.loader = $.avia_utilities.loading(this.$slider);
4553				
4554				//preload the images ony by one
4555				this._bgPreloadImages();
4556				
4557			}
4558			else //if it was a default slider all images are already loaded and we can start showing the slider
4559			{			
4560				//kickoff the slider: bind functions, show first slide, if active start the autorotation timer
4561				this._kickOff();
4562			}
4563    	},
4564
4565    	//set the slider options by first merging the efault options and the passed options, then checking the slider element if any data attributes overwrite the option set
4566    	_setOptions: function(options)
4567		{
4568			var newOptions 	= $.extend( true, {}, $.AviaSlider.defaults, options ),
4569				htmlData 	= this.$slider.data(),
4570				i 			= "";
4571
4572			//overwritte passed option set with any data properties on the html element
4573			for (i in htmlData)
4574			{
4575				if (htmlData.hasOwnProperty(i))
4576				{
4577					if(typeof htmlData[i] === "string" || typeof htmlData[i] === "number" || typeof htmlData[i] === "boolean")
4578					{
4579						newOptions[i] = htmlData[i];
4580					}
4581				}
4582			}
4583
4584			return newOptions;
4585		},
4586		
4587		_prepareSlides: function(options)
4588		{	
4589			//if its a mobile device find all video slides that need to be altered
4590			if(this.isMobile)
4591			{
4592				var alter = this.$slider.find('.av-mobile-fallback-image');
4593				alter.each(function()
4594				{	
4595					var current  = $(this).removeClass('av-video-slide').data({'avia_video_events': true, 'video-ratio':0}),
4596						fallback = current.data('mobile-img');
4597						
4598					current.find('.av-click-overlay, .mejs-mediaelement, .mejs-container').remove();
4599					
4600					if(!fallback)
4601					{
4602						var appendTo = current.find('.avia-slide-wrap');
4603						$('<p class="av-fallback-message"><span>Please set a mobile device fallback image for this video in your wordpress backend</span></p>').appendTo(appendTo);
4604					}
4605					
4606					if(options && options.bg_slider)
4607					{
4608						current.data('img-url', fallback);
4609					}
4610					else
4611					{
4612						var image = $('<img src="'+fallback+'" alt="" title="" />');
4613						current.find('.avia-slide-wrap').append(image);
4614					}
4615					
4616				});
4617			}
4618			
4619		},
4620		
4621		//start preloading the background images
4622		_bgPreloadImages : function(callback)
4623    	{
4624    		this._getImageURLS();
4625    		
4626    		this._preloadSingle(0, function()
4627    		{
4628    			this._kickOff();
4629				this._preloadNext(1);
4630    		});
4631    	},
4632		
4633    	//if we are using a background image slider, fetch the images from a data attribute and preload them one by one
4634    	_getImageURLS: function()
4635    	{
4636    		var _self = this;
4637    		
4638    		//collect url strings of the images to preload
4639			this.$slides.each(function(i)
4640			{
4641				_self.imageUrls[i] = [];
4642				_self.imageUrls[i]['url'] = $(this).data("img-url");
4643				
4644				//if no image is passed we can set the slide to loaded
4645				if(typeof _self.imageUrls[i]['url'] == 'string')
4646				{
4647					_self.imageUrls[i]['status'] = false;
4648				}
4649				else
4650				{
4651					_self.imageUrls[i]['status'] = true;
4652				}
4653			});
4654    	},
4655    	
4656    	
4657    	_preloadSingle: function(key, callback)
4658		{
4659			var _self 		= this,
4660				objImage	= new Image();
4661			
4662			if(typeof _self.imageUrls[key]['url'] == 'string')
4663			{
4664				$(objImage).bind('load error', function()
4665				{ 
4666					_self.imageUrls[key]['status'] = true; 
4667					_self.$slides.eq(key).css('background-image','url(' + _self.imageUrls[key]['url'] + ')');
4668					if(typeof callback == 'function') callback.apply( _self, [objImage, key] );
4669				});
4670				
4671				if(_self.imageUrls[key]['url'] != "")
4672				{
4673					objImage.src = _self.imageUrls[key]['url'];
4674				}
4675				else
4676				{
4677					$(objImage).trigger('error');
4678				}
4679			}
4680			else
4681			{
4682				if(typeof callback == 'function') callback.apply( _self, [objImage, key] );
4683			}
4684		},
4685		
4686		_preloadNext: function(key)
4687		{
4688			if(typeof this.imageUrls[key] != "undefined")
4689    		{
4690				this._preloadSingle(key, function()
4691	    		{
4692					this._preloadNext(key + 1);
4693	    		});
4694    		}
4695		},
4696    	
4697
4698    	//bind click events of slide controlls to the public functions
4699    	_bindEvents: function()
4700    	{
4701    		var self = this,
4702    			win  = $( window );
4703
4704    		this.$slider.on('click','.next-slide', $.proxy( this.next, this) );
4705    		this.$slider.on('click','.prev-slide', $.proxy( this.previous, this) );
4706    		this.$slider.on('click','.goto-slide', $.proxy( this.go2, this) );
4707
4708    		if(this.options.hoverpause)
4709    		{
4710    			this.$slider.on('mouseenter', $.proxy( this.pause, this) );
4711    			this.$slider.on('mouseleave', $.proxy( this.resume, this) );
4712    		}
4713
4714			if(this.options.stopinfiniteloop && this.options.autoplay)
4715			{
4716				if(this.options.stopinfiniteloop == 'last')
4717				{
4718					this.$slider.on('avia_slider_last_slide', $.proxy(this._stopSlideshow, this) );
4719				}
4720				else if(this.options.stopinfiniteloop == 'first')
4721				{
4722					this.$slider.on('avia_slider_first_slide', $.proxy(this._stopSlideshow, this) );
4723				}
4724			}
4725
4726    		win.on( 'debouncedresize.aviaSlider',  $.proxy( this._setSize, this) );
4727
4728    		//if its a desktop browser add arrow navigation, otherwise add touch nav
4729    		if(!this.isMobile)
4730    		{
4731    			this.$slider.avia_keyboard_controls();
4732    		}
4733    		else
4734    		{
4735    			this.$slider.avia_swipe_trigger();
4736    		}
4737			
4738			self._attach_video_events();
4739    	},
4740
4741    	//kickoff the slider by binding all functions to slides and buttons, show the first slide and start autoplay
4742    	_kickOff: function()
4743    	{
4744    		var self 			= this,
4745    			first_slide 	= self.$slides.eq(0),
4746    			video			= first_slide.data('video-ratio');
4747    		  		
4748    		// bind events to to the controll buttons
4749			self._bindEvents();
4750    		
4751    		this.$slider.removeClass('av-default-height-applied');
4752    		
4753    		//show the first slide. if its a video set the correct size, otherwise make sure to remove the % padding
4754    		if(video)
4755    		{ 
4756    			self._setSize(true); 
4757    		}
4758    		else
4759    		{
4760	    		if(this.options.keep_pading != true)
4761	    		{
4762    				self.$sliderUl.css('padding',0);
4763					self.$win.trigger('av-height-change');
4764				}
4765    		}
4766    		
4767    		self._setCenter();
4768    		first_slide.css({visibility:'visible', opacity:0}).avia_animate({opacity:1}, function()
4769    		{
4770    			var current = $(this).addClass('active-slide');
4771    			
4772    			if(self.permaCaption.length)
4773	    		{
4774	    			self.permaCaption.addClass('active-slide');
4775	    		}
4776    		});
4777    		
4778    		
4779    		
4780    		// start autoplay if active
4781			if( self.options.autoplay )
4782			{
4783				self._startSlideshow();
4784			}
4785    		
4786    	},
4787
4788    	//calculate which slide should be displayed next and call the executing transition function
4789    	_navigate : function( dir, pos ) {
4790			
4791			if( this.isAnimating || this.itemsCount < 2 || !this.$slider.is(":visible") )
4792			{
4793				return false;
4794			}
4795			
4796			this.isAnimating = true;
4797
4798			// current item's index
4799			this.prev = this.current;
4800
4801			// if position is passed
4802			if( pos !== undefined )
4803			{
4804				this.current = pos;
4805				dir = this.current > this.prev ? 'next' : 'prev';
4806			}
4807			// if not check the boundaries
4808			else if( dir === 'next' )
4809			{
4810				this.current = this.current < this.itemsCount - 1 ? this.current + 1 : 0;
4811				
4812				if( this.current === 0 && this.options.autoplay_stopper == 1 && this.options.autoplay )
4813				{
4814					this.isAnimating = false;
4815					this.current = this.prev;
4816					this._stopSlideshow();
4817					return false;
4818				}
4819			}
4820			else if( dir === 'prev' )
4821			{
4822				this.current = this.current > 0 ? this.current - 1 : this.itemsCount - 1;
4823			}
4824
4825			//set goto button
4826			this.gotoButtons.removeClass('active').eq(this.current).addClass('active');
4827
4828			//set slideshow size
4829			this._setSize();
4830			
4831			//if we are using a background slider make sure that the image is loaded. if not preload it, then show the slide
4832			if(this.options.bg_slider == true)
4833			{
4834				if(this.imageUrls[this.current]['status'] == true )
4835				{
4836					this['_' + this.options.animation].call(this, dir);
4837				}
4838				else
4839				{
4840					this.loader.show();
4841					this._preloadSingle(this.current, function()
4842    				{
4843    					this['_' + this.options.animation].call(this, dir);
4844    					this.loader.hide();
4845    				});
4846				}
4847			}
4848			else //no background loader -> images are already loaded
4849			{
4850				//call the executing function. for example _slide, or _fade. since the function call is absed on a var we can easily extend the slider with new animations
4851				this['_' + this.options.animation].call(this, dir);
4852			}
4853
4854			if(this.current == 0)
4855			{
4856				this.loopCount++;
4857				this.$slider.trigger('avia_slider_first_slide');
4858			}
4859			else if(this.current == this.itemsCount - 1)
4860			{
4861				this.$slider.trigger('avia_slider_last_slide');
4862			}
4863			else
4864			{
4865				this.$slider.trigger('avia_slider_navigate_slide');
4866			}
4867		},
4868
4869		//if the next slide has a different height than the current change the slideshow height
4870		_setSize: function(instant)
4871		{
4872			//if images are attached as bg images the slider has a fixed height
4873			if(this.options.bg_slider == true) return;
4874			
4875			var self    		= this,
4876				slide 			= this.$slides.eq(this.current),
4877				img 			= slide.find('img'),
4878				current			= Math.floor(this.$sliderUl.height()),
4879				ratio			= slide.data('video-ratio'),
4880				setTo   		= ratio ? this.$sliderUl.width() / ratio : Math.floor(slide.height()),
4881				video_height 	= slide.data('video-height'), //forced video height %. needs to be set only once
4882				video_toppos 	= slide.data('video-toppos'); //forced video top position
4883				
4884				this.$sliderUl.height(current).css('padding',0); //make sure to set the slideheight to an actual value
4885				
4886				if(setTo != current)
4887				{
4888					if(instant == true)
4889					{
4890						this.$sliderUl.css({height:setTo});
4891						this.$win.trigger('av-height-change');
4892					}
4893					else
4894					{
4895						this.$sliderUl.avia_animate({height:setTo}, function()
4896						{
4897							self.$win.trigger('av-height-change');
4898						});
4899					}
4900				}
4901				
4902				this._setCenter();
4903				
4904				if(video_height && video_height!= "set")
4905				{
4906					slide.find('iframe, embed, video, object, .av_youtube_frame').css({height: video_height + '%', top: video_toppos + '%'});
4907					slide.data('video-height','set');
4908				}
4909		},
4910		
4911		_setCenter: function()
4912		{
4913			//if the image has a min width and is larger than the slider center it
4914			//positon img based on caption. right caption->left pos, left caption -> right pos
4915			var slide 		= this.$slides.eq(this.current),
4916				img 		= slide.find('img'),
4917				min_width 	= parseInt(img.css('min-width'),10),
4918				slide_width	= slide.width(),
4919				caption		= slide.find('.av-slideshow-caption'),
4920				css_left 	= ((slide_width - min_width) / 2);
4921			
4922			if(caption.length)
4923			{
4924				if(caption.is('.caption_left'))
4925				{
4926					css_left = ((slide_width - min_width) / 1.5);
4927				}
4928				else if(caption.is('.caption_right'))
4929				{
4930					css_left = ((slide_width - min_width) / 2.5);
4931				}
4932			}
4933			
4934			if(slide_width >= min_width)
4935			{
4936				css_left = 0;
4937			}
4938			
4939			img.css({left:css_left});
4940		},
4941		
4942		_slide: function(dir)
4943		{
4944			var dynamic			= false, //todo: pass by option if a slider is dynamic
4945				modifier		= dynamic == true ? 2 : 1,
4946				sliderWidth		= this.$slider.width(),
4947				direction		= dir === 'next' ? -1 : 1,
4948				property  		= this.browserPrefix + 'transform',
4949				reset			= {}, transition = {},  transition2 = {},
4950				trans_val 		= ( sliderWidth * direction * -1),
4951				trans_val2 		= ( sliderWidth * direction) / modifier;
4952			
4953			//do a css3 animation
4954			if(this.cssActive)
4955			{
4956				property  = this.browserPrefix + 'transform';
4957
4958				//do a translate 3d transformation if available, since it uses hardware acceleration
4959				if(this.css3DActive)
4960				{
4961					reset[property]  = "translate3d(" + trans_val + "px, 0, 0)";
4962					transition[property]  = "translate3d(" + trans_val2 + "px, 0, 0)";
4963					transition2[property] = "translate3d(0,0,0)";
4964				}
4965				else //do a 2d transform. still faster than a position "left" change
4966				{
4967					reset[property]  = "translate(" + trans_val + "px,0)";
4968					transition[property]  = "translate(" + trans_val2 + "px,0)";
4969					transition2[property] = "translate(0,0)";					}
4970			}
4971			else
4972			{
4973				reset.left = trans_val;
4974				transition.left = trans_val2;
4975				transition2.left = 0;
4976			}
4977			
4978			if(dynamic)
4979			{
4980				transition['z-index']  = "1";
4981				transition2['z-index']  = "2";
4982			}
4983			
4984			this._slide_animate(reset, transition, transition2);
4985		},
4986		
4987		_slide_up: function(dir)
4988		{
4989			var dynamic			= true, //todo: pass by option if a slider is dynamic
4990				modifier		= dynamic == true ? 2 : 1,
4991				sliderHeight	= this.$slider.height(),
4992				direction		= dir === 'next' ? -1 : 1,
4993				property  		= this.browserPrefix + 'transform',
4994				reset			= {}, transition = {},  transition2 = {},
4995				trans_val 		= ( sliderHeight * direction * -1),
4996				trans_val2 		= ( sliderHeight * direction) / modifier;
4997			
4998			//do a css3 animation
4999			if(this.cssActive)
5000			{
5001				property  = this.browserPrefix + 'transform';
5002
5003				//do a translate 3d transformation if available, since it uses hardware acceleration
5004				if(this.css3DActive)
5005				{
5006					reset[property]  = "translate3d( 0," + trans_val + "px, 0)";
5007					transition[property]  = "translate3d( 0," + trans_val2 + "px, 0)";
5008					transition2[property] = "translate3d(0,0,0)";
5009				}
5010				else //do a 2d transform. still faster than a position "left" change
5011				{
5012					reset[property]  = "translate( 0," + trans_val + "px)";
5013					transition[property]  = "translate( 0," + trans_val2 + "px)";
5014					transition2[property] = "translate(0,0)";					}
5015			}
5016			else
5017			{
5018				reset.top = trans_val;
5019				transition.top = trans_val2;
5020				transition2.top = 0;
5021			}
5022			
5023			if(dynamic)
5024			{
5025				transition['z-index']  = "1";
5026				transition2['z-index']  = "2";
5027			}
5028			this._slide_animate(reset, transition, transition2);
5029		},
5030		
5031		
5032		//slide animation: do a slide transition by css3 transform if possible. if not simply do a position left transition
5033		_slide_animate: function( reset , transition , transition2 )
5034		{
5035			
5036			var self			= this,
5037				displaySlide 	= this.$slides.eq(this.current),
5038				hideSlide		= this.$slides.eq(this.prev);
5039				
5040				hideSlide.trigger('pause');	
5041				if( !displaySlide.data('disableAutoplay') ) displaySlide.trigger('play');
5042
5043				displaySlide.css({visibility:'visible', zIndex:4, opacity:1, left
5043:0, top:0});
5044				displaySlide.css(reset);
5045				
5046				hideSlide.avia_animate(transition, this.options.transitionSpeed, this.options.easing);
5047				
5048				var after_slide = function()
5049				{
5050					self.isAnimating = false;
5051					displaySlide.addClass('active-slide');
5052					hideSlide.css({visibility:'hidden'}).removeClass('active-slide');
5053					self.$slider.trigger('avia-transition-done');
5054				}
5055				
5056				if(self.options.show_slide_delay > 0)
5057				{
5058					setTimeout(function() { displaySlide.avia_animate(transition2, self.options.transitionSpeed, self.options.easing, after_slide); },self.options.show_slide_delay);
5059				}
5060				else
5061				{
5062					displaySlide.avia_animate(transition2, self.options.transitionSpeed, self.options.easing, after_slide);
5063				}
5064
5065		},
5066		
5067		//simple fade transition of the slideshow
5068		_fade: function()
5069		{
5070			var self			= this,
5071				displaySlide 	= this.$slides.eq(this.current),
5072				hideSlide		= this.$slides.eq(this.prev),
5073				properties		= {visibility:'visible', zIndex:3, opacity:0},
5074				fadeCallback 	= function()
5075				{
5076					self.isAnimating = false;
5077					displaySlide.addClass('active-slide');
5078					hideSlide.css({visibility:'hidden', zIndex:2}).removeClass('active-slide');
5079					self.$slider.trigger('avia-transition-done');
5080					
5081				};
5082			
5083			hideSlide.trigger('pause');	
5084			if( !displaySlide.data('disableAutoplay') ) displaySlide.trigger('play');
5085			
5086			if(self.options.fullfade == true)
5087			{
5088				hideSlide.avia_animate({opacity:0}
5088, 200, 'linear', function()
5089				{	
5090					displaySlide.css(properties).avia_animate({opacity:1}, self.options.transitionSpeed, 'linear',fadeCallback);				
5091				});
5092			}
5093			else
5094			{
5095				displaySlide.css(properties).avia_animate({opacity:1}, self.options.transitionSpeed/2, 'linear', function()
5096				{
5097					hideSlide.avia_animate({opacity:0}, 200, 'linear', fadeCallback);
5098				});
5099			}
5100			
5101		},
5102		
5103		
5104		/************************************************************************
5105		Video functions
5106		*************************************************************************/
5107		
5108		//bind events to the video that tell the slider to autorotate once a video has been played
5109		_attach_video_events: function()
5110		{
5111			var self = this, $html = $('html');
5112						
5113			self.$slides.each(function(i)
5114			{
5115				var currentSlide 	= $(this),
5116					caption			= currentSlide.find('.caption_fullwidth, .av-click-overlay'),
5117					mejs			= currentSlide.find('.mejs-mediaelement');
5118								
5119				if(currentSlide.data('avia_video_events') != true)
5120				{
5121					currentSlide.data('avia_video_events', true);
5122					
5123					currentSlide.on('av-video-events-bound', { slide: currentSlide, wrap: mejs , iteration: i , self: self }, onReady);
5124					
5125					currentSlide.on('av-video-ended', { slide: currentSlide , self: self}, onFinish);
5126					
5127					currentSlide.on('av-video-play-executed', function(){ setTimeout(function(){  self.pause() }, 100); });
5128						
5129					caption.on('click', { slide: currentSlide }, toggle);
5130					
5131					// also if the player was loaded before the _bindEvents function was bound trigger it manually
5132					if(currentSlide.is('.av-video-events-bound')) currentSlide.trigger('av-video-events-bound');
5133				}
5134			});
5135			
5136			
5137			//helper functions
5138			function onReady( event ) 
5139			{ 	
5140				//autostart for first slide
5141				if(event.data.iteration === 0) 
5142				{	
5143					event.data.wrap.css('opacity',0);
5144					if(!event.data.self.isMobile && !event.data.slide.data('disableAutoplay')) { event.data.slide.trigger('play'); } 
5145					setTimeout(function(){ event.data.wrap.avia_animate({opacity:1}, 400); }, 50);
5146				}
5147				else if ($html.is('.avia-msie') && !event.data.slide.is('.av-video-service-html5'))
5148				{	
5149					/*
5150					* Internet Explorer fires the ready event for external videos once they become visible 
5151					* as oposed to other browsers which always fire immediately. 
5152					*/
5153					if( !event.data.slide.data('disableAutoplay') ) event.data.slide.trigger('play');
5154				}
5155				
5156			}
5157			
5158			
5159			
5160			
5161			function onFinish( event )
5162			{ 	
5163				//if the video is not looped resume the slideshow
5164				if(!event.data.slide.is('.av-single-slide') && !event.data.slide.is('.av-loop-video'))
5165				{
5166					event.data.slide.trigger('reset');
5167					self._navigate( 'next' );  
5168					self.resume(); 
5169				}
5170				
5171				//safari 8 workaround for self hosted videos which wont loop by default
5172				if(event.data.slide.is('.av-loop-video') && event.data.slide.is('.av-video-service-html5'))
5173				{
5174					if($html.is('.avia-safari-8'))
5175					{
5176						setTimeout(function(){ event.data.slide.trigger('play'); },1);
5177					}
5178				}
5179			}
5180			
5181			function toggle( event )
5182			{
5183				if(event.target.tagName != "A") 
5184				{
5185					event.data.slide.trigger('toggle');
5186				}
5187			}
5188			
5189		},
5190		
5191		
5192		
5193		/************************************************************************
5194		Slideshow control functions
5195		*************************************************************************/
5196		
5197		_timer: function(callback, delay, first)
5198		{	
5199		    var self = this, start, remaining = delay;
5200			
5201			self.timerId = 0;
5202			
5203		    this.pause = function() {
5204		        window.clearTimeout(self.timerId);
5205		        remaining -= new Date() - start;
5206		    };
5207
5208		    this.resume = function() {
5209		        start = new Date();
5210		        self.timerId = window.setTimeout(callback, remaining);
5211		    };
5212
5213		    this.destroy = function()
5214		    {
5215		    	window.clearTimeout(self.timerId);
5216		    };
5217
5218		    this.resume(true);
5219		},
5220
5221		//start autorotation
5222		_startSlideshow: function()
5223		{
5224			var self = this;
5225			
5226			this.isPlaying = true;
5227			
5228			this.slideshow = new this._timer( function()
5229			{
5230				/*
5231				var videoApi = self.$slides.eq(self.current).data('aviaVideoApi')
5232				if(!videoApi){}
5233				*/
5234				
5235				self._navigate( 'next' );
5236		
5237				if ( self.options.autoplay )
5238				{
5239					self._startSlideshow();
5240				}
5241
5242			}, (this.options.interval * 1000));
5243		},
5244
5245		//stop autorotation
5246		_stopSlideshow: function()
5247		{
5248			if ( this.options.autoplay ) {
5249
5250				this.slideshow.destroy();
5251				this.isPlaying = false;
5252				this.options.autoplay = false;
5253			}
5254		},
5255
5256		// public method: shows next image
5257		next : function(e)
5258		{	
5259			e.preventDefault();
5260			this._stopSlideshow();
5261			this._navigate( 'next' );
5262		},
5263
5264		// public method: shows previous image
5265		previous : function(e)
5266		{
5267			e.preventDefault();
5268			this._stopSlideshow();
5269			this._navigate( 'prev' );
5270		},
5271
5272		// public method: goes to a specific image
5273		go2 : function( pos )
5274		{
5275			//if we didnt pass a number directly lets asume someone clicked on a link that triggered the goto transition
5276			if(isNaN(pos))
5277			{
5278				//in that case prevent the default link behavior and set the slide number to the links hash
5279				pos.preventDefault();
5280				pos = pos.currentTarget.hash.replace('#','');
5281			}
5282
5283			pos -= 1;
5284
5285			if( pos === this.current || pos >= this.itemsCount || pos < 0 )
5286			{
5287				return false;
5288			}
5289
5290			this._stopSlideshow();
5291			this._navigate( false, pos );
5292
5293		},
5294
5295		// public method: starts the slideshow
5296		// any call to next(), previous() or goto() will stop the slideshow autoplay
5297		play : function()
5298		{
5299			if( !this.isPlaying )
5300			{
5301				this.isPlaying = true;
5302
5303				this._navigate( 'next' );
5304				this.options.autoplay = true;
5305				this._startSlideshow();
5306			}
5307
5308		},
5309
5310		// public methos: pauses the slideshow
5311		pause : function()
5312		{
5313			if( this.isPlaying )
5314			{
5315				this.slideshow.pause();
5316			}
5317		},
5318
5319		// publiccmethos: resumes the slideshow
5320		resume : function()
5321		{
5322			if( this.isPlaying )
5323			{
5324				this.slideshow.resume();
5325			}
5326		},
5327
5328		// public methos: destroys the instance
5329		destroy : function( callback )
5330		{
5331			this.slideshow.destroy( callback );
5332		}
5333
5334    }
5335
5336    //simple wrapper to call the slideshow. makes sure that the slide data is not applied twice
5337    $.fn.aviaSlider = function( options )
5338    {
5339    	return this.each(function()
5340    	{
5341    		var self = $.data( this, 'aviaSlider' );
5342
5343    		if(!self)
5344    		{
5345    			self = $.data( this, 'aviaSlider', new $.AviaSlider( options, this ) );
5346    		}
5347    	});
5348    }
5349
5350
5351
5352})( jQuery );
5353
5354
5355
5356
5357// -------------------------------------------------------------------------------------------
5358// keyboard controls
5359// -------------------------------------------------------------------------------------------
5360
5361(function($)
5362{
5363	"use strict";
5364
5365	/************************************************************************
5366	keyboard arrow nav
5367	*************************************************************************/
5368	$.fn.avia_keyboard_controls = function(options_passed)
5369	{
5370		var defaults	=
5371		{
5372			37: '.prev-slide',	// prev
5373			39: '.next-slide'	// next
5374		},
5375
5376		methods		= {
5377
5378			mousebind: function(slider)
5379			{
5380				slider.hover(
5381					function(){  slider.mouseover	= true;  },
5382					function(){  slider.mouseover	= false; }
5383				);
5384			},
5385
5386			keybind: function(slider)
5387			{
5388				$(document).keydown(function(e)
5389				{
5390					if(slider.mouseover && typeof slider.options[e.keyCode] !== 'undefined')
5391					{
5392						var item;
5393
5394						if(typeof slider.options[e.keyCode] === 'string')
5395						{
5396							item = slider.find(slider.options[e.keyCode]);
5397						}
5398						else
5399						{
5400							item = slider.options[e.keyCode];
5401						}
5402
5403						if(item.length)
5404						{
5405							item.trigger('click', ['keypress']);
5406							return false;
5407						}
5408					}
5409				});
5410			}
5411		};
5412
5413
5414		return this.each(function()
5415		{
5416			var slider			= $(this);
5417			slider.options		= $.extend({}, defaults, options_passed);
5418			slider.mouseover	= false;
5419
5420			methods.mousebind(slider);
5421			methods.keybind(slider);
5422
5423		});
5424	};
5425
5426
5427	/************************************************************************
5428	swipe nav
5429	*************************************************************************/
5430	$.fn.avia_swipe_trigger = function(passed_options)
5431	{
5432		var win		= $(window),
5433		isMobile	= $.avia_utilities.isMobile,
5434		defaults	=
5435		{
5436			prev: '.prev-slide',
5437			next: '.next-slide',
5438			event: {
5439				prev: 'click',
5440				next: 'click'
5441			}
5442		},
5443
5444		methods = {
5445
5446			activate_touch_control: function(slider)
5447			{
5448				var i, differenceX, differenceY;
5449
5450				slider.touchPos = {};
5451				slider.hasMoved = false;
5452
5453				slider.on('touchstart', function(event)
5454				{
5455					slider.touchPos.X = event.originalEvent.touches[0].clientX;
5456					slider.touchPos.Y = event.originalEvent.touches[0].clientY;
5457				});
5458
5459				slider.on('touchend', function(event)
5460				{
5461					slider.touchPos = {};
5462	                if(slider.hasMoved) { event.preventDefault(); }
5463	                slider.hasMoved = false;
5464				});
5465
5466				slider.on('touchmove', function(event)
5467				{
5468					if(!slider.touchPos.X)
5469					{
5470						slider.touchPos.X = event.originalEvent.touches[0].clientX;
5471						slider.touchPos.Y = event.originalEvent.touches[0].clientY;
5472					}
5473					else
5474					{
5475						differenceX = event.originalEvent.touches[0].clientX - slider.touchPos.X;
5476						differenceY = event.originalEvent.touches[0].clientY - slider.touchPos.Y;
5477
5478						//check if user is scrolling the window or moving the slider
5479						if(Math.abs(differenceX) > Math.abs(differenceY))
5480						{
5481							event.preventDefault();
5482
5483							if(slider.touchPos !== event.originalEvent.touches[0].clientX)
5484							{
5485								if(Math.abs(differenceX) > 50)
5486								{
5487									i = differenceX > 0 ? 'prev' : 'next';
5488
5489									if(typeof slider.options[i] === 'string')
5490									{
5491										slider.find(slider.options[i]).trigger(slider.options.event[i], ['swipe']);
5492									}
5493									else
5494									{
5495										slider.options[i].trigger(slider.options.event[i], ['swipe']);
5496									}
5497
5498									slider.hasMoved = true;
5499									slider.touchPos = {};
5500									return false;
5501								}
5502							}
5503						}
5504	                }
5505				});
5506			}
5507		};
5508
5509		return this.each(function()
5510		{
5511			if(isMobile)
5512			{
5513				var slider	= $(this);
5514
5515				slider.options	= $.extend({}, defaults, passed_options);
5516
5517				methods.activate_touch_control(slider);
5518			}
5519		});
5520	};
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534}(jQuery));
5535
5536
5537
5538

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.