// Created 4/22/2014 10:21:27 AM
var iosContent={CONTENT_LOAD_COMPLETE:"CONTENT_LOAD_COMPLETE",initPageContentAPI:function(b){b.highlightContainer=el.createElement("div",{position:"absolute"});b.initContentImage=function(){this.image=el.createElement("img",{styles:this.styleObj});this.image.parent=this.parentObject};b.initContentDiv=function(){this.div=el.createElement("div",{styles:this.styleObj},this.parentObject)};b.displayDOMHighlight=function(){if(search.active&&search.pages[this.position]){var b=this;highlight.getHighlights(this.position,
function(a){b.clearDOMHighlights();b.div.appendChild(b.highlightContainer);parseContentItems("highlight",a,b.highlightContainer,b.scale)})}else this.clearDOMHighlights()};b.clearDOMHighlights=function(){deleteAllChildren(this.highlightContainer);this.div.contains(this.highlightContainer)&&this.div.removeChild(this.highlightContainer)};b.setHighlight=function(b){b?this.displayDOMHighlight():this.clearDOMHighlights()};b.rebuildTop=function(){this.div&&!hasClearChildrenBug?deleteAllChildren(this.div):
(this.div&&this.div.parentNode&&this.div.parentNode.removeChild(this.div),this.initContentDiv());this.loaded&&(this.vector&&parseVectorizedContentToDiv(this.vector,this.div,this.scale),parseContentItems("link",publicationData.page[this.position].links,this.div,this.scale),parseContentItems("video",publicationData.page[this.position].videos,this.div,this.scale),"undefined"!==typeof publicationData.shopInfo&&parseContentItems("cartItem",publicationData.page[this.position].shopItems,this.div,this.scale,
publicationData.getPageProperty(this.position,"contentScale")),this.displayDOMHighlight())};b.hidePreloader=function(){};b.onComplete=function(){};b.setIndex=function(b){if(this.position!=b){this.position=b;this.vector=null;this.loaded=!1;deleteAllChildren(this.div);var a=this;loadManager.addPageToQueue({skipCurrentLoading:!0,image:this.image,quality:!0,position:this.position,onImageLoadComplete:function(){},onPageLoadError:function(){a.loaded=!1},onAllIsComplete:function(c,h){a.vector=h;a.loaded=
!0;a.rebuildTop();a.hidePreloader();if(a.onComplete)a.onComplete();customEvents.fireEvent(PAGE_CONTENT_DISPLAYED);a.dispatcher.fireEvent(iosContent.CONTENT_LOAD_COMPLETE,{position:a.position})},onJSLoadComplete:function(){}})}};b.dispatcher=new CustomEvents},setContent:function(b,d,a){a=a||bookModel.getRect(d);var c=publicationData.page[d].BGColor||publicationData.page.defaults.BGColor;b.style.backgroundColor=c;if(publicationData.page[d].stub)return el.css(b,{"background-repeat":"no-repeat","background-size":"0% 0%",
"background-position-y":"0%","background-position-x":"0%","background-color":c}),!1;el.css(b,{"background-size":100*a.contentWidth/a.pageWidth+"% "+100*a.contentHeight/a.pageHeight+"%","background-position":"center center"});c={};c.styleObj={position:"absolute",top:a.padding[0]+"px",left:a.padding[1]+"px",width:a.contentWidth+"px",height:a.contentHeight+"px"};this.initPageContentAPI(c);c.parentObject=b;c.initContentImage();c.scale=a.contentWidth/publicationData.getPageProperty(d,"width");hasClearChildrenBug||
c.initContentDiv();c.setIndex(d);return c},addContainer:function(b,d,a){a=a||!1;d="current"===d?pageMediator.page:"left"===d?pageMediator.rtl?1*pageMediator.page+1:pageMediator.page-1:pageMediator.rtl?pageMediator.page-1:1*pageMediator.page+1;if(1>d||d>publicationData.pageCount)return a=el.createElement("div",{id:"stopSlide",styles:{width:"100%",height:"100%",position:"absolute","background-size":"cover"}},b),{container:a,object:null};var c=bookModel.getRect(d),h=publicationData.page[d].BGColor||
publicationData.page[d].BGColor;a?(a=a.cloneNode(!1),el.clear(a),el.css(a,{width:c.pageWidth+"px",height:c.pageHeight+"px","background-size":100*c.contentWidth/c.pageWidth+"% "+100*c.contentHeight/c.pageHeight+"%","background-position":"center center"}),b.appendChild(a)):a=el.createElement("div",{"data-wide":publicationData.page[d].wide?"true":"false",styles:{width:c.pageWidth+"px",height:c.pageHeight+"px",position:"absolute",overflow:"hidden","background-repeat":"no-repeat","background-origin":"padding-box",
"background-size":100*c.contentWidth/c.pageWidth+"% "+100*c.contentHeight/c.pageHeight+"%","background-position":"center center","background-color":h}},b);return{object:this.setContent(a,d,c),container:a}},resultBlockStore:"",isBlock:function(b,d){var a=pageMediator.page,c=bookModel.getRect(a,bookModel.zoomLevel),h=(b-c.padding[1])/c.ratio,e=(d-c.padding[0])/c.ratio;if(publicationData.page[a].blocks)for(var m=0,k=publicationData.page[a].blocks.length;m<k;m++){var f=publicationData.page[a].blocks[m];
if(h>=f.rect[0]&&h<=f.rect[0]+f.rect[2]&&e>=f.rect[1]&&e<=f.rect[1]+f.rect[3]){h={rect:[]};h.rect[0]=f.rect[0]*c.ratio-5*(window.devicePixelRatio||1);h.rect[1]=f.rect[1]*c.ratio;h.rect[2]=f.rect[2]*c.ratio+10*(window.devicePixelRatio||1);h.rect[3]=f.rect[3]*c.ratio;h.rect[0]+=c.padding[1];h.rect[1]+=c.padding[0];if(this.resultBlockStore===a+"-"+m)return this.resultBlockStore="",!1;this.resultBlockStore=a+"-"+m;return h}}this.resultBlockStore="";return!1},resizeContainer:function(b,d){var a;switch(d){case "current":a=
pageMediator.page;break;case "left":a=pageMediator.rtl?1*pageMediator.page+1:pageMediator.page-1;break;case "right":a=pageMediator.rtl?pageMediator.page-1:1*pageMediator.page+1;break;default:a=d}if(!(1>a||a>publicationData.pageCount)){var c=bookModel.getRect(a);el.clear(b);if(c.pageWidth!==b.getBoundingClientRect().width||c.pageHeight!==b.getBoundingClientRect().height)return el.css(b,{width:c.pageWidth+"px",height:c.pageHeight+"px"}),this.setContent(b,a,c);if(-1===b.style.backgroundImage.indexOf("page"+
this._getNum(a)+"_"))return this.setContent(b,a,c)}},_getNum:function(b){b="000"+page;9<page&&(b="00"+page);99<page&&(b="0"+page);999<page&&(b=""+page);return b},linksSh:function(b){b=b.getElementsByClassName("link");for(var d=0,a=b.length;d<a;d++)b[d].style.webkitAnimation="linkss 2s"}};
function PagePreloader(){function b(){d&&(a+=30,c.style.webkitTransform="rotate("+a+"deg)")}var d=!1,a=0,c=el.createElement("div",{styles:{position:"absolute",left:"50%",top:"50%",margin:"-"+40*(window.devicePixelRatio||1)/2+"px 0 0 -"+40*(window.devicePixelRatio||1)/2+"px",backgroundImage:"url("+STYLES_FOLDER+"/preloader.png)",backgroundSize:"cover",width:34*(window.devicePixelRatio||1)+"px",height:34*(window.devicePixelRatio||1)+"px"}});c.style.webkitTransition="-webkit-transform 0ms";c.style.webkitTransitionTimingFunction=
"cubic-bezier(0,0,1,1)";c.style.webkitTransitionDelay="80ms";c.style.webkitTransform="rotate("+a+"deg)";c.addEventListener("webkitTransitionEnd",b);this.show=function(){d||(d=!0,window.resources.MAIN_FRAME.appendChild(c),setTimeout(b,100))};this.hide=function(){d&&(d=!1,window.resources.MAIN_FRAME.removeChild(c))}}window.pagePreloader=new PagePreloader;
!function(){function b(){function a(a,c){this.x=a;this.y=c}this.MAX_RESOLUTION=15E6*(window.devicePixelRatio||1);this.mainContainer=el.id("mainFrame");this.globalWidth=this.mainContainer.clientWidth;this.globalHeight=this.mainContainer.clientHeight;this.maxPullSize=this.globalWidth/7;this.currentPageCorner=new a(0,0);this.leftPageCorner=new a(0,0);this.rightPageCorner=new a(0,0);this.contentCorner=new a(0,0);this.leftContentCorner=new a(0,0);this.rightContentCorner=new a(0,0);this.contentCornerStore=
new a(0,0);this.currentPageCornerStore=new a(0,0);this._newWrapper("current");this._newWrapper("right");this._newWrapper("left");var c=this;customEvents.addListener(ROTATE_DEVICE,function(){c._orientationChange.call(c)});this._bindDom();this.setHighlight=function(a){a||(search.active=!1);["left","right","current"].forEach(function(c){(c=this[c+"ContentObject"])&&c.setHighlight(a)},this)};this.updatePreloader();Hammer(el.id("mainFrame"),{stop_browser_behavior:!0,prevent_default:!0}).on("swipeleft",
function(a){"wrapper"===a.target.className&&pageMediator.right()});Hammer(el.id("mainFrame"),{stop_browser_behavior:!0,prevent_default:!0}).on("swiperight",function(a){"wrapper"===a.target.className&&pageMediator.left()})}b.prototype._orientationChange=function(){this.refresh.call(this);bookModel.getRect(pageMediator.page,bookModel.zoomLevel);var a=this.currentContentElement.getBoundingClientRect();if(this.globalWidth>a.width||1.05>bookModel.zoomLevel)bookModel.zoomLevel=1,iosContent.resizeContainer(this.currentContentElement,
"current");iosContent.resizeContainer(this.leftContentElement,"left");iosContent.resizeContainer(this.rightContentElement,"right");this._initSizes(0)};b.prototype._startRender=function(a){this.contentCornerStore.x=this.contentCorner.x;this.contentCornerStore.y=this.contentCorner.y;this.currentPageCornerStore.x=this.currentPageCorner.x;this.currentPageCornerStore.y=this.currentPageCorner.y;this._render(a)};b.prototype._render=function(a,c){c=c||0;a&&(this.contentCorner.x=this.contentCornerStore.x+
a.deltaX,this.contentCorner.y=this.contentCornerStore.y+a.deltaY);var b=this.contentCorner.x-this.currentPageCornerStore.x,e=this.contentCorner.y-this.currentPageCornerStore.y;0>this.deltaHeight?(this.contentCorner.y=Math.abs(this.deltaHeight)/2,this.currentPageCorner.y=0):0<e?(a||(this.contentCorner.y=this.currentPageCorner.y),this.contentCorner.y=this.currentPageCorner.y+this.contentCorner.y/3):Math.abs(e)>this.deltaHeight?(a||(this.contentCorner.y=this.currentPageCorner.y-this.deltaHeight),this.contentCorner.y=
this.currentPageCorner.y-this.deltaHeight+(this.contentCorner.y+this.deltaHeight)/3):this.currentPageCorner.y=this.currentPageCornerStore.y;0>this.deltaWidth?(this.currentPageCorner.x=this.contentCorner.x-Math.abs(this.deltaWidth)/2,this.contentCorner.x=Math.abs(this.deltaWidth)/2):0<b?(this.currentPageCorner.x=this.contentCorner.x,this.contentCorner.x=0):Math.abs(b)>this.deltaWidth?(this.currentPageCorner.x=this.contentCorner.x+this.deltaWidth,this.contentCorner.x=-this.deltaWidth):this.currentPageCorner.x=
this.currentPageCornerStore.x;this.leftPageCorner.x=this.currentPageCorner.x-this.globalWidth;this.rightPageCorner.x=this.currentPageCorner.x+this.globalWidth;this.leftPageCorner.y=this.currentPageCorner.y;this.rightPageCorner.y=this.currentPageCorner.y;this._setStyles(c)};b.prototype._stopRender=function(a,c,b){c=void 0===c?200:c;b=b||!1;var e=this;if("stop"!==b&&(0>this.currentPageCorner.x&&Math.abs(this.currentPageCorner.x)>this.maxPullSize||"left"===b)){if(!b&&!pageMediator.checkSlide("left")){this._render(!1,
c);return}this._animationEnd=function(a){b||(e.fireTrigger=!0,pageMediator.right());e._goToLeft.call(e,a);e.updatePreloader();customEvents.fireEvent(SLIDE_ANIMATION_END)};this.currentContainerElement.addEventListener("webkitTransitionEnd",this._animationEnd);this.contentCorner.x=-(this.globalWidth+this.deltaWidth);0>this.deltaWidth&&(this.contentCorner.x+=this.deltaWidth/2)}else if("stop"!==b&&(0<this.currentPageCorner.x&&Math.abs(this.currentPageCorner.x)>this.maxPullSize||"right"===b)){if(!b&&!pageMediator.checkSlide("right")){this._render(!1,
c);return}this._animationEnd=function(a){b||(e.fireTrigger=!0,pageMediator.left());e._goToRight.call(e,a);e.updatePreloader();customEvents.fireEvent(SLIDE_ANIMATION_END)};this.currentContainerElement.addEventListener("webkitTransitionEnd",this._animationEnd);this.contentCorner.x=this.globalWidth;0>this.deltaWidth&&(this.contentCorner.x-=this.deltaWidth/2)}this._render(!1,c)};b.prototype._startZoomRender=function(a){this._unbindDragEvent();var c=this.currentContentElement.getBoundingClientRect(),b=
a.gesture.center.pageY-c.top;a=a.gesture.center.pageX-c.left;this.transformStore=d(this.currentContentElement.style.webkitTransform);this.transformStore.accamulatedScale=1;this.currentContentElement.style.webkitTransition="-webkit-transform 0ms";this.currentContentElement.style.webkitTransformOrigin=a+"px "+b+"px";this.minZoom=bookModel.getRect(pageMediator.page,1).pageHeight/this.currentContentElement.clientHeight;this.maxZoom=fbUtils.getMaxZoom(this.MAX_RESOLUTION,bookModel.getRect(pageMediator.page).pageWidth,
bookModel.getRect(pageMediator.page).pageHeight)};b.prototype._stopZoomRender=function(a){var c=this.currentContentElement.parentNode.getBoundingClientRect(),b=this.currentContentElement.getBoundingClientRect();bookModel.setZoomLevel(b);a=Math.round(b.top-c.top);var c=Math.round(b.left-c.left),e=iosContent.addContainer(this.currentContainerElement,"current",this.currentContentElement),d=e.container,k=this;el.css(d,{webkitTransform:"translate3d("+c+"px,"+a+"px, 0px)"});setTimeout(function(){el.del(k.currentContentElement);
k.currentContentElement=d;k.currentContentObject=e.object;setTimeout(function(){iosContent.resizeContainer(k.leftContentElement,"left");iosContent.resizeContainer(k.rightContentElement,"right")},200);k.refresh.call(k,50)},150)};b.prototype._zoomRender=function(a,c){c=c||0;var b=Math.max(a.gesture.scale,this.minZoom),b=Math.min(b,this.maxZoom),e="translate3d("+this.transformStore.translate.x+"px,"+this.transformStore.translate.y+"px, 0px)",e=e+(" scale("+b+")");if(c){this.currentContentElement.style.webkitTransition=
"-webkit-transform 200ms";this.currentContentElement.style.webkitTransitionTimingFunction="cubic-bezier(0.4, 0, 1, 1)";var d=this,k=function(){d._stopZoomRender.call(d,a);d.currentContainerElement.removeEventListener("webkitTransitionEnd",k);k=null};this.currentContainerElement.addEventListener("webkitTransitionEnd",k)}this.currentContentElement.style.webkitTransform=e;this.transformStore.accamulatedScale=b};b.prototype._setStyles=function(a,c){a=a||0;c=c||"cubic-bezier(0,0,1,1)";this.leftContainerElement.style.webkitTransition=
"-webkit-transform "+a+"ms";this.currentContainerElement.style.webkitTransition="-webkit-transform "+a+"ms";this.rightContainerElement.style.webkitTransition="-webkit-transform "+a+"ms";this.currentContentElement.style.webkitTransition="-webkit-transform "+a+"ms";this.leftContainerElement.style.webkitTransitionTimingFunction=c;this.currentContainerElement.style.webkitTransitionTimingFunction=c;this.rightContainerElement.style.webkitTransitionTimingFunction=c;this.currentContentElement.style.webkitTransitionTimingFunction=
c;this.leftContainerElement.style.webkitTransform="translate3d("+this.leftPageCorner.x+"px,"+this.leftPageCorner.y+"px,0px)";this.currentContainerElement.style.webkitTransform="translate3d("+this.currentPageCorner.x+"px,"+this.currentPageCorner.y+"px,0px)";this.rightContainerElement.style.webkitTransform="translate3d("+this.rightPageCorner.x+"px,"+this.rightPageCorner.y+"px,0px)";this.currentContentElement.style.webkitTransform="translate3d("+this.contentCorner.x+"px,"+this.contentCorner.y+"px,0px)"};
b.prototype._setCorners=function(){var a=this.leftContentElement.clientWidth-this.globalWidth,c=this.rightContentElement.clientWidth-this.globalWidth,b=this.leftContentElement.clientHeight-this.globalHeight,e=this.rightContentElement.clientHeight-this.globalHeight;this.leftContentCorner.x=0>a?this.leftContentCorner.x+a/2:this.leftContentCorner.x-1;this.rightContentCorner.x=0>c?this.rightContentCorner.x-c/2:this.rightContentCorner.x+1;this.leftContentCorner.y=0>b?this.leftContentCorner.y-b/2:this.leftContentCorner.y+
1;this.rightContentCorner.y=0>e?this.rightContentCorner.y-e/2:this.rightContentCorner.y+1;this.leftContentElement.style.webkitTransform="translate3d("+this.leftContentCorner.x+"px,"+this.leftContentCorner.y+"px,0px)";this.rightContentElement.style.webkitTransform="translate3d("+this.rightContentCorner.x+"px,"+this.rightContentCorner.y+"px,0px)"};b.prototype._initSizes=function(a){a=a||0;this.leftPageCorner.x=-this.globalWidth;this.rightPageCorner.x=this.globalWidth;this.deltaWidth=this.currentContentElement.clientWidth-
this.globalWidth;this.deltaHeight=this.currentContentElement.clientHeight-this.globalHeight;var c=d(this.currentContentElement.style.webkitTransform);this.contentCorner.x=c.translate.x;this.contentCorner.y=c.translate.y;0===this.contentCorner.x&&0>this.deltaWidth&&(this.contentCorner.x=-this.deltaWidth/2);this.leftContentCorner.x=-(this.leftContentElement.clientWidth-this.globalWidth);this.leftContentCorner.y=0;this.rightContentCorner.x=0;this.rightContentCorner.y=0;this.contentCornerStore.x=0;this.contentCornerStore.y=
0;this.currentPageCornerStore.x=0;this.currentPageCornerStore.y=0;this._setCorners();this._render(!1);this._stopRender(!1,a,"stop")};b.prototype._tapStart=function(){};b.prototype._tapMove=function(){};b.prototype._tapEnd=function(){};b.prototype._animationEnd=function(){};b.prototype._bindDom=function(a){a=a||0;this._bindDragEvent();this._bindPinchEvent();Hammer(this.currentContainerElement,{prevent_default:!0}).on("drag",function(){});Hammer(this.mainContainer,{prevent_default:!0}).on("drag",function(){});
var c=this;iosContent.linksSh(this.currentContentElement);Hammer(this.currentContentElement,{prevent_default:!0}).on("release",function(){c._unbindDragEvent();c._unbindPinchEvent();c._bindDragEvent();c._bindPinchEvent()});this._initSizes(a)};b.prototype._bindDragEvent=function(){var a=this;this._tapStart=function(c){a._unbindPinchEvent();a._startRender.call(a,{deltaX:c.gesture.deltaX,deltaY:c.gesture.deltaY})};this._tapMove=function(c){a._render.call(a,{deltaX:c.gesture.deltaX,deltaY:c.gesture.deltaY})};
this._tapEnd=function(c){a._stopRender.call(a,{deltaX:c.gesture.deltaX,deltaY:c.gesture.deltaY})};this._swipeLeft=function(){"true"===a.currentContentElement.getAttribute("data-wide")&&a.currentContentElement.getBoundingClientRect().left>-(a.globalWidth/2)&&(a.contentCorner.x=a.currentContainerElement.getBoundingClientRect().width-a.currentContentElement.getBoundingClientRect().width)};this._swipeRight=function(){"true"===a.currentContentElement.getAttribute("data-wide")&&a.currentContentElement.getBoundingClientRect().left<
a.globalWidth/2&&(a.contentCorner.x=0)};Hammer(this.currentContentElement,{prevent_default:!0,fb_lock_to_axis:!0}).on("dragstart",this._tapStart);Hammer(this.currentContentElement,{prevent_default:!0,fb_lock_to_axis:!0}).on("drag",this._tapMove);Hammer(this.currentContentElement,{prevent_default:!0,fb_lock_to_axis:!0}).on("dragend",this._tapEnd);Hammer(this.currentContentElement,{prevent_default:!0}).on("swipeleft",this._swipeLeft);Hammer(this.currentContentElement,{prevent_default:!0}).on("swiperight",
this._swipeRight)};b.prototype._unbindDragEvent=function(){Hammer(this.currentContentElement,{prevent_default:!0,fb_lock_to_axis:!0}).off("dragstart",this._tapStart);Hammer(this.currentContentElement,{prevent_default:!0,fb_lock_to_axis:!0}).off("drag",this._tapMove);Hammer(this.currentContentElement,{prevent_default:!0,fb_lock_to_axis:!0}).off("dragend",this._tapEnd);Hammer(this.currentContentElement,{prevent_default:!0}).off("swipeleft",this._swipeLeft);Hammer(this.currentContentElement,{prevent_default:!0}).off("swiperight",
this._swipeRight)};b.prototype._bindPinchEvent=function(){var a=this;this._pinchStart=function(c){a._startZoomRender(c)};this._pinchMove=function(c){a._zoomRender(c)};this._pinchEnd=function(c){a._stopZoomRender(c)};Hammer(this.currentContentElement,{prevent_default:!0}).on("transformstart",this._pinchStart);Hammer(this.currentContentElement,{prevent_default:!0}).on("pinch",this._pinchMove);Hammer(this.currentContentElement,{prevent_default:!0}).on("transformend",this._pinchEnd);this._doubletap=function(c){var b=
a.currentContentElement.getBoundingClientRect(),e=iosContent.isBlock(c.gesture.center.pageX-b.left,c.gesture.center.pageY-b.top);if(e){var d={width:e.rect[2],height:e.rect[3],top:e.rect[1],left:e.rect[0]},e=window.innerWidth/d.width,k=Math.sqrt(this.MAX_RESOLUTION/(b.width*b.height));k<e&&(e=k);k={width:d.width*e,height:d.height*e,top:(window.innerHeight-d.height*e)/2,left:(window.innerWidth-d.width*e)/2};b=a._correctionCenter(b,d,k);c.gesture.center.pageX=b.x;c.gesture.center.pageY=k.height<window.innerHeight?
b.y:c.gesture.center.pageY;b=a._comeOutCorrection.call(a,c.gesture.center.pageX,c.gesture.center.pageY,e);c.gesture.center.pageX=b.x;c.gesture.center.pageY=b.y;a._startZoomRender(c);c.gesture.scale=e}else 1.05>bookModel.zoomLevel?(b=a._comeOutCorrection.call(a,c.gesture.center.pageX,c.gesture.center.pageY,2),c.gesture.center.pageX=b.x,c.gesture.center.pageY=b.y,a._startZoomRender(c),c.gesture.scale=2):(e=bookModel.getRect(pageMediator.page,1).pageHeight/a.currentContentElement.clientHeight,b=a._comeOutCorrection.call(a,
c.gesture.center.pageX,c.gesture.center.pageY,e),c.gesture.center.pageX=b.x,c.gesture.center.pageY=b.y,a._startZoomRender(c),c.gesture.scale=e);a._zoomRender(c,100)};Hammer(this.currentContentElement,{prevent_default:!0}).on("doubletap",this._doubletap)};b.prototype._comeOutCorrection=function(a,c,b){var e=this.currentContentElement.getBoundingClientRect(),e={top:Math.round(e.top),left:Math.round(e.left),width:Math.round(e.width),height:Math.round(e.height)};c-=e.top;a-=e.left;a=e.left+(a-a*b);c=
e.top+(c-c*b);var d=e.width*b;b*=e.height;return this._correctionCenter(e,{left:0,top:0,width:e.width,height:e.height},{left:d<window.innerWidth?(window.innerWidth-d)/2:a+d<window.innerWidth?window.innerWidth-d:0<a?0:a,top:b<window.innerHeight?(window.innerHeight-b)/2:c+b<window.innerHeight?window.innerHeight-b:0<c?0:c,width:d,height:b})};b.prototype._correctionCenter=function(a,c,b){var d=a.left+c.left-b.left,m=a.top+c.top-b.top;return{x:c.left+a.left+c.width/((d+(b.left+b.width-(a.left+c.left+c.width)))/
d),y:c.top+a.top+c.height/((m+(b.top+b.height-(a.top+c.top+c.height)))/m)}};b.prototype._unbindPinchEvent=function(){Hammer(this.currentContentElement,{prevent_default:!0}).off("transformstart",this._pinchStart);Hammer(this.currentContentElement,{prevent_default:!0}).off("pinch",this._pinchMove);Hammer(this.currentContentElement,{prevent_default:!0}).off("transformend",this._pinchEnd);Hammer(this.currentContentElement,{prevent_default:!0}).off("doubletap",this._doubletap)};b.prototype._unbindDom=
function(){this.currentContainerElement.removeEventListener("webkitTransitionEnd",this._animationEnd);this._unbindDragEvent();this._unbindPinchEvent()};b.prototype.setContainerAs=function(a,c){this[c+"ContainerElement"]=this[a+"ContainerElement"];this[c+"ContentElement"]=this[a+"ContentElement"];this[c+"ContentObject"]=this[a+"ContentObject"]};b.prototype._goToLeft=function(){bookModel.resetZoomLevel();iosContent.resizeContainer(this.currentContentElement,"left");this._unbindDom();this.mainContainer.removeChild(this.leftContainerElement);
this.setContainerAs("current","left");this.setContainerAs("right","current");this._newWrapper("right");this._bindDom()};b.prototype._goToRight=function(){bookModel.resetZoomLevel();iosContent.resizeContainer(this.currentContentElement,"right");this._unbindDom();this.mainContainer.removeChild(this.rightContainerElement);this.setContainerAs("current","right");this.setContainerAs("left","current");this._newWrapper("left");this._bindDom()};b.prototype._newWrapper=function(a){a=a||"right";var c=el.createElement("div",
{"class":"wrapper"}),b=iosContent.addContainer(c,a);"left"===a?this.mainContainer.insertBefore(c,this.mainContainer.getElementsByTagName("div")[0]):this.mainContainer.appendChild(c);this[a+"ContainerElement"]=c;this[a+"ContentElement"]=b.container;this[a+"ContentObject"]=b.object};b.prototype.right=function(){this._stopRender(!1,100,"right")};b.prototype.left=function(){this._stopRender(!1,100,"left")};b.prototype.updatePreloader=function(){if(this.currentContentObject&&!this.currentContentObject.loaded){pagePreloader.show();
var a=function(c){pagePreloader.hide();c.target.removeListener(iosContent.CONTENT_LOAD_COMPLETE,a)};this.currentContentObject.dispatcher.addListener(iosContent.CONTENT_LOAD_COMPLETE,a)}else this.currentContentObject&&pagePreloader.hide()};b.prototype.goToPage=function(a){if(a!=pageMediator.previousPage)if(bookModel.resetZoomLevel(),this.fireTrigger)this.fireTrigger=!1;else{var c=function(a,c,b){el.clear(this[a+"ContentElement"]);this[a+"ContentElement"].style.backgroundImage="";this[a+"ContentObject"]=
iosContent.resizeContainer(this[a+"ContentElement"],c);this.updatePreloader();this._initSizes(0);var d=this.currentContentElement,f=this,r=function(){iosContent.resizeContainer(d,b);f._initSizes(0);customEvents.removeListener(SLIDE_ANIMATION_END,r)};customEvents.addListener(SLIDE_ANIMATION_END,r)};a>parseInt(pageMediator.previousPage,10)?pageMediator.rtl?(1<Math.abs(pageMediator.previousPage-a)&&c.call(this,"left",a,a-1),this.right()):(1<Math.abs(pageMediator.previousPage-a)&&c.call(this,"right",
a,a-1),this.left()):a<pageMediator.previousPage&&(pageMediator.rtl?(1<Math.abs(pageMediator.previousPage-a)&&c.call(this,"right",a,a+1),this.left()):(1<Math.abs(pageMediator.previousPage-a)&&c.call(this,"left",a,a+1),this.right()))}};b.prototype.refresh=function(a){this.width=innerWidth;this.height=innerHeight;a=a||0;this.globalWidth=this.mainContainer.clientWidth;this.globalHeight=this.mainContainer.clientHeight;this.maxPullSize=this.globalWidth/7;this._unbindDom();this._bindDom(a)};var d=function(a){function c(a){return parseInt(a.replace("px",
""),10)}a=a.match(/[^(),\s]+/g);var b={};if(null===a)return b.translate={x:0,y:0,z:0},b;for(var d=0,m=a.length;d<m;d++)switch(a[d]){case "translate":b.translate={x:c(a[d+1]),y:c(a[d+2]),z:0};break;case "translateX":b.translate={x:c(a[d+1]),y:0,z:0};break;case "translateY":b.translate={x:0,y:c(a[d+1]),z:0};break;case "translate3d":b.translate={x:c(a[d+1]),y:c(a[d+2]),z:c(a[d+3])};break;case "translateZ":b.translate={x:0,y:0,z:c(a[d+1])}}return b};window.Slide=b}();
function setElementPosition(b,d){b.style.left=String(d.left).concat("px");b.style.top=String(d.top).concat("px")}function flipPage(b){b?pageMediator.right():pageMediator.left()}function hidePreloader(){window.preloaderIsShown&&(workspace.preloader.del(),window.preloaderIsShown=!1)}function showPreloader(){window.preloaderIsShown||(window.preloaderIsShown=!0,workspace.preloader.add())}function dev_rotateXY(b){return"rotate("+b.toString()+"rad)"}
function deleteAllChildren(b){for(;b.firstChild;)b.removeChild(b.firstChild)}function sizeDiv(b,d,a,c){void 0==d&&void 0==a&&(d=window.innerWidth,a=window.innerHeight);b.style.width=c?d+"%":Math.ceil(d)+"px";b.style.height=c?a+"%":Math.ceil(a)+"px"}function px(b){return b.toString()+"px"}
function parseVectorizedContentToDiv(b,d,a,c){c="undefined"!=typeof c?c:!0;for(var h=0;4>h;h++);d=d||createDiv();for(var h=[],e=0;e<b.length;e++){var m=b[e],k=0,f=m[k++].toString(),r=m[k++].toString(),s=parseFloat(m[k++]);parseFloat(m[k++]);var x=parseFloat(m[k++]),q=parseFloat(m[k++]),n=parseFloat(m[k++]),l=m[k++].toString(),m=parseFloat(m[k++]),t=Math.round(q*a),k=q=document.createElement("p");k.style.position="absolute";k.style.whiteSpace="nowrap";q.innerText=f;q.style.fontFamily=r;k.style.top=
px(Math.round(x*a));k.style.left=px(t);r=n;x=h[r];n="undefined"==typeof x?Math.floor(n*a):x.size;q.style.fontSize=px(n);q.style.color=l;d.appendChild(k);s*=a;if(c)for(;q.offsetWidth>s&&1<n;)n-=1,q.style.fontSize=px(n);if("undefined"==typeof x)h[r]={size:n,elements:[q]};else if(x.size>=n){if(x.size>n){h[r].size=n;for(var y in x.elements)l=x.elements[y],n=l.offsetWidth,l.style.fontSize=px(h[r].size),l.style.wordSpacing="0px",l.style.wordSpacing=px((n-l.offsetWidth)/(l.innerText.split(" ").length-1))}h[r].elements.push(q)}q.style.webkitTransform=
m?dev_rotateXY(m):"";q.style.webkitTransformOrigin=m?"0 0":"";f=f.split(" ");q.style.wordSpacing="0px";q.style.wordSpacing=px((s-q.offsetWidth)/(f.length-1))}return d}function getDefaultMobileScaleMode(b,d,a,c){var h={};switch(b){case PT_CATALOG:case PT_MAGAZINE:h.isHalfPage=!d&&a;case PT_BOOK:case PT_DOCUMENT:h.fitMode=c?"screen":"width";break;case PT_PHOTOALBUM:h.fitMode="screen";break;default:throw"unknown publication type";}return h}
function getKeepZoomScaleWhileFlipping(b){return-1!=[PT_BOOK,PT_DOCUMENT].indexOf(b)}
function determineScaleMap(b,d){var a=getDefaultMobileScaleMode(publicationData.type,"tablet"==system.device.type,d,innerWidth<=innerHeight),c=a.isHalfPage?2:1,h=(new Vector2(innerWidth,innerHeight)).stretchToMe(b.x/c/b.y,!0).x/b.x,c=innerWidth/(b.x/c),e=c/0.8,a=["screen"==a.fitMode?h:c];ALBUM?(h=Math.sqrt(e/c),a=a.concat([c*h,e])):h=1.5;for(;2.15>a[a.length-1]*h;)a[a.length]=a[a.length-1]*h;return{defaultPos:0,map:a,textVisibleMaxPos:4}}var v=window.system.platform.version;
window.hasClearChildrenBug="safari"==window.system.browser.name&&fbUtils.isArray(v)&&2<=v.length&&"4"==v[0]&&2<=v[1];
function parseContentItems(b,d,a,c,h){if("undefined"!=typeof d&&d)for(var e=0,m=d.length;e<m;e++){var k=d[e],f={cart:publicationData.shopInfo?cart:null,searchHighlightColor:publicationData.visibility.search?highlight.getFillStyle():null,linkHighlightColor:publicationData.linkcolor,onInternalLinkClick:function(a){pageMediator.goToPage(parseInt(a))},getVideoImageUrl:function(a){return video.getVideoImageUrl(a)},videoPlayImage:video.getPlayImage(),onVideoClick:function(a){video.play(a.type,a.id,function(){system.platform.ios||
(window.resources.MAIN_FRAME.style.visibility="visible")});system.platform.ios||(window.resources.MAIN_FRAME.style.visibility="hidden")},formCartItemOptions:function(a,c){function b(a,c){return a.hasOwnProperty(c)?a[c]:publicationData.shopInfo.cartIconGlobals[c]}return{orientation:b(a,"position"),circleColor:b(a,"circleColor"),priceColor:b(a,"priceColor"),priceTagColor:b(a,"priceTagColor"),priceTagOpacity:b(a,"priceTagColorAlpha"),tagVisible:b(a,"tagVisible"),basketColor:b(a,"basketColor"),showTitle:b(a,
"showTitle"),cost:c.price,title:c.name,onClickAction:b(a,"onClickAction")}},onCartItemClick:function(a,b,c){a?(new ProductInfoWindow(b.id)).show():window.location.href=c.url},onNewCartItemRenderConstruction:function(a){window.cartRenders.push(a)}};parseContentItem(b,k,a,c,f,h)}}
function parseContentItem(b,d,a,c,h,e){var m=new Vector2(d.x,d.y),k=new Vector2(d.width,d.height),f=document.createElement("div");f.style.position="absolute";m=m.mul(c);k=k.mul(c);(function(a,b,c,d){a.style[HTML5lib.browserPrefix+"TransformOrigin"]="0 0";var e=d?Math.sin(d):0;d=d?Math.cos(d):1;a.style[HTML5lib.browserPrefix+"Transform"]="matrix("+[d,e,-e,d,b.x,b.y].join()+")";sizeDiv(a,c.x,c.y,!1)})(f,m,k,d.angle);"undefined"!=typeof d.zindex&&(f.style.zIndex=d.zindex);if("highlight"==b)f.style.backgroundColor=
h.searchHighlightColor,a.appendChild(f);else if("link"==b)f.style.backgroundColor=h.linkHighlightColor,f.style.opacity="0",f.style.webkitAnimation="linkss 2s",f.className="link",c=d.urls,Hammer(f,{prevent_default:!0,stop_browser_behavior:!0}).on("touch",function(){f.style.opacity="0.3"}),Hammer(f,{prevent_default:!0,stop_browser_behavior:!0}).on("drag transform hold release",function(){f.style.opacity="0"}),c&&0!=c.length?(function(a){var b=!1,c=function(a,c){setTimeout(function(){b?b=!1:(a.stopPropagation(),
window.location=c)},300)};Hammer(f,{prevent_default:!0,stop_browser_behavior:!0}).on("tap",function(b){c(b,a[0])});Hammer(f,{prevent_default:!0,stop_browser_behavior:!0}).on("doubletap",function(){b=!0})}(c),a.appendChild(f)):"undefined"!==typeof d.page&&(function(a){var b=!1,c=function(a,c){setTimeout(function(){b?b=!1:(a.stopPropagation(),h.onInternalLinkClick(c))},300)};Hammer(f,{prevent_default:!0,stop_browser_behavior:!0}).on("tap",function(b){c(b,a)});Hammer(f,{prevent_default:!0,stop_browser_behavior:!0}).on("doubletap",
function(){b=!0})}(d.page),a.appendChild(f));else if("video"==b){f.id="video."+d.id;if(d.showImage){var r=h.getVideoImageUrl(d.imageUri);(function(a){changeUrlWhenPubl(r,function(b){a.style.backgroundImage="url('"+b+"')";a.style.backgroundSize="cover";a.style.backgroundPosition="center"})})(f)}b=new Image;c*=d.height;c=50<c?50:0.8*c;b.src=h.videoPlayImage;f.appendChild(b);b.style.position="absolute";b.style.margin="auto";b.style.left="0";b.style.right="0";b.style.top="0";b.style.bottom="0";b.style.height=
c+"px";var s=!1,x=function(a){setTimeout(function(){s?s=!1:(a.stopPropagation(),h.onVideoClick(d))},300)};Hammer(f,{prevent_default:!0,stop_browser_behavior:!0}).on("tap",function(a){x(a)});Hammer(f,{prevent_default:!0,stop_browser_behavior:!0}).on("doubletap",function(){s=!0});a.appendChild(f)}else"cartItem"==b&&function(b,c,d,e){cart.getItems(function(f){f=f[0];var k=h.formCartItemOptions(b,f),m=new CartItemRender(b.id,c,d,e,k,a,cart);(function(a,b,c,d){b.div.style.pointerEvents="auto";var e=!1,
f=function(b){setTimeout(function(){e?e=!1:(b.stopPropagation(),h.onCartItemClick("Window"==c.onClickAction,a,d))},300)};Hammer(b.div,{prevent_default:!0,stop_browser_behavior:!0}).on("tap",function(a){f(a)});Hammer(b.div,{prevent_default:!0,stop_browser_behavior:!0}).on("doubletap",function(){e=!0});h.onNewCartItemRenderConstruction(b)})(b,m,k,f)},function(){throw"productsDB error";},b.id)}(d,m,k,c*e)}
function CartItemRender(b,d,a,c,h,e,m){this.itemID=b||NaN;b=18*c;var k=14*c,f=!1!==h.tagVisible,r=!1!==h.showTitle&&"string"===typeof h.title&&""!=h.title,s=12*c,x=5*c,q=5*c,n=r?0:3*c;a.x=Math.max(a.x,5*b);a.y=Math.max(a.y,3*b);var l=-1!=h.orientation.indexOf("top"),t=-1!=h.orientation.indexOf("left"),y=-1!=h.orientation.indexOf("bottom"),y=!l&&!y;e=el.createElement("div",{id:"cartItem-"+(1E3*Math.random()).toFixed(0),styles:{position:"absolute",cursor:"pointer",borderRadius:x+"px",fontFamily:"Arial",
textAlign:"center",color:h.priceColor}},e);d.applyAsPosition(e);d=new Vector2(b,y?n:b);var w=a.sub(new Vector2(d.x,d.y*(y?2:1)));w.applyAsSize(e);d.applyAsMargin(e,t,y?null:l);f&&(e.style.background="rgba("+fbUtils.hexToRGB(h.priceTagColor)+","+h.priceTagOpacity+")",a=el.createElement("p",{styles:{fontWeight:"bold",fontSize:k+"px",lineHeight:k+"px"}},null,{textContent:fbUtils.formatPrice(h.cost)}),r?(r=new Vector2(w.x-10*c,w.y-k-q),d=el.createElement("p",{styles:{fontSize:s+"px",lineHeight:s+"px",
width:r.x+"px"}},e,{textContent:h.title}),f=d.offsetHeight,q=el.createElement("p",{styles:{fontSize:s+"px",lineHeight:s+"px",marginLeft:5*c+"px",marginRight:5*c+"px",marginBottom:q+"px"}},e,{textContent:h.title}),f<r.y?(e.removeChild(d),s=(r.y-f)/2):(f=r.y-r.y%s,s=(r.y-f)/2,e.removeChild(d),q.style.maxWidth=r.x+"px",q.style.overflow="hidden",q.style.textOverflow="ellipsis",q.style.maxHeight=f+"px"),q.style.marginTop=s+"px"):(s=(w.y-k)/2,a.style.marginTop=s+"px"),a.style.marginBottom=s+"px",function(a,
b){a.style.maxWidth=w.x+"px";a.style.whiteSpace="nowrap";a.style.overflow="hidden";a.style.textOverflow="ellipsis"}(a,k),e.appendChild(a));c*=3;h=el.createElement("span",{styles:{position:"absolute",background:h.circleColor,borderRadius:b+"px",borderWidth:c+"px",borderColor:"white",borderStyle:"solid",color:h.basketColor,verticalAlign:"middle"}},e);k=(new Vector2(b,b)).mul(2);k.applyAsSize(h);s=k.x/2;h.style.lineHeight=k.x-2*c+"px";h.style.fontSize=s+"px";(new Vector2(-b,y?w.y/2-b:-b)).applyAsPosition(h,
t,y||l);this.updateQuantity=function(){var a=m.getItemQuantity(this.itemID);if("undefined"==typeof this.qty||this.qty!=a)this.qty=a,this.circleSpan.className=(0<a?"fullCartButtonInPage":"cartButtonInPage")+" cartIconShadow"};this.div=e;this.circleSpan=h;this.updateQuantity()}
function OnePage(b,d){function a(){var a;publicationData.shopInfo&&(window.cartRenders=[]);t?(g.div.parentNode&&g.div.parentNode.removeChild(g.div),q()):deleteAllChildren(g.div);g.loaded?((a=document.getElementById("stubPage"))&&b.contains(a)&&b.removeChild(a),g.vector&&parseVectorizedContentToDiv(g.vector,g.div,F),a=n().stretchToMe(g.publishedSize.proportions(),!0).x/g.publishedSize.x,sizeDiv(g.div,n().x,n().y),parseContentItems("link",publicationData.page[u].links,g.div,a),parseContentItems("video",
publicationData.page[u].videos,g.div,a),publicationData.shopInfo&&parseContentItems("cartItem",publicationData.page[u].shopItems,g.div,a,publicationData.getPageProperty(u,"contentScale")),s()):h()&&(a=document.getElementById("stubPage")||createDiv("stubPage"),sizeDiv(a,this.width,this.height),a.style.backgroundColor=publicationData.getPageProperty(u,"BGColor"),b.contains(a)||b.appendChild(a))}function c(b,c){if(u!=b)if(u&&h(u)&&!h(b)&&(g.image.style.visibility="visible"),u=b,fconsole.update("pos",
u),y||showPreloader(),h())g.loaded=!1,w||(g.image.style.visibility="hidden"),g.rasterSize.set(publicationData.getPageProperty(u,"width"),publicationData.getPageProperty(u,"height")),d(!0),a(),hidePreloader(),c&&c();else{g.vector=null;g.publishedSize=new Vector2(publicationData.getPageProperty(u,"width"),publicationData.getPageProperty(u,"height"));z.style.backgroundColor=publicationData.getPageProperty(u,"BGColor");K=publicationData.getPageProperty(u,"wide");var e;G&&(e="undefined"==typeof g.isWide||
g.isWide!=K,g.isWide=K,d(e));deleteAllChildren(g.div);loadManager.addPageToQueue({skipCurrentLoading:!0,image:g.image,quality:!0,position:u,onImageLoadComplete:function(){C=!0;g.loaded=!0;w&&A.createPattern(g.image,"no-repeat");var a=new Vector2(g.image.naturalWidth,g.image.naturalHeight);G||(e=g.rasterSize.x!=a.x||g.rasterSize.y!=a.y);g.rasterSize=a;G||d(e)},onPageLoadError:function(){g.loaded=!1},onAllIsComplete:function(b,d){g.vector=d;a();hidePreloader();c&&c()},onJSLoadComplete:function(){}})}}
function h(a){a=void 0!=a?a:u;return publicationData.getPageProperty(a,"stub")}function e(){B.width=this.width;B.height=this.height}function m(){if(g.loaded||h()){var a=B.width,b=B.height;if(C||E||H||I){A.clearRect(0,0,a,b);if(h())A.fillStyle=publicationData.getPageProperty(u,"BGColor"),A.fillRect(0,0,a,b);else{var c=g.image,d=D,e=F,f=Math.round(d.x),d=Math.round(d.y),k=0<f?0:Math.abs(f/e),m=0<d?0:Math.abs(d/e),a=Math.min(c.width*e,a)/e-k,b=Math.min(c.height*e,b)/e-m;(a||b)&&A.drawImage(c,f,d,c.width*
e,c.height*e);c=Math.round(D.x);e=Math.round(D.y);r(g.div,c,e,!1)}I=H=E=C=!1}}}function k(){sizeDiv(b,this.width,this.height)}function f(){if(H||C||I){var a=n(),b=function(a){return Math.floor(a)},c=a.stretchToMe(g.rasterSize.x/g.rasterSize.y,!0).map(b);c.applyAsSize(g.image);c.applyAsSize(g.div);b=a.getCenterPosition(c).map(b);b.applyAsPosition(g.image);b.applyAsPosition(g.div);a.applyAsSize(z);g.widthScale=a.x!==c.x?a.x:a.y;C=H=!1}if(E||I)a=Math.round(D.x),c=Math.round(D.y),r(z,a,c,!1),I=E=!1}function r(a,
b,c,d){d=d?"%":"px";a.style.left=b.toString()+d;a.style.top=c.toString()+d}function s(){search.active&&search.pages[u]?highlight.getHighlights(u,function(a){x();g.div.appendChild(J);parseContentItems("highlight",a,J,F)}):x()}function x(){deleteAllChildren(J);g.div.contains(J)&&g.div.removeChild(J)}function q(){g.div=createDiv("contentDiv");w?b.appendChild(g.div):(g.div.style.webkitTransform=null,z.appendChild(g.div))}function n(a){a=a||F;return(G?g.isWide?L:G:g.publishedSize).map(function(b){return Math.floor(b*
a)})}var l=window.system.platform.version,t="safari"==window.system.browser.name&&fbUtils.isArray(l)&&2<=l.length&&"4"==l[0]&&2<=l[1],y="safari"==window.system.browser.name&&fbUtils.isArray(l)&&3==l.length&&"4"==l[0]&&"0"==l[1]&&"4"==l[2],w=!1,z=createDiv("scrollDiv"),g={},B=document.createElement("canvas"),A=B.getContext("2d");g.loaded=!1;var C,D=new Vector2(0,0),F=0.1,E,H,I,u;g.rasterSize=new Vector2;g.publishedSize=new Vector2(100,100);var K;this.goToPage=function(a){c(a,function(){})};this.resize=
function(b,c){this.width=b;this.height=c;a();w?e():k()};this.setOffset=function(a,b){D.set(a);b||(E=!0)};this.getScale=function(){return F};this.setScale=function(a,b){F=a;b||(H=!0)};this.startPinchMode=function(){g.div.style.visibility="hidden";w||(this.pinchRedrawInterval=setInterval(function(){I=!0},1E3))};this.stopPinchMode=function(){a();this.pinchRedrawInterval&&(clearInterval(this.pinchRedrawInterval),this.pinchRedrawInterval=null);g.div.style.visibility="visible";H=E=!0};this.updateTopContent=
function(){a()};var J=createDiv("highlightContainer");this.setHighlight=function(a){a?s():(search.active=!1,x())};this.set=function(a,d){w?(b.style.overflow="visible",b.appendChild(B)):(b.style.position="absolute",z.style.webkitTransform=null,b.style.webkitTransform=null,b.style.overflow="hidden",b.appendChild(z));g.image=new Image;w||(g.image.style.webkitTransform=null,g.image.style.position="absolute",z.appendChild(g.image));q();c(a,d)};var G=publicationData.size&&publicationData.size.width&&publicationData.size.height?
new Vector2(publicationData.size.width,publicationData.size.height):null,L=G.vclone();L.x*=2;this.getScaledSize=n;this.getImageLoaded=function(){return g.loaded};this.isStub=function(){return h()};this.getOriginalSize=function(){return n(1)};this.drawFrame=w?m:f;this.getIsWide=function(){return K}}
function SimpleViewer(b){function d(){lastTime=(new Date).getTime();window.requestAnimFrame=window.requestAnimFrame||function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)}}();(function C(){t.drawFrame();requestAnimFrame(C)})()}function a(a,b){a!=n&&(n=a,fconsole.update("scale",n),t.setScale(n,b),b||r())}function c(a,b){a.sub(q).vlength()&&
(q=a,t.setOffset(q,b))}function h(a,b){var c=new e(b);return a.clip(c.xmin,c.ymin,c.xmax,c.ymax)}function e(a){var b=t.getScaledSize(a).x;a=t.getScaledSize(a).y;var c=a>innerHeight;b>innerWidth?(this.xmax=0,this.xmin=innerWidth-b):this.xmax=this.xmin=innerWidth/2-b/2;c?(this.ymax=0,this.ymin=innerHeight-a):this.ymax=this.ymin=innerHeight/2-a/2}function m(b,d,e){var g=n;b=d&&f(l.map,n)!=l.defaultPos?l.defaultPos:f(l.map,n*(d?2:1))+(d?0:b?1:-1);b=Math.min(Math.max(b,0),l.map.length-1);b=l.map[b];e=
e?e:ALBUM?new Vector2(innerWidth/2,innerHeight/2):new Vector2(publicationData.rtlMode?innerWidth:0,0);g=q.sub(e.sub(q).mul(b/g-1));g=h(g,b);a(b);c(g);t.updateTopContent()}function k(b,d,e){var g,f=t.getOriginalSize(),k=(g="change"==b)&&d;d="resize"==b;b=l;if(k||d)b=determineScaleMap(f,t.getIsWide());f=n;if(k||g&&!B)f=b.map[b.defaultPos];var k=t.getScaledSize(f).x,m=t.getScaledSize(f).y,u=q.vclone();d?publicationData.rtlMode&&(u.x+=e):u.x=ALBUM?(innerWidth-k)/2:publicationData.rtlMode?innerWidth-k:
0;g&&(u.y=ALBUM?(innerHeight-m)/2:0);e=h(u,f);g=f;l=b;c(e);a(g);r()}function f(a,b){for(var c=0;c<a.length;c++){var d=a[c];if(0==c){if(b<=d||1==a.length)return 0}else{if(c==a.length-1)return a.length-1;if(b<a[c])return b<=(a[c-1]+a[c])/2?c-1:c;if(b<=(a[c]+a[c+1])/2)return c}}throw"determineScale abnormal return";}function r(){customEvents.fireEvent(ZOOM_LEVEL_CHANGED_FOR_WORKSPACE,{isSmallest:0==f(l.map,n),isLargest:f(l.map,n)==l.map.length-1})}function s(a,b,d){function e(a){a.ctrlKey&&(b.sendPinch&&
(b.startPinch&&b.startPinch(new Vector2(a.pageX,a.pageY)),b.sendPinch(s,new Vector2(0,0),new Vector2(a.pageX,a.pageY)),b.endPinch&&b.endPinch()),a.stopImmediatePropagation());a.altKey&&b.sendPinch&&(b.startPinch&&b.startPinch(new Vector2(a.pageX,a.pageY)),b.sendPinch(w,new Vector2(0,0),new Vector2(a.pageX,a.pageY)),b.endPinch&&b.endPinch());a.shiftKey&&b.handleDoubleClick(a);var c=a.currentTarget;if(Modernizr.touch){if(1<a.touches.length){f(a);return}c.addEventListener(DOWN_EVENT,f,!1)}c.removeEventListener(DOWN_EVENT,
e,!1);c.addEventListener(MOVE_EVENT,g,!1);c.addEventListener(UP_EVENT,l,!1);c.addEventListener("touchcancel",l,!1);c.addEventListener("mouseout",l,!1);a=a.touches?a.touches[0]:a;c.pos=new Vector2(a.pageX,a.pageY);r()}function g(a){a.preventDefault();var b=a.touches?a.touches[0]:a,b=new Vector2(b.pageX,b.pageY),e=a.currentTarget.pos;a.currentTarget.pos=b;a=b.sub(e);p.dv0x=p.dv0x||a.x;if(p.timeStamp){b=(new Date).getTime();e=b-p.timeStamp;p.vDiff=p.vDiff.add(a);p.moveTime+=e;p.timeStamp=b;p.trackLength+=
Math.abs(a.x);p.movePath.push({dv:a,time:e});b=t.getScaledSize(void 0).x<=innerWidth||t.isStub();d&&(e=p.vDiff.y?Math.abs(p.vDiff.x)/Math.abs(p.vDiff.y):1E10,Math.abs(p.vDiff.x)>y/1.5*(1.5-e)?p.horizontalAllowed=!0:!p.vDiff.y||1.5<e||p.horizontalAllowed||(a.x=0));if(1E3<p.moveTime||p.dv0x&&a.x&&p.dv0x/Math.abs(p.dv0x)!=a.x/Math.abs(a.x))p.slideDisabledThisTime=!0;!p.slideDisabledThisTime&&p.vDiff.x&&0.5>Math.abs(p.vDiff.y)/Math.abs(p.vDiff.x)&&(a.y=0);if(b&&!p.slideDisabledThisTime&&4<p.trackLength&&
75<p.moveTime){for(var f=p.movePath,b=t.getScaledSize(void 0).y>innerHeight,k,l,A,m=A=l=e=k=0;m<f.length;m++){var n=f[m];k+=n.dv.x;e+=n.dv.y;l+=Math.abs(n.dv.x);A+=n.time}f=Math.abs(k);l=Math.abs(l-f);k=0>k;14>l&&7<f&&(!b&&1>=Math.abs(e)/f||b&&f>7+200*Math.abs(e)/f&&f>0.2*A)?(flipPage(k),b=!0):b=!1;b&&(p.slideDisabledThisTime=!0)}}(a.x||a.y)&&c(h(q.add(a)))}function f(a){if(1<a.touches.length){var c=a.currentTarget,d=a.touches[0];a=a.touches[1];c.pos=new Vector2((d.pageX+a.pageX)/2,(d.pageY+a.pageY)/
2);c.startDist=x(d,a);c.removeEventListener(UP_EVENT,l,!1);c.removeEventListener("touchcancel",l,!1);c.removeEventListener(MOVE_EVENT,g,!1);c.removeEventListener(DOWN_EVENT,f,!1);c.addEventListener(MOVE_EVENT,k,!1);c.addEventListener(UP_EVENT,m,!1);c.addEventListener("touchcancel",m,!1);b.startPinch&&b.startPinch(c.pos)}}function k(a){a.preventDefault();if(1<a.touches.length){var c=a.currentTarget,d=a.touches[0],e=a.touches[1];a=x(d,e);var d=new Vector2((d.pageX+e.pageX)/2,(d.pageY+e.pageY)/2),e=
a/c.startDist,f=d.sub(c.pos);b.sendPinch(e,f,d);c.startDist=a;c.pos=d}}function m(a){var c=a.currentTarget,d=a.touches.length;if(0<d){c.removeEventListener(MOVE_EVENT,k,!1);c.removeEventListener(UP_EVENT,m,!1);c.removeEventListener("touchcancel",m,!1);c.addEventListener(MOVE_EVENT,g,!1);c.addEventListener(UP_EVENT,l,!1);c.addEventListener("touchcancel",l,!1);var e=a.touches?a.touches[0]:a;c.pos=new Vector2(e.pageX,e.pageY);r()}b.endPinch&&b.endPinch();0==d&&l(a)}function n(a){p.timeoutID||(p.timeoutID=
setTimeout(function(){p.horizontalAllowed=!1;p.timeoutID=null},a))}function l(a){var b=a.currentTarget;Modernizr.touch&&a.touches&&0!=a.touches.length||(b.removeEventListener(MOVE_EVENT,g,!1),b.removeEventListener(UP_EVENT,l,!1),b.removeEventListener("touchcancel",l,!1),b.removeEventListener("mouseout",l,!1),b.addEventListener(DOWN_EVENT,e,!1));p.xDiff=0;p.yDiff=0;n(z)}function r(){p.timeStamp=(new Date).getTime();p.moveTime=0;p.movePath=[];p.trackLength=0;p.slideDisabledThisTime=!1;p.dv0x=0;p.vDiff.set(0,
0)}var s=1.15,w=0.8,y=innerWidth/4,z=1250;a.addEventListener(DOWN_EVENT,e,!1);var p={};p.vDiff=new Vector2(0,0)}function x(a,b){var c=a.pageX-b.pageX,d=a.pageY-b.pageY;return Math.sqrt(c*c+d*d)}var q=new Vector2(0,0),n=0.1,l,t=new OnePage(b,function(a){k("change",a)});this.goToPage=function(a){t.goToPage(a)};var y=this;setInterval(function(){y.width==innerWidth&&y.height==innerHeight||y.resize()},500);this.resize=function(){var a=innerWidth-this.width;this.width=innerWidth;this.height=innerHeight;
t.getImageLoaded()&&k("resize",!1,a);t.resize()};var w,z=function(){var a=document.createElement("p");a.style.opacity="0.7";a.style.backgroundColor="#e0efee";a.style.color="#11111f";a.style.fontSize="18px";a.style.zIndex=1E3;a.style.position="absolute";this.element=a};z.prototype.setText=function(a){this.element.innerText=a};z.prototype.positionMe=function(a){this.element.style.left=px(a.x-this.element.offsetWidth/2);this.element.style.top=px(a.y-this.element.offsetHeight/2)};var g=new z;this.startPinch=
function(a){b.appendChild(g.element);g.positionMe(a);w?(clearTimeout(w),w=null):t.startPinchMode()};this.endPinch=function(){b.removeChild(g.element);w=setTimeout(function(){t.stopPinchMode();w=null;r()},t.isStub()?0:500)};this.sendPinch=function(b,d,e){n*b<l.map[0]?b=l.map[0]/n:n*b>l.map[l.map.length-1]&&(b=l.map[l.map.length-1]/n);d=d.add(e.sub(q).mul(1-b));d=q.add(d);b*=n;d=h(d,b);a(b,!0);c(d,!0);g.setText(window.LOCALS.ZOOM+" "+(100*n).toFixed(0)+"%");g.positionMe(e)};this.incZoom=function(){m(!0)};
this.decZoom=function(){m(!1)};this.setHighlight=function(a){t.setHighlight(a)};var B=getKeepZoomScaleWhileFlipping(publicationData.type);this.set=function(a,c){setElementPosition(b,{left:0,top:0});t.set(a,c);this.resize();d();s(b,this,publicationData.type!=PT_PHOTOALBUM)};this.handleDoubleClick=function(a){a=a.touches?a.touches[0]:a;a=new Vector2(a.pageX,a.pageY);m(!0,!0,a)}};
