!function(t){"use strict";t.avia_utilities=t.avia_utilities||{},t(function(){t.fn.avia_parallax&&t(".av-parallax,.av-parallax-object").avia_parallax()});var i=function(i,e){(this.transform||this.transform3d)&&(this.options=t.extend({},i),this.win=t(window),this.body=t("body"),this.isMobile=t.avia_utilities.isMobile,this.winHeight=this.win.height(),this.winWidth=this.win.width(),this.el=t(e).addClass("active-parallax"),this.objectType=this.el.hasClass("av-parallax-object")?"object":"background-image",this.elInner=this.el,this.elBackgroundParent=this.el.parent(),this.elParallax=this.el.data("parallax")||{},this.direction="",this.speed=.5,this.elProperty={},this.ticking=!1,this.isTransformed=!1,void 0===t.avia_utilities.supported.transition&&(t.avia_utilities.supported.transition=t.avia_utilities.supports("transition")),this._init(i))};i.prototype={mediaQueries:{"av-mini-":"(max-width: 479px)","av-small-":"(min-width: 480px) and (max-width: 767px)","av-medium-":"(min-width: 768px) and (max-width: 989px)","av-desktop-":"(min-width: 990px)"},transform:-1!==document.documentElement.className.indexOf("avia_transform"),transform3d:-1!==document.documentElement.className.indexOf("avia_transform3d"),mobileNoAnimation:t("body").hasClass("avia-mobile-no-animations"),defaultSpeed:.5,defaultDirections:["bottom_top","left_right","right_left","no_parallax"],transformCSSProps:["transform","-webkit-transform","-moz-transform","-ms-transform","-o-transform"],matrixDef:[1,0,0,1,0,0],matrix3dDef:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],_init:function(){var t=this;if(void 0!==this.el.data("parallax-selector")&&""!==this.el.data("parallax-selector")&&(this.elInner=this.el.find(this.el.data("parallax-selector")),0==this.elInner.length&&(this.elInner=this.el)),"background-image"==this.objectType){if(this.isMobile&&this.mobileNoAnimation)return;this.elParallax.parallax="bottom_top",this.elParallax.parallax_speed=parseFloat(this.el.data("avia-parallax-ratio"))||.5}setTimeout(function(){t._fetchProperties()},30),this.win.on("debouncedresize av-height-change",t._fetchProperties.bind(t)),this.body.on("av_resize_finished",t._fetchProperties.bind(t)),setTimeout(function(){t.win.on("scroll",t._onScroll.bind(t))},100)},_setParallaxProps:function(){if("background-image"==this.objectType)return this.direction=this.elParallax.parallax,void(this.speed=this.elParallax.parallax_speed);var i=this.elParallax.parallax||"",e=this.elParallax.parallax_speed||"",a="",r="",s="all";if(this.defaultDirections.indexOf(i)<0&&(i="no_parallax"),"function"==typeof window.matchMedia&&t.each(this.mediaQueries,function(t,i){if(window.matchMedia(i).matches)return s=t,!1}),"all"==s)return this.direction=i,void(this.speed=""==e?this.defaultSpeed:parseFloat(e)/100);a=this.elParallax[s+"parallax"]||"",r=this.elParallax[s+"parallax_speed"]||"","inherit"==a&&(a=i,r=e),this.defaultDirections.indexOf(a)<0&&(a="no_parallax"),this.direction=a,this.speed=""==r?this.defaultSpeed:parseFloat(r)/100},_getTranslateObject:function(i){var e={type:"",matrix:[],x:0,y:0,z:0};return t.each(this.transformCSSProps,function(t,a){var r=i.css(a);if("string"==typeof r&&"none"!=r){if(r.indexOf("matrix")>=0){var s=r.match(/matrix.*\((.+)\)/)[1].split(", ");return r.indexOf("matrix3d")>=0?(e.type="3d",e.matrix=s,e.x=s[12],e.y=s[13],e.z=s[14]):(e.type="2d",e.matrix=s,e.x=s[4],e.y=s[5]),!1}e.type="";var l=r.match(/translateX\((-?\d+\.?\d*px)\)/);l&&(e.x=parseInt(l[1],10));var h=r.match(/translateY\((-?\d+\.?\d*px)\)/);h&&(e.y=parseInt(h[1],10))}}),e},_getTranslateMatrix:function(i,e){var a="";if(t.each(e,function(t,e){i[t]=e}),this.transform3d){var r=this.matrix3dDef.slice(0);switch(i.type){case"2d":r[0]=i.matrix[0],r[1]=i.matrix[1],r[4]=i.matrix[2],r[5]=i.matrix[3],r[12]=i.x,r[13]=i.y;break;case"3d":(r=i.matrix.slice(0))[12]=i.x,r[13]=i.y,r[14]=i.z;break;default:r[12]=i.x,r[13]=i.y}a="matrix3d("+r.join(", ")+")"}else if(this.transform){var s=this.matrixDef.slice(0);switch(i.type){case"2d":(s=i.matrix.slice(0))[4]=i.x,s[5]=i.y;break;case"3d":s[0]=i.matrix[0],s[1]=i.matrix[1],s[2]=i.matrix[4],s[3]=i.matrix[5],s[4]=i.x,s[5]=i.y;break;default:s[4]=i.x,s[5]=i.y}a="matrix("+s.join(", ")+")"}return a},_fetchProperties:function(){this._setParallaxProps(),this.el.css(t.avia_utilities.supported.transition+"transform",""),this.winHeight=this.win.height(),this.winWidth=this.win.width(),"background-image"==this.objectType?(this.elProperty.top=this.elBackgroundParent.offset().top,this.elProperty.height=this.elBackgroundParent.outerHeight(),this.el.height(Math.ceil(this.winHeight*Math.abs(this.speed)+this.elProperty.height))):(this.elProperty.top=this.elInner.offset().top,this.elProperty.left=this.elInner.offset().left,this.elProperty.height=this.elInner.outerHeight(),this.elProperty.width=this.elInner.outerWidth(),this.elProperty.bottom=this.elProperty.top+this.elProperty.height,this.elProperty.right=this.elProperty.left+this.elProperty.width,this.elProperty.distanceLeft=this.elProperty.right,this.elProperty.distanceRight=this.winWidth-this.elProperty.left),this.elProperty.translateObj=this._getTranslateObject(this.el),this._parallaxScroll()},_onScroll:function(t){this.ticking||(this.ticking=!0,window.requestAnimationFrame(this._parallaxRequest.bind(this)))},_inViewport:function(t,i,e,a,r,s,l,h){return!(t>s+10||eh+10||is?(p=0,n=0):p=1-(o+d)/this.winHeight,this.direction){case"bottom_top":l=Math.ceil((n-d)*this.speed),c.y=-l,h=this._getTranslateMatrix(this.elProperty.translateObj,{y:-l});break;case"left_right":l=Math.ceil(this.elProperty.distanceRight*p*this.speed),c.x=l,h=this._getTranslateMatrix(this.elProperty.translateObj,{x:l});break;case"right_left":l=Math.ceil(this.elProperty.distanceLeft*p*this.speed),c.x=-l,h=this._getTranslateMatrix(this.elProperty.translateObj,{x:-l})}var x=this._inViewport(this.elProperty.top,this.elProperty.right,this.elProperty.bottom,this.elProperty.left,e,s,a,r),f=this._inViewport(this.elProperty.top+c.y,this.elProperty.right+c.x,this.elProperty.bottom+c.y,this.elProperty.left+c.x,e,s,a,r);(x||f)&&this.el.css(t.avia_utilities.supported.transition+"transform",h),this.ticking=!1,this.isTransformed=!0}else this.ticking=!1}},t.fn.avia_parallax=function(e){return this.each(function(){var a=t(this),r=a.data("aviaParallax");r||(r=a.data("aviaParallax",new i(e,this)))})}}(jQuery);