!function(t,e){var a,n=t.jQuery||t.Cowboy||(t.Cowboy={});n.throttle=a=function(t,a,i,s){var o,r=0;function c(){var n=this,c=+new Date-r,l=arguments;function u(){r=+new Date,i.apply(n,l)}s&&!o&&u(),o&&clearTimeout(o),s===e&&c>t?u():!0!==a&&(o=setTimeout(s?function(){o=e}:u,s===e?t-c:t))}return"boolean"!=typeof a&&(s=i,i=a,a=e),n.guid&&(c.guid=i.guid=i.guid||n.guid++),c},n.debounce=function(t,n,i){return i===e?a(t,n,!1):a(t,i,!1!==n)}}(this),function(t,e,a,n){"use strict";var i=t(e),s=t(a),o="paver",r={failureMessage:"Scroll left/right to pan through panorama.",failureMessageInsert:"after",gracefulFailure:!0,meta:!1,responsive:!0,startPosition:.5,minimumOverflow:200,grain:3,cursorThrottle:1e3/60,gyroscopeThrottle:1e3/60,resizeThrottle:500,mouseSmoothingFunction:"linear",tilt:!0,tiltSensitivity:.1,tiltScrollerPersistence:500,tiltSmoothingFunction:"gaussian",tiltThresholdPortrait:12,tiltThresholdLandscape:24},c={};void 0===console&&(console={},void 0===console.info&&(console.info=function(){}),void 0===console.warn&&(console.warn=function(){}));var l=function(e,a){this.element=e,this.settings=t.extend({},r,a,t(this.element).data()),parseInt(this.settings.grain<=0)&&(this.settings.grain=1),this.settings.startPosition=Math.max(Math.min(this.settings.startPosition,1),0),this.settings.tiltThresholdPortrait=Math.max(Math.min(this.settings.tiltThresholdPortrait,180),0),this.settings.tiltThresholdLandscape=Math.max(Math.min(this.settings.tiltThresholdLandscape,180),0),this._name=o,this.mousemove={},c.features.hasGyroscope?this.init():(c.features.isTouch,this.init())};t.extend(l.prototype,{init:function(){s.trigger("enabled.paver"),u.defineElements(this);var a=this;if(!a.instanceData||!a.instanceData.initialized){a.instanceData={},a.instanceData.initialized=!0,a.instanceData.originalNode=a.$t.html(),u.domReplacement(this),u.getContainerDimensions(this),u.getCenter(this);var n=new Image,o=function(){if(a.$t.trigger("imageLoadDone.paver"),a.instanceData.naturalWidth=a.$p[0].naturalWidth,a.instanceData.naturalHeight=a.$p[0].naturalHeight,a.instanceData.panoAspectRatio=a.instanceData.naturalWidth/a.instanceData.naturalHeight,a.instanceData.containerAspectRatio=a.instanceData.outerWidth/a.instanceData.outerHeight,u.checkURL(a.$p.attr("src")))return!1;u.replacePanorama(a),u.compute(a),u.checkOverflow(a)?(a.instanceData.panCounter=0,a.pan({xPos:a.settings.startPosition,yPos:a.settings.startPosition}),u.paverOn(a)):(a.$t.find("div.paver__pano").css({margin:"auto"}),u.paverOff(a)),i.on("resize",t.throttle(a.settings.resizeThrottle,function(){a.recompute()})),a.$t.on("recompute.paver",function(){a.recompute()}),a.$t.on("destroy.paver",function(){a.destroy()}),a.$t.on("pan.paver",function(t,e){a.pan(e)})},r=!1,c=setInterval(function(){n.naturalWidth&&n.naturalHeight&&(o(),r=!0,e.clearInterval(c))},100);n.onload=function(){r||o(),e.clearInterval(c)},n.src=a.$p.attr("src")}},fallback:function(){if(s.trigger("disabled.paver"),this.settings.gracefulFailure){var e=t(this.element),a=t("
",{class:"paver__fallbackMessage"});switch(e.addClass("paver--fallback"),this.settings.failureMessageInsert.toLowerCase()){case"after":e.after(a.html(this.settings.failureMessage));break;case"before":e.before(a.html(this.settings.failureMessage));break;case"prepend":e.prepend(a.html(this.settings.failureMessage));break;case"append":e.append(a.html(this.settings.failureMessage));break;default:e.after(a.html(this.settings.failureMessage))}e.trigger("fallbackend.paver")}},unbindEvents:function(){t(this.element).off("mousemove.paver devicetilt.paver").removeClass("paver--on").addClass("paver--off")},destroy:function(){var e=t(this.element).data("plugin_paver");e&&(this.unbindEvents(),t(this.element).trigger("destroyed.paver").removeClass("paver--initialized paver--ready").empty().html(e.instanceData.originalNode),t(this.element).data("plugin_paver",null))},recompute:function(){var e=t(this.element),a=e.data("plugin_paver");e.off("mousemove.paver devicetilt.paver"),u.getContainerDimensions(this),a.instanceData.containerAspectRatio=a.instanceData.outerWidth/a.instanceData.outerHeight,e.trigger("recomputeStart.paver"),u.compute(this),u.checkOverflow(this)?(a.pan({xPos:Math.min(a.instanceData.lastPanX,1),yPos:Math.min(a.instanceData.lastPanY,1)}),u.paverOn(this)):u.paverOff(this)},pan:function(e){var a=t(this.element),n=a.find("div.paver__scroller"),s=n.find("span"),o=parseInt(this.settings.grain),r=a.data("plugin_paver");e?(void 0===e.xPos&&(e.xPos=r.settings.startPosition),void 0===e.yPos&&(e.yPos=r.settings.startPosition)):e={xPos:r.settings.startPosition,yPos:r.settings.startPosition},e.xPos>1?e.xPos=1:e.xPos<0&&(e.xPos=0),e.yPos>1?e.yPos=1:e.yPos<0&&(e.yPos=0);var c=e.xPos.toFixed(o),l=e.yPos.toFixed(o);r.instanceData.panCounter&&0!==r.instanceData.panCounter?a.trigger("panStart.paver"):a.trigger("initialPanStart.paver"),a.find("div.paver__pano").css("transform","translate("+-c*(r.instanceData.computedWidth-r.instanceData.outerWidth)+"px, "+-l*(r.instanceData.computedHeight-r.instanceData.outerHeight)+"px)").end().find("div.paver__scroller span").css("transform","translateX("+c*(n.width()-s.width())+"px)").end(),i.one(u.whichTransitionEnd(),function(){r.instanceData.panCounter&&0!==r.instanceData.panCounter?a.trigger("panEnd.paver"):a.trigger("initialPanEnd.paver")}),r.instanceData.panCounter+=1,r.instanceData.lastPanX=c,r.instanceData.lastPanY=l}});var u={whichTransitionEnd:function(){var t,e=a.createElement("div"),n={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",transition:"transitionend"};for(t in n)if(void 0!==e.style[t])return n[t]},normalcdf:function(t,e,a){var n=(a-t)/Math.sqrt(2*e*e),i=1/(1+.3275911*Math.abs(n)),s=1-((((1.061405429*i-1.453152027)*i+1.421413741)*i-.284496736)*i+.254829592)*i*Math.exp(-n*n),o=1;return n<0&&(o=-1),.5*(1+o*s)},smoothingFunction:{linear:function(t,e){return t>=e?1:t<=-e?0:.5*(t/e+1)},tangent:function(t,e){return t>=e?1:t<=-e?0:.5*(.5*Math.tan(t/e*(.351*Math.PI))+1)},cosine:function(t,e){return t>=e?1:t<=-e?0:.5*(Math.sin(t/e*(Math.PI/2))+1)},gaussian:function(t,e){return t>=e?1:t<=-e?0:u.normalcdf(0,.375,t/e)}},defineElements:function(e){e.t=e.element,e.$t=t(e.element),e.$p=e.$t.find("img").first(),e.instanceData=e.$t.data("instance-data")},domReplacement:function(e){e.$t.addClass("paver--initialized").append(t("
",{class:"paver__meta"})),!e.settings.meta||void 0===e.$p.attr("title")&&void 0===e.$p.attr("alt")||!e.$p.attr("title").length&&!e.$p.attr("alt").length||e.$t.addClass("paver--metaActive").find(".paver__meta").html(''+e.$p.attr("title")+''+e.$p.attr("alt")+""),e.$t.trigger("init.paver")},getContainerDimensions:function(t){t.instanceData.outerWidth=t.$t.width(),t.instanceData.outerHeight=t.$t.height(),t.instanceData.offsetX=t.$t.offset().left,t.instanceData.offsetY=t.$t.offset().top},getCenter:function(t){t.instanceData.centerX=.5*t.instanceData.outerWidth,t.instanceData.centerY=.5*t.instanceData.outerHeight},replacePanorama:function(e){var a=t("
",{class:"paver__pano"}).css("background-image","url("+u.formatURL(e.$p.attr("src"))+")").css("background-size","cover"),n=t("
",{class:"paver__scroller"}).append(t(""));e.$t.addClass("paver--ready").append(a).append(n),e.$p.remove(),e.$t.trigger("ready.paver"),e.instanceData.ready=!0},checkOverflow:function(t){return t.instanceData.containerAspectRatio<=t.instanceData.panoAspectRatio&&t.instanceData.outerWidth<=t.instanceData.computedWidth-t.settings.minimumOverflow},paverOn:function(t){t.$t.removeClass("paver--off").addClass("paver--on").find("div.paver__pano").css("left",0),u.bindEvents(t)},paverOff:function(t){t.unbindEvents(t),t.settings.responsive&&(t.instanceData.naturalWidth<=t.instanceData.outerWidth||t.$t.find("div.paver__pano").css({margin:"auto"}))},compute:function(t){t.instanceData.computedWidth=t.instanceData.outerHeight*t.instanceData.panoAspectRatio,t.instanceData.computedHeight=t.instanceData.computedWidth/t.instanceData.panoAspectRatio,u.getCenter(t),t.$t.find("div.paver__pano").css({width:t.instanceData.computedWidth,height:t.instanceData.outerHeight}),t.$t.trigger("computeEnd.paver")},bindEvents:function(t){c.features.isTouch?c.features.hasGyroscope&&t.settings.tilt&&u.bindOrientationEvents(t):u.bindMouseEvents(t),t.$t.trigger("eventsBound.paver")},bindMouseEvents:function(e){e.$t.on("mousemove.paver",t.throttle(e.settings.cursorThrottle,function(t){if(e.mousemove.dX=t.pageX-e.instanceData.offsetX-e.instanceData.centerX,e.mousemove.dY=t.pageY-e.instanceData.offsetY-e.instanceData.centerY,"string"==typeof e.settings.mouseSmoothingFunction)u.defaultSmooth(e,e.settings.mouseSmoothingFunction,e.mousemove.dX,e.instanceData.centerX,e.mousemove.dY,e.instanceData.centerY);else if("function"==typeof e.settings.mouseSmoothingFunction){var a=e.settings.mouseSmoothingFunction.call(e,e.mousemove.dX,e.instanceData.centerX,e.mousemove.dY,e.instanceData.centerY);if(void 0===a)return void u.defaultSmooth(e,r.settings.mouseSmoothingFunction,e.mousemove.dX,e.instanceData.centerX,e.mousemove.dY,e.instanceData.centerY);e.pan({xPos:a.x,yPos:a.y})}}))},bindOrientationEvents:function(a){a.instanceData.prevTilt={};var n=null;a.$t.on("devicetilt.paver",t.throttle(a.settings.gyroscopeThrottle,function(i,s){if(0===a.settings.tiltScrollerPersistence)a.$t.addClass("paver--tilting");else if(!t.isEmptyObject(a.instanceData.prevTilt)&&(Math.abs(a.instanceData.prevTilt.b-s.b)>a.settings.tiltSensitivity||Math.abs(a.instanceData.prevTilt.g-s.g)>a.settings.tiltSensitivity)||t.isEmptyObject(a.instanceData.prevTilt)){a.$t.addClass("paver--tilting"),null!==n&&clearTimeout(n),n=e.setTimeout(function(){a.$t.removeClass("paver--tilting")},a.settings.tiltScrollerPersistence);var o,r={};switch(c.screenOrientationAngle){case 0:r={beta:s.b,gamma:s.g},o=a.settings.tiltThresholdPortrait;break;case 180:case-180:r={beta:-s.b,gamma:-s.g},o=a.settings.tiltThresholdPortrait;break;case 90:case-270:r={beta:-s.g,gamma:s.b},o=a.settings.tiltThresholdLandscape;break;case 270:case-90:r={beta:s.g,gamma:-s.b},o=a.settings.tiltThresholdLandscape;break;default:r={beta:s.b,gamma:s.g},o=a.settings.tiltThresholdPortrait}if("string"==typeof a.settings.tiltSmoothingFunction)u.defaultSmooth(a,a.settings.tiltSmoothingFunction,r.gamma,o,r.beta,o);else if("function"==typeof a.settings.tiltSmoothingFunction){var l=a.settings.mouseSmoothingFunction.call(a,r.gamma,o,r.beta,o);if(void 0===l)return void u.defaultSmooth(a,a.settings.tiltSmoothingFunction,r.gamma,o,r.beta,o);a.pan({xPos:l.x,yPos:l.y})}a.instanceData.prevTilt={a:s.a,b:s.b,g:s.g}}}))},defaultSmooth:function(t,e,a,n,i,s){var o=u.smoothingFunction[e];t.pan({xPos:o(a,n),yPos:o(i,s)})},checkURL:function(t){var e=0;return/[\s+]/g.test(t)?(console.warn("Paver: Paver has detected characters in your URL string ("+t+") that need to be properly encoded/escaped. Whitespace(s) have to be escaped manually. See RFC3986 documentation."),e=1):/[\"\'\(\)]/g.test(t)&&(console.warn("Paver: Plugin will proceed, but it has detected characters in your URL string ("+t+") that need to be properly encoded/escaped. These will be escaped for you. See RFC3986 documentation."),e=0),e},formatURL:function(t){return t.replace(/"/g,"%22").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29")}};t.fn.paver=function(n){var i=this,u=arguments;c={features:{isTouch:!1,hasGyroscope:!1,hasScreenOrientationAPI:!(!e.screen||!e.screen.orientation||void 0===e.screen.orientation.angle||null===e.screen.orientation.angle)},screenOrientationAngle:null,startTilt:{}};var p=function(){var a=new t.Deferred,n=function(t){return null!==t.alpha&&null!==t.beta&&null!==t.gamma?a.resolve({orientation:{alpha:t.alpha,beta:t.beta,gamma:t.gamma},status:{deviceOrientationEventSupport:!0,deviceOrientationData:!0}}):a.reject({status:{deviceOrientationEventSupport:!0,deviceOrientationData:!1}}),e.removeEventListener("deviceorientation",n,!1),!0,a.promise()};return e.DeviceOrientationEvent?(e.addEventListener("deviceorientation",n,!1),e.setTimeout(function(){return console.info("DeviceOrientationEvent support is detected, but browser is not feeding any gyroscopic data. Will not check for further gyroscopic data."),a.reject({status:{deviceOrientationEventSupport:!0,deviceOrientationData:!1}}),a.promise()},250)):a.reject({status:{deviceOrientationEventSupport:!1,deviceOrientationData:!1}}),a.promise()},d=function(){c.screenOrientationAngle=c.features.hasScreenOrientationAPI?e.screen.orientation.angle:e.orientation||0};(function(){try{a.createEvent("TouchEvent"),c.features.isTouch=!0}catch(t){c.features.isTouch=!1}})(),d(),e.addEventListener("orientationchange",function(){d(),p()},!1);var h=function(){var a,i=t(this);return c.features.hasGyroscope&&e.addEventListener("deviceorientation",function(t){var e={a:t.alpha-c.startTilt.alpha,b:t.beta-c.startTilt.beta,g:t.gamma-c.startTilt.gamma};i.trigger("devicetilt.paver",[e])},!1),void 0===n||"object"==typeof n?i.each(function(){t.data(this,"plugin_"+o)||t.data(this,"plugin_"+o,new l(this,n))}):"string"==typeof n&&"_"!==n[0]&&"init"!==n?(i.each(function(){var e=t.data(this,"plugin_"+o);e instanceof l&&"function"==typeof e[n]&&(a=e[n].apply(e,Array.prototype.slice.call(u,1)))}),void 0!==a?a:i):void 0},g=function(t){c.features.hasGyroscope=!0,c.startTilt.alpha=t.orientation.alpha,c.startTilt.beta=t.orientation.beta,c.startTilt.gamma=t.orientation.gamma,s.trigger("hasGyroscopeData.paver",[t]),h.call(i)},v=function(){console.info("Gyroscopic data unavailable. Falling back to cursor-based panning."),c.features.hasGyroscope=!1;s.trigger("hasNoGyroscopeData.paver",[{status:{deviceOrientationEventSupport:!1,deviceOrientationData:!1}}]),h.call(i)},f=t.extend({},r,n,t(this.element).data());return t.when(p()).then(function(t){void 0===t||!0!==f.tilt?v():g(t)},function(){v()}),i}}(jQuery,window,document);