(function(c,l){function g(a,d,e){this.area=a;this.element=document.createElement("div");this.element.className="panoramaViever";this.imageUrl=d;this.loaded=!1;this.width=a.clientWidth;this.height=a.clientHeight;this._fullscreen=!1;a.appendChild(this.element);"object"===typeof e&&("undefined"!==typeof e.context&&(c=e.context),isNaN(e.width)||(this.width=e.width),isNaN(e.height)||(this.height=e.height),"undefined"!==typeof e.aspectRatio&&(this.aspectRatio=e.aspectRatio));this.init()}g.prototype.setStyles= function(a,d){this.element.style.backgroundImage="url('"+this.imageUrl+"')";this.element.style.width=String(a)+"px";this.element.style.height=String(d)+"px";this.element.style.backgroundRepeat="repeat-x";this.element.style.mozBackgroundSize="auto "+String(d)+"px";this.element.style.oBackgroundSize="auto "+String(d)+"px";this.element.style.webkitBackgroundSize="auto "+String(d)+"px";this.element.style.backgroundSize="auto "+String(d)+"px";this.element.style.backgroundPosition="0 0"};g.prototype.init= function(){var a=this,d=new Image;d.onload=function(){a.loaded=!0;a.aspectRatio=d.naturalWidth/d.naturalHeight;a.setStyles(a.width,a.height);c.Hammer(a.area,{swipe_velocity:0.04}).on("pinchin",function(b){a.zoomOut(0.66+0.33*b.gesture.scale)}).on("pinchout",function(b){a.zoomIn(0.66+0.33*b.gesture.scale)}).on("drag",function(b){a.drag(b.gesture.deltaX>>5,b.gesture.deltaY>>5)});var e=function(b){"undefined"!==typeof b.wheelDeltaY?0b.detail?a.zoomIn(1.05):a.zoomOut(0.95)};a.area.addEventListener("mousewheel",e,!0);a.area.addEventListener("DOMMouseScroll",e,!0)};d.src=a.imageUrl};g.prototype.makeFullscreen=function(){var a=this;if(a.element.requestFullscreen)a.element.requestFullscreen(),c.document.addEventListener("fullscreenchange",function(){if(null===c.document.fullScreenElement)a.setStyles(a.width,a.height),a._fullscreen=!1;else return a.setStyles(c.outerWidth,c.innerHeight), a._fullscreen=!0});else if(a.element.msRequestFullscreen)a.element.msRequestFullscreen(),c.document.addEventListener("MSFullscreenChange",function(){if(null===c.document.msFullscreenElement)a.setStyles(a.width,a.height),a._fullscreen=!1;else return a.setStyles(c.screen.width,c.screen.height),a._fullscreen=!0});else if(a.element.mozRequestFullScreen)a.element.mozRequestFullScreen(),c.document.onmozfullscreenchange=function(){if(null===c.document.mozFullScreenElement)a.setStyles(a.width,a.height),a._fullscreen= !1;else return a.setStyles(c.outerWidth,c.outerHeight),a._fullscreen=!0};else if(a.element.webkitRequestFullscreen)a.element.webkitRequestFullscreen(),c.document.addEventListener("webkitfullscreenchange",function(){if(null===c.document.webkitFullscreenElement)a.setStyles(a.width,a.height),a._fullscreen=!1;else return a.setStyles(c.outerWidth,c.outerHeight),a._fullscreen=!0});else return alert("Your browser doesn't support fullscreen API"),!1};g.prototype.zoomIn=function(a){var d=(this.element.style.backgroundSize|| this.element.style.msBackgroundSize||this.element.style.mozBackgroundSize||this.element.style.webkitBackgroundSize||this.element.style.oBackgroundSize).split(" "),d=parseFloat(d[1].replace("px","")),e=d*this.aspectRatio;a*=d;var b=a*this.aspectRatio,c=this.element.style.backgroundPosition.split(" "),f=parseFloat(c[0].replace("px","")),c=parseFloat(c[1].replace("px","")),f=((this.width>>1)-f)/e,c=((this.height>>1)-c)/d;this.element.style.backgroundSize=String(b)+"px "+String(a)+"px";this.element.style.msBackgroundSize= String(b)+"px "+String(a)+"px";this.element.style.mozBackgroundSize=String(b)+"px "+String(a)+"px";this.element.style.webkitBackgroundSize=String(b)+"px "+String(a)+"px";this.element.style.oBackgroundSize=String(b)+"px "+String(a)+"px";this.drag(f*(e-b),c*(d-a))};g.prototype.zoomOut=function(a){var d=this.element.style.backgroundSize||this.element.style.msBackgroundSize||this.element.style.mozBackgroundSize||this.element.style.webkitBackgroundSize||this.element.style.oBackgroundSize,e=d.split(" "), e=parseFloat(e[1].replace("px","")),b=e*this.aspectRatio;a*=e;if(!(a<(this._fullscreen?c.screen.height:this.area.clientHeight))){var h=a*this.aspectRatio,f=this.element.style.backgroundPosition;d.split(" ");f=f.split(" ");d=parseFloat(f[0].replace("px",""));f=parseFloat(f[1].replace("px",""));d=((this.width>>1)-d)/b;f=((this.height>>1)-f)/e;202*f&&(b-=f);b<-2*f&&(b+=f);this.element.style.backgroundPosition=Math.ceil(b)+"px "+Math.ceil(g)+"px"};c.PanoramaViever=g})(window,Hammer);