PageSourceSearch

https://www.esmn-cost.eu/wp-content/themes/enfold2017/js/shortcodes.js?ver=3

js esmn-cost.eu collected 2026-10-07 03:39:44 UTC 155,479 bytes, 5,517 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			
2976			set_up = function( init )
2977			{
2978				var sl_height = (slide_container.width() / 100 ) * slide_container.data('av-height');
2979				
2980				slide_container.css({'padding':0}).height(sl_height);
2981				
2982				//fixes img distortion when resizing browser:
2983				imgs.css('display','inline-block');
2984				setTimeout(function(){ imgs.css('display','block'); }, 10);
2985				
2986				//calculate the slidelement width based on the elements inside
2987				all_elements_width = 0;
2988				
2989				slide_content.each(function()
2990				{ 
2991					all_elements_width += $(this).outerWidth( true ); 
2992				});
2993				
2994				slide_element.css( 'min-width' , all_elements_width );
2995				
2996				if(currentIndex !== false )
2997				{
2998					change_active(currentIndex);
2999				}
3000			},
3001			change_active = function(index)
3002			{
3003				//scroll the tabs if there is not enough room to display them all
3004				var current 	= slide_element.find(options.slide_content).eq(index),
3005					viewport	= slide_container.width(),
3006					outerWidth	= current.outerWidth( true ),
3007					left_pos	= viewport < all_elements_width ? (current.position().left * - 1) - (outerWidth / 2) + (viewport / 2): 0;
3008				
3009				//out of bounce right side
3010				if(left_pos + all_elements_width < viewport) left_pos = (all_elements_width - viewport - parseInt(current.css('margin-right'),10) ) * -1;
3011				
3012				//out of bounce left side
3013				if(left_pos > 0) left_pos = 0;
3014				
3015				//set pos
3016				slide_element.css('left',left_pos );
3017				
3018				slide_container.find("." +options.active).removeClass(options.active);
3019				current.addClass(options.active);
3020				currentIndex = index;
3021				
3022			};
3023
3024			
3025		// activate behavior
3026		set_up( 'init' );
3027		win.on('debouncedresize', set_up);
3028		
3029		//swipe on mobile
3030		slide_element.avia_swipe_trigger({prev:options.prev, next:options.next});
3031		
3032		//element click
3033		slide_content.on('click', function(e)
3034		{
3035			var current = $(this);
3036			var index = slide_content.index(current);
3037			
3038			if(currentIndex === index)
3039			{
3040				if(container.data('av-enlarge') > 1 && !$(e.target).is('a') )
3041				{
3042					slide_container.find("." +options.active).removeClass(options.active);
3043					currentIndex = false;	
3044				}
3045				return;
3046			}
3047			
3048			change_active(index);
3049		});
3050		
3051		prev.on('click', function(e)
3052		{
3053			if(currentIndex === false) currentIndex = 1;
3054			var index = currentIndex - 1;
3055			if(index < 0) index = 0;
3056			
3057			change_active(index);
3058		});
3059		
3060		next.on('click', function(e)
3061		{
3062			if(currentIndex === false) currentIndex = -1;
3063			var index = currentIndex + 1;
3064			if(index > slide_content.length - 1) index = slide_content.length - 1;
3065			
3066			change_active(index);
3067		});
3068		
3069		//if its a desktop browser add arrow navigation, otherwise add touch nav
3070		if(!isMobile)
3071		{
3072			container.avia_keyboard_controls({ 37: options.prev, 39: options.next });
3073		}
3074		else
3075		{
3076			container.avia_swipe_trigger({next: options.next, prev: options.prev});
3077		}
3078		
3079		
3080	
3081	});
3082};
3083
3084// -------------------------------------------------------------------------------------------
3085// Big Number animation shortcode javascript
3086// -------------------------------------------------------------------------------------------
3087
3088(function($)
3089{
3090	// options.simple_up = dont prepend leading zeros, options.instant_start = trigger counting instantly, options.start_timer = delay when to start counting
3091	$.fn.avia_sc_animated_number = function(options) 
3092	{
3093		if(!this.length) return;
3094		if(this.is('.avia_sc_animated_number_active')) return;
3095		
3096		this.addClass('avia_sc_animated_number_active');
3097	
3098		var skipStep = false,
3099			simple_upcount 	= (options && options.simple_up) ? true : false,
3100			start_timer 	= (options && options.start_timer) ? options.start_timer : 300,
3101		start_count = function(element, countTo, increment, current, fakeCountTo)
3102		{
3103			
3104			
3105			//calculate the new number
3106			var newCount = current + increment;
3107			
3108			//if the number is bigger than our final number set the number and finish
3109			if(newCount >= fakeCountTo) 
3110			{
3111				element.text(countTo); //exit
3112				
3113			}
3114			else
3115			{
3116				var prepend = "", addZeros = countTo.toString().length - newCount.toString().length
3117				
3118				//if the number has less digits than the final number some zeros where omitted. add them to the front
3119				for(var i = addZeros; i > 0; i--){ prepend += "0"; }
3120				
3121				if(simple_upcount) prepend = 0;
3122				element.text(prepend + newCount);
3123				
3124				window.requestAnimationFrame(function(){ start_count(element, countTo, increment, newCount, fakeCountTo) });
3125			}
3126		};
3127	
3128		return this.each(function()
3129		{
3130			var number_container = $(this), elements = number_container.find('.__av-single-number'), countTimer = number_container.data('timer') || 3000;
3131			
3132			//prepare elements
3133			elements.each(function(i)
3134			{
3135				var element = $(this), text = element.text();
3136				if(window.addEventListener) element.text( text.replace(/./g, "0")); /*https://github.com/AviaThemes/wp-themes/issues/812*/
3137			});
3138			
3139			//trigger number animation
3140			number_container.addClass('number_prepared').on('avia_start_animation', function()
3141			{
3142				if(number_container.is('.avia_animation_done')) return;
3143				number_container.addClass('avia_animation_done');
3144				
3145				elements.each(function(i)
3146				{
3147					var element = $(this), countTo = element.data('number'), fakeCountTo = countTo, current = parseInt(element.text(),10), zeroOnly = /^0+$/.test(countTo), increment = 0;
3148					
3149					//fallback for decimals like 00 or 000
3150					if(zeroOnly && countTo !== 0) fakeCountTo = countTo.replace(/0/g, '9');
3151					
3152					increment = Math.round( fakeCountTo * 32 / countTimer);
3153					if(increment == 0 || increment % 10 == 0) increment += 1;
3154					
3155					setTimeout(function(){ start_count(element, countTo, increment, current, fakeCountTo);}, start_timer);
3156				});
3157			});
3158			
3159			if(options && options.instant_start == true)
3160			{
3161				number_container.trigger('avia_start_animation');
3162			}
3163			
3164			
3165		});
3166	}
3167})(jQuery);
3168
3169
3170
3171
3172// -------------------------------------------------------------------------------------------
3173// contact form ajax
3174// -------------------------------------------------------------------------------------------
3175
3176(function($)
3177{
3178	$.fn.avia_ajax_form = function(variables)
3179	{	
3180		var defaults =
3181		{
3182			sendPath: 'send.php',
3183			responseContainer: '.ajaxresponse'
3184		};
3185
3186		var options = $.extend(defaults, variables);
3187
3188		return this.each(function()
3189		{
3190			var form = $(this),
3191				form_sent = false,
3192				send =
3193				{
3194					formElements: form.find('textarea, select, input[type=text], input[type=checkbox], input[type=hidden]'),
3195					validationError:false,
3196					button : form.find('input:submit'),
3197					dataObj : {}
3198				},
3199
3200				responseContainer = form.next(options.responseContainer+":eq(0)");
3201
3202				send.button.bind('click', checkElements);
3203				
3204				
3205				//change type of email forms on mobile so the e-mail keyboard with @ sign is used
3206				if($.avia_utilities.isMobile)
3207				{
3208					send.formElements.each(function(i)
3209					{
3210						var currentElement = $(this), is_email = currentElement.hasClass('is_email');
3211						if(is_email) currentElement.attr('type','email');
3212					});
3213				}
3214			
3215
3216			function checkElements( e )
3217			{
3218				// reset validation var and send data
3219				send.validationError = false;
3220				send.datastring = 'ajax=true';
3221
3222				send.formElements.each(function(i)
3223				{
3224					var currentElement = $(this),
3225						surroundingElement = currentElement.parent(),
3226						value = currentElement.val(),
3227						name = currentElement.attr('name'),
3228					 	classes = currentElement.attr('class'),
3229					 	nomatch = true;
3230
3231					 	if(currentElement.is(':checkbox'))
3232					 	{
3233					 		if(currentElement.is(':checked')) { value = true } else {value = ''}
3234					 	}
3235					 	
3236					 	send.dataObj[name] = encodeURIComponent(value);
3237
3238					 	if(classes && classes.match(/is_empty/))
3239						{
3240							if(value == '' || value == null)
3241							{
3242								surroundingElement.removeClass("valid error ajax_alert").addClass("error");
3243								send.validationError = true;
3244							}
3245							else
3246							{
3247								surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
3248							}
3249							nomatch = false;
3250						}
3251
3252						if(classes && classes.match(/is_email/))
3253						{
3254							if(!value.match(/^[\w|\.|\-]+@\w[\w|\.|\-]*\.[a-zA-Z]{2,20}$/))
3255							{
3256								surroundingElement.removeClass("valid error ajax_alert").addClass("error");
3257								send.validationError = true;
3258							}
3259							else
3260							{
3261								surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
3262							}
3263							nomatch = false;
3264						}
3265
3266						if(classes && classes.match(/is_phone/))
3267						{
3268							if(!value.match(/^(\d|\s|\-|\/|\(|\)|\[|\]|e|x|t|ension|\.|\+|\_|\,|\:|\;){3,}$/))
3269							{
3270								surroundingElement.removeClass("valid error ajax_alert").addClass("error");
3271								send.validationError = true;
3272							}
3273							else
3274							{
3275								surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
3276							}
3277							nomatch = false;
3278						}
3279
3280						if(classes && classes.match(/is_number/))
3281						{
3282							if(!($.isNumeric(value)) || value == "")
3283							{
3284								surroundingElement.removeClass("valid error ajax_alert").addClass("error");
3285								send.validationError = true;
3286							}
3287							else
3288							{
3289								surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
3290							}
3291							nomatch = false;
3292						}
3293
3294						if(classes && classes.match(/captcha/))
3295						{
3296							var verifier 	= form.find("#" + name + "_verifier").val(),
3297								lastVer		= verifier.charAt(verifier.length-1),
3298								finalVer	= verifier.charAt(lastVer);
3299
3300							if(value != finalVer)
3301							{
3302								surroundingElement.removeClass("valid error ajax_alert").addClass("error");
3303								send.validationError = true;
3304							}
3305							else
3306							{
3307								surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
3308							}
3309							nomatch = false;
3310						}
3311
3312						if(nomatch && value != '')
3313						{
3314							surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
3315						}
3316				});
3317
3318				if(send.validationError == false)
3319				{
3320					if(form.data('av-custom-send'))
3321					{
3322						mailchimp_send();	
3323					}
3324					else
3325					{
3326						send_ajax_form();
3327					}
3328				}
3329				
3330				return false;
3331			}
3332			
3333			
3334			function send_ajax_form()
3335			{
3336				if(form_sent){ return false; }
3337
3338				form_sent = true;
3339				send.button.addClass('av-sending-button');
3340				send.button.val(send.button.data('sending-label'));
3341				
3342				var redirect_to = form.data('avia-redirect') || false,
3343					action		= form.attr('action');
3344				
3345				responseContainer.load(action+' '+options.responseContainer, send.dataObj, function()
3346				{
3347					if(redirect_to && action != redirect_to)
3348					{
3349						form.attr('action', redirect_to);
3350						location.href = redirect_to;
3351						// form.submit();
3352					}
3353					else
3354					{
3355						responseContainer.removeClass('hidden').css({display:"block"});
3356						form.slideUp(400, function(){responseContainer.slideDown(400, function(){ $('body').trigger('av_resize_finished'); }); send.formElements.val('');});
3357					}
3358				});
3359			}
3360			
3361			
3362			function mailchimp_send()
3363			{
3364				if(form_sent){ return false; }
3365
3366				form_sent = true;
3367				
3368				var original_label = send.button.val();
3369
3370				send.button.addClass('av-sending-button');
3371				send.button.val(send.button.data('sending-label'));
3372				send.dataObj.ajax_mailchimp = true;
3373				
3374				var redirect_to 		= form.data('avia-redirect') || false,
3375					action				= form.attr('action'),
3376					error_msg_container = form.find('.av-form-error-container'),
3377					form_id 			= form.data('avia-form-id'); 
3378				
3379				$.ajax({
3380					url: action,
3381					type: "POST",
3382					data:send.dataObj,
3383					beforeSend: function()
3384					{
3385						if(error_msg_container.length)
3386						{
3387							error_msg_container.slideUp(400, function()
3388							{
3389								error_msg_container.remove();
3390								$('body').trigger('av_resize_finished');
3391							});
3392						}
3393					},
3394					success: function(responseText)
3395					{
3396						var response	= jQuery("<div>").append(jQuery.parseHTML(responseText)),
3397							error		= response.find('.av-form-error-container');	
3398						
3399						if(error.length)
3400						{
3401							form_sent = false;
3402							form.prepend(error);
3403							error.css({display:"none"}).slideDown(400, function()
3404							{
3405								$('body').trigger('av_resize_finished');
3406							});
3407
3408							send.button.removeClass('av-sending-button');
3409							send.button.val(original_label);
3410						}
3411						else
3412						{
3413							if(redirect_to && action != redirect_to)
3414							{
3415								form.attr('action', redirect_to);
3416								location.href = redirect_to;
3417								// form.submit();
3418							}
3419							else
3420							{
3421								var success_text = response.find(options.responseContainer + "_" + form_id);
3422								
3423								responseContainer.html(success_text).removeClass('hidden').css({display:"block"});
3424								
3425								form.slideUp(400, function()
3426								{
3427									responseContainer.slideDown(400, function()
3428									{ 
3429										$('body').trigger('av_resize_finished'); 
3430									});
3431									
3432								send.formElements.val('');
3433							});
3434							}
3435						}
3436						
3437					},
3438					error: function()
3439					{
3440						
3441					},
3442					complete: function()
3443					{
3444					    
3445					}
3446				});
3447
3448			}
3449			
3450			
3451		});
3452	};
3453})(jQuery);
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466// -------------------------------------------------------------------------------------------
3467// Aviaccordion Slideshow 
3468// 
3469// accordion slider script
3470// -------------------------------------------------------------------------------------------
3471
3472	$.AviaccordionSlider  =  function(options, slider)
3473	{
3474	    this.$slider  	= $( slider );
3475	    this.$inner	  	= this.$slider.find('.aviaccordion-inner');
3476	    this.$slides	= this.$inner.find('.aviaccordion-slide');
3477	    this.$images	= this.$inner.find('.aviaccordion-image');
3478	    this.$last		= this.$slides.filter(':last');
3479	    this.$titles  	= this.$slider.find('.aviaccordion-preview');
3480	    this.$titlePos  = this.$slider.find('.aviaccordion-preview-title-pos');
3481	    this.$titleWrap = this.$slider.find('.aviaccordion-preview-title-wrap');
3482	    this.$win	  	= $( window );
3483	    
3484	    if($.avia_utilities.supported.transition === undefined)
3485		{
3486			$.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
3487		}
3488		
3489		this.browserPrefix 	= $.avia_utilities.supported.transition;
3490	    this.cssActive 		= this.browserPrefix !== false ? true : false;
3491	    this.transform3d	= document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
3492		this.isMobile 		= $.avia_utilities.isMobile;
3493		this.property		= this.browserPrefix + 'transform',
3494		this.count			= this.$slides.length;
3495		this.open			= false;
3496		this.autoplay		= false;
3497		this.increaseTitle  = this.$slider.is(".aviaccordion-title-on-hover");
3498		// this.cssActive    = false; //testing no css3 browser
3499		
3500	    this._init( options );
3501	}
3502
3503  	$.AviaccordionSlider.prototype =
3504    {
3505    	_init: function( options )
3506    	{
3507    		var _self = this;
3508    		_self.options = $.extend({}, options, this.$slider.data());
3509			 $.avia_utilities.preload({container: this.$slider , single_c
3509allback:  function(){ _self._kickOff(); }});
3510    	},
3511    	
3512    	_kickOff: function()
3513    	{
3514    		var _self = this;
3515    		
3516    		_self._calcMovement();
3517    		_self._bindEvents();
3518    		_self._showImages();
3519    		_self._autoplay();
3520    	},
3521    	
3522    	_autoplay: function()
3523    	{
3524    		var _self = this;
3525    		
3526    		if(_self.options.autoplay)
3527    		{
3528    			_self.autoplay = setInterval(function()
3529    			{
3530    				_self.open = _self.open === false ? 0 : _self.open + 1;
3531    				if(_self.open >= _self.count) _self.open = 0;
3532    				_self._move({}, _self.open);
3533    				
3534    			}, _self.options.interval * 1000)
3535    		}
3536    	},
3537    	
3538    	_showImages: function()
3539    	{
3540    		var _self = this, counter = 0, delay = 300, title_delay = this.count * delay;
3541    		
3542    		if(this.cssActive)
3543    		{
3544    			setTimeout(function(){ _self.$slider.addClass('av-animation-active'); } , 10);
3545    		}
3546    		
3547    		this.$images.each(function(i)
3548    		{
3549    			var current = $(this), timer = delay * (i + 1);
3550    				
3551    			setTimeout(function()
3552    			{ 
3553    				current.avia_animate({opacity:1}, 400, function()
3554    				{
3555    					current.css($.avia_utilities.supported.transition + "transform", "none");
3556    				}); 
3557    			},timer);
3558    		});
3559    		
3560    		if(_self.increaseTitle) title_delay = 0;
3561    		
3562    		this.$titlePos.each(function(i)
3563    		{
3564    			var current = $(this), new_timer = title_delay + 100 * (i + 1);
3565    					
3566    			setTimeout(function()
3567    			{ 
3568    				current.avia_animate({opacity:1}, 200, function()
3569    				{
3570    					current.css($.avia_utilities.supported.transition + "transform", "none");
3571    				}); 
3572    			},new_timer);
3573    		});
3574    	},
3575    	
3576    	_bindEvents: function()
3577    	{
3578    		var trigger = this.isMobile ? "click" : "mouseenter";
3579    	
3580    		this.$slider.on(trigger,'.aviaccordion-slide', $.proxy( this._move, this));
3581    		this.$slider.on('mouseleave','.aviaccordion-inner', $.proxy( this._move, this));
3582    		this.$win.on('debouncedresize', $.proxy( this._calcMovement, this));
3583    		this.$slider.on('av-prev av-next', $.proxy( this._moveTo, this));
3584    		
3585    		if(this.isMobile)
3586    		{
3587    			this.$slider.avia_swipe_trigger({next: this.$slider, prev: this.$slider, event:{prev: 'av-prev', next: 'av-next'}});
3588    		}
3589    		
3590    	},
3591    	
3592    	_titleHeight: function()
3593    	{
3594    		var th = 0;
3595    		
3596    		this.$titleWrap.css({'height':'auto'}).each(function()
3597    		{
3598    			var new_h = $(this).outerHeight();
3599    			if( new_h > th) th = new_h;
3600    		
3601    		}).css({'height':th + 2});
3602    		
3603    	},
3604    	
3605    	_calcMovement: function(event, allow_repeat)
3606    	{ 
3607    		var _self			= this,
3608    			containerWidth	= this.$slider.width(),
3609    			defaultPos		= this.$last.data('av-left'),
3610    			imgWidth		= this.$images.filter(':last').width() || containerWidth,
3611    			imgWidthPercent = Math.floor((100 / containerWidth) * imgWidth),
3612    			allImageWidth	= imgWidthPercent * _self.count,
3613    			modifier		= 3, // 10 - _self.count,
3614    			tempMinLeft		= 100 - imgWidthPercent,
3615    			minLeft 		= tempMinLeft > defaultPos / modifier ? tempMinLeft : 0,
3616    			oneLeft			= minLeft / (_self.count -1 ),
3617    			titleWidth		= imgWidth;
3618    		
3619    		
3620    		
3621    		if(allImageWidth < 110 && allow_repeat !== false)
3622    		{
3623    			//set height if necessary	
3624    			var slideHeight = this.$slider.height(), 
3625    				maxHeight 	= (slideHeight / allImageWidth) * 110 ;
3626    			
3627    			this.$slider.css({'max-height': maxHeight});
3628    			_self._calcMovement(event, false);
3629    			return;
3630    		}
3631    		
3632    		//backup so the minimized slides dont get too small
3633    		if(oneLeft < 2) minLeft = 0;
3634    		
3635			this.$slides.each(function(i)
3636			{
3637				var current = $(this), newLeft = 0, newRight = 0, defaultLeft = current.data('av-left');
3638					
3639				if( minLeft !== 0)
3640				{
3641					newLeft  = oneLeft * i;
3642					newRight = imgWidthPercent + newLeft - oneLeft;
3643				}
3644				else
3645				{
3646					newLeft  = defaultLeft / Math.abs(modifier);
3647					newRight = 100 - ((newLeft / i) * (_self.count - i));
3648				}
3649				
3650				if(i == 1 && _self.increaseTitle) { titleWidth = newRight + 1; } 
3651				
3652				if(_self.cssActive)
3653				{	
3654					//if we are not animating based on the css left value but on css transform we need to subtract the left value
3655					newLeft = newLeft - defaultLeft;
3656					newRight = newRight - defaultLeft;
3657					defaultLeft = 0;
3658				}
3659				
3660				current.data('av-calc-default', defaultLeft);
3661				current.data('av-calc-left', newLeft);
3662				current.data('av-calc-right', newRight);
3663				
3664			});
3665			
3666			if(_self.increaseTitle) { _self.$titles.css({width: titleWidth + "%"});} 
3667    	},
3668    	
3669    	_moveTo: function(event)
3670    	{
3671    		var direction 	= event.type == "av-next" ? 1 : -1,
3672    			nextSlide 	= this.open === false ? 0 : this.open + direction;
3673    			
3674    		if(nextSlide >= 0 && nextSlide < this.$slides.length) this._move(event, nextSlide);
3675    	},
3676    	
3677    	_move: function(event, direct_open)
3678    	{
3679    		var _self  = this,
3680    			slide  = event.currentTarget,
3681    			itemNo = typeof direct_open != "undefined" ? direct_open : this.$slides.index(slide);
3682    			
3683    		this.open = itemNo;
3684    		
3685    		if(_self.autoplay && typeof slide != "undefined") { clearInterval(_self.autoplay); _self.autoplay = false; }
3686    		
3687    		this.$slides.removeClass('aviaccordion-active-slide').each(function(i)
3688    		{
3689    			var current 	= $(this),
3690    				dataSet 	= current.data(),
3691    				trans_val	= i <= itemNo ? dataSet.avCalcLeft : dataSet.avCalcRight,
3692					transition 	= {},
3693					reset		= event.type == 'mouseleave' ? 1 : 0,
3694					active 		= itemNo === i ? _self.$titleWrap.eq(i) : false;
3695    			
3696    			if(active) current.addClass('aviaccordion-active-slide');
3697    				
3698    			if(reset)
3699    			{
3700    				trans_val = dataSet.avCalcDefault; 
3701    				this.open = false;
3702    			}
3703    				
3704				if(_self.cssActive) //do a css3 animation
3705				{
3706					//move the slides
3707					transition[_self.property]  = _self.transform3d ? "translate3d(" + trans_val  + "%, 0, 0)" : "translate(" + trans_val + "%,0)"; //3d or 2d transform?
3708					current.css(transition);
3709				}
3710				else
3711				{
3712					transition.left =  trans_val + "%";
3713					current.stop().animate(transition, 700, 'easeOutQuint');
3714				}	
3715    		});
3716    	}
3717    };
3718
3719
3720$.fn.aviaccordion = function( options )
3721{
3722	return this.each(function()
3723	{
3724		var active = $.data( this, 'AviaccordionSlider' );
3725
3726		if(!active)
3727		{
3728			//make sure that the function doesnt get aplied a second time
3729			$.data( this, 'AviaccordionSlider', 1 );
3730			
3731			//create the preparations for fullscreen slider
3732			new $.AviaccordionSlider( options, this );
3733		}
3734	});
3735}
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747// -------------------------------------------------------------------------------------------
3748// Aviaccordion Slideshow 
3749// 
3750// accordion slider script
3751// -------------------------------------------------------------------------------------------
3752
3753	$.AviaTextRotator  =  function(options, slider)
3754	{
3755	    this.$win	  	= $( window );
3756	    this.$slider  	= $( slider );
3757	    this.$inner	  	= this.$slider.find('.av-rotator-text');
3758	    this.$slides	= this.$inner.find('.av-rotator-text-single');
3759	    this.$current   = this.$slides.eq(0);
3760	    this.open		= 0;
3761	    this.count		= this.$slides.length;
3762	    
3763	    if($.avia_utilities.supported.transition === undefined)
3764		{
3765			$.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
3766		}
3767		
3768		this.browserPrefix 	= $.avia_utilities.supported.transition;
3769	    this.cssActive 		= this.browserPrefix !== false ? true : false;
3770		this.property		= this.browserPrefix + 'transform',
3771		
3772		//this.cssActive    = false; //testing no css3 browser
3773		
3774	    this._init( options );
3775	}
3776
3777  	$.AviaTextRotator.prototype =
3778    {
3779    	_init: function( options )
3780    	{
3781    		var _self = this;
3782    		
3783    		if(this.count <= 1) return;
3784    		
3785    		_self.options = $.extend({}, options, this.$slider.data());
3786			_self.$inner.addClass('av-rotation-active');
3787			//if(_self.options.fixwidth == 1) this.$inner.width(this.$current.width());
3788			_self._autoplay();
3789    	},
3790    	
3791    	_autoplay: function()
3792    	{
3793    		var _self = this;
3794    		
3795			_self.autoplay = setInterval(function()
3796			{
3797				_self.open = _self.open === false ? 0 : _self.open + 1;
3798				if(_self.open >= _self.count) _self.open = 0;
3799				_self._move({}, _self.open);
3800				
3801			}, _self.options.interval * 1000)
3802    	},
3803    	    	
3804    	_move: function(event)
3805    	{
3806	    	var _self 		= this, 
3807	    		modifier 	= 30 * _self.options.animation, 
3808	    		fade_out 	= {opacity:0}, 
3809	    		fade_start  = {display:'inline-block', opacity:0},
3810	    		fade_in		= {opacity:1};
3811	    		
3812    		this.$next = _self.$slides.eq(this.open);
3813    		
3814    		if(this.cssActive)
3815    		{
3816	    		fade_out[_self.property] 	= "translate(0px," + modifier +"px)";
3817	    		fade_start[_self.property] 	= "translate(0px," + (modifier * -1) +"px)";
3818	    		fade_in[_self.property] 	= "translate(0px,0px)";
3819    		}
3820    		else
3821    		{
3822	    		fade_out['top'] 	= modifier;
3823	    		fade_start['top'] 	= (modifier * -1);
3824	    		fade_in['top'] 		= 0;
3825    		}
3826    		
3827    		
3828    		_self.$current.avia_animate(fade_out, function()
3829    		{
3830	    		_self.$current.css({display:'none'});
3831	    		_self.$next.css(fade_start).avia_animate(fade_in, function()
3832	    		{
3833		    		_self.$current = _self.$slides.eq(_self.open);
3834	    		});
3835    		});
3836    	}
3837    };
3838
3839
3840$.fn.avia_textrotator = function( options )
3841{
3842	return this.each(function()
3843	{
3844		var active = $.data( this, 'AviaTextRotator' );
3845
3846		if(!active)
3847		{
3848			//make sure that the function doesnt get aplied a second time
3849			$.data( this, 'AviaTextRotator', 1 );
3850			
3851			//create the preparations for fullscreen slider
3852			new $.AviaTextRotator( options, this );
3853		}
3854	});
3855}
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871// -------------------------------------------------------------------------------------------
3872// HELPER FUNCTIONS
3873// -------------------------------------------------------------------------------------------
3874
3875
3876//waipoint script when something comes into viewport
3877 $.fn.avia_waypoints = function(options_passed)
3878	{
3879		if(! $('html').is('.avia_transform')) return;
3880
3881		var defaults = { offset: 'bottom-in-view' , triggerOnce: true},
3882			options  = $.extend({}, defaults, options_passed),
3883			isMobile = $.avia_utilities.isMobile;
3884
3885		return this.each(function()
3886		{
3887			var element = $(this);
3888			
3889			setTimeout(function()
3890			{
3891				if(isMobile)
3892				{
3893					element.addClass('avia_start_animation').trigger('avia_start_animation');
3894				}
3895				else
3896				{
3897					element.waypoint(function(direction)
3898					{
3899					 	var current 	= $(this.element),
3900					 		parent  	= current.parents('.av-animation-delay-container:eq(0)');
3901					 	
3902					 	if(parent.length)
3903					 	{
3904						 	current.addClass('avia_start_animation_when_active').trigger('avia_start_animation_when_active');
3905					 	}
3906					 	
3907					 	if(!parent.length || (parent.length && parent.is('.__av_init_open')))
3908					 	{
3909						 	current.addClass('avia_start_animation').trigger('avia_start_animation');
3910					 	}
3911					 	
3912					 	
3913					 	
3914					}, options );
3915				}
3916			},100)
3917			
3918		});
3919	};
3920
3921
3922
3923
3924
3925
3926
3927// window resize script
3928var $event = $.event, $special, resizeTimeout;
3929
3930$special = $event.special.debouncedresize = {
3931	setup: function() {
3932		$( this ).on( "resize", $special.handler );
3933	},
3934	teardown: function() {
3935		$( this ).off( "resize", $special.handler );
3936	},
3937	handler: function( event, execAsap ) {
3938		// Save the context
3939		var context = this,
3940			args = arguments,
3941			dispatch = function() {
3942				// set correct event type
3943				event.type = "debouncedresize";
3944				$event.dispatch.apply( context, args );
3945			};
3946
3947		if ( resizeTimeout ) {
3948			clearTimeout( resizeTimeout );
3949		}
3950
3951		execAsap ?
3952			dispatch() :
3953			resizeTimeout = setTimeout( dispatch, $special.threshold );
3954	},
3955	threshold: 150
3956};
3957
3958
3959
3960
3961
3962$.easing['jswing'] = $.easing['swing'];
3963
3964$.extend( $.easing,
3965{
3966	def: 'easeOutQuad',
3967	swing: function (x, t, b, c, d) { return $.easing[$.easing.def](x, t, b, c, d); },
3968	easeInQuad: function (x, t, b, c, d) { return c*(t/=d)*t + b; },
3969	easeOutQuad: function (x, t, b, c, d) { return -c *(t/=d)*(t-2) + b; },
3970	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 3971-4076
3971	easeInCubic: function (x, t, b, c, d) { return c*(t/=d)*t*t + b; },
3972	easeOutCubic: function (x, t, b, c, d) { return c*((t=t/d-1)*t*t + 1) + b; },
3973	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;	},
3974	easeInQuart: function (x, t, b, c, d) { return c*(t/=d)*t*t*t + b;	},
3975	easeOutQuart: function (x, t, b, c, d) { return -c * ((t=t/d-1)*t*t*t - 1) + b; },
3976	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;	},
3977	easeInQuint: function (x, t, b, c, d) { return c*(t/=d)*t*t*t*t + b;	},
3978	easeOutQuint: function (x, t, b, c, d) { return c*((t=t/d-1)*t*t*t*t + 1) + b;	},
3979	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;	},
3980	easeInSine: function (x, t, b, c, d) {	return -c * Math.cos(t/d * (Math.PI/2)) + c + b;	},
3981	easeOutSine: function (x, t, b, c, d) { return c * Math.sin(t/d * (Math.PI/2)) + b;	},
3982	easeInOutSine: function (x, t, b, c, d) { return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;	},
3983	easeInExpo: function (x, t, b, c, d) { return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;	},
3984	easeOutExpo: function (x, t, b, c, d) { return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;	},
3985	easeInOutExpo: function (x, t, b, c, d) {
3986		if (t==0) return b;
3987		if (t==d) return b+c;
3988		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
3989		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
3990	},
3991	easeInCirc: function (x, t, b, c, d) { return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;	},
3992	easeOutCirc: function (x, t, b, c, d) {return c * Math.sqrt(1 - (t=t/d-1)*t) + b;	},
3993	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;	},
3994	easeInElastic: function (x, t, b, c, d) {
3995		var s=1.70158;var p=0;var a=c;
3996		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
3997		if (a < Math.abs(c)) { a=c; var s=p/4; }
3998		else var s = p/(2*Math.PI) * Math.asin (c/a);
3999		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
4000	},
4001	easeOutElastic: function (x, t, b, c, d) {
4002		var s=1.70158;var p=0;var a=c;
4003		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
4004		if (a < Math.abs(c)) { a=c; var s=p/4; }
4005		else var s = p/(2*Math.PI) * Math.asin (c/a);
4006		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
4007	},
4008	easeInOutElastic: function (x, t, b, c, d) {
4009		var s=1.70158;var p=0;var a=c;
4010		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
4011		if (a < Math.abs(c)) { a=c; var s=p/4; }
4012		else var s = p/(2*Math.PI) * Math.asin (c/a);
4013		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
4014		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
4015	},
4016	easeInBack: function (x, t, b, c, d, s) {
4017		if (s == undefined) s = 1.70158;
4018		return c*(t/=d)*t*((s+1)*t - s) + b;
4019	},
4020	easeOutBack: function (x, t, b, c, d, s) {
4021		if (s == undefined) s = 1.70158;
4022		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
4023	},
4024	easeInOutBack: function (x, t, b, c, d, s) {
4025		if (s == undefined) s = 1.70158;
4026		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
4027		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
4028	},
4029	easeInBounce: function (x, t, b, c, d) {
4030		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
4031	},
4032	easeOutBounce: function (x, t, b, c, d) {
4033		if ((t/=d) < (1/2.75)) {
4034			return c*(7.5625*t*t) + b;
4035		} else if (t < (2/2.75)) {
4036			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
4037		} else if (t < (2.5/2.75)) {
4038			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
4039		} else {
4040			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
4041		}
4042	},
4043	easeInOutBounce: function (x, t, b, c, d) {
4044		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
4045		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
4046	}
4047});
4048
4049})( jQuery );
4050
4051
4052
4053/*utility functions*/
4054
4055
4056(function($)
4057{
4058	"use strict";
4059
4060	$.avia_utilities = $.avia_utilities || {};
4061
4062	/************************************************************************
4063	gloabl loading function
4064	*************************************************************************/
4065	$.avia_utilities.loading = function(attach_to, delay){
4066
4067		var loader = {
4068
4069			active: false,
4070
4071			show: function()
4072			{
4073				if(loader.active === false)
4074				{
4075					loader.active = true;
4076					loader.loading_item.css({display:'block', opacity:0}
4076);
4077				}
4078
4079				loader.loading_item.stop().animate({opacity:1});
4080			},
4081
4082			hide: function()
4083			{	
4084				if(typeof delay === 'undefined'){ delay = 600; }
4085
4086				loader.loading_item.stop().delay( delay ).animate({opacity:0}, function()
4087				{
4088					loader.loading_item.css({display:'none'});
4089					loader.active = false;
4090				});
4091			},
4092
4093			attach: function()
4094			{
4095				if(typeof attach_to === 'undefined'){ attach_to = 'body';}
4096
4097				loader.loading_item = $('<div class="avia_loading_icon"><div class="av-siteloader"></div></div>').css({display:"none"}).appendTo(attach_to);
4098			}
4099		}
4100
4101		loader.attach();
4102		return loader;
4103	};
4104	
4105	/************************************************************************
4106	gloabl play/pause visualizer function
4107	*************************************************************************/
4108	$.avia_utilities.playpause = function(attach_to, delay){
4109
4110		var pp = {
4111
4112			active: false,
4113			to1: "", 
4114			to2: "", 
4115			set: function(status)
4116			{	
4117				pp.loading_item.removeClass('av-play av-pause');
4118				pp.to1 = setTimeout(function(){ pp.loading_item.addClass('av-' + status); },10);
4119				pp.to2 = setTimeout(function(){ pp.loading_item.removeClass('av-' + status); },1500);
4120			},
4121
4122			attach: function()
4123			{
4124				if(typeof attach_to === 'undefined'){ attach_to = 'body';}
4125
4126				pp.loading_item = $('<div class="avia_playpause_icon"></div>').css({display:"none"}).appendTo(attach_to);
4127			}
4128		}
4129
4130		pp.attach();
4131		return pp;
4132	};
4133	
4134	
4135
4136	/************************************************************************
4137	preload images, as soon as all are loaded trigger a special load ready event
4138	*************************************************************************/
4139	$.avia_utilities.preload = function(options_passed)
4140	{
4141		new $.AviaPreloader(options_passed);
4142	}
4143	
4144	$.AviaPreloader  =  function(options)
4145	{
4146	    this.win 		= $(window);
4147	    this.defaults	=
4148		{
4149			container:			'body',
4150			maxLoops:			10,
4151			trigger_single:		true,
4152			single_callback:	function(){},
4153			global_callback:	function(){}
4154
4155		};
4156		this.options 	= $.extend({}, this.defaults, options);
4157		this.preload_images = 0;
4158		
4159		this.load_images();
4160	}
4161	
4162	$.AviaPreloader.prototype  = 
4163	{
4164		load_images: function()
4165		{	
4166			var _self = this;
4167			
4168			if(typeof _self.options.container === 'string'){ _self.options.container = $(_self.options.container); }
4169
4170			_self.options.container.each(function()
4171			{
4172				var container		= $(this);
4173	
4174				container.images	= container.find('img');
4175				container.allImages	= container.images;
4176	
4177				_self.preload_images += container.images.length;
4178				setTimeout(function(){ _self.checkImage(container); }, 10);
4179			});	
4180		},
4181		
4182		checkImage: function(container)
4183		{	
4184			var _self = this;
4185			
4186			container.images.each(function()
4187			{
4188				if(this.complete === true)
4189				{
4190					container.images = container.images.not(this);
4191					_self.preload_images -= 1;
4192				}
4193			});
4194
4195			if(container.images.length && _self.options.maxLoops >= 0)
4196			{
4197				_self.options.maxLoops-=1;
4198				setTimeout(function(){ _self.checkImage(container); }, 500);
4199			}
4200			else
4201			{
4202				_self.preload_images = _self.preload_images - container.images.length;
4203				_self.trigger_loaded(container);
4204			}
4205		},
4206
4207		trigger_loaded: function(container)
4208		{
4209			var _self = this;
4210			
4211			if(_self.options.trigger_single !== false)
4212			{
4213				_self.win.trigger('avia_images_loaded_single', [container]);
4214				_self.options.single_callback.call(container);
4215			}
4216
4217			if(_self.preload_images === 0)
4218			{
4219				_self.win.trigger('avia_images_loaded');
4220				_self.options.global_callback.call();
4221			}
4222
4223		}
4224	}
4225
4226
4227	/************************************************************************
4228	CSS Easing transformation table
4229	*************************************************************************/
4230	/*
4231	Easing transform table from jquery.animate-enhanced plugin
4232	http://github.com/benbarnett/jQuery-Animate-Enhanced
4233	*/
4234	$.avia_utilities.css_easings = {
4235			linear:			'linear',
4236			swing:			'ease-in-out',
4237			bounce:			'cubic-bezier(0.0, 0.35, .5, 1.3)',
4238			easeInQuad:     'cubic-bezier(0.550, 0.085, 0.680, 0.530)' ,
4239			easeInCubic:    'cubic-bezier(0.550, 0.055, 0.675, 0.190)' ,
4240			easeInQuart:    'cubic-bezier(0.895, 0.030, 0.685, 0.220)' ,
4241			easeInQuint:    'cubic-bezier(0.755, 0.050, 0.855, 0.060)' ,
4242			easeInSine:     'cubic-bezier(0.470, 0.000, 0.745, 0.715)' ,
4243			easeInExpo:     'cubic-bezier(0.950, 0.050, 0.795, 0.035)' ,
4244			easeInCirc:     'cubic-bezier(0.600, 0.040, 0.980, 0.335)' ,
4245			easeInBack:     'cubic-bezier(0.600, -0.280, 0.735, 0.04)' ,
4246			easeOutQuad:    'cubic-bezier(0.250, 0.460, 0.450, 0.940)' ,
4247			easeOutCubic:   'cubic-bezier(0.215, 0.610, 0.355, 1.000)' ,
4248			easeOutQuart:   'cubic-bezier(0.165, 0.840, 0.440, 1.000)' ,
4249			easeOutQuint:   'cubic-bezier(0.230, 1.000, 0.320, 1.000)' ,
4250			easeOutSine:    'cubic-bezier(0.390, 0.575, 0.565, 1.000)' ,
4251			easeOutExpo:    'cubic-bezier(0.190, 1.000, 0.220, 1.000)' ,
4252			easeOutCirc:    'cubic-bezier(0.075, 0.820, 0.165, 1.000)' ,
4253			easeOutBack:    'cubic-bezier(0.175, 0.885, 0.320, 1.275)' ,
4254			easeInOutQuad:  'cubic-bezier(0.455, 0.030, 0.515, 0.955)' ,
4255			easeInOutCubic: 'cubic-bezier(0.645, 0.045, 0.355, 1.000)' ,
4256			easeInOutQuart: 'cubic-bezier(0.770, 0.000, 0.175, 1.000)' ,
4257			easeInOutQuint: 'cubic-bezier(0.860, 0.000, 0.070, 1.000)' ,
4258			easeInOutSine:  'cubic-bezier(0.445, 0.050, 0.550, 0.950)' ,
4259			easeInOutExpo:  'cubic-bezier(1.000, 0.000, 0.000, 1.000)' ,
4260			easeInOutCirc:  'cubic-bezier(0.785, 0.135, 0.150, 0.860)' ,
4261			easeInOutBack:  'cubic-bezier(0.680, -0.550, 0.265, 1.55)' ,
4262			easeInOutBounce:'cubic-bezier(0.580, -0.365, 0.490, 1.365)',
4263			easeOutBounce:	'cubic-bezier(0.760, 0.085, 0.490, 1.365)' 
4264		};
4265
4266	/************************************************************************
4267	check if a css feature is supported and save it to the supported array
4268	*************************************************************************/
4269	$.avia_utilities.supported	= {};
4270	$.avia_utilities.supports	= (function()
4271	{
4272		var div		= document.createElement('div'),
4273			vendors	= ['Khtml', 'Ms','Moz','Webkit'];  // vendors	= ['Khtml', 'Ms','Moz','Webkit','O']; 
4274
4275		return function(prop, vendor_overwrite)
4276		{
4277			if ( div.style[prop] !== undefined  ) { return ""; }
4278			if (vendor_overwrite !== undefined) { vendors = vendor_overwrite; }
4279
4280			prop = prop.replace(/^[a-z]/, function(val)
4281			{
4282				return val.toUpperCase();
4283			});
4284
4285			var len	= vendors.length;
4286			while(len--)
4287			{
4288				if ( div.style[vendors[len] + prop] !== undefined )
4289				{
4290					return "-" + vendors[len].toLowerCase() + "-";
4291				}
4292			}
4293
4294			return false;
4295		};
4296
4297	}());
4298
4299	/************************************************************************
4300	animation function
4301	*************************************************************************/
4302	$.fn.avia_animate = function(prop, speed, easing, callback)
4303	{
4304		if(typeof speed === 'function') {callback = speed; speed = false; }
4305		if(typeof easing === 'function'){callback = easing; easing = false;}
4306		if(typeof speed === 'string'){easing = speed; speed = false;}
4307
4308		if(callback === undefined || callback === false){ callback = function(){}; }
4309		if(easing === undefined || easing === false)	{ easing = 'easeInQuad'; }
4310		if(speed === undefined || speed === false)		{ speed = 400; }
4311
4312		if($.avia_utilities.supported.transition === undefined)
4313		{
4314			$.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
4315		}
4316		
4317		
4318
4319		if($.avia_utilities.supported.transition !== false )
4320		{
4321			var prefix		= $.avia_utilities.supported.transition + 'transition',
4322				cssRule		= {},
4323				cssProp		= {},
4324				thisStyle	= document.body.style,
4325				end			= (thisStyle.WebkitTransition !== undefined) ? 'webkitTransitionEnd' : (thisStyle.OTransition !== undefined) ? 'oTransitionEnd' : 'transitionend';
4326
4327			//translate easing into css easing
4328			easing = $.avia_utilities.css_easings[easing];
4329
4330			//create css transformation rule
4331			cssRule[prefix]	=  'all '+(speed/1000)+'s '+easing;
4332			//add namespace to the transition end trigger
4333			end = end + ".avia_animate";
4334			
4335			//since jquery 1.10 the items passed need to be {} and not [] so make sure they are converted properly
4336			for (var rule in prop)
4337			{
4338				if (prop.hasOwnProperty(rule)) { cssProp[rule] = prop[rule]; }
4339			}
4340			prop = cssProp;
4341			
4342			
4343			
4344			this.each(function()
4345			{
4346				var element	= $(this), css_difference = false, rule, current_css;
4347
4348				for (rule in prop)
4349				{
4350					if (prop.hasOwnProperty(rule))
4351					{
4352						current_css = element.css(rule);
4353
4354						if(prop[rule] != current_css && prop[rule] != current_css.replace(/px|%/g,""))
4355						{
4356							css_difference = true;
4357							break;
4358						}
4359					}
4360				}
4361
4362				if(css_difference)
4363				{
4364					//if no transform property is set set a 3d translate to enable hardware acceleration
4365					if(!($.avia_utilities.supported.transition+"transform" in prop))
4366					{
4367						prop[$.avia_utilities.supported.transition+"transform"] = "translateZ(0)";
4368					}
4369					
4370					var endTriggered = false;
4371					
4372					element.on(end,  function(event)
4373					{
4374						if(event.target != event.currentTarget) return false;
4375						
4376						if(endTriggered == true) return false;
4377						endTriggered = true;
4378
4379						cssRule[prefix] = "none";
4380
4381						element.off(end);
4382						element.css(cssRule);
4383						setTimeout(function(){ callback.call(element); });
4384					});
4385					
4386					
4387					//desktop safari fallback if we are in another tab to trigger the end event
4388					setTimeout(function(){ 
4389						if(!endTriggered && !avia_is_mobile && $('html').is('.avia-safari') ) { 
4390							element.trigger(end); 
4391							$.avia_utilities.log('Safari Fallback '+end+' trigger'); 
4392						}
4393					}, speed + 100);
4394					
4395					setTimeout(function(){ element.css(cssRule);},10);
4396					setTimeout(function(){ element.css(prop);	},20);
4397				}
4398				else
4399				{
4400					setTimeout(function(){ callback.call(element); });
4401				}
4402
4403			});
4404		}
4405		else // if css animation is not available use default JS animation
4406		{
4407			this.animate(prop, speed, easing, callback);
4408		}
4409
4410		return this;
4411	};
4412
4413})( jQuery );
4414
4415
4416/* ======================================================================================================================================================
4417Avia Slideshow
4418====================================================================================================================================================== */
4419
4420(function($)
4421{
4422    "use strict";
4423
4424	$.AviaSlider  =  function(options, slider)
4425	{
4426		var self = this;
4427		
4428		this.$win	 = $( window );
4429		
4430	    this.$slider = $( slider );
4431	    
4432		this.isMobile = $.avia_utilities.isMobile;
4433	    
4434	    this._prepareSlides(options);
4435	    
4436		//default preload images then init slideshow
4437	    $.avia_utilities.preload({container: this.$slider , single_callback:  function(){ self._init( options ); }});
4438	}
4439
4440	$.AviaSlider.defaults  = {
4441
4442		//interval between autorotation switches
4443		interval:5,
4444
4445		//autorotation active or not
4446		autoplay:false,
4447		
4448		//set if the loop will stop at the last/first slide or if the slides will loop infinite
4449		//set to false for infinite loop, "last" to stop at the last slide or "first" to stop at the first slide
4450		stopinfiniteloop: false,
4451
4452		//fade or slide animation
4453		animation:'slide',
4454
4455		//transition speed when switching slide
4456		transitionSpeed:900,
4457
4458		//easing method for the transition
4459		easing:'easeInOutQuart',
4460
4461		//slide wrapper
4462		wrapElement: '>ul',
4463
4464		//slide element
4465		slideElement: '>li',
4466
4467		//pause if mouse cursor is above item
4468		hoverpause: false,
4469		
4470		//attach images as background
4471		bg_slider: false,
4472		
4473		//delay of miliseconds to wait before showing the next slide
4474		show_slide_delay: 0,
4475		
4476		//if slider animation is set to "fade" the fullfade property sets the crossfade behaviour
4477		fullfade: false
4478
4479	};
4480
4481  	$.AviaSlider.prototype =
4482    {
4483    	_init: function( options )
4484    	{
4485			// set slider options
4486			this.options = this._setOptions(options);
4487
4488			//slidewrap
4489			this.$sliderUl  = this.$slider.find(this.options.wrapElement);
4490
4491			// slide elements
4492			this.$slides = this.$sliderUl.find(this.options.slideElement);
4493
4494			// goto dots
4495			this.gotoButtons = this.$slider.find('.avia-slideshow-dots a');
4496			
4497			//perma caption
4498			this.permaCaption =  this.$slider.find('>.av-slideshow-caption');
4499
4500			// slide count
4501			this.itemsCount = this.$slides.length;
4502
4503			// current image index
4504			this.current = 0;
4505
4506			//loop count
4507			this.loopCount = 0;
4508
4509			// control if the slicebox is animating
4510			this.isAnimating = false;
4511
4512			// css browser prefix like -webkit-, -moz-
4513			this.browserPrefix = $.avia_utilities.supports('transition');
4514			
4515			// css3 animation?
4516			this.cssActive = this.browserPrefix !== false ? true : false;
4517			
4518			// css3D animation?
4519			this.css3DActive = document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
4520			
4521			//store the aviaVideoApi object for the current slide if available
4522			this.video	= false;
4523			
4524			//if we have a bg slider no images were preloaded yet. in that case start preloading and attaching images
4525			if(this.options.bg_slider == true)
4526			{
4527				//create array that holds all image urls to preload
4528				this.imageUrls = [];
4529				
4530				//create a preloader icon to indicate loading
4531				this.loader = $.avia_utilities.loading(this.$slider);
4532				
4533				//preload the images ony by one
4534				this._bgPreloadImages();
4535				
4536			}
4537			else //if it was a default slider all images are already loaded and we can start showing the slider
4538			{			
4539				//kickoff the slider: bind functions, show first slide, if active start the autorotation timer
4540				this._kickOff();
4541			}
4542    	},
4543
4544    	//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
4545    	_setOptions: function(options)
4546		{
4547			var newOptions 	= $.extend( true, {}, $.AviaSlider.defaults, options ),
4548				htmlData 	= this.$slider.data(),
4549				i 			= "";
4550
4551			//overwritte passed option set with any data properties on the html element
4552			for (i in htmlData)
4553			{
4554				if (htmlData.hasOwnProperty(i))
4555				{
4556					if(typeof htmlData[i] === "string" || typeof htmlData[i] === "number" || typeof htmlData[i] === "boolean")
4557					{
4558						newOptions[i] = htmlData[i];
4559					}
4560				}
4561			}
4562
4563			return newOptions;
4564		},
4565		
4566		_prepareSlides: function(options)
4567		{	
4568			//if its a mobile device find all video slides that need to be altered
4569			if(this.isMobile)
4570			{
4571				var alter = this.$slider.find('.av-mobile-fallback-image');
4572				alter.each(function()
4573				{	
4574					var current  = $(this).removeClass('av-video-slide').data({'avia_video_events': true, 'video-ratio':0}),
4575						fallback = current.data('mobile-img');
4576						
4577					current.find('.av-click-overlay, .mejs-mediaelement, .mejs-container').remove();
4578					
4579					if(!fallback)
4580					{
4581						var appendTo = current.find('.avia-slide-wrap');
4582						$('<p class="av-fallback-message"><span>Please set a mobile device fallback image for this video in your wordpress backend</span></p>').appendTo(appendTo);
4583					}
4584					
4585					if(options && options.bg_slider)
4586					{
4587						current.data('img-url', fallback);
4588					}
4589					else
4590					{
4591						var image = $('<img src="'+fallback+'" alt="" title="" />');
4592						current.find('.avia-slide-wrap').append(image);
4593					}
4594					
4595				});
4596			}
4597			
4598		},
4599		
4600		//start preloading the background images
4601		_bgPreloadImages : function(callback)
4602    	{
4603    		this._getImageURLS();
4604    		
4605    		this._preloadSingle(0, function()
4606    		{
4607    			this._kickOff();
4608				this._preloadNext(1);
4609    		});
4610    	},
4611		
4612    	//if we are using a background image slider, fetch the images from a data attribute and preload them one by one
4613    	_getImageURLS: function()
4614    	{
4615    		var _self = this;
4616    		
4617    		//collect url strings of the images to preload
4618			this.$slides.each(function(i)
4619			{
4620				_self.imageUrls[i] = [];
4621				_self.imageUrls[i]['url'] = $(this).data("img-url");
4622				
4623				//if no image is passed we can set the slide to loaded
4624				if(typeof _self.imageUrls[i]['url'] == 'string')
4625				{
4626					_self.imageUrls[i]['status'] = false;
4627				}
4628				else
4629				{
4630					_self.imageUrls[i]['status'] = true;
4631				}
4632			});
4633    	},
4634    	
4635    	
4636    	_preloadSingle: function(key, callback)
4637		{
4638			var _self 		= this,
4639				objImage	= new Image();
4640			
4641			if(typeof _self.imageUrls[key]['url'] == 'string')
4642			{
4643				$(objImage).bind('load error', function()
4644				{ 
4645					_self.imageUrls[key]['status'] = true; 
4646					_self.$slides.eq(key).css('background-image','url(' + _self.imageUrls[key]['url'] + ')');
4647					if(typeof callback == 'function') callback.apply( _self, [objImage, key] );
4648				});
4649				
4650				if(_self.imageUrls[key]['url'] != "")
4651				{
4652					objImage.src = _self.imageUrls[key]['url'];
4653				}
4654				else
4655				{
4656					$(objImage).trigger('error');
4657				}
4658			}
4659			else
4660			{
4661				if(typeof callback == 'function') callback.apply( _self, [objImage, key] );
4662			}
4663		},
4664		
4665		_preloadNext: function(key)
4666		{
4667			if(typeof this.imageUrls[key] != "undefined")
4668    		{
4669				this._preloadSingle(key, function()
4670	    		{
4671					this._preloadNext(key + 1);
4672	    		});
4673    		}
4674		},
4675    	
4676
4677    	//bind click events of slide controlls to the public functions
4678    	_bindEvents: function()
4679    	{
4680    		var self = this,
4681    			win  = $( window );
4682
4683    		this.$slider.on('click','.next-slide', $.proxy( this.next, this) );
4684    		this.$slider.on('click','.prev-slide', $.proxy( this.previous, this) );
4685    		this.$slider.on('click','.goto-slide', $.proxy( this.go2, this) );
4686
4687    		if(this.options.hoverpause)
4688    		{
4689    			this.$slider.on('mouseenter', $.proxy( this.pause, this) );
4690    			this.$slider.on('mouseleave', $.proxy( this.resume, this) );
4691    		}
4692
4693			if(this.options.stopinfiniteloop && this.options.autoplay)
4694			{
4695				if(this.options.stopinfiniteloop == 'last')
4696				{
4697					this.$slider.on('avia_slider_last_slide', $.proxy(this._stopSlideshow, this) );
4698				}
4699				else if(this.options.stopinfiniteloop == 'first')
4700				{
4701					this.$slider.on('avia_slider_first_slide', $.proxy(this._stopSlideshow, this) );
4702				}
4703			}
4704
4705    		win.on( 'debouncedresize.aviaSlider',  $.proxy( this._setSize, this) );
4706
4707    		//if its a desktop browser add arrow navigation, otherwise add touch nav
4708    		if(!this.isMobile)
4709    		{
4710    			this.$slider.avia_keyboard_controls();
4711    		}
4712    		else
4713    		{
4714    			this.$slider.avia_swipe_trigger();
4715    		}
4716			
4717			self._attach_video_events();
4718    	},
4719
4720    	//kickoff the slider by binding all functions to slides and buttons, show the first slide and start autoplay
4721    	_kickOff: function()
4722    	{
4723    		var self 			= this,
4724    			first_slide 	= self.$slides.eq(0),
4725    			video			= first_slide.data('video-ratio');
4726    		  		
4727    		// bind events to to the controll buttons
4728			self._bindEvents();
4729    		
4730    		this.$slider.removeClass('av-default-height-applied');
4731    		
4732    		//show the first slide. if its a video set the correct size, otherwise make sure to remove the % padding
4733    		if(video)
4734    		{ 
4735    			self._setSize(true); 
4736    		}
4737    		else
4738    		{
4739	    		if(this.options.keep_pading != true)
4740	    		{
4741    				self.$sliderUl.css('padding',0);
4742					self.$win.trigger('av-height-change');
4743				}
4744    		}
4745    		
4746    		self._setCenter();
4747    		first_slide.css({visibility:'visible', opacity:0}).avia_animate({opacity:1}, function()
4748    		{
4749    			var current = $(this).addClass('active-slide');
4750    			
4751    			if(self.permaCaption.length)
4752	    		{
4753	    			self.permaCaption.addClass('active-slide');
4754	    		}
4755    		});
4756    		
4757    		
4758    		
4759    		// start autoplay if active
4760			if( self.options.autoplay )
4761			{
4762				self._startSlideshow();
4763			}
4764    		
4765    	},
4766
4767    	//calculate which slide should be displayed next and call the executing transition function
4768    	_navigate : function( dir, pos ) {
4769			
4770			if( this.isAnimating || this.itemsCount < 2 || !this.$slider.is(":visible") )
4771			{
4772				return false;
4773			}
4774			
4775			this.isAnimating = true;
4776
4777			// current item's index
4778			this.prev = this.current;
4779
4780			// if position is passed
4781			if( pos !== undefined )
4782			{
4783				this.current = pos;
4784				dir = this.current > this.prev ? 'next' : 'prev';
4785			}
4786			// if not check the boundaries
4787			else if( dir === 'next' )
4788			{
4789				this.current = this.current < this.itemsCount - 1 ? this.current + 1 : 0;
4790				
4791				if( this.current === 0 && this.options.autoplay_stopper == 1 && this.options.autoplay )
4792				{
4793					this.isAnimating = false;
4794					this.current = this.prev;
4795					this._stopSlideshow();
4796					return false;
4797				}
4798			}
4799			else if( dir === 'prev' )
4800			{
4801				this.current = this.current > 0 ? this.current - 1 : this.itemsCount - 1;
4802			}
4803
4804			//set goto button
4805			this.gotoButtons.removeClass('active').eq(this.current).addClass('active');
4806
4807			//set slideshow size
4808			this._setSize();
4809			
4810			//if we are using a background slider make sure that the image is loaded. if not preload it, then show the slide
4811			if(this.options.bg_slider == true)
4812			{
4813				if(this.imageUrls[this.current]['status'] == true )
4814				{
4815					this['_' + this.options.animation].call(this, dir);
4816				}
4817				else
4818				{
4819					this.loader.show();
4820					this._preloadSingle(this.current, function()
4821    				{
4822    					this['_' + this.options.animation].call(this, dir);
4823    					this.loader.hide();
4824    				});
4825				}
4826			}
4827			else //no background loader -> images are already loaded
4828			{
4829				//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
4830				this['_' + this.options.animation].call(this, dir);
4831			}
4832
4833			if(this.current == 0)
4834			{
4835				this.loopCount++;
4836				this.$slider.trigger('avia_slider_first_slide');
4837			}
4838			else if(this.current == this.itemsCount - 1)
4839			{
4840				this.$slider.trigger('avia_slider_last_slide');
4841			}
4842			else
4843			{
4844				this.$slider.trigger('avia_slider_navigate_slide');
4845			}
4846		},
4847
4848		//if the next slide has a different height than the current change the slideshow height
4849		_setSize: function(instant)
4850		{
4851			//if images are attached as bg images the slider has a fixed height
4852			if(this.options.bg_slider == true) return;
4853			
4854			var self    		= this,
4855				slide 			= this.$slides.eq(this.current),
4856				img 			= slide.find('img'),
4857				current			= Math.floor(this.$sliderUl.height()),
4858				ratio			= slide.data('video-ratio'),
4859				setTo   		= ratio ? this.$sliderUl.width() / ratio : Math.floor(slide.height()),
4860				video_height 	= slide.data('video-height'), //forced video height %. needs to be set only once
4861				video_toppos 	= slide.data('video-toppos'); //forced video top position
4862				
4863				this.$sliderUl.height(current).css('padding',0); //make sure to set the slideheight to an actual value
4864				
4865				if(setTo != current)
4866				{
4867					if(instant == true)
4868					{
4869						this.$sliderUl.css({height:setTo});
4870						this.$win.trigger('av-height-change');
4871					}
4872					else
4873					{
4874						this.$sliderUl.avia_animate({height:setTo}, function()
4875						{
4876							self.$win.trigger('av-height-change');
4877						});
4878					}
4879				}
4880				
4881				this._setCenter();
4882				
4883				if(video_height && video_height!= "set")
4884				{
4885					slide.find('iframe, embed, video, object, .av_youtube_frame').css({height: video_height + '%', top: video_toppos + '%'});
4886					slide.data('video-height','set');
4887				}
4888		},
4889		
4890		_setCenter: function()
4891		{
4892			//if the image has a min width and is larger than the slider center it
4893			//positon img based on caption. right caption->left pos, left caption -> right pos
4894			var slide 		= this.$slides.eq(this.current),
4895				img 		= slide.find('img'),
4896				min_width 	= parseInt(img.css('min-width'),10),
4897				slide_width	= slide.width(),
4898				caption		= slide.find('.av-slideshow-caption'),
4899				css_left 	= ((slide_width - min_width) / 2);
4900			
4901			if(caption.length)
4902			{
4903				if(caption.is('.caption_left'))
4904				{
4905					css_left = ((slide_width - min_width) / 1.5);
4906				}
4907				else if(caption.is('.caption_right'))
4908				{
4909					css_left = ((slide_width - min_width) / 2.5);
4910				}
4911			}
4912			
4913			if(slide_width >= min_width)
4914			{
4915				css_left = 0;
4916			}
4917			
4918			img.css({left:css_left});
4919		},
4920		
4921		_slide: function(dir)
4922		{
4923			var dynamic			= false, //todo: pass by option if a slider is dynamic
4924				modifier		= dynamic == true ? 2 : 1,
4925				sliderWidth		= this.$slider.width(),
4926				direction		= dir === 'next' ? -1 : 1,
4927				property  		= this.browserPrefix + 'transform',
4928				reset			= {}, transition = {},  transition2 = {},
4929				trans_val 		= ( sliderWidth * direction * -1),
4930				trans_val2 		= ( sliderWidth * direction) / modifier;
4931			
4932			//do a css3 animation
4933			if(this.cssActive)
4934			{
4935				property  = this.browserPrefix + 'transform';
4936
4937				//do a translate 3d transformation if available, since it uses hardware acceleration
4938				if(this.css3DActive)
4939				{
4940					reset[property]  = "translate3d(" + trans_val + "px, 0, 0)";
4941					transition[property]  = "translate3d(" + trans_val2 + "px, 0, 0)";
4942					transition2[property] = "translate3d(0,0,0)";
4943				}
4944				else //do a 2d transform. still faster than a position "left" change
4945				{
4946					reset[property]  = "translate(" + trans_val + "px,0)";
4947					transition[property]  = "translate(" + trans_val2 + "px,0)";
4948					transition2[property] = "translate(0,0)";					}
4949			}
4950			else
4951			{
4952				reset.left = trans_val;
4953				transition.left = trans_val2;
4954				transition2.left = 0;
4955			}
4956			
4957			if(dynamic)
4958			{
4959				transition['z-index']  = "1";
4960				transition2['z-index']  = "2";
4961			}
4962			
4963			this._slide_animate(reset, transition, transition2);
4964		},
4965		
4966		_slide_up: function(dir)
4967		{
4968			var dynamic			= true, //todo: pass by option if a slider is dynamic
4969				modifier		= dynamic == true ? 2 : 1,
4970				sliderHeight	= this.$slider.height(),
4971				direction		= dir === 'next' ? -1 : 1,
4972				property  		= this.browserPrefix + 'transform',
4973				reset			= {}, transition = {},  transition2 = {},
4974				trans_val 		= ( sliderHeight * direction * -1),
4975				trans_val2 		= ( sliderHeight * direction) / modifier;
4976			
4977			//do a css3 animation
4978			if(this.cssActive)
4979			{
4980				property  = this.browserPrefix + 'transform';
4981
4982				//do a translate 3d transformation if available, since it uses hardware acceleration
4983				if(this.css3DActive)
4984				{
4985					reset[property]  = "translate3d( 0," + trans_val + "px, 0)";
4986					transition[property]  = "translate3d( 0," + trans_val2 + "px, 0)";
4987					transition2[property] = "translate3d(0,0,0)";
4988				}
4989				else //do a 2d transform. still faster than a position "left" change
4990				{
4991					reset[property]  = "translate( 0," + trans_val + "px)";
4992					transition[property]  = "translate( 0," + trans_val2 + "px)";
4993					transition2[property] = "translate(0,0)";					}
4994			}
4995			else
4996			{
4997				reset.top = trans_val;
4998				transition.top = trans_val2;
4999				transition2.top = 0;
5000			}
5001			
5002			if(dynamic)
5003			{
5004				transition['z-index']  = "1";
5005				transition2['z-index']  = "2";
5006			}
5007			this._slide_animate(reset, transition, transition2);
5008		},
5009		
5010		
5011		//slide animation: do a slide transition by css3 transform if possible. if not simply do a position left transition
5012		_slide_animate: function( reset , transition , transition2 )
5013		{
5014			
5015			var self			= this,
5016				displaySlide 	= this.$slides.eq(this.current),
5017				hideSlide		= this.$slides.eq(this.prev);
5018				
5019				hideSlide.trigger('pause');	
5020				if( !displaySlide.data('disableAutoplay') ) displaySlide.trigger('play');
5021
5022				displaySlide.css({visibility:'visible', zIndex:4, opacity:1, left
5022:0, top:0});
5023				displaySlide.css(reset);
5024				
5025				hideSlide.avia_animate(transition, this.options.transitionSpeed, this.options.easing);
5026				
5027				var after_slide = function()
5028				{
5029					self.isAnimating = false;
5030					displaySlide.addClass('active-slide');
5031					hideSlide.css({visibility:'hidden'}).removeClass('active-slide');
5032					self.$slider.trigger('avia-transition-done');
5033				}
5034				
5035				if(self.options.show_slide_delay > 0)
5036				{
5037					setTimeout(function() { displaySlide.avia_animate(transition2, self.options.transitionSpeed, self.options.easing, after_slide); },self.options.show_slide_delay);
5038				}
5039				else
5040				{
5041					displaySlide.avia_animate(transition2, self.options.transitionSpeed, self.options.easing, after_slide);
5042				}
5043
5044		},
5045		
5046		//simple fade transition of the slideshow
5047		_fade: function()
5048		{
5049			var self			= this,
5050				displaySlide 	= this.$slides.eq(this.current),
5051				hideSlide		= this.$slides.eq(this.prev),
5052				properties		= {visibility:'visible', zIndex:3, opacity:0},
5053				fadeCallback 	= function()
5054				{
5055					self.isAnimating = false;
5056					displaySlide.addClass('active-slide');
5057					hideSlide.css({visibility:'hidden', zIndex:2}).removeClass('active-slide');
5058					self.$slider.trigger('avia-transition-done');
5059					
5060				};
5061			
5062			hideSlide.trigger('pause');	
5063			if( !displaySlide.data('disableAutoplay') ) displaySlide.trigger('play');
5064			
5065			if(self.options.fullfade == true)
5066			{
5067				hideSlide.avia_animate({opacity:0}
5067, 200, 'linear', function()
5068				{	
5069					displaySlide.css(properties).avia_animate({opacity:1}, self.options.transitionSpeed, 'linear',fadeCallback);				
5070				});
5071			}
5072			else
5073			{
5074				displaySlide.css(properties).avia_animate({opacity:1}, self.options.transitionSpeed/2, 'linear', function()
5075				{
5076					hideSlide.avia_animate({opacity:0}, 200, 'linear', fadeCallback);
5077				});
5078			}
5079			
5080		},
5081		
5082		
5083		/************************************************************************
5084		Video functions
5085		*************************************************************************/
5086		
5087		//bind events to the video that tell the slider to autorotate once a video has been played
5088		_attach_video_events: function()
5089		{
5090			var self = this, $html = $('html');
5091						
5092			self.$slides.each(function(i)
5093			{
5094				var currentSlide 	= $(this),
5095					caption			= currentSlide.find('.caption_fullwidth, .av-click-overlay'),
5096					mejs			= currentSlide.find('.mejs-mediaelement');
5097								
5098				if(currentSlide.data('avia_video_events') != true)
5099				{
5100					currentSlide.data('avia_video_events', true);
5101					
5102					currentSlide.on('av-video-events-bound', { slide: currentSlide, wrap: mejs , iteration: i , self: self }, onReady);
5103					
5104					currentSlide.on('av-video-ended', { slide: currentSlide , self: self}, onFinish);
5105					
5106					currentSlide.on('av-video-play-executed', function(){ setTimeout(function(){  self.pause() }, 100); });
5107						
5108					caption.on('click', { slide: currentSlide }, toggle);
5109					
5110					// also if the player was loaded before the _bindEvents function was bound trigger it manually
5111					if(currentSlide.is('.av-video-events-bound')) currentSlide.trigger('av-video-events-bound');
5112				}
5113			});
5114			
5115			
5116			//helper functions
5117			function onReady( event ) 
5118			{ 	
5119				//autostart for first slide
5120				if(event.data.iteration === 0) 
5121				{	
5122					event.data.wrap.css('opacity',0);
5123					if(!event.data.self.isMobile && !event.data.slide.data('disableAutoplay')) { event.data.slide.trigger('play'); } 
5124					setTimeout(function(){ event.data.wrap.avia_animate({opacity:1}, 400); }, 50);
5125				}
5126				else if ($html.is('.avia-msie') && !event.data.slide.is('.av-video-service-html5'))
5127				{	
5128					/*
5129					* Internet Explorer fires the ready event for external videos once they become visible 
5130					* as oposed to other browsers which always fire immediately. 
5131					*/
5132					if( !event.data.slide.data('disableAutoplay') ) event.data.slide.trigger('play');
5133				}
5134				
5135			}
5136			
5137			
5138			
5139			
5140			function onFinish( event )
5141			{ 	
5142				//if the video is not looped resume the slideshow
5143				if(!event.data.slide.is('.av-single-slide') && !event.data.slide.is('.av-loop-video'))
5144				{
5145					event.data.slide.trigger('reset');
5146					self._navigate( 'next' );  
5147					self.resume(); 
5148				}
5149				
5150				//safari 8 workaround for self hosted videos which wont loop by default
5151				if(event.data.slide.is('.av-loop-video') && event.data.slide.is('.av-video-service-html5'))
5152				{
5153					if($html.is('.avia-safari-8'))
5154					{
5155						setTimeout(function(){ event.data.slide.trigger('play'); },1);
5156					}
5157				}
5158			}
5159			
5160			function toggle( event )
5161			{
5162				if(event.target.tagName != "A") 
5163				{
5164					event.data.slide.trigger('toggle');
5165				}
5166			}
5167			
5168		},
5169		
5170		
5171		
5172		/************************************************************************
5173		Slideshow control functions
5174		*************************************************************************/
5175		
5176		_timer: function(callback, delay, first)
5177		{	
5178		    var self = this, start, remaining = delay;
5179			
5180			self.timerId = 0;
5181			
5182		    this.pause = function() {
5183		        window.clearTimeout(self.timerId);
5184		        remaining -= new Date() - start;
5185		    };
5186
5187		    this.resume = function() {
5188		        start = new Date();
5189		        self.timerId = window.setTimeout(callback, remaining);
5190		    };
5191
5192		    this.destroy = function()
5193		    {
5194		    	window.clearTimeout(self.timerId);
5195		    };
5196
5197		    this.resume(true);
5198		},
5199
5200		//start autorotation
5201		_startSlideshow: function()
5202		{
5203			var self = this;
5204			
5205			this.isPlaying = true;
5206			
5207			this.slideshow = new this._timer( function()
5208			{
5209				/*
5210				var videoApi = self.$slides.eq(self.current).data('aviaVideoApi')
5211				if(!videoApi){}
5212				*/
5213				
5214				self._navigate( 'next' );
5215		
5216				if ( self.options.autoplay )
5217				{
5218					self._startSlideshow();
5219				}
5220
5221			}, (this.options.interval * 1000));
5222		},
5223
5224		//stop autorotation
5225		_stopSlideshow: function()
5226		{
5227			if ( this.options.autoplay ) {
5228
5229				this.slideshow.destroy();
5230				this.isPlaying = false;
5231				this.options.autoplay = false;
5232			}
5233		},
5234
5235		// public method: shows next image
5236		next : function(e)
5237		{	
5238			e.preventDefault();
5239			this._stopSlideshow();
5240			this._navigate( 'next' );
5241		},
5242
5243		// public method: shows previous image
5244		previous : function(e)
5245		{
5246			e.preventDefault();
5247			this._stopSlideshow();
5248			this._navigate( 'prev' );
5249		},
5250
5251		// public method: goes to a specific image
5252		go2 : function( pos )
5253		{
5254			//if we didnt pass a number directly lets asume someone clicked on a link that triggered the goto transition
5255			if(isNaN(pos))
5256			{
5257				//in that case prevent the default link behavior and set the slide number to the links hash
5258				pos.preventDefault();
5259				pos = pos.currentTarget.hash.replace('#','');
5260			}
5261
5262			pos -= 1;
5263
5264			if( pos === this.current || pos >= this.itemsCount || pos < 0 )
5265			{
5266				return false;
5267			}
5268
5269			this._stopSlideshow();
5270			this._navigate( false, pos );
5271
5272		},
5273
5274		// public method: starts the slideshow
5275		// any call to next(), previous() or goto() will stop the slideshow autoplay
5276		play : function()
5277		{
5278			if( !this.isPlaying )
5279			{
5280				this.isPlaying = true;
5281
5282				this._navigate( 'next' );
5283				this.options.autoplay = true;
5284				this._startSlideshow();
5285			}
5286
5287		},
5288
5289		// public methos: pauses the slideshow
5290		pause : function()
5291		{
5292			if( this.isPlaying )
5293			{
5294				this.slideshow.pause();
5295			}
5296		},
5297
5298		// publiccmethos: resumes the slideshow
5299		resume : function()
5300		{
5301			if( this.isPlaying )
5302			{
5303				this.slideshow.resume();
5304			}
5305		},
5306
5307		// public methos: destroys the instance
5308		destroy : function( callback )
5309		{
5310			this.slideshow.destroy( callback );
5311		}
5312
5313    }
5314
5315    //simple wrapper to call the slideshow. makes sure that the slide data is not applied twice
5316    $.fn.aviaSlider = function( options )
5317    {
5318    	return this.each(function()
5319    	{
5320    		var self = $.data( this, 'aviaSlider' );
5321
5322    		if(!self)
5323    		{
5324    			self = $.data( this, 'aviaSlider', new $.AviaSlider( options, this ) );
5325    		}
5326    	});
5327    }
5328
5329
5330
5331})( jQuery );
5332
5333
5334
5335
5336// -------------------------------------------------------------------------------------------
5337// keyboard controls
5338// -------------------------------------------------------------------------------------------
5339
5340(function($)
5341{
5342	"use strict";
5343
5344	/************************************************************************
5345	keyboard arrow nav
5346	*************************************************************************/
5347	$.fn.avia_keyboard_controls = function(options_passed)
5348	{
5349		var defaults	=
5350		{
5351			37: '.prev-slide',	// prev
5352			39: '.next-slide'	// next
5353		},
5354
5355		methods		= {
5356
5357			mousebind: function(slider)
5358			{
5359				slider.hover(
5360					function(){  slider.mouseover	= true;  },
5361					function(){  slider.mouseover	= false; }
5362				);
5363			},
5364
5365			keybind: function(slider)
5366			{
5367				$(document).keydown(function(e)
5368				{
5369					if(slider.mouseover && typeof slider.options[e.keyCode] !== 'undefined')
5370					{
5371						var item;
5372
5373						if(typeof slider.options[e.keyCode] === 'string')
5374						{
5375							item = slider.find(slider.options[e.keyCode]);
5376						}
5377						else
5378						{
5379							item = slider.options[e.keyCode];
5380						}
5381
5382						if(item.length)
5383						{
5384							item.trigger('click', ['keypress']);
5385							return false;
5386						}
5387					}
5388				});
5389			}
5390		};
5391
5392
5393		return this.each(function()
5394		{
5395			var slider			= $(this);
5396			slider.options		= $.extend({}, defaults, options_passed);
5397			slider.mouseover	= false;
5398
5399			methods.mousebind(slider);
5400			methods.keybind(slider);
5401
5402		});
5403	};
5404
5405
5406	/************************************************************************
5407	swipe nav
5408	*************************************************************************/
5409	$.fn.avia_swipe_trigger = function(passed_options)
5410	{
5411		var win		= $(window),
5412		isMobile	= $.avia_utilities.isMobile,
5413		defaults	=
5414		{
5415			prev: '.prev-slide',
5416			next: '.next-slide',
5417			event: {
5418				prev: 'click',
5419				next: 'click'
5420			}
5421		},
5422
5423		methods = {
5424
5425			activate_touch_control: function(slider)
5426			{
5427				var i, differenceX, differenceY;
5428
5429				slider.touchPos = {};
5430				slider.hasMoved = false;
5431
5432				slider.on('touchstart', function(event)
5433				{
5434					slider.touchPos.X = event.originalEvent.touches[0].clientX;
5435					slider.touchPos.Y = event.originalEvent.touches[0].clientY;
5436				});
5437
5438				slider.on('touchend', function(event)
5439				{
5440					slider.touchPos = {};
5441	                if(slider.hasMoved) { event.preventDefault(); }
5442	                slider.hasMoved = false;
5443				});
5444
5445				slider.on('touchmove', function(event)
5446				{
5447					if(!slider.touchPos.X)
5448					{
5449						slider.touchPos.X = event.originalEvent.touches[0].clientX;
5450						slider.touchPos.Y = event.originalEvent.touches[0].clientY;
5451					}
5452					else
5453					{
5454						differenceX = event.originalEvent.touches[0].clientX - slider.touchPos.X;
5455						differenceY = event.originalEvent.touches[0].clientY - slider.touchPos.Y;
5456
5457						//check if user is scrolling the window or moving the slider
5458						if(Math.abs(differenceX) > Math.abs(differenceY))
5459						{
5460							event.preventDefault();
5461
5462							if(slider.touchPos !== event.originalEvent.touches[0].clientX)
5463							{
5464								if(Math.abs(differenceX) > 50)
5465								{
5466									i = differenceX > 0 ? 'prev' : 'next';
5467
5468									if(typeof slider.options[i] === 'string')
5469									{
5470										slider.find(slider.options[i]).trigger(slider.options.event[i], ['swipe']);
5471									}
5472									else
5473									{
5474										slider.options[i].trigger(slider.options.event[i], ['swipe']);
5475									}
5476
5477									slider.hasMoved = true;
5478									slider.touchPos = {};
5479									return false;
5480								}
5481							}
5482						}
5483	                }
5484				});
5485			}
5486		};
5487
5488		return this.each(function()
5489		{
5490			if(isMobile)
5491			{
5492				var slider	= $(this);
5493
5494				slider.options	= $.extend({}, defaults, passed_options);
5495
5496				methods.activate_touch_control(slider);
5497			}
5498		});
5499	};
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513}(jQuery));
5514
5515
5516
5517

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.