PageSourceSearch

https://www.crazybananas.com/wp-content/themes/enfold/js/shortcodes.js?ver=4.1

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

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.