(function(a,i,d,h){var f="parallax";var e=30;var c={relativeInput:false,clipRelativeInput:false,calibrationThreshold:100,calibrationDelay:500,supportDelay:500,calibrateX:false,calibrateY:true,invertX:true,invertY:true,limitX:false,limitY:false,scalarX:10,scalarY:10,frictionX:0.1,frictionY:0.1,originX:0.5,originY:0.5,pointerEvents:true,precision:1};function g(k,m){this.element=k;this.$context=a(k).data("api",this);this.$layers=this.$context.find(".layer");var j={calibrateX:this.$context.data("calibrate-x")||null,calibrateY:this.$context.data("calibrate-y")||null,invertX:this.$context.data("invert-x")||null,invertY:this.$context.data("invert-y")||null,limitX:parseFloat(this.$context.data("limit-x"))||null,limitY:parseFloat(this.$context.data("limit-y"))||null,scalarX:parseFloat(this.$context.data("scalar-x"))||null,scalarY:parseFloat(this.$context.data("scalar-y"))||null,frictionX:parseFloat(this.$context.data("friction-x"))||null,frictionY:parseFloat(this.$context.data("friction-y"))||null,originX:parseFloat(this.$context.data("origin-x"))||null,originY:parseFloat(this.$context.data("origin-y"))||null,pointerEvents:this.$context.data("pointer-events")||true,precision:parseFloat(this.$context.data("precision"))||1};for(var l in j){if(j[l]===null){delete j[l]}}a.extend(this,c,m,j);this.calibrationTimer=null;this.calibrationFlag=true;this.enabled=false;this.depthsX=[];this.depthsY=[];this.raf=null;this.bounds=null;this.ex=0;this.ey=0;this.ew=0;this.eh=0;this.ecx=0;this.ecy=0;this.erx=0;this.ery=0;this.cx=0;this.cy=0;this.ix=0;this.iy=0;this.mx=0;this.my=0;this.vx=0;this.vy=0;this.onMouseMove=this.onMouseMove.bind(this);this.onDeviceOrientation=this.onDeviceOrientation.bind(this);this.onOrientationTimer=this.onOrientationTimer.bind(this);this.onCalibrationTimer=this.onCalibrationTimer.bind(this);this.onAnimationFrame=this.onAnimationFrame.bind(this);this.onWindowResize=this.onWindowResize.bind(this);this.initialise()}g.prototype.transformSupport=function(w){var o=d.createElement("div");var u=false;var v=null;var p=false;var k=null;var s=null;for(var q=0,t=this.vendors.length;q0&&v!=="none";m.style.overflow=n;j.removeChild(o);if(r){j.removeAttribute("style");j.parentNode.removeChild(j)}}break}return p};g.prototype.ww=null;g.prototype.wh=null;g.prototype.wcx=null;g.prototype.wcy=null;g.prototype.wrx=null;g.prototype.wry=null;g.prototype.portrait=null;g.prototype.desktop=!navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|BB10|mobi|tablet|opera mini|nexus 7)/i);g.prototype.vendors=[null,["-webkit-","webkit"],["-moz-","Moz"],["-o-","O"],["-ms-","ms"]];g.prototype.motionSupport=!!i.DeviceMotionEvent;g.prototype.orientationSupport=!!i.DeviceOrientationEvent;g.prototype.orientationStatus=0;g.prototype.transform2DSupport=g.prototype.transformSupport("2D");g.prototype.transform3DSupport=g.prototype.transformSupport("3D");g.prototype.propertyCache={};g.prototype.initialise=function(){if(this.$context.css("position")==="static"){this.$context.css({position:"relative"})}if(!this.pointerEvents){this.$context.css({pointerEvents:"none"})}this.accelerate(this.$context);this.updateLayers();this.updateDimensions();this.enable();this.queueCalibration(this.calibrationDelay)};g.prototype.updateLayers=function(){this.$layers=this.$context.find(".layer");this.depthsX=[];this.depthsY=[];this.$layers.css({position:"absolute",display:"block",left:0,top:0});this.$layers.first().css({position:"relative"});this.accelerate(this.$layers);this.$layers.each(a.proxy(function(l,k){var j=a(k).data("depth")||0;this.depthsX.push(a(k).data("depth-x")||j);this.depthsY.push(a(k).data("depth-y")||j)},this))};g.prototype.updateDimensions=function(){this.ww=i.innerWidth;this.wh=i.innerHeight;this.wcx=this.ww*this.originX;this.wcy=this.wh*this.originY;this.wrx=Math.max(this.wcx,this.ww-this.wcx);this.wry=Math.max(this.wcy,this.wh-this.wcy)};g.prototype.updateBounds=function(){this.bounds=this.element.getBoundingClientRect();this.ex=this.bounds.left;this.ey=this.bounds.top;this.ew=this.bounds.width;this.eh=this.bounds.height;this.ecx=this.ew*this.originX;this.ecy=this.eh*this.originY;this.erx=Math.max(this.ecx,this.ew-this.ecx);this.ery=Math.max(this.ecy,this.eh-this.ecy)};g.prototype.queueCalibration=function(j){clearTimeout(this.calibrationTimer);this.calibrationTimer=setTimeout(this.onCalibrationTimer,j)};g.prototype.enable=function(){if(!this.enabled){this.enabled=true;if(this.orientationSupport){this.portrait=null;i.addEventListener("deviceorientation",this.onDeviceOrientation);setTimeout(this.onOrientationTimer,this.supportDelay)}else{this.cx=0;this.cy=0;this.portrait=false;i.addEventListener("mousemove",this.onMouseMove)}i.addEventListener("resize",this.onWindowResize);this.raf=requestAnimationFrame(this.onAnimationFrame)}};g.prototype.disable=function(){if(this.enabled){this.enabled=false;if(this.orientationSupport){i.removeEventListener("deviceorientation",this.onDeviceOrientation)}else{i.removeEventListener("mousemove",this.onMouseMove)}i.removeEventListener("resize",this.onWindowResize);cancelAnimationFrame(this.raf)}};g.prototype.calibrate=function(j,k){this.calibrateX=j===h?this.calibrateX:j;this.calibrateY=k===h?this.calibrateY:k};g.prototype.invert=function(j,k){this.invertX=j===h?this.invertX:j;this.invertY=k===h?this.invertY:k};g.prototype.friction=function(j,k){this.frictionX=j===h?this.frictionX:j;this.frictionY=k===h?this.frictionY:k};g.prototype.scalar=function(j,k){this.scalarX=j===h?this.scalarX:j;this.scalarY=k===h?this.scalarY:k};g.prototype.limit=function(j,k){this.limitX=j===h?this.limitX:j;this.limitY=k===h?this.limitY:k};g.prototype.origin=function(j,k){this.originX=j===h?this.originX:j;this.originY=k===h?this.originY:k};g.prototype.clamp=function(l,k,j){l=Math.max(l,k);l=Math.min(l,j);return l};g.prototype.css=function(j,o,p){var m=this.propertyCache[o];if(!m){for(var k=0,n=this.vendors.length;kthis.calibrationThreshold)||(Math.abs(n)>this.calibrationThreshold)){this.queueCalibration(0)}if(this.portrait){this.mx=this.calibrateX?n:this.iy;this.my=this.calibrateY?m:this.ix}else{this.mx=this.calibrateX?m:this.ix;this.my=this.calibrateY?n:this.iy}this.mx*=this.ew*(this.scalarX/100);this.my*=this.eh*(this.scalarY/100);if(!isNaN(parseFloat(this.limitX))){this.mx=this.clamp(this.mx,-this.limitX,this.limitX)}if(!isNaN(parseFloat(this.limitY))){this.my=this.clamp(this.my,-this.limitY,this.limitY)}this.vx+=(this.mx-this.vx)*this.frictionX;this.vy+=(this.my-this.vy)*this.frictionY;for(var o=0,p=this.$layers.length;oi.innerWidth;if(this.portrait!==k){this.portrait=k;this.calibrationFlag=true}if(this.calibrationFlag){this.calibrationFlag=false;this.cx=l;this.cy=m}this.ix=l;this.iy=m}};g.prototype.onMouseMove=function(l){var j=l.clientX;var k=l.clientY;if(!this.orientationSupport&&this.relativeInput){if(this.clipRelativeInput){j=Math.max(j,this.ex);j=Math.min(j,this.ex+this.ew);k=Math.max(k,this.ey);k=Math.min(k,this.ey+this.eh)}this.ix=(j-this.ex-this.ecx)/this.erx;this.iy=(k-this.ey-this.ecy)/this.ery}else{this.ix=(j-this.wcx)/this.wrx;this.iy=(k-this.wcy)/this.wry}};var b={enable:g.prototype.enable,disable:g.prototype.disable,updateLayers:g.prototype.updateLayers,calibrate:g.prototype.calibrate,friction:g.prototype.friction,invert:g.prototype.invert,scalar:g.prototype.scalar,limit:g.prototype.limit,origin:g.prototype.origin};a.fn[f]=function(k){var j=arguments;return this.each(function(){var l=a(this);var m=l.data(f);if(!m){m=new g(this,k);l.data(f,m)}if(b[k]){m[k].apply(m,Array.prototype.slice.call(j,1))}})}})(window.jQuery||window.Zepto,window,document);