// Created 12/11/2013 12:56:17 PM
(function(){var c=function b(){if(2===arguments.length&&"number"===typeof arguments[0]&&"number"===typeof arguments[1])this.x=arguments[0],this.y=arguments[1];else if(1===arguments.length&&arguments[0].type===b.type)this.x=arguments[0].x,this.y=arguments[0].y;else if(0===arguments.length)this.y=this.x=0;else throw"Arguments must be 2 numbers or nothing at all";},d=c.prototype;c.type="Vector2";d.type=c.type;d.set=function(b,a){if(2===arguments.length&&"number"===typeof arguments[0]&&"number"===typeof arguments[1])this.x=
arguments[0],this.y=arguments[1];else if(1===arguments.length&&arguments[0].type===c.type)this.x=arguments[0].x,this.y=arguments[0].y;else throw'Argument must be 2 numbers or 1 "Vector2"';};d.neg=function(){return new c(-this.x,-this.y)};d.vclone=function(){return new c(this.x,this.y)};d.add=function(b){var a=new c(this.x,this.y);if("number"===typeof b)a.x+=b,a.y+=b;else if(b.type&&b.type===c.type)a.x+=b.x,a.y+=b.y;else throw'Argument must be of type "Vector2" or "number"';return a};d.sub=function(b){var a=
new c(this.x,this.y);if("number"===typeof b)a.x-=b,a.y-=b;else if(b.type&&b.type===c.type)a.x-=b.x,a.y-=b.y;else throw'Argument must be of type "Vector2" or "number"';return a};d.mul=function(b){var a=new c(this.x,this.y);if("number"===typeof b)a.x*=b,a.y*=b;else if(b.type&&b.type===c.type)a.x*=b.x,a.y*=b.y;else throw'Argument must be of type "Vector2" or "number"';return a};d.div=function(b){var a=new c(this.x,this.y);if("number"===typeof b)a.x/=b,a.y/=b;else if(b.type&&b.type===c.type)a.x/=b.x,
a.y/=b.y;else throw'Argument must be of type "Vector2" or "number"';return a};d.dot=function(b){if(!b||!b.type||b.type!==c.type)throw'Arguments must be of type "Vector2"';return this.x*b.x+this.y*b.y};d.square=function(){return new c(this.x*this.x,this.y*this.y)};d.vlength=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};d.abs=function(){return new c(Math.abs(this.x),Math.abs(this.y))};d.proportions=function(){return this.x/this.y};d.map=function(b){var a=new c;a.x=b(this.x);a.y=b(this.y);
return a};c.dot=function(b,a){if(b.type!==c.type||a.type!==c.type)throw'Arguments must be of type "Vector2"';return b.x*a.x+b.y*a.y};c.crossVV=function(b,a){if(b.type!==c.type||a.type!==c.type)throw'Arguments must be of type "Vector2"';return b.x*a.y-b.y*a.x};c.crossVN=function(b,a){if(b.type!==c.type||"number"!==typeof a)throw'Arguments must be of type "Vector2" and "number"';return new c(a*b.y,-a*b.x)};c.crossNV=function(b,a){if("number"!==typeof b||a.type!==c.type)throw'Arguments must be of type "number" and "Vector2"';
return new c(-b*a.y,b*a.x)};d.clip=function(b,a,d,l){var g=new c;g.x=Math.max(b,Math.min(d,this.x));g.y=Math.max(a,Math.min(l,this.y));return g};d.toString=function(){return"("+this.x+","+this.y+")"};window.Vector2=c;d.applyAsPosition=function(b,a,c){b.style["undefined"===typeof a||a?"left":"right"]=this.x+"px";b.style["undefined"===typeof c||c?"top":"bottom"]=this.y+"px"};d.applyAsSize=function(b){b.style.width=this.x+"px";b.style.height=this.y+"px"};d.applyAsMargin=function(b,a,c){var d=function(a,
b,c,d,m,q){"undefined"===typeof c||null===c?(a.style[b+d]=q+"px",a.style[b+m]=q+"px"):a.style[b+(c?d:m)]=q+"px"};d(b,"margin",a,"Left","Right",this.x);d(b,"margin",c,"Top","Bottom",this.y)};d.stretchToMe=function(b,a){var d=new c;d.x=Math[a?"min":"max"](this.x,b*this.y);d.y=d.x/b;return d};d.getCenterPosition=function(b){return this.sub(b).div(2)}})();function setElementPosition(c,d){c.style.left=String(d.left).concat("px");c.style.top=String(d.top).concat("px")}
function flipPage(c){c?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 deleteAllChildren(c){for(;c.firstChild;)c.removeChild(c.firstChild)}
function sizeDiv(c,d,h,b){void 0==d&&void 0==h&&(d=window.innerWidth,h=window.innerHeight);c.style.width=b?d+"%":Math.ceil(d)+"px";c.style.height=b?h+"%":Math.ceil(h)+"px"}function px(c){return c.toString()+"px"}
function parseVectorizedContentToDiv(c,d,h,b){b="undefined"!=typeof b?b:!0;for(var a=0;4>a;a++);d=d||createDiv();for(var a=[],m=0;m<c.length;m++){var l=c[m],g=0,e=l[g++].toString(),r=l[g++].toString(),s=parseFloat(l[g++]);parseFloat(l[g++]);var x=parseFloat(l[g++]),q=parseFloat(l[g++]),n=parseFloat(l[g++]),p=l[g++].toString(),l=parseFloat(l[g++]),t=Math.round(q*h),g=q=document.createElement("p");g.style.position="absolute";g.style.whiteSpace="nowrap";q.innerText=e;q.style.fontFamily=r;g.style.top=
px(Math.round(x*h));g.style.left=px(t);r=n;x=a[r];n="undefined"==typeof x?Math.floor(n*h):x.size;q.style.fontSize=px(n);q.style.color=p;d.appendChild(g);s*=h;if(b)for(;q.offsetWidth>s&&1<n;)n-=1,q.style.fontSize=px(n);if("undefined"==typeof x)a[r]={size:n,elements:[q]};else if(x.size>=n){if(x.size>n){a[r].size=n;for(var y in x.elements)p=x.elements[y],n=p.offsetWidth,p.style.fontSize=px(a[r].size),p.style.wordSpacing="0px",p.style.wordSpacing=px((n-p.offsetWidth)/(p.innerText.split(" ").length-1))}a[r].elements.push(q)}q.style.webkitTransform=
l?dev_rotateXY(l):"";q.style.webkitTransformOrigin=l?"0 0":"";e=e.split(" ");q.style.wordSpacing="0px";q.style.wordSpacing=px((s-q.offsetWidth)/(e.length-1))}return d}function getDefaultMobileScaleMode(c,d,h,b){var a={};switch(c){case PT_CATALOG:case PT_MAGAZINE:a.isHalfPage=!d&&h;case PT_BOOK:case PT_DOCUMENT:a.fitMode=b?"screen":"width";break;case PT_PHOTOALBUM:a.fitMode="screen";break;default:throw"unknown publication type";}return a}
function getKeepZoomScaleWhileFlipping(c){return-1!=[PT_BOOK,PT_DOCUMENT].indexOf(c)}
function determineScaleMap(c,d){var h=getDefaultMobileScaleMode(publicationData.type,"tablet"==system.device.type,d,innerWidth<=innerHeight),b=h.isHalfPage?2:1,a=(new Vector2(innerWidth,innerHeight)).stretchToMe(c.x/b/c.y,!0).x/c.x,b=innerWidth/(c.x/b),m=b/0.8,h=["screen"==h.fitMode?a:b];ALBUM?(a=Math.sqrt(m/b),h=h.concat([b*a,m])):a=1.5;for(;2.15>h[h.length-1]*a;)h[h.length]=h[h.length-1]*a;return{defaultPos:0,map:h,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(c,d,h,b,a){if("undefined"!=typeof d&&d)for(var m=0,l=d.length;m<l;m++){var g=d[m],e={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,b){function c(a,b){return a.hasOwnProperty(b)?a[b]:publicationData.shopInfo.cartIconGlobals[b]}return{orientation:c(a,"position"),circleColor:c(a,"circleColor"),priceColor:c(a,"priceColor"),priceTagColor:c(a,"priceTagColor"),priceTagOpacity:c(a,"priceTagColorAlpha"),tagVisible:c(a,"tagVisible"),basketColor:c(a,"basketColor"),showTitle:c(a,
"showTitle"),cost:b.price,title:b.name,onClickAction:c(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(c,g,h,b,e,a)}}
function parseContentItem(c,d,h,b,a,m){var l=new Vector2(d.x,d.y),g=new Vector2(d.width,d.height),e=document.createElement("div");e.style.position="absolute";l=l.mul(b);g=g.mul(b);(function(a,b,c,d){a.style[HTML5lib.browserPrefix+"TransformOrigin"]="0 0";var h=d?Math.sin(d):0;d=d?Math.cos(d):1;a.style[HTML5lib.browserPrefix+"Transform"]="matrix("+[d,h,-h,d,b.x,b.y].join()+")";sizeDiv(a,c.x,c.y,!1)})(e,l,g,d.angle);"undefined"!=typeof d.zindex&&(e.style.zIndex=d.zindex);if("highlight"==c)e.style.backgroundColor=
a.searchHighlightColor,h.appendChild(e);else if("link"==c)e.style.backgroundColor=a.linkHighlightColor,e.style.opacity="0",e.style.webkitAnimation="linkss 2s",e.className="link",b=d.urls,Hammer(e,{prevent_default:!0,stop_browser_behavior:!0}).on("touch",function(){e.style.opacity="0.3"}),Hammer(e,{prevent_default:!0,stop_browser_behavior:!0}).on("drag transform hold release",function(){e.style.opacity="0"}),b&&0!=b.length?(function(a){var b=!1,c=function(a,c){setTimeout(function(){b?b=!1:(a.stopPropagation(),
window.location=c)},300)};Hammer(e,{prevent_default:!0,stop_browser_behavior:!0}).on("tap",function(b){c(b,a[0])});Hammer(e,{prevent_default:!0,stop_browser_behavior:!0}).on("doubletap",function(){b=!0})}(b),h.appendChild(e)):"undefined"!==typeof d.page&&(function(b){var c=!1,d=function(b,d){setTimeout(function(){c?c=!1:(b.stopPropagation(),a.onInternalLinkClick(d))},300)};Hammer(e,{prevent_default:!0,stop_browser_behavior:!0}).on("tap",function(a){d(a,b)});Hammer(e,{prevent_default:!0,stop_browser_behavior:!0}).on("doubletap",
function(){c=!0})}(d.page),h.appendChild(e));else if("video"==c){e.id="video."+d.id;if(d.showImage){var r=a.getVideoImageUrl(d.imageUri);(function(a){changeUrlWhenPubl(r,function(b){a.style.backgroundImage="url('"+b+"')";a.style.backgroundSize="100% 100%"})})(e)}c=new Image;b*=d.height;b=50<b?50:0.8*b;c.src=a.videoPlayImage;e.appendChild(c);c.style.position="absolute";c.style.margin="auto";c.style.left="0";c.style.right="0";c.style.top="0";c.style.bottom="0";c.style.height=b+"px";var s=!1,x=function(b){setTimeout(function(){s?
s=!1:(b.stopPropagation(),a.onVideoClick(d))},300)};Hammer(e,{prevent_default:!0,stop_browser_behavior:!0}).on("tap",function(a){x(a)});Hammer(e,{prevent_default:!0,stop_browser_behavior:!0}).on("doubletap",function(){s=!0});h.appendChild(e)}else"cartItem"==c&&function(b,c,d,e){cart.getItems(function(g){g=g[0];var m=a.formCartItemOptions(b,g),l=new CartItemRender(b.id,c,d,e,m,h,cart);(function(b,c,d,C){c.div.style.pointerEvents="auto";var h=!1,e=function(c){setTimeout(function(){h?h=!1:(c.stopPropagation(),
a.onCartItemClick("Window"==d.onClickAction,b,C))},300)};Hammer(c.div,{prevent_default:!0,stop_browser_behavior:!0}).on("tap",function(a){e(a)});Hammer(c.div,{prevent_default:!0,stop_browser_behavior:!0}).on("doubletap",function(){h=!0});a.onNewCartItemRenderConstruction(c)})(b,l,m,g)},function(){throw"productsDB error";},b.id)}(d,l,g,b*m)}
function CartItemRender(c,d,h,b,a,m,l){this.itemID=c||NaN;c=18*b;var g=14*b,e=!1!==a.tagVisible,r=!1!==a.showTitle&&"string"===typeof a.title&&""!=a.title,s=12*b,x=5*b,q=5*b,n=r?0:3*b;h.x=Math.max(h.x,5*c);h.y=Math.max(h.y,3*c);var p=-1!=a.orientation.indexOf("top"),t=-1!=a.orientation.indexOf("left"),y=-1!=a.orientation.indexOf("bottom"),y=!p&&!y;m=el.createElement("div",{id:"cartItem-"+(1E3*Math.random()).toFixed(0),styles:{position:"absolute",cursor:"pointer",borderRadius:x+"px",fontFamily:"Arial",
textAlign:"center",color:a.priceColor}},m);d.applyAsPosition(m);d=new Vector2(c,y?n:c);var w=h.sub(new Vector2(d.x,d.y*(y?2:1)));w.applyAsSize(m);d.applyAsMargin(m,t,y?null:p);e&&(m.style.background="rgba("+fbUtils.hexToRGB(a.priceTagColor)+","+a.priceTagOpacity+")",h=el.createElement("p",{styles:{fontWeight:"bold",fontSize:g+"px",lineHeight:g+"px"}},null,{textContent:fbUtils.formatPrice(a.cost)}),r?(r=new Vector2(w.x-10*b,w.y-g-q),d=el.createElement("p",{styles:{fontSize:s+"px",lineHeight:s+"px",
width:r.x+"px"}},m,{textContent:a.title}),e=d.offsetHeight,q=el.createElement("p",{styles:{fontSize:s+"px",lineHeight:s+"px",marginLeft:5*b+"px",marginRight:5*b+"px",marginBottom:q+"px"}},m,{textContent:a.title}),e<r.y?(m.removeChild(d),s=(r.y-e)/2):(e=r.y-r.y%s,s=(r.y-e)/2,m.removeChild(d),q.style.maxWidth=r.x+"px",q.style.overflow="hidden",q.style.textOverflow="ellipsis",q.style.maxHeight=e+"px"),q.style.marginTop=s+"px"):(s=(w.y-g)/2,h.style.marginTop=s+"px"),h.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"}(h,g),m.appendChild(h));b*=3;a=el.createElement("span",{styles:{position:"absolute",background:a.circleColor,borderRadius:c+"px",borderWidth:b+"px",borderColor:"white",borderStyle:"solid",color:a.basketColor,verticalAlign:"middle"}},m);g=(new Vector2(c,c)).mul(2);g.applyAsSize(a);s=g.x/2;a.style.lineHeight=g.x-2*b+"px";a.style.fontSize=s+"px";(new Vector2(-c,y?w.y/2-c:-c)).applyAsPosition(a,
t,y||p);this.updateQuantity=function(){var a=l.getItemQuantity(this.itemID);if("undefined"==typeof this.qty||this.qty!=a)this.qty=a,this.circleSpan.className=(0<a?"fullCartButtonInPage":"cartButtonInPage")+" cartIconShadow"};this.div=m;this.circleSpan=a;this.updateQuantity()}
function OnePage(c,d){function h(){var b;publicationData.shopInfo&&(window.cartRenders=[]);t?(f.div.parentNode&&f.div.parentNode.removeChild(f.div),q()):deleteAllChildren(f.div);f.loaded?((b=document.getElementById("stubPage"))&&c.contains(b)&&c.removeChild(b),f.vector&&parseVectorizedContentToDiv(f.vector,f.div,G),b=n().stretchToMe(f.publishedSize.proportions(),!0).x/f.publishedSize.x,sizeDiv(f.div,n().x,n().y),parseContentItems("link",publicationData.page[u].links,f.div,b),parseContentItems("video",
publicationData.page[u].videos,f.div,b),publicationData.shopInfo&&parseContentItems("cartItem",publicationData.page[u].shopItems,f.div,b,publicationData.getPageProperty(u,"contentScale")),s()):a()&&(b=document.getElementById("stubPage")||createDiv("stubPage"),sizeDiv(b,this.width,this.height),b.style.backgroundColor=publicationData.getPageProperty(u,"BGColor"),c.contains(b)||c.appendChild(b))}function b(b,c){if(u!=b)if(u&&a(u)&&!a(b)&&(f.image.style.visibility="visible"),u=b,fconsole.update("pos",
u),y||showPreloader(),a())f.loaded=!1,w||(f.image.style.visibility="hidden"),f.rasterSize.set(publicationData.getPageProperty(u,"width"),publicationData.getPageProperty(u,"height")),d(!0),h(),hidePreloader(),c&&c();else{f.vector=null;f.publishedSize=new Vector2(publicationData.getPageProperty(u,"width"),publicationData.getPageProperty(u,"height"));z.style.backgroundColor=publicationData.getPageProperty(u,"BGColor");L=publicationData.getPageProperty(u,"wide");var e;H&&(e="undefined"==typeof f.isWide||
f.isWide!=L,f.isWide=L,d(e));deleteAllChildren(f.div);loadManager.addPageToQueue({skipCurrentLoading:!0,image:f.image,quality:!0,position:u,onImageLoadComplete:function(){C=!0;f.loaded=!0;w&&A.createPattern(f.image,"no-repeat");var a=new Vector2(f.image.naturalWidth,f.image.naturalHeight);H||(e=f.rasterSize.x!=a.x||f.rasterSize.y!=a.y);f.rasterSize=a;H||d(e)},onPageLoadError:function(){f.loaded=!1},onAllIsComplete:function(a,b){f.vector=b;h();hidePreloader();c&&c()},onJSLoadComplete:function(){}})}}
function a(a){a=void 0!=a?a:u;return publicationData.getPageProperty(a,"stub")}function m(){D.width=this.width;D.height=this.height}function l(){if(f.loaded||a()){var b=D.width,c=D.height;if(C||F||I||J){A.clearRect(0,0,b,c);if(a())A.fillStyle=publicationData.getPageProperty(u,"BGColor"),A.fillRect(0,0,b,c);else{var d=f.image,k=E,B=G,h=Math.round(k.x),k=Math.round(k.y),e=0<h?0:Math.abs(h/B),g=0<k?0:Math.abs(k/B),b=Math.min(d.width*B,b)/B-e,c=Math.min(d.height*B,c)/B-g;(b||c)&&A.drawImage(d,h,k,d.width*
B,d.height*B);d=Math.round(E.x);B=Math.round(E.y);r(f.div,d,B,!1)}J=I=F=C=!1}}}function g(){sizeDiv(c,this.width,this.height)}function e(){if(I||C||J){var a=n(),b=function(a){return Math.floor(a)},c=a.stretchToMe(f.rasterSize.x/f.rasterSize.y,!0).map(b);c.applyAsSize(f.image);c.applyAsSize(f.div);b=a.getCenterPosition(c).map(b);b.applyAsPosition(f.image);b.applyAsPosition(f.div);a.applyAsSize(z);f.widthScale=a.x!==c.x?a.x:a.y;C=I=!1}if(F||J)a=Math.round(E.x),c=Math.round(E.y),r(z,a,c,!1),J=F=!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();f.div.appendChild(K);parseContentItems("highlight",a,K,G)}):x()}function x(){deleteAllChildren(K);f.div.contains(K)&&f.div.removeChild(K)}function q(){f.div=createDiv("contentDiv");w?c.appendChild(f.div):(f.div.style.webkitTransform=null,z.appendChild(f.div))}function n(a){a=a||G;return(H?f.isWide?M:H:f.publishedSize).map(function(b){return Math.floor(b*
a)})}var p=window.system.platform.version,t="safari"==window.system.browser.name&&fbUtils.isArray(p)&&2<=p.length&&"4"==p[0]&&2<=p[1],y="safari"==window.system.browser.name&&fbUtils.isArray(p)&&3==p.length&&"4"==p[0]&&"0"==p[1]&&"4"==p[2],w=!1,z=createDiv("scrollDiv"),f={},D=document.createElement("canvas"),A=D.getContext("2d");f.loaded=!1;var C,E=new Vector2(0,0),G=0.1,F,I,J,u;f.rasterSize=new Vector2;f.publishedSize=new Vector2(100,100);var L;this.goToPage=function(a){b(a,function(){})};this.resize=
function(a,b){this.width=a;this.height=b;h();w?m():g()};this.setOffset=function(a,b){E.set(a);b||(F=!0)};this.getScale=function(){return G};this.setScale=function(a,b){G=a;b||(I=!0)};this.startPinchMode=function(){f.div.style.visibility="hidden";w||(this.pinchRedrawInterval=setInterval(function(){J=!0},1E3))};this.stopPinchMode=function(){h();this.pinchRedrawInterval&&(clearInterval(this.pinchRedrawInterval),this.pinchRedrawInterval=null);f.div.style.visibility="visible";I=F=!0};this.updateTopContent=
function(){h()};var K=createDiv("highlightContainer");this.setHighlight=function(a){a?s():(search.active=!1,x())};this.set=function(a,d){w?(c.style.overflow="visible",c.appendChild(D)):(c.style.position="absolute",z.style.webkitTransform=null,c.style.webkitTransform=null,c.style.overflow="hidden",c.appendChild(z));f.image=new Image;w||(f.image.style.webkitTransform=null,f.image.style.position="absolute",z.appendChild(f.image));q();b(a,d)};var H=publicationData.size&&publicationData.size.width&&publicationData.size.height?
new Vector2(publicationData.size.width,publicationData.size.height):null,M=H.vclone();M.x*=2;this.getScaledSize=n;this.getImageLoaded=function(){return f.loaded};this.isStub=function(){return a()};this.getOriginalSize=function(){return n(1)};this.drawFrame=w?l:e;this.getIsWide=function(){return L}}
function SimpleViewer(c){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 h(a,b){a!=n&&(n=a,fconsole.update("scale",n),t.setScale(n,b),b||r())}function b(a,b){a.sub(q).vlength()&&
(q=a,t.setOffset(q,b))}function a(a,b){var c=new m(b);return a.clip(c.xmin,c.ymin,c.xmax,c.ymax)}function m(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 l(c,d,f){var g=n;c=d&&e(p.map,n)!=p.defaultPos?p.defaultPos:e(p.map,n*(d?2:1))+(d?0:c?1:-1);c=Math.min(Math.max(c,0),p.map.length-1);c=p.map[c];f=
f?f:ALBUM?new Vector2(innerWidth/2,innerHeight/2):new Vector2(publicationData.rtlMode?innerWidth:0,0);g=q.sub(f.sub(q).mul(c/g-1));g=a(g,c);h(c);b(g);t.updateTopContent()}function g(c,d,f){var e,g=t.getOriginalSize(),m=(e="change"==c)&&d;d="resize"==c;c=p;if(m||d)c=determineScaleMap(g,t.getIsWide());g=n;if(m||e&&!D)g=c.map[c.defaultPos];var m=t.getScaledSize(g).x,l=t.getScaledSize(g).y,u=q.vclone();d?publicationData.rtlMode&&(u.x+=f):u.x=ALBUM?(innerWidth-m)/2:publicationData.rtlMode?innerWidth-m:
0;e&&(u.y=ALBUM?(innerHeight-l)/2:0);f=a(u,g);e=g;p=c;b(f);h(e);r()}function e(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==e(p.map,n),isLargest:e(p.map,n)==p.map.length-1})}function s(c,d,f){function e(a){a.ctrlKey&&(d.sendPinch&&
(d.startPinch&&d.startPinch(new Vector2(a.pageX,a.pageY)),d.sendPinch(s,new Vector2(0,0),new Vector2(a.pageX,a.pageY)),d.endPinch&&d.endPinch()),a.stopImmediatePropagation());a.altKey&&d.sendPinch&&(d.startPinch&&d.startPinch(new Vector2(a.pageX,a.pageY)),d.sendPinch(w,new Vector2(0,0),new Vector2(a.pageX,a.pageY)),d.endPinch&&d.endPinch());a.shiftKey&&d.handleDoubleClick(a);var b=a.currentTarget;if(Modernizr.touch){if(1<a.touches.length){g(a);return}b.addEventListener(DOWN_EVENT,g,!1)}b.removeEventListener(DOWN_EVENT,
e,!1);b.addEventListener(MOVE_EVENT,h,!1);b.addEventListener(UP_EVENT,l,!1);b.addEventListener("touchcancel",l,!1);b.addEventListener("mouseout",l,!1);a=a.touches?a.touches[0]:a;b.pos=new Vector2(a.pageX,a.pageY);r()}function h(c){c.preventDefault();var d=c.touches?c.touches[0]:c,d=new Vector2(d.pageX,d.pageY),e=c.currentTarget.pos;c.currentTarget.pos=d;c=d.sub(e);k.dv0x=k.dv0x||c.x;if(k.timeStamp){d=(new Date).getTime();e=d-k.timeStamp;k.vDiff=k.vDiff.add(c);k.moveTime+=e;k.timeStamp=d;k.trackLength+=
Math.abs(c.x);k.movePath.push({dv:c,time:e});d=t.getScaledSize(void 0).x<=innerWidth||t.isStub();f&&(e=k.vDiff.y?Math.abs(k.vDiff.x)/Math.abs(k.vDiff.y):1E10,Math.abs(k.vDiff.x)>y/1.5*(1.5-e)?k.horizontalAllowed=!0:!k.vDiff.y||1.5<e||k.horizontalAllowed||(c.x=0));if(1E3<k.moveTime||k.dv0x&&c.x&&k.dv0x/Math.abs(k.dv0x)!=c.x/Math.abs(c.x))k.slideDisabledThisTime=!0;!k.slideDisabledThisTime&&k.vDiff.x&&0.5>Math.abs(k.vDiff.y)/Math.abs(k.vDiff.x)&&(c.y=0);if(d&&!k.slideDisabledThisTime&&4<k.trackLength&&
75<k.moveTime){for(var g=k.movePath,d=t.getScaledSize(void 0).y>innerHeight,A,l,m,n=m=l=e=A=0;n<g.length;n++){var p=g[n];A+=p.dv.x;e+=p.dv.y;l+=Math.abs(p.dv.x);m+=p.time}g=Math.abs(A);l=Math.abs(l-g);A=0>A;14>l&&7<g&&(!d&&1>=Math.abs(e)/g||d&&g>7+200*Math.abs(e)/g&&g>0.2*m)?(flipPage(A),d=!0):d=!1;d&&(k.slideDisabledThisTime=!0)}}(c.x||c.y)&&b(a(q.add(c)))}function g(a){if(1<a.touches.length){var b=a.currentTarget,c=a.touches[0];a=a.touches[1];b.pos=new Vector2((c.pageX+a.pageX)/2,(c.pageY+a.pageY)/
2);b.startDist=x(c,a);b.removeEventListener(UP_EVENT,l,!1);b.removeEventListener("touchcancel",l,!1);b.removeEventListener(MOVE_EVENT,h,!1);b.removeEventListener(DOWN_EVENT,g,!1);b.addEventListener(MOVE_EVENT,m,!1);b.addEventListener(UP_EVENT,n,!1);b.addEventListener("touchcancel",n,!1);d.startPinch&&d.startPinch(b.pos)}}function m(a){a.preventDefault();if(1<a.touches.length){var b=a.currentTarget,c=a.touches[0],e=a.touches[1];a=x(c,e);var c=new Vector2((c.pageX+e.pageX)/2,(c.pageY+e.pageY)/2),e=
a/b.startDist,f=c.sub(b.pos);d.sendPinch(e,f,c);b.startDist=a;b.pos=c}}function n(a){var b=a.currentTarget,c=a.touches.length;if(0<c){b.removeEventListener(MOVE_EVENT,m,!1);b.removeEventListener(UP_EVENT,n,!1);b.removeEventListener("touchcancel",n,!1);b.addEventListener(MOVE_EVENT,h,!1);b.addEventListener(UP_EVENT,l,!1);b.addEventListener("touchcancel",l,!1);var e=a.touches?a.touches[0]:a;b.pos=new Vector2(e.pageX,e.pageY);r()}d.endPinch&&d.endPinch();0==c&&l(a)}function p(a){k.timeoutID||(k.timeoutID=
setTimeout(function(){k.horizontalAllowed=!1;k.timeoutID=null},a))}function l(a){var b=a.currentTarget;Modernizr.touch&&a.touches&&0!=a.touches.length||(b.removeEventListener(MOVE_EVENT,h,!1),b.removeEventListener(UP_EVENT,l,!1),b.removeEventListener("touchcancel",l,!1),b.removeEventListener("mouseout",l,!1),b.addEventListener(DOWN_EVENT,e,!1));k.xDiff=0;k.yDiff=0;p(z)}function r(){k.timeStamp=(new Date).getTime();k.moveTime=0;k.movePath=[];k.trackLength=0;k.slideDisabledThisTime=!1;k.dv0x=0;k.vDiff.set(0,
0)}var s=1.15,w=0.8,y=innerWidth/4,z=1250;c.addEventListener(DOWN_EVENT,e,!1);var k={};k.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,p,t=new OnePage(c,function(a){g("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()&&g("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 f=new z;this.startPinch=
function(a){c.appendChild(f.element);f.positionMe(a);w?(clearTimeout(w),w=null):t.startPinchMode()};this.endPinch=function(){c.removeChild(f.element);w=setTimeout(function(){t.stopPinchMode();w=null;r()},t.isStub()?0:500)};this.sendPinch=function(c,d,e){n*c<p.map[0]?c=p.map[0]/n:n*c>p.map[p.map.length-1]&&(c=p.map[p.map.length-1]/n);d=d.add(e.sub(q).mul(1-c));d=q.add(d);c*=n;d=a(d,c);h(c,!0);b(d,!0);f.setText(window.LOCALS.ZOOM+" "+(100*n).toFixed(0)+"%");f.positionMe(e)};this.incZoom=function(){l(!0)};
this.decZoom=function(){l(!1)};this.setHighlight=function(a){t.setHighlight(a)};var D=getKeepZoomScaleWhileFlipping(publicationData.type);this.set=function(a,b){setElementPosition(c,{left:0,top:0});t.set(a,b);this.resize();d();s(c,this,publicationData.type!=PT_PHOTOALBUM)};this.handleDoubleClick=function(a){a=a.touches?a.touches[0]:a;a=new Vector2(a.pageX,a.pageY);l(!0,!0,a)}};
