// Created 4/22/2014 10:21:29 AM
(function(a,b){function d(){if(!e.READY){e.event.determineEventTypes();for(var a in e.gestures)e.gestures.hasOwnProperty(a)&&e.detection.register(e.gestures[a]);e.event.onTouch(e.DOCUMENT,e.EVENT_MOVE,e.detection.detect);e.event.onTouch(e.DOCUMENT,e.EVENT_END,e.detection.detect);e.READY=!0}}var e=function(a,b){return new e.Instance(a,b||{})};e.defaults={stop_browser_behavior:{userSelect:"none",touchAction:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};
e.HAS_POINTEREVENTS=navigator.pointerEnabled||navigator.msPointerEnabled;e.HAS_TOUCHEVENTS="ontouchstart"in a;e.MOBILE_REGEX=/mobile|tablet|ip(ad|hone|od)|android/i;e.NO_MOUSEEVENTS=e.HAS_TOUCHEVENTS&&navigator.userAgent.match(e.MOBILE_REGEX);e.EVENT_TYPES={};e.DIRECTION_DOWN="down";e.DIRECTION_LEFT="left";e.DIRECTION_UP="up";e.DIRECTION_RIGHT="right";e.POINTER_MOUSE="mouse";e.POINTER_TOUCH="touch";e.POINTER_PEN="pen";e.EVENT_START="start";e.EVENT_MOVE="move";e.EVENT_END="end";e.DOCUMENT=document;
e.plugins={};e.READY=!1;e.Instance=function(a,b){var c=this;d();this.element=a;this.enabled=!0;this.options=e.utils.extend(e.utils.extend({},e.defaults),b||{});this.options.stop_browser_behavior&&e.utils.stopDefaultBrowserBehavior(this.element,this.options.stop_browser_behavior);e.event.onTouch(a,e.EVENT_START,function(a){c.enabled&&e.detection.startDetect(c,a)});return this};e.Instance.prototype={on:function(a,e){for(var b=a.split(" "),d=0;d<b.length;d++)this.element.addEventListener(b[d],e,!1);
return this},off:function(a,e){for(var b=a.split(" "),d=0;d<b.length;d++)this.element.removeEventListener(b[d],e,!1);return this},trigger:function(a,b){var d=e.DOCUMENT.createEvent("Event");d.initEvent(a,!0,!0);d.gesture=b;var c=this.element;e.utils.hasParent(b.currentContentElement,c)&&(c=b.currentContentElement);c.dispatchEvent(d);return this},enable:function(a){this.enabled=a;return this}};var c=null,f=!1,h=!1;e.event={_bindDom:function(a,e,b){e=e.split(" ");for(var d=0;d<e.length;d++)a.addEventListener(e[d],
b,!1)},onTouch:function(a,b,d){var k=this;this._bindDom(a,e.EVENT_TYPES[b],function(t){var m=t.type.toLowerCase();if(!m.match(/mouse/)||!h){if(m.match(/touch/)||m.match(/pointerdown/)||m.match(/mouse/)&&1===t.which)f=!0;m.match(/touch|pointer/)&&(h=!0);var r=0;f&&(e.HAS_POINTEREVENTS&&b!=e.EVENT_END?r=e.PointerEvent.updatePointer(b,t):m.match(/touch/)?r=t.touches.length:h||(r=m.match(/up/)?0:1),0<r&&b==e.EVENT_END?b=e.EVENT_MOVE:r||(b=e.EVENT_END),r||null===c?c=t:t=c,d.call(e.detection,k.collectEventData(a,
b,t)),e.HAS_POINTEREVENTS&&b==e.EVENT_END&&(r=e.PointerEvent.updatePointer(b,t)));r||(c=null,h=f=!1,e.PointerEvent.reset())}})},determineEventTypes:function(){var a;a=e.HAS_POINTEREVENTS?e.PointerEvent.getEvents():e.NO_MOUSEEVENTS?["touchstart","touchmove","touchend touchcancel"]:["touchstart mousedown","touchmove mousemove","touchend touchcancel mouseup"];e.EVENT_TYPES[e.EVENT_START]=a[0];e.EVENT_TYPES[e.EVENT_MOVE]=a[1];e.EVENT_TYPES[e.EVENT_END]=a[2]},getTouchList:function(a){return e.HAS_POINTEREVENTS?
e.PointerEvent.getTouchList():a.touches?a.touches:[{identifier:1,pageX:a.pageX,pageY:a.pageY,currentContentElement:a.currentContentElement}]},collectEventData:function(a,b,d){a=this.getTouchList(d,b);var c=e.POINTER_TOUCH;if(d.type.match(/mouse/)||e.PointerEvent.matchType(e.POINTER_MOUSE,d))c=e.POINTER_MOUSE;return{center:e.utils.getCenter(a),timeStamp:(new Date).getTime(),currentContentElement:d.currentContentElement,touches:a,eventType:b,pointerType:c,srcEvent:d,preventDefault:function(){this.srcEvent.preventManipulation&&
this.srcEvent.preventManipulation();this.srcEvent.preventDefault&&this.srcEvent.preventDefault()},stopPropagation:function(){this.srcEvent.stopPropagation()},stopDetect:function(){return e.detection.stopDetect()}}}};e.PointerEvent={pointers:{},getTouchList:function(){var a=this,e=[];Object.keys(a.pointers).sort().forEach(function(b){e.push(a.pointers[b])});return e},updatePointer:function(a,b){a==e.EVENT_END?this.pointers={}:(b.identifier=b.pointerId,this.pointers[b.pointerId]=b);return Object.keys(this.pointers).length},
matchType:function(a,b){if(!b.pointerType)return!1;var d={};d[e.POINTER_MOUSE]=b.pointerType==b.MSPOINTER_TYPE_MOUSE||b.pointerType==e.POINTER_MOUSE;d[e.POINTER_TOUCH]=b.pointerType==b.MSPOINTER_TYPE_TOUCH||b.pointerType==e.POINTER_TOUCH;d[e.POINTER_PEN]=b.pointerType==b.MSPOINTER_TYPE_PEN||b.pointerType==e.POINTER_PEN;return d[a]},getEvents:function(){return["pointerdown MSPointerDown","pointermove MSPointerMove","pointerup pointercancel MSPointerUp MSPointerCancel"]},reset:function(){this.pointers=
{}}};e.utils={extend:function(a,e,d){for(var c in e)a[c]!==b&&d||(a[c]=e[c]);return a},hasParent:function(a,e){for(;a;){if(a==e)return!0;a=a.parentNode}return!1},getCenter:function(a){for(var e=[],b=[],d=0,c=a.length;d<c;d++)e.push(a[d].pageX),b.push(a[d].pageY);return{pageX:(Math.min.apply(Math,e)+Math.max.apply(Math,e))/2,pageY:(Math.min.apply(Math,b)+Math.max.apply(Math,b))/2}},getVelocity:function(a,e,b){return{x:Math.abs(e/a)||0,y:Math.abs(b/a)||0}},getAngle:function(a,e){return 180*Math.atan2(e.pageY-
a.pageY,e.pageX-a.pageX)/Math.PI},getDirection:function(a,b){var d=Math.abs(a.pageX-b.pageX),c=Math.abs(a.pageY-b.pageY);return d>=c?0<a.pageX-b.pageX?e.DIRECTION_LEFT:e.DIRECTION_RIGHT:0<a.pageY-b.pageY?e.DIRECTION_UP:e.DIRECTION_DOWN},getDistance:function(a,e){var b=e.pageX-a.pageX,d=e.pageY-a.pageY;return Math.sqrt(b*b+d*d)},getScale:function(a,e){return 2<=a.length&&2<=e.length?this.getDistance(e[0],e[1])/this.getDistance(a[0],a[1]):1},getRotation:function(a,e){return 2<=a.length&&2<=e.length?
this.getAngle(e[1],e[0])-this.getAngle(a[1],a[0]):0},isVertical:function(a){return a==e.DIRECTION_UP||a==e.DIRECTION_DOWN},stopDefaultBrowserBehavior:function(a,e){var b,d="webkit khtml moz ms o ".split(" ");if(e&&a.style){for(var c=0;c<d.length;c++)for(var f in e)e.hasOwnProperty(f)&&(b=f,d[c]&&(b=d[c]+b.substring(0,1).toUpperCase()+b.substring(1)),a.style[b]=e[f]);"none"==e.userSelect&&(a.onselectstart=function(){return!1})}}};e.detection={gestures:[],current:null,previous:null,stopped:!1,startDetect:function(a,
b){this.current||(this.stopped=!1,this.current={inst:a,startEvent:e.utils.extend({},b),lastEvent:!1,name:""},this.detect(b))},detect:function(a){if(this.current&&!this.stopped){a=this.extendEventData(a);for(var b=this.current.inst.options,d=0,c=this.gestures.length;d<c;d++){var f=this.gestures[d];if(!this.stopped&&!1!==b[f.name]&&!1===f.handler.call(f,a,this.current.inst)){this.stopDetect();break}}this.current&&(this.current.lastEvent=a);a.eventType==e.EVENT_END&&!a.touches.length-1&&this.stopDetect();
return a}},stopDetect:function(){this.previous=e.utils.extend({},this.current);this.current=null;this.stopped=!0},extendEventData:function(a){var b=this.current.startEvent;if(b&&(a.touches.length!=b.touches.length||a.touches===b.touches)){b.touches=[];for(var d=0,c=a.touches.length;d<c;d++)b.touches.push(e.utils.extend({},a.touches[d]))}var d=a.timeStamp-b.timeStamp,c=a.center.pageX-b.center.pageX,f=a.center.pageY-b.center.pageY,h=e.utils.getVelocity(d,c,f);e.utils.extend(a,{deltaTime:d,deltaX:c,
deltaY:f,velocityX:h.x,velocityY:h.y,distance:e.utils.getDistance(b.center,a.center),angle:e.utils.getAngle(b.center,a.center),direction:e.utils.getDirection(b.center,a.center),scale:e.utils.getScale(b.touches,a.touches),rotation:e.utils.getRotation(b.touches,a.touches),startEvent:b});return a},register:function(a){var d=a.defaults||{};d[a.name]===b&&(d[a.name]=!0);e.utils.extend(e.defaults,d,!0);a.index=a.index||1E3;this.gestures.push(a);this.gestures.sort(function(a,e){return a.index<e.index?-1:
a.index>e.index?1:0});return this.gestures}};e.gestures=e.gestures||{};e.gestures.Hold={name:"hold",index:10,defaults:{hold_timeout:500,hold_threshold:1},timer:null,handler:function(a,b){switch(a.eventType){case e.EVENT_START:clearTimeout(this.timer);e.detection.current.name=this.name;this.timer=setTimeout(function(){"hold"==e.detection.current.name&&b.trigger("hold",a)},b.options.hold_timeout);break;case e.EVENT_MOVE:a.distance>b.options.hold_threshold&&clearTimeout(this.timer);break;case e.EVENT_END:clearTimeout(this.timer)}}};
e.gestures.Tap={name:"tap",index:100,defaults:{tap_max_touchtime:250,tap_max_distance:10,tap_always:!1,doubletap_distance:20,doubletap_interval:300},handler:function(a,b){if(a.eventType==e.EVENT_END){var d=e.detection.previous,c=!1;a.deltaTime>b.options.tap_max_touchtime||a.distance>b.options.tap_max_distance||(d&&"tap"==d.name&&a.timeStamp-d.lastEvent.timeStamp<b.options.doubletap_interval&&a.distance<b.options.doubletap_distance&&(b.trigger("doubletap",a),c=!0),c&&!b.options.tap_always)||(e.detection.current.name=
"tap",b.trigger(e.detection.current.name,a))}}};e.gestures.Swipe={name:"swipe",index:40,defaults:{swipe_max_touches:1,swipe_velocity:0.7},handler:function(a,b){a.eventType!=e.EVENT_END||0<b.options.swipe_max_touches&&a.touches.length>b.options.swipe_max_touches||!(a.velocityX>b.options.swipe_velocity||a.velocityY>b.options.swipe_velocity)||(b.trigger(this.name,a),b.trigger(this.name+a.direction,a))}};e.gestures.Drag={name:"drag",index:50,defaults:{drag_min_distance:5,drag_max_touches:1,drag_block_horizontal:!1,
drag_block_vertical:!1,drag_lock_to_axis:!1,drag_lock_min_distance:20,fb_lock_to_axis:!1,fb_lock_min_distance:10,fb_lock_sensitivity:5},triggered:!1,counter:0,fbDirection:"",fbLock:!1,fbNeverLock:!1,saveX:0,saveY:0,handler:function(a,b){if(e.detection.current.name!=this.name&&this.triggered)b.trigger(this.name+"end",a),this.triggered=!1;else if(!(0<b.options.drag_max_touches&&a.touches.length>b.options.drag_max_touches))switch(a.eventType){case e.EVENT_START:this.triggered=!1;this.counter=0;this.fbDirection=
"";this.fbNeverLock=this.fbLock=!1;break;case e.EVENT_MOVE:if(a.distance<b.options.drag_min_distance&&e.detection.current.name!=this.name)break;e.detection.current.name=this.name;if(e.detection.current.lastEvent.drag_locked_to_axis||b.options.drag_lock_to_axis&&b.options.drag_lock_min_distance<=a.distance)a.drag_locked_to_axis=!0;var d=e.detection.current.lastEvent.direction;a.drag_locked_to_axis&&d!==a.direction&&(e.utils.isVertical(d)?a.direction=0>a.deltaY?e.DIRECTION_UP:e.DIRECTION_DOWN:a.direction=
0>a.deltaX?e.DIRECTION_LEFT:e.DIRECTION_RIGHT);this.triggered||(b.trigger(this.name+"start",a),this.triggered=!0);b.options.fb_lock_to_axis&&(++this.counter,!this.fbNeverLock&&this.counter<=b.options.fb_lock_min_distance&&!this.fbLock?Math.abs(a.deltaX)>b.options.fb_lock_sensitivity&&Math.abs(a.deltaY)<b.options.fb_lock_sensitivity?("v"===this.fbDirection&&(this.fbNeverLock=!0),this.fbDirection="h"):Math.abs(a.deltaX)<b.options.fb_lock_sensitivity&&Math.abs(a.deltaY)>b.options.fb_lock_sensitivity?
("h"===this.fbDirection&&(this.fbNeverLock=!0),this.fbDirection="v"):Math.abs(a.deltaX)>b.options.fb_lock_sensitivity&&Math.abs(a.deltaY)>b.options.fb_lock_sensitivity?this.fbNeverLock=!0:""!==this.fbDirection&&(this.fbNeverLock=!0):this.fbNeverLock||this.fbLock||(this.fbLock=!0,this.saveY=a.deltaY,this.saveX=a.deltaX),this.fbLock&&("h"===this.fbDirection?a.deltaY=this.saveY:a.deltaX=this.saveX));b.trigger(this.name,a);b.trigger(this.name+a.direction,a);(b.options.drag_block_vertical&&e.utils.isVertical(a.direction)||
b.options.drag_block_horizontal&&!e.utils.isVertical(a.direction))&&a.preventDefault();break;case e.EVENT_END:this.triggered&&b.trigger(this.name+"end",a),this.triggered=!1}}};e.gestures.Transform={name:"transform",index:45,defaults:{transform_min_scale:0.01,transform_min_rotation:1,transform_always_block:!1},triggered:!1,handler:function(a,b){if(e.detection.current.name!=this.name&&this.triggered)b.trigger(this.name+"end",a),this.triggered=!1;else if(!(2>a.touches.length))switch(b.options.transform_always_block&&
a.preventDefault(),a.eventType){case e.EVENT_START:this.triggered=!1;break;case e.EVENT_MOVE:var d=Math.abs(1-a.scale),c=Math.abs(a.rotation);if(d<b.options.transform_min_scale&&c<b.options.transform_min_rotation)break;e.detection.current.name=this.name;this.triggered||(b.trigger(this.name+"start",a),this.triggered=!0);b.trigger(this.name,a);c>b.options.transform_min_rotation&&b.trigger("rotate",a);d>b.options.transform_min_scale&&(b.trigger("pinch",a),b.trigger("pinch"+(1>a.scale?"in":"out"),a));
break;case e.EVENT_END:this.triggered&&b.trigger(this.name+"end",a),this.triggered=!1}}};e.gestures.Touch={name:"touch",index:-Infinity,defaults:{prevent_default:!1,prevent_mouseevents:!1},handler:function(a,b){b.options.prevent_mouseevents&&a.pointerType==e.POINTER_MOUSE?a.stopDetect():(b.options.prevent_default&&a.preventDefault(),a.eventType==e.EVENT_START&&b.trigger(this.name,a))}};e.gestures.Release={name:"release",index:Infinity,handler:function(a,b){a.eventType==e.EVENT_END&&b.trigger(this.name,
a)}};"object"===typeof module&&"object"===typeof module.exports?module.exports=e:(a.Hammer=e,"function"===typeof a.define&&a.define.amd&&a.define("hammer",[],function(){return e}))})(this);
!function(){function a(a){a=a||publicationData.type;switch(a){case "catalog":this.portrait="fitScreen";this.landscape="fitWidth";this.widePageTablet=1;this.widePageMobile=0.5;this.zoomLevel=1;this.zoomSave=!1;this.field=!0;break;case "magazine":this.portrait="fitScreen";this.landscape="fitWidth";this.widePageTablet=1;this.widePageMobile=0.5;this.zoomLevel=1;this.zoomSave=!1;this.field=!0;break;case "book":this.portrait="fitScreen";this.landscape="fitWidth";this.zoomLevel=this.widePageMobile=this.widePageTablet=
1;this.field=this.zoomSave=!0;break;case "document":this.portrait="fitScreen";this.landscape="fitWidth";this.zoomLevel=this.widePageMobile=this.widePageTablet=1;this.field=this.zoomSave=!0;break;case "photo_album":this.landscape=this.portrait="fitScreen";this.zoomLevel=this.widePageMobile=this.widePageTablet=1;this.field=this.zoomSave=!1;break;case "presentation":this.landscape=this.portrait="fitScreen";this.zoomLevel=this.widePageMobile=this.widePageTablet=1;this.zoomSave=!1;this.field=!0;break;
default:this.portrait="fitScreen",this.landscape="fitWidth",this.zoomLevel=this.widePageMobile=this.widePageTablet=1,this.zoomSave=!1,this.field=!0}}a.prototype.getFit=function(){return window.innerWidth>window.innerHeight?this.landscape:this.portrait};a.prototype.getWideFactor=function(){return"tablet"===system.device.type?this.widePageTablet:this.widePageMobile};a.prototype.getRect=function(a,c){var f=publicationData.page[a].width||publicationData.page.defaults.width,h=publicationData.page[a].height||
publicationData.page.defaults.height,g=publicationData.size.width,l=publicationData.size.height,s=this.zoomSave?this.zoomLevel:1,k=this.getWideFactor();a===pageMediator.page&&(s=this.zoomLevel);c&&(s=c);publicationData.page[a].wide&&(f*=k,g=2*g*k);k={};this.field?(g="fitScreen"===this.getFit()||system.device.ipad&&publicationData.page[a].wide?b(g,l,s):d(g,l,s),g.width=publicationData.page[a].wide&&"tablet"!==system.device.type?2*g.width:g.width,f=publicationData.page[a].wide&&"tablet"!==system.device.type?
2*f:f,f=b(f,h,1,g.width,g.height),k.pageWidth=g.width,k.pageHeight=g.height,k.ratio=f.ratio,k.contentWidth=f.width,k.contentHeight=f.height,k.padding=[(k.pageHeight-k.contentHeight)/2,(g.width-k.contentWidth)/2]):(f="fitScreen"===this.getFit()?b(f,h,s):d(f,h,s),k.pageWidth=k.contentWidth=f.width,k.pageHeight=k.contentHeight=f.height,k.padding=[0,0],k.ratio=f.ratio);return k};a.prototype.setZoomLevel=function(a){var b=this.getRect(pageMediator.page,1);this.zoomLevel=a.width/b.pageWidth;this.zoomLevel=
1>this.zoomLevel?1:this.zoomLevel};a.prototype.resetZoomLevel=function(){this.zoomSave||(this.zoomLevel=1)};var b=function(a,b,d,h,g){h=h||window.innerWidth;var l=g||window.innerHeight-2,s=h/l,k=a/b;g=s>k?l:b*h/a;b=Math.round((s>k?a*l/b:h)*d);g=Math.round(g*d);return{width:b,height:g,ratio:b/a}},d=function(a,b,d){var h=window.innerWidth;b=b*h/a;h=Math.round(h*d);b=Math.round(b*d);return{width:h,height:b,ratio:h/a}};window.BookModel=a}();
var SINGLE_CLICK="singleClick",DOUBLE_CLICK="doubleClick",WAIT_FOR_DOUBLE_CLICK_TIMEOUT=250,MS_CLICKED_ONCE="clickedOnce";
function setClickEvents(a,b,d){function e(a,b,e){b.changedTouches&&(b=b.changedTouches[0]);a.initMouseEvent(e,!0,!0,window,1,b.screenX,b.screenY,b.clientX,b.clientY,b.ctrlKey,b.altKey,b.shiftKey,b.metaKey,0,null)}d=d?d:!1;var c=!1,f=!1;if(!0===b||!1===b)h=b;else var h=b?-1!=b.indexOf("d"):!1,g=b?-1!=b.indexOf("m"):!1,c=b?-1!=b.indexOf("s"):!1,f=b?-1!=b.indexOf("p"):!1;a.ondblclick=function(a){a.preventDefault();return!1};var l=function(b){function k(){a.removeEventListener(t,z,d);a.removeEventListener(m,
n,d);a.removeEventListener("touchcancel",u)}var t;if(!(b.ctrlKey||b.altKey||b.shiftKey)){if("touchstart"==b.type){a.removeEventListener("mousedown",l,d);var m="touchend";t="touchmove"}else m="mouseup",t="mousemove",a.removeEventListener("touchstart",l,d);if(a.mstate==MS_CLICKED_ONCE){window.clearTimeout(a.resetClickTimeout);a.mstate="";var r=function(b){var g=Modernizr.touch?b.changedTouches[0]:b;30>Math.abs(g.clientX-a.positionObj.x)&&30>Math.abs(g.clientY-a.positionObj.y)&&(g=document.createEvent("MouseEvent"),
e(g,b,DOUBLE_CLICK),a.dispatchEvent(g));a.removeEventListener(m,r,d);k();f&&b.preventDefault();if(c)return b.stopPropagation(),!1};h&&a.addEventListener(m,r,d);f&&b.preventDefault()}else{var p=Modernizr.touch?b.touches[0]:b;a.positionObj={x:p.clientX,y:p.clientY};var n=function(b){a.removeEventListener(m,n,d);var f=document.createEvent("MouseEvent");e(f,b,SINGLE_CLICK);h?(a.mstate=MS_CLICKED_ONCE,a.resetClickTimeout=setTimeout(function(){a.dispatchEvent(f);k();a.mstate=""},WAIT_FOR_DOUBLE_CLICK_TIMEOUT)):
(a.dispatchEvent(f),k(),a.mstate="");if(c)return b.stopPropagation(),!1};a.addEventListener(m,n,d);a.addEventListener("touchcancel",u,!1);var u=function(){k();a.mstate=""};if(g){if(!Modernizr.touch)var q=b.clientX,v=b.clientY;var z=function(b){if(Modernizr.touch||q!=b.clientX||v!=b.clientY)k(),a.mstate=""};a.addEventListener(t,z,d)}}}};a.addEventListener(Modernizr.touch?"touchstart":"mousedown",l,d)}
function mouseHandler(a){var b="";switch(a.type){case "mousedown":b="touchstart";break;case "mousemove":b="touchmove";break;case "mouseup":b="touchend";break;default:return}var d=[{screenX:a.screenX,screenY:a.screenY,clientX:a.clientX,clientY:a.clientY}],e=document.createEvent("MouseEvent");e.initMouseEvent(b,!0,!0,window,1,a.screenX,a.screenY,a.clientX,a.clientY,!1,!1,!1,!1,1,null);e.simulated=!0;e.touches=d;e.targetTouches=d;e.changedTouches=d;a.target.dispatchEvent(e);a.preventDefault();a.stopPropagation();
return!1}function redirectGlobalEvents(){}
function testCrossEvents(){redirectGlobalEvents();setClickEvents(document.getElementById("test"),!1);setClickEvents(document.getElementById("Div2"),!0);document.getElementById("Div2").addEventListener(DOUBLE_CLICK,function(a){document.getElementById("log").innerHTML+="btn"+a.type+a.screenX+a.currentTarget.id+"<br>";return!1});document.getElementById("test").addEventListener(SINGLE_CLICK,function(a){document.getElementById("log").innerHTML+="div"+a.type+a.screenX+"<br>";return!1});document.getElementById("test").addEventListener("touchstart",
function(a){document.getElementById("log").innerHTML+="touch "+a.touches+"<br>";return!1})}
function initCrossEvents(){if(Modernizr){var a=Modernizr.touch;DOWN_EVENT=a?"touchstart":"mousedown";UP_EVENT=a?"touchend":"mouseup";MOVE_EVENT=a?"touchmove":"mousemove"}else console.log("Modernizr is undefined");window.fconsole=new FBConsole;window.showConsole=function(){window.fconsole.append()};for(a=0;a<document.head.getElementsByTagName("meta").length;a++){var b=document.head.getElementsByTagName("meta")[a];"viewport"==b.name&&fconsole.log(b.content)}fconsole.log("displayRatio:",window.devicePixelRatio)}
ADD_BM="addBm";REMOVE_BM="removeBm";START_SEARCH="startSearch";CANCEL_SEARCH="cancelSearch";SHOW_SEARCH_RESULTS="showSearchResults";ZOOMIN_FROM_WORKSPACE="zoomInFromWorkspace";ZOOMOUT_FROM_WORKSPACE="zoomOutFromWorkspace";BOOK_FLIPPING_START="bookFlippingStart";BOOK_FLIPPING_END="bookFlippingEnd";CHANGE_BOOK_TYPE="changeBookType";SLIDER_TO_PAGER_CHANGE_LABEL="sliderToPagerChangeLabel";ROTATE_DEVICE="rotateDevice";DOUBLE_TAP_FROM_WORKSPACE="double_tap_from_workspace";IOS_LOAD_PAGE_START="iOSLoadPageStart";
IOS_LOAD_VECTOR_END="iOSLoadVectorEnd";IOS_LOAD_BITMAP_END="iOSLoadBitmapEnd";IOS_FULLSCREEN="iOSFullScreen";LOAD_MANAGER_PAGE_CONTENT_LOAD_COMPLETE="LOAD_MANAGER_PAGE_CONTENT_LOAD_COMPLETE";ANDROID_PAGE_PREPARED="ANDROID_PAGE_PREPARED";ZOOM_ANIMATION_START="zoom_animation_start";ZOOM_ANIMATION_END="zoom_animation_end";ZOOM_ANIMATION_END_TO_ONE="zoom_animation_end_to_one";ZOOM_ANIMATION_END_TO_TWO="zoom_animation_end_to_two";ZOOM_ZOOM_ANIMATION_END="ZOOM_ZOOM_ANIMATION_END";START_ZOOM_PRELOADER="startZoomPreloader";
STOP_ZOOM_PRELOADER="stopZoomPreloader";ZOOM_LEVEL_CHANGED_FOR_WORKSPACE="zoom_level_changed_for_workspace";SEND_STATISTICS="send_statistics";PAGE_CONTENT_DISPLAYED="page_content_displayed";SLIDE_ANIMATION_END="slide_animation_end";function CustomEvents(){this._listeners={}}
CustomEvents.prototype={addEvent:function(a){throw Error("obsolete function");},removeEvent:function(a){throw Error("obsolete function");},addListener:function(a,b){void 0==this._listeners[a]&&(this._listeners[a]=[]);this._listeners[a].push(b);return!0},removeListener:function(a,b){if(void 0==this._listeners[a])return!1;var d=this._listeners[a].indexOf(b);if(-1!=d)this._listeners[a].splice(d,1);else return!1;return!0},fireEvent:function(a,b){if(void 0!=this._listeners[a])for(var d=0,e=this._listeners[a].length;d<
e;d++)void 0!=this._listeners[a][d]&&this._listeners[a][d].call(this,{type:a,data:b,target:this})}};customEvents=new CustomEvents;
var sendPage=function(){var a=window.location.hash.replace("#",""),b=window.location.hostname+window.location.pathname;GAEnable&&PUBL&&_trackPageview(b+"-"+pageTable.getUserIDFromFileID(a))},sendZoomIn=function(){var a=window.location.hash.replace("#",""),b=window.location.hostname+window.location.pathname;sendPage();GAEnable&&PUBL&&_trackEvent(b+"","Zooming","page"+a)},sendZoomOut=function(){var a=window.location.hash.replace("#",""),b=window.location.hostname+window.location.pathname;sendPage();
GAEnable&&PUBL&&_trackEvent(b+"","Zooming out","page"+a)};customEvents.addListener(BOOK_FLIPPING_END,sendPage);customEvents.addListener(ZOOM_ANIMATION_END,sendZoomIn);customEvents.addListener(ZOOM_ANIMATION_END_TO_ONE,sendZoomOut);customEvents.addListener(ZOOM_ANIMATION_END_TO_TWO,sendZoomOut);customEvents.addListener(ANDROID_PAGE_PREPARED,sendPage);customEvents.addListener(ZOOMIN_FROM_WORKSPACE,sendZoomIn);customEvents.addListener(ZOOMOUT_FROM_WORKSPACE,sendZoomOut);
customEvents.addListener(DOUBLE_TAP_FROM_WORKSPACE,sendZoomIn);function createDiv(a,b){var d=document.createElement("div");d.setAttribute("id",a);d.style.position="absolute";b&&(d.style.overflow="hidden");return d}var FCONSOLE_MAX_ROWS=33,LINE_BR="<br />";
function FBConsole(){function a(a){for(var b="",d=0;d<a.length;d++){switch(typeof a[d]){case "number":b+=e(a[d].toString(),"blue");break;default:b+=a[d]}d<a.length-1&&(b+=" ")}return b}function b(){d.innerHTML=h+(g?"":LINE_BR+LINE_BR+f)}var d=createDiv("fconsole"),e=function(a,b){return'<font color="'+b+'">'+a+"</font>"};d.style.left="0px";d.style.top="100px";d.style.width="100";d.style.height="100";d.style.opacity="0.7";d.style.backgroundColor="#e0efee";d.style.color="#11111f";d.style.fontSize="14px";
d.style.zIndex=100;d.style.webkitTransform="translate3d(0px,0px,500px)";d.addEventListener(UP_EVENT,function(a){g?(g=!1,b()):(f=[],b(),g=!0)},!1);var c=[],f=[],h="",g,l=!1;this.append=function(){l=!0;document.body.appendChild(d);b()};this.update=function(a,d){for(var f,g=0;g<c.length;g++)c[g].name==a&&(f=c[g]);"number"==typeof d&&(d=d.toString());f?f.value=d:c.push({name:a,value:d});h="";for(g=0;g<c.length;g++)h+=e(c[g].name,"green")+": "+e(c[g].value,"blue")+(g==c.length-1?"":LINE_BR);l&&b()};this.log=
function(e){f.length>FCONSOLE_MAX_ROWS-1&&f.shift();var d=a(arguments);f.push(d+LINE_BR);l&&b()};this.logAdd=function(e){var d=a(arguments);f[f.length-1]+=" "+d;l&&b()}}function HighlightItem(a,b,d,e){var c="R"==a[1],f,h,g;c?(f=a[2]/10,h=a[3]/10,g=a[4]/1E3,a=a[5]/10):(f=a[1]/10,h=a[2]/10,g=a[3]/1E3,a=a[4]/10);var l=0===d?0:b[d-1]/10;b=b[d+(e-1)]/10-l;this.y=h;this.x=f+l-(c?b:0);this.width=b;this.height=a;this.angle=g}
var highlight={getFillStyle:function(){return"rgba("+fbUtils.hexToRGB(publicationData.search.color)+",0.4)"},active:!1,init:function(){var a=this;customEvents.addListener(SHOW_SEARCH_RESULTS,function(){a.show()});customEvents.addListener(CANCEL_SEARCH,function(){a.hide()})},show:function(a,b,d){d=d||b;a=a||-10;search.active&&search.pages[a]&&(-10==a&&(a=pageMediator.page),b=b||el.id("highlightCanvas"+a),this.process(function(){highlight.light.apply(this,arguments)},a,b),this.active=!0);publicationData.page[a].videos&&
video.inject(d,a)},hide:function(a,b){a=a||-10;-10==a?this.active=!1:this.claerPage(a,b);search.stop()},claerPage:function(a,b){b=b||el.id("highlightCanvas"+a);b.getContext("2d").clearRect(0,0,b.width,b.height);this.active=!1},process:function(a,b,d,e){d&&this.claerPage(b,d);var c=function(){for(var c=this.responseText.split("\n"),f=search.query.toLowerCase()||"",f=fbUtils.split(f,0),l=1;l<c.length;l++)for(var s=c[l],k=0,t=0;t<f.length;t++){var m=f[t],r=s.split(String.fromCharCode(2));if(m.length<
publicationData.search.lim){var p=void 0!=c[l-1]?c[l-1].split(String.fromCharCode(2))[0]:"",k=c[l].split(String.fromCharCode(2))[0]||"",n=void 0!=c[l+1]?c[l+1].split(String.fromCharCode(2))[0]:"",p=p+" "+k,k=k+" "+n,n=f[t-1]||"",u=f[t],q=f[t+1]||"",v=n+" "+u,z=u+" "+q,u=!1;""!=n&&-1!=p.toLowerCase().indexOf(v)&&(u=!0);""!=q&&-1!=k.toLowerCase().indexOf(z)&&(u=!0)}else u=!0;if(-1!=(k=r[0].toLowerCase().indexOf(m))&&u)if(n=s.split(String.fromCharCode(4)),1<n.length){r=[];p=[];for(q=0;q<n.length;q++)r[q]=
n[q].split(String.fromCharCode(2)),0<q&&r[q].unshift(r[0][0]),p[q]=r[q][5].split(String.fromCharCode(3));n=k;m=k+m.length;for(k=0;k<r.length;k++)p[k].length<=n?(n-=p[k].length,m-=p[k].length):(m>p[k].length?(q=p[k].length,m-=p[k].length):(q=m,m=0),0<n&&(q-=n),q=new HighlightItem(r[k],p[k],n,q),n=0,a(q,d,b))}else p="R"==r[1]?r[6].split(String.fromCharCode(3)):r[5].split(String.fromCharCode(3)),q=new HighlightItem(r,p,k,m.length),a(q,d,b)}e&&e()};if(PUBL)publ.getData(ASSETS_FOLDER+"/search/search"+
fbUtils.getNum(b)+".xml",c);else{var f=new XMLHttpRequest;f.open("GET",ASSETS_FOLDER+"/search/search"+fbUtils.getNum(b)+".xml");f.onload=c;f.onerror=function(){};f.send();delete f}},light:function(a,b,d){var e=b.getContext("2d");e.fillStyle=window.highlight.getFillStyle();b=b.width/(publicationData.page[d].width||publicationData.page.defaults.width);d=a.x;var c=a.y,f=a.width,h=a.height;e.save();e.scale(b,b);e.translate(d,c);e.rotate(a.angle);e.clearRect(0,0,f,h);e.fillRect(0,0,f,h);e.restore();delete null},
getHighlights:function(a,b){var d=[];this.process(function(a){d.push(a)},a,null,function(){b(d)})}},HTML5lib={init:function(){switch(system.browser.name){case "safari":this.browserPrefix="webkit";break;case "firefox":this.browserPrefix="Moz";break;case "opera":this.browserPrefix="O";break;case "ie":this.browserPrefix="ms";break;case "chrome":this.browserPrefix="webkit"}},translate:function(a,b,d,e){b=b||0;d=d||0;a.style[this.browserPrefix+"Transform"]=Modernizr.csstransforms3d?"translate3d("+b+"px,"+
d+"px,"+(e||0)+"px)":"translate("+b+"px,"+d+"px)"},duration:function(a,b){a.style[this.browserPrefix+"TransitionDuration"]=b+"ms"},perspective:function(a,b){a.style[this.browserPrefix+"Transform"]="perspective("+b+")"},scale:function(a,b,d){a=a||0;b=b||0;el.style[this.browserPrefix+"Transform"]=Modernizr.csstransforms3d?"scale3d("+a+","+b+","+(d||0)+")":"scale("+a+","+b+")"},rotate:function(a,b,d,e,c){d=d||0;a.style[this.browserPrefix+"Transform"]=Modernizr.csstransforms3d?"rotate3d("+d+","+d+","+
d+","+b+"deg)":"rotate("+b+"deg)"},backfaceVisibility:function(a,b){a.style[this.browserPrefix+"BackfaceVisibility"]=b},boxShadow:function(a,b){a&&(a.style[this.browserPrefix+"BoxShadow"]=b)},getTransform:function(a){return a.style[this.browserPrefix+"Transform"]},transform:function(a,b,d){a.style[this.browserPrefix+"TransformOrigin"]="0px 0px";a.style[this.browserPrefix+"Transform"]="translate3d("+b+"px,"+d+"px,0px)"},getParseTranslate:function(a){a=a.style[this.browserPrefix+"Transform"].match(/-*\d+(?=px)|\d+\%/ig);
null==a&&(a=[0,0,0]);return{x:a[0],y:a[1],z:a[2]}},changeOnlyScale:function(a,b,d,e){re=/translate3d\([A-Za-z0-9_, ]*\)/i;var c=a.style[this.browserPrefix+"Transform"].match(re);null===c&&(c="");a.style[this.browserPrefix+"Transform"]=c+" scale3d("+b+","+d+","+e+")"}};
(function(a,b){function d(a){if(""===f)return a;a=a.charAt(0).toUpperCase()+a.substr(1);return f+a}var e=Math,c=b.createElement("div").style,f=function(){for(var a=["t","webkitT","MozT","msT","OT"],b,e=0,d=a.length;e<d;e++)if(b=a[e]+"ransform",b in c)return a[e].substr(0,a[e].length-1);return!1}(),h=f?"-"+f.toLowerCase()+"-":"",g=d("transform"),l=d("transitionProperty"),s=d("transitionDuration"),k=d("transformOrigin"),t=d("transitionTimingFunction"),m=d("transitionDelay"),r=/android/gi.test(navigator.appVersion),
p=/iphone|ipad/gi.test(navigator.appVersion),n=/hp-tablet/gi.test(navigator.appVersion),u=d("perspective")in c,q="ontouchstart"in a&&!n,v=!1!==f,z=d("transition")in c,E="onorientationchange"in a?"orientationchange":"resize",F=q?"touchstart":"mousedown",B=q?"touchmove":"mousemove",C=q?"touchend":"mouseup",D=q?"touchcancel":"mouseup",A=!1===f?!1:{"":"transitionend",webkit:"webkitTransitionEnd",Moz:"transitionend",O:"otransitionend",ms:"MSTransitionEnd"}[f],H=function(){return a.requestAnimationFrame||
a.webkitRequestAnimationFrame||a.mozRequestAnimationFrame||a.oRequestAnimationFrame||a.msRequestAnimationFrame||function(a){return setTimeout(a,1)}}(),G=a.cancelRequestAnimationFrame||a.webkitCancelAnimationFrame||a.webkitCancelRequestAnimationFrame||a.mozCancelRequestAnimationFrame||a.oCancelRequestAnimationFrame||a.msCancelRequestAnimationFrame||clearTimeout,w=u?" translateZ(0)":"",n=function(e,d){var c=this,f;c.wrapper="object"==typeof e?e:b.getElementById(e);c.wrapper.style.overflow="hidden";
c.scroller=c.wrapper.children[0];c.options={hScroll:!0,vScroll:!0,x:0,y:0,bounce:!0,bounceLock:!1,momentum:!0,lockDirection:!0,useTransform:!0,useTransition:!1,topOffset:0,checkDOMChanges:!1,handleClick:!0,hScrollbar:!0,vScrollbar:!0,fixedScrollbar:r,hideScrollbar:p,fadeScrollbar:p&&u,scrollbarClass:"",zoom:!1,zoomMin:1,zoomMax:4,doubleTapZoom:2,wheelAction:"scroll",snap:!1,snapThreshold:1,onRefresh:null,onBeforeScrollStart:function(a){a.preventDefault()},onScrollStart:null,onBeforeScrollMove:null,
onScrollMove:null,onBeforeScrollEnd:null,onScrollEnd:null,onTouchEnd:null,onDestroy:null,onZoomStart:null,onZoom:null,onZoomEnd:null};for(f in d)c.options[f]=d[f];c.x=c.options.x;c.y=c.options.y;c.options.useTransform=v&&c.options.useTransform;c.options.hScrollbar=c.options.hScroll&&c.options.hScrollbar;c.options.vScrollbar=c.options.vScroll&&c.options.vScrollbar;c.options.zoom=c.options.useTransform&&c.options.zoom;c.options.useTransition=z&&c.options.useTransition;c.options.zoom&&r&&(w="");c.scroller.style[l]=
c.options.useTransform?h+"transform":"top left";c.scroller.style[s]="0";c.scroller.style[k]="0 0";c.options.useTransition&&(c.scroller.style[t]="cubic-bezier(0.33,0.66,0.66,1)");c.options.useTransform?c.scroller.style[g]="translate("+c.x+"px,"+c.y+"px)"+w:c.scroller.style.cssText+=";position:absolute;top:"+c.y+"px;left:"+c.x+"px";c.options.useTransition&&(c.options.fixedScrollbar=!0);c.refresh();c._bind(E,a);c._bind(F);q||"none"==c.options.wheelAction||(c._bind("DOMMouseScroll"),c._bind("mousewheel"));
c.options.checkDOMChanges&&(c.checkDOMTime=setInterval(function(){c._checkDOMChanges()},500))};n.prototype={enabled:!0,x:0,y:0,steps:[],scale:1,currPageX:0,currPageY:0,pagesX:[],pagesY:[],aniTime:null,wheelZoomCount:0,handleEvent:function(a){switch(a.type){case F:if(!q&&0!==a.button)break;this._start(a);break;case B:this._move(a);break;case C:case D:this._end(a);break;case E:this._resize();break;case "DOMMouseScroll":case "mousewheel":this._wheel(a);break;case A:this._transitionEnd(a)}},_checkDOMChanges:function(){this.moved||
this.zoomed||this.animating||this.scrollerW==this.scroller.offsetWidth*this.scale&&this.scrollerH==this.scroller.offsetHeight*this.scale||this.refresh()},_scrollbar:function(a){var d;this[a+"Scrollbar"]?(this[a+"ScrollbarWrapper"]||(d=b.createElement("div"),this.options.scrollbarClass?d.className=this.options.scrollbarClass+a.toUpperCase():d.style.cssText="position:absolute;z-index:100;"+("h"==a?"height:7px;bottom:1px;left:2px;right:"+(this.vScrollbar?"7":"2")+"px":"width:7px;bottom:"+(this.hScrollbar?
"7":"2")+"px;top:2px;right:1px"),d.style.cssText+=";pointer-events:none;"+h+"transition-property:opacity;"+h+"transition-duration:"+(this.options.fadeScrollbar?"350ms":"0")+";overflow:hidden;opacity:"+(this.options.hideScrollbar?"0":"1"),this.wrapper.appendChild(d),this[a+"ScrollbarWrapper"]=d,d=b.createElement("div"),this.options.scrollbarClass||(d.style.cssText="position:absolute;z-index:100;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);"+h+"background-clip:padding-box;"+h+"box-sizing:border-box;"+
("h"==a?"height:100%":"width:100%")+";"+h+"border-radius:3px;border-radius:3px"),d.style.cssText+=";pointer-events:none;"+h+"transition-property:"+h+"transform;"+h+"transition-timing-function:cubic-bezier(0.33,0.66,0.66,1);"+h+"transition-duration:0;"+h+"transform: translate(0,0)"+w,this.options.useTransition&&(d.style.cssText+=";"+h+"transition-timing-function:cubic-bezier(0.33,0.66,0.66,1)"),this[a+"ScrollbarWrapper"].appendChild(d),this[a+"ScrollbarIndicator"]=d),"h"==a?(this.hScrollbarSize=this.hScrollbarWrapper.clientWidth,
this.hScrollbarIndicatorSize=e.max(e.round(this.hScrollbarSize*this.hScrollbarSize/this.scrollerW),8),this.hScrollbarIndicator.style.width=this.hScrollbarIndicatorSize+"px",this.hScrollbarMaxScroll=this.hScrollbarSize-this.hScrollbarIndicatorSize,this.hScrollbarProp=this.hScrollbarMaxScroll/this.maxScrollX):(this.vScrollbarSize=this.vScrollbarWrapper.clientHeight,this.vScrollbarIndicatorSize=e.max(e.round(this.vScrollbarSize*this.vScrollbarSize/this.scrollerH),8),this.vScrollbarIndicator.style.height=
this.vScrollbarIndicatorSize+"px",this.vScrollbarMaxScroll=this.vScrollbarSize-this.vScrollbarIndicatorSize,this.vScrollbarProp=this.vScrollbarMaxScroll/this.maxScrollY),this._scrollbarPos(a,!0)):this[a+"ScrollbarWrapper"]&&(v&&(this[a+"ScrollbarIndicator"].style[g]=""),this[a+"ScrollbarWrapper"].parentNode.removeChild(this[a+"ScrollbarWrapper"]),this[a+"ScrollbarWrapper"]=null,this[a+"ScrollbarIndicator"]=null)},_resize:function(){var a=this;setTimeout(function(){a.refresh()},r?200:0)},_pos:function(a,
b){this.zoomed||(a=this.hScroll?a:0,b=this.vScroll?b:0,this.options.useTransform?this.scroller.style[g]="translate("+a+"px,"+b+"px) scale("+this.scale+")"+w:(a=e.round(a),b=e.round(b),this.scroller.style.left=a+"px",this.scroller.style.top=b+"px"),this.x=a,this.y=b,this._scrollbarPos("h"),this._scrollbarPos("v"))},_scrollbarPos:function(a,b){var d="h"==a?this.x:this.y;this[a+"Scrollbar"]&&(d*=this[a+"ScrollbarProp"],0>d?(this.options.fixedScrollbar||(d=this[a+"ScrollbarIndicatorSize"]+e.round(3*d),
8>d&&(d=8),this[a+"ScrollbarIndicator"].style["h"==a?"width":"height"]=d+"px"),d=0):d>this[a+"ScrollbarMaxScroll"]&&(this.options.fixedScrollbar?d=this[a+"ScrollbarMaxScroll"]:(d=this[a+"ScrollbarIndicatorSize"]-e.round(3*(d-this[a+"ScrollbarMaxScroll"])),8>d&&(d=8),this[a+"ScrollbarIndicator"].style["h"==a?"width":"height"]=d+"px",d=this[a+"ScrollbarMaxScroll"]+(this[a+"ScrollbarIndicatorSize"]-d))),this[a+"ScrollbarWrapper"].style[m]="0",this[a+"ScrollbarWrapper"].style.opacity=b&&this.options.hideScrollbar?
"0":"1",this[a+"ScrollbarIndicator"].style[g]="translate("+("h"==a?d+"px,0)":"0,"+d+"px)")+w)},_start:function(b){var d=q?b.touches[0]:b,c,f;this.enabled&&(this.options.onBeforeScrollStart&&this.options.onBeforeScrollStart.call(this,b),(this.options.useTransition||this.options.zoom)&&this._transitionTime(0),this.zoomed=this.animating=this.moved=!1,this.dirY=this.dirX=this.absDistY=this.absDistX=this.distY=this.distX=0,this.options.zoom&&q&&1<b.touches.length&&(f=e.abs(b.touches[0].pageX-b.touches[1].pageX),
c=e.abs(b.touches[0].pageY-b.touches[1].pageY),this.touchesDistStart=e.sqrt(f*f+c*c),this.originX=e.abs(b.touches[0].pageX+b.touches[1].pageX-2*this.wrapperOffsetLeft)/2-this.x,this.originY=e.abs(b.touches[0].pageY+b.touches[1].pageY-2*this.wrapperOffsetTop)/2-this.y,this.options.onZoomStart&&this.options.onZoomStart.call(this,b)),this.options.momentum&&(this.options.useTransform?(c=getComputedStyle(this.scroller,null)[g].replace(/[^0-9\-.,]/g,"").split(","),f=+(c[12]||c[4]),c=+(c[13]||c[5])):(f=
+getComputedStyle(this.scroller,null).left.replace(/[^0-9-]/g,""),c=+getComputedStyle(this.scroller,null).top.replace(/[^0-9-]/g,"")),f!=this.x||c!=this.y)&&(this.options.useTransition?this._unbind(A):G(this.aniTime),this.steps=[],this._pos(f,c),this.options.onScrollEnd&&this.options.onScrollEnd.call(this)),this.absStartX=this.x,this.absStartY=this.y,this.startX=this.x,this.startY=this.y,this.pointX=d.pageX,this.pointY=d.pageY,this.startTime=b.timeStamp||Date.now(),this.options.onScrollStart&&this.options.onScrollStart.call(this,
b),this._bind(B,a),this._bind(C,a),this._bind(D,a))},_move:function(a){var b=q?a.touches[0]:a,d=b.pageX-this.pointX,c=b.pageY-this.pointY,f=this.x+d,h=this.y+c,k=a.timeStamp||Date.now();this.options.onBeforeScrollMove&&this.options.onBeforeScrollMove.call(this,a);if(this.options.zoom&&q&&1<a.touches.length)f=e.abs(a.touches[0].pageX-a.touches[1].pageX),h=e.abs(a.touches[0].pageY-a.touches[1].pageY),this.touchesDist=e.sqrt(f*f+h*h),this.zoomed=!0,b=1/this.touchesDistStart*this.touchesDist*this.scale,
b<this.options.zoomMin?b=0.5*this.options.zoomMin*Math.pow(2,b/this.options.zoomMin):b>this.options.zoomMax&&(b=2*this.options.zoomMax*Math.pow(0.5,this.options.zoomMax/b)),this.lastScale=b/this.scale,f=this.originX-this.originX*this.lastScale+this.x,h=this.originY-this.originY*this.lastScale+this.y,this.scroller.style[g]="translate("+f+"px,"+h+"px) scale("+b+")"+w,this.options.onZoom&&this.options.onZoom.call(this,a);else{this.pointX=b.pageX;this.pointY=b.pageY;if(0<f||f<this.maxScrollX)f=this.options.bounce?
this.x+d/2:0<=f||0<=this.maxScrollX?0:this.maxScrollX;if(h>this.minScrollY||h<this.maxScrollY)h=this.options.bounce?this.y+c/2:h>=this.minScrollY||0<=this.maxScrollY?this.minScrollY:this.maxScrollY;this.distX+=d;this.distY+=c;this.absDistX=e.abs(this.distX);this.absDistY=e.abs(this.distY);6>this.absDistX&&6>this.absDistY||(this.options.lockDirection&&(this.absDistX>this.absDistY+5?(h=this.y,c=0):this.absDistY>this.absDistX+5&&(f=this.x,d=0)),this.moved=!0,this._pos(f,h),this.dirX=0<d?-1:0>d?1:0,this.dirY=
0<c?-1:0>c?1:0,300<k-this.startTime&&(this.startTime=k,this.startX=this.x,this.startY=this.y),this.options.onScrollMove&&this.options.onScrollMove.call(this,a))}},_end:function(d){if(!q||0===d.touches.length){var c=this,f=q?d.changedTouches[0]:d,h,k,m={dist:0,time:0},l={dist:0,time:0},r=(d.timeStamp||Date.now())-c.startTime,n=c.x,p=c.y;c._unbind(B,a);c._unbind(C,a);c._unbind(D,a);c.options.onBeforeScrollEnd&&c.options.onBeforeScrollEnd.call(c,d);if(c.zoomed)n=c.scale*c.lastScale,n=Math.max(c.options.zoomMin,
n),n=Math.min(c.options.zoomMax,n),c.lastScale=n/c.scale,c.scale=n,c.x=c.originX-c.originX*c.lastScale+c.x,c.y=c.originY-c.originY*c.lastScale+c.y,c.scroller.style[s]="200ms",c.scroller.style[g]="translate("+c.x+"px,"+c.y+"px) scale("+c.scale+")"+w,c.zoomed=!1,c.refresh(),c.options.onZoomEnd&&c.options.onZoomEnd.call(c,d);else{if(c.moved){if(300>r&&c.options.momentum){m=n?c._momentum(n-c.startX,r,-c.x,c.scrollerW-c.wrapperW+c.x,c.options.bounce?c.wrapperW:0):m;l=p?c._momentum(p-c.startY,r,-c.y,0>
c.maxScrollY?c.scrollerH-c.wrapperH+c.y-c.minScrollY:0,c.options.bounce?c.wrapperH:0):l;n=c.x+m.dist;p=c.y+l.dist;if(0<c.x&&0<n||c.x<c.maxScrollX&&n<c.maxScrollX)m={dist:0,time:0};if(c.y>c.minScrollY&&p>c.minScrollY||c.y<c.maxScrollY&&p<c.maxScrollY)l={dist:0,time:0}}m.dist||l.dist?(m=e.max(e.max(m.time,l.time),10),c.options.snap&&(l=n-c.absStartX,r=p-c.absStartY,e.abs(l)<c.options.snapThreshold&&e.abs(r)<c.options.snapThreshold?c.scrollTo(c.absStartX,c.absStartY,200):(l=c._snap(n,p),n=l.x,p=l.y,
m=e.max(l.time,m))),c.scrollTo(e.round(n),e.round(p),m)):c.options.snap?(l=n-c.absStartX,r=p-c.absStartY,e.abs(l)<c.options.snapThreshold&&e.abs(r)<c.options.snapThreshold?c.scrollTo(c.absStartX,c.absStartY,200):(l=c._snap(c.x,c.y),l.x==c.x&&l.y==c.y||c.scrollTo(l.x,l.y,l.time))):c._resetPos(200)}else q&&(c.doubleTapTimer&&c.options.zoom?(clearTimeout(c.doubleTapTimer),c.doubleTapTimer=null,c.options.onZoomStart&&c.options.onZoomStart.call(c,d),c.zoom(c.pointX,c.pointY,1==c.scale?c.options.doubleTapZoom:
1),c.options.onZoomEnd&&setTimeout(function(){c.options.onZoomEnd.call(c,d)},200)):this.options.handleClick&&(c.doubleTapTimer=setTimeout(function(){c.doubleTapTimer=null;for(h=f.target;1!=h.nodeType;)h=h.parentNode;"SELECT"!=h.tagName&&"INPUT"!=h.tagName&&"TEXTAREA"!=h.tagName&&(k=b.createEvent("MouseEvents"),k.initMouseEvent("click",!0,!0,d.view,1,f.screenX,f.screenY,f.clientX,f.clientY,d.ctrlKey,d.altKey,d.shiftKey,d.metaKey,0,null),k._fake=!0,h.dispatchEvent(k))},c.options.zoom?250:0))),c._resetPos(400);
c.options.onTouchEnd&&c.options.onTouchEnd.call(c,d)}}},_resetPos:function(a){var b=0<=this.x?0:this.x<this.maxScrollX?this.maxScrollX:this.x,c=this.y>=this.minScrollY||0<this.maxScrollY?this.minScrollY:this.y<this.maxScrollY?this.maxScrollY:this.y;b==this.x&&c==this.y?(this.moved&&(this.moved=!1,this.options.onScrollEnd&&this.options.onScrollEnd.call(this)),this.hScrollbar&&this.options.hideScrollbar&&("webkit"==f&&(this.hScrollbarWrapper.style[m]="300ms"),this.hScrollbarWrapper.style.opacity="0"),
this.vScrollbar&&this.options.hideScrollbar&&("webkit"==f&&(this.vScrollbarWrapper.style[m]="300ms"),this.vScrollbarWrapper.style.opacity="0")):this.scrollTo(b,c,a||0)},_wheel:function(a){var b=this,c,e;if("wheelDeltaX"in a)c=a.wheelDeltaX/12,e=a.wheelDeltaY/12;else if("wheelDelta"in a)c=e=a.wheelDelta/12;else if("detail"in a)c=e=3*-a.detail;else return;"zoom"==b.options.wheelAction?(e=b.scale*Math.pow(2,1/3*(e?e/Math.abs(e):0)),e<b.options.zoomMin&&(e=b.options.zoomMin),e>b.options.zoomMax&&(e=b.options.zoomMax),
e!=b.scale&&(!b.wheelZoomCount&&b.options.onZoomStart&&b.options.onZoomStart.call(b,a),b.wheelZoomCount++,b.zoom(a.pageX,a.pageY,e,400),setTimeout(function(){b.wheelZoomCount--;!b.wheelZoomCount&&b.options.onZoomEnd&&b.options.onZoomEnd.call(b,a)},400))):(c=b.x+c,e=b.y+e,0<c?c=0:c<b.maxScrollX&&(c=b.maxScrollX),e>b.minScrollY?e=b.minScrollY:e<b.maxScrollY&&(e=b.maxScrollY),0>b.maxScrollY&&b.scrollTo(c,e,0))},_transitionEnd:function(a){a.target==this.scroller&&(this._unbind(A),this._startAni())},_startAni:function(){var a=
this,b=a.x,c=a.y,d=Date.now(),f,g,h;a.animating||(a.steps.length?(f=a.steps.shift(),f.x==b&&f.y==c&&(f.time=0),a.animating=!0,a.moved=!0,a.options.useTransition?(a._transitionTime(f.time),a._pos(f.x,f.y),a.animating=!1,f.time?a._bind(A):a._resetPos(0)):(h=function(){var l=Date.now(),k;l>=d+f.time?(a._pos(f.x,f.y),a.animating=!1,a.options.onAnimationEnd&&a.options.onAnimationEnd.call(a),a._startAni()):(l=(l-d)/f.time-1,g=e.sqrt(1-l*l),l=(f.x-b)*g+b,k=(f.y-c)*g+c,a._pos(l,k),a.animating&&(a.aniTime=
H(h)))},h())):a._resetPos(400))},_transitionTime:function(a){a+="ms";this.scroller.style[s]=a;this.hScrollbar&&(this.hScrollbarIndicator.style[s]=a);this.vScrollbar&&(this.vScrollbarIndicator.style[s]=a)},_momentum:function(a,b,c,d,f){b=e.abs(a)/b;var g=b*b/0.0012;0<a&&g>c?(c+=f/(6/(6E-4*(g/b))),b=b*c/g,g=c):0>a&&g>d&&(d+=f/(6/(6E-4*(g/b))),b=b*d/g,g=d);return{dist:g*(0>a?-1:1),time:e.round(b/6E-4)}},_offset:function(a){for(var b=-a.offsetLeft,c=-a.offsetTop;a=a.offsetParent;)b-=a.offsetLeft,c-=a.offsetTop;
a!=this.wrapper&&(b*=this.scale,c*=this.scale);return{left:b,top:c}},_snap:function(a,b){var c,d,f;f=this.pagesX.length-1;c=0;for(d=this.pagesX.length;c<d;c++)if(a>=this.pagesX[c]){f=c;break}f==this.currPageX&&0<f&&0>this.dirX&&f--;a=this.pagesX[f];d=(d=e.abs(a-this.pagesX[this.currPageX]))?500*(e.abs(this.x-a)/d):0;this.currPageX=f;f=this.pagesY.length-1;for(c=0;c<f;c++)if(b>=this.pagesY[c]){f=c;break}f==this.currPageY&&0<f&&0>this.dirY&&f--;b=this.pagesY[f];c=(c=e.abs(b-this.pagesY[this.currPageY]))?
500*(e.abs(this.y-b)/c):0;this.currPageY=f;f=e.round(e.max(d,c))||200;return{x:a,y:b,time:f}},_bind:function(a,b,c){(b||this.scroller).addEventListener(a,this,!!c)},_unbind:function(a,b,c){(b||this.scroller).removeEventListener(a,this,!!c)},destroy:function(){this.scroller.style[g]="";this.vScrollbar=this.hScrollbar=!1;this._scrollbar("h");this._scrollbar("v");this._unbind(E,a);this._unbind(F);this._unbind(B,a);this._unbind(C,a);this._unbind(D,a);this.options.hasTouch||(this._unbind("DOMMouseScroll"),
this._unbind("mousewheel"));this.options.useTransition&&this._unbind(A);this.options.checkDOMChanges&&clearInterval(this.checkDOMTime);this.options.onDestroy&&this.options.onDestroy.call(this)},refresh:function(){var a,b,c,d=0;b=0;this.scale<this.options.zoomMin&&(this.scale=this.options.zoomMin);this.wrapperW=this.wrapper.clientWidth||1;this.wrapperH=this.wrapper.clientHeight||1;this.minScrollY=-this.options.topOffset||0;this.scrollerW=e.round(this.scroller.offsetWidth*this.scale);this.scrollerH=
e.round((this.scroller.offsetHeight+this.minScrollY)*this.scale);this.maxScrollX=this.wrapperW-this.scrollerW;this.maxScrollY=this.wrapperH-this.scrollerH+this.minScrollY;this.dirY=this.dirX=0;this.options.onRefresh&&this.options.onRefresh.call(this);this.hScroll=this.options.hScroll&&0>this.maxScrollX;this.vScroll=this.options.vScroll&&(!this.options.bounceLock&&!this.hScroll||this.scrollerH>this.wrapperH);this.hScrollbar=this.hScroll&&this.options.hScrollbar;this.vScrollbar=this.vScroll&&this.options.vScrollbar&&
this.scrollerH>this.wrapperH;a=this._offset(this.wrapper);this.wrapperOffsetLeft=-a.left;this.wrapperOffsetTop=-a.top;if("string"==typeof this.options.snap)for(this.pagesX=[],this.pagesY=[],c=this.scroller.querySelectorAll(this.options.snap),a=0,b=c.length;a<b;a++)d=this._offset(c[a]),d.left+=this.wrapperOffsetLeft,d.top+=this.wrapperOffsetTop,this.pagesX[a]=d.left<this.maxScrollX?this.maxScrollX:d.left*this.scale,this.pagesY[a]=d.top<this.maxScrollY?this.maxScrollY:d.top*this.scale;else if(this.options.snap){for(this.pagesX=
[];d>=this.maxScrollX;)this.pagesX[b]=d,d-=this.wrapperW,b++;this.maxScrollX%this.wrapperW&&(this.pagesX[this.pagesX.length]=this.maxScrollX-this.pagesX[this.pagesX.length-1]+this.pagesX[this.pagesX.length-1]);b=d=0;for(this.pagesY=[];d>=this.maxScrollY;)this.pagesY[b]=d,d-=this.wrapperH,b++;this.maxScrollY%this.wrapperH&&(this.pagesY[this.pagesY.length]=this.maxScrollY-this.pagesY[this.pagesY.length-1]+this.pagesY[this.pagesY.length-1])}this._scrollbar("h");this._scrollbar("v");this.zoomed||(this.scroller.style[s]=
"0",this._resetPos(400))},scrollTo:function(a,b,c,e){var d=a;this.stop();d.length||(d=[{x:a,y:b,time:c,relative:e}]);a=0;for(b=d.length;a<b;a++)d[a].relative&&(d[a].x=this.x-d[a].x,d[a].y=this.y-d[a].y),this.steps.push({x:d[a].x,y:d[a].y,time:d[a].time||0});this._startAni()},scrollToElement:function(a,b){var c;if(a=a.nodeType?a:this.scroller.querySelector(a))c=this._offset(a),c.left+=this.wrapperOffsetLeft,c.top+=this.wrapperOffsetTop,c.left=0<c.left?0:c.left<this.maxScrollX?this.maxScrollX:c.left,
c.top=c.top>this.minScrollY?this.minScrollY:c.top<this.maxScrollY?this.maxScrollY:c.top,b=void 0===b?e.max(2*e.abs(c.left),2*e.abs(c.top)):b,this.scrollTo(c.left,c.top,b)},scrollToPage:function(a,b,c){c=void 0===c?400:c;this.options.onScrollStart&&this.options.onScrollStart.call(this);this.options.snap?(a="next"==a?this.currPageX+1:"prev"==a?this.currPageX-1:a,b="next"==b?this.currPageY+1:"prev"==b?this.currPageY-1:b,a=0>a?0:a>this.pagesX.length-1?this.pagesX.length-1:a,b=0>b?0:b>this.pagesY.length-
1?this.pagesY.length-1:b,this.currPageX=a,this.currPageY=b,a=this.pagesX[a],b=this.pagesY[b]):(a*=-this.wrapperW,b*=-this.wrapperH,a<this.maxScrollX&&(a=this.maxScrollX),b<this.maxScrollY&&(b=this.maxScrollY));this.scrollTo(a,b,c)},disable:function(){this.stop();this._resetPos(0);this.enabled=!1;this._unbind(B,a);this._unbind(C,a);this._unbind(D,a)},enable:function(){this.enabled=!0},stop:function(){this.options.useTransition?this._unbind(A):G(this.aniTime);this.steps=[];this.animating=this.moved=
!1},zoom:function(a,b,c,d){var e=c/this.scale;this.options.useTransform&&(this.zoomed=!0,d=void 0===d?200:d,a=a-this.wrapperOffsetLeft-this.x,b=b-this.wrapperOffsetTop-this.y,this.x=a-a*e+this.x,this.y=b-b*e+this.y,this.scale=c,this.refresh(),this.x=0<this.x?0:this.x<this.maxScrollX?this.maxScrollX:this.x,this.y=this.y>this.minScrollY?this.minScrollY:this.y<this.maxScrollY?this.maxScrollY:this.y,this.scroller.style[s]=d+"ms",this.scroller.style[g]="translate("+this.x+"px,"+this.y+"px) scale("+c+")"+
w,this.zoomed=!1)},isReady:function(){return!this.moved&&!this.zoomed&&!this.animating}};c=null;"undefined"!==typeof exports?exports.iScroll=n:a.iScroll=n})(window,document);ONLY_RASTER=!1;
function LoadManager(){function a(a){if(!a.waitingForImage&&!a.waitingForVector){if(a.onAllIsComplete)a.onAllIsComplete(a.image,a.vector);customEvents.fireEvent(PAGE_CONTENT_DISPLAYED);customEvents.fireEvent(LOAD_MANAGER_PAGE_CONTENT_LOAD_COMPLETE,{page:a.position});d.length?c():e="standby"}}function b(b,c){void 0!=window.fakeLoadComplete&&fconsole.log("error on fakeLoadComplete");(function(b){window.fakeLoadComplete=function(c){window.loadBuffers[c]=window.loadBuffer;b.waitingForVector=!1;if(b.onJSLoadComplete)b.onJSLoadComplete(window.loadBuffers[c]);
b.vector=window.loadBuffers[c];a(b)}})(c);addScript(b)}var d=[],e="standby";window.loadBuffers=[];var c=function(){var a=d.shift();h(a)},f=[],h=function(g){function h(){system.platform.ios&&this.parent.style.backgroundImage!=="url("+this.src+")"&&(this.parent.style.backgroundImage='url("'+this.src+'")');g.image=p;g.waitingForImage=!1;if(g.onImageLoadComplete)g.onImageLoadComplete(p,r);a(g)}function s(){g.waitingForImage=!1;var b=p.src;if(void 0!=g.onPageLoadError)g.onPageLoadError(g.position);else fconsole.log("load error ",
b);a(g)}if(publicationData.getPageProperty(g.position,"stub"))console.log("loadManager error: attempt to draw stub"),d.length?c():e="standby";else{var k=g.quality,t=publicationData.getPageProperty(g.position,k?"zoomFormat":"format"),m=-1!=t.indexOf("jpg")?"jpg":"png",r=-1!=t.indexOf("js")&&!ONLY_RASTER,k=window.debugSVG_IMG?"content/current_"+g.position+".svg":r?COMMON_FOLDER+"/page-substrates/"+("page"+fill4Zero(g.position))+"."+m:ASSETS_FOLDER+"/pages/"+("page"+fill4Zero(g.position))+(k?"_i2.":
"_i1.")+m,p=g.image||new Image;g.waitingForImage=!0;p.onload=h;p.onerror=s;(m=g.onImageStartLoading)&&m(p);r&&-1!==t.indexOf("js+")?(t=PAGES_JS_FOLDER+"/"+("page"+fill4Zero(g.position))+".js",g.waitingForVector=!0,function(c,d){changeUrlWhenPubl(c,function(c){if(-1!=f.indexOf(d.position)){d.waitingForVector=!1;d.vector=window.loadBuffers[d.position];if(d.onJSLoadComplete)d.onJSLoadComplete(window.loadBuffers[d.position]);a(d)}else d.waitingForVector=!0,b(c,d)})}(t,g)):g.waitingForVector=!1;changeUrlWhenPubl(k,
function(a){p.src!=a&&p.src!=qualifyURL(a)?p.src=a:h()})}};this.addPageToQueue=function(a){d.push(a);"standby"==e&&(e="loading",c())}}function escapeHTML(a){return a.split("&").join("&amp;").split("<").join("&lt;").split('"').join("&quot;")}function qualifyURL(a){var b=document.createElement("div");b.innerHTML='<a href="'+escapeHTML(a)+'">x</a>';return b.firstChild.href}function fill4Zero(a){return 1E3>a?Math.pow(10,4-a.toString().length).toString().slice(1)+a.toString():a.toString()}
function addScript(a){var b=document.createElement("script");b.type="text/javascript";b.src=a;a=document.head;a.insertBefore(b,a.firstChild)}PT_DOCUMENT="document";PT_PHOTOALBUM="photo_album";PT_CATALOG="catalog";PT_BOOK="book";PT_MAGAZINE="magazine";BOOK_FLIP_DURATION=0.5;PATH_TO_PROPERTIES=ASSETS_FOLDER+"/";ZOOM_LOCK=!1;
function initPublicationTypeShortcuts(){ALBUM=publicationData.type==PT_PHOTOALBUM;BOOK=publicationData.type==PT_BOOK;CATALOG=publicationData.type==PT_CATALOG;MAGAZINE=publicationData.type==PT_MAGAZINE;DOCUMENT=publicationData.type==PT_DOCUMENT}
function initPageDisplayedEvent(){function a(){if(null!==c){for(var a=!0,b=0;b<c.length;b++)if(-1==e.indexOf(c[b])){a=!1;break}a&&(customEvents.fireEvent(PAGE_CONTENT_DISPLAYED,{pages:c}),c=null)}}function b(b){e.push(b.data.page);6<e.length&&(e=e.slice(-6));a()}function d(b){c=b.data.page;a()}var e=[],c=null;customEvents.addListener(LOAD_MANAGER_PAGE_CONTENT_LOAD_COMPLETE,b);customEvents.addListener(ANDROID_PAGE_PREPARED,d);customEvents.addListener(BOOK_FLIPPING_END,d);customEvents.addListener(IOS_LOAD_BITMAP_END,
b)}
var initializeBook=function(){function a(a){b.setHighlight(a.type==SHOW_SEARCH_RESULTS);a.type==CANCEL_SEARCH&&search.stop()}window.GAEnable||(GAEnable=!1);var b;system.init();initPublicationTypeShortcuts();window.orientationObserver=new OrientationObserver;window.pageTable=new PageTable;HTML5lib.init();window.resources={};resources.MAIN_FRAME=el.id("mainFrame");publicationData.presentationMode=publicationData.type==PT_PHOTOALBUM||publicationData.type==PT_DOCUMENT;publicationData.shopInfo&&(window.cartRenders=[],
cart.on("change",function(a){-1!=["changeQuantity","addItem","delItem","checkout"].indexOf(a.type)&&cart.each(null,window.cartRenders,function(a){a.updateQuantity()})}));if(1<window.location.hash.length){publicationData.restoreSession=!1;var d=window.location.hash.substring(1,window.location.hash.length).split("/"),e=1<d.length&&"z"!==d[1]?d[1]:2<d.length?d[2]:null,c=parseInt(d[0])}else c=1;c=pageTable.getFileIDFromUserID(c);void 0===c&&(c=1);pageMediator=new PageController(c,"single",publicationData.rtlMode);
null!==e&&"undefined"!==typeof e&&(new ProductInfoWindow(e)).show();initCrossEvents();setClickEvents(resources.MAIN_FRAME,"dmp");2==window.devicePixelRatio&&"ios"==system.platform.name&&(el.id("body").style.fontSize="16px");system.publisher.isOn&&(el.id("body").style.fontSize="6px");system.platform.ios||(window.WORKSPACE_ZOOM=!0);initPageDisplayedEvent();workspace.init(resources.MAIN_FRAME,DEV);window.loadManager=new LoadManager;resources.BODY=document.body;publicationData.getPageProperty=function(a,
b){var c=publicationData.page[a][b];return void 0==c?publicationData.page.defaults[b]:c};window.PAGES_JS_FOLDER=ASSETS_FOLDER+"/pages/"+(system.platform.ios?"ios":"android");simpleLoadBook=function(){function a(c){switch(c.type){case ZOOMIN_FROM_WORKSPACE:b.incZoom();break;case ZOOMOUT_FROM_WORKSPACE:b.decZoom()}}b=new SimpleViewer(resources.MAIN_FRAME);Math.min(innerWidth,innerHeight);(function(){var a=window.getComputedStyle(document.body,null).getPropertyValue("font-size");return parseFloat(a.substr(0,
a.length-2))})();window.addEventListener("resize",function(){b.resize()});b.set(c);customEvents.addListener(ZOOMIN_FROM_WORKSPACE,a);customEvents.addListener(ZOOMOUT_FROM_WORKSPACE,a);customEvents.addListener(DOUBLE_TAP_FROM_WORKSPACE,function(a){b.handleDoubleClick(a.data)})};customEvents.addListener(SHOW_SEARCH_RESULTS,a);customEvents.addListener(CANCEL_SEARCH,a);system.publisher.isOn?"android"==system.device.name?simpleLoadBook():(bookModel=new BookModel,b=new Slide):"ipad"==system.device.name||
"iphone"==system.device.name?(bookModel=new BookModel,b=new Slide):simpleLoadBook();var f=function(){workspace.toolbars.isHide&&workspace.toolbars.toggle();f=null};customEvents.addListener(ZOOM_ANIMATION_END,f);window.book=b;pageMediator.addListener(function(a){b.goToPage.call(b,a);workspace.buttons.pageTurnHandler(a)});publicationData.shopInfo&&cart.getCheckoutStatus(function(){window.confirm(LOCALS.CLEAR_CART+"?")&&cart.clear(publicationId)},this.publicationID);initSearchEvent()};
window.PUBL?(PUBL=!0,PUBLDOMAIN=window.location):PUBL=!1;
function OrientationObserver(){that=this;this.zoom=!1;var a="onorientationchange"in window;this.prevWidth=window.innerWidth;this.prevHeight=window.innerHeight;this.getOrientation=function(){system.publisher.isOn&&console.log(system.publisher.orientation);if(window.innerWidth>window.innerHeight)return"landscape";if(window.innerWidth<window.innerHeight)return"portrait"};this.rotateDevice=function(){setTimeout(b,100)};this.getType=function(a){return 1};this.getType();var b=function(){that.prevWidth=
window.innerWidth;that.prevHeight=window.innerHeight;that.getType();customEvents.fireEvent(ROTATE_DEVICE);iOS7LandscapeHeightBugFix()},d=function(){system.publisher.isOn?b():that.prevHeight>that.prevWidth&&window.innerWidth>=that.prevHeight?b():that.prevHeight<that.prevWidth&&window.innerWidth>=that.prevHeight&&window.innerWidth!=that.prevWidth&&b()};a&&!PUBL?window.addEventListener("orientationchange",b):system.publisher.isOn||window.addEventListener("resize",d);if(system.device.iphone&&"7"!==system.device.version&&
!system.publisher.isOn){var e=function(){var a={};that.prevHeight!=window.innerHeight&&that.prevWidth==window.innerWidth?(that.getType(),customEvents.fireEvent(ROTATE_DEVICE),a=window.innerHeight>that.prevHeight||520==window.innerHeight?{state:"in",by:"buttonPress"}:{state:"out",by:"buttonPress"}):a=that.prevWidth==window.innerHeight?{state:"in",by:"rotation"}:window.innerHeight>window.innerWidth&&system.browser.fullscreen?{state:"out",by:"rotation"}:!1;a&&(customEvents.fireEvent(IOS_FULLSCREEN,a),
system.browser.fullscreen="in"==a.state?!0:!1);that.prevWidth=window.innerWidth;that.prevHeight=window.innerHeight};window.addEventListener("resize",e);customEvents.addListener(ADD_BM,function(){system.browser.fullscreen&&e()})}customEvents.addListener(CHANGE_BOOK_TYPE,function(a){that.zoom=3==a.data.type?!0:!1})}
function PageController(a,b,d){this.page=1*a||1;this.previousPage=0;this.rtl=d||!1;this._listeners=[];var e=this;this.hashChangeHandler=function(a){var b=a.newURL.split("#")[1].split("/"),d=a.oldURL.split("#")[1].split("/");a=!1;if(1===b.length&&1<d.length||1<b.length&&1===d.length)a=!0;b=window.location.hash.substring(1,window.location.hash.length).split("/")[0];0>=b?b=1:b>publicationData.pageUserCount&&(b=publicationData.pageUserCount);this.page!=pageTable.getFileIDFromUserID(b)&&(this.changePage(pageTable.getFileIDFromUserID(b)),
c());if(!a)for(a=0,d=e._listeners.length;a<d;a++)e._listeners[a].call(e,pageTable.getFileIDFromUserID(b))};Modernizr.hashchange&&window.addEventListener("hashchange",function(a){e.hashChangeHandler(a)});var c=function(a){"undefined"==typeof a||2!=a.data.type&&2!=a.data||e.changePage(e.page);e.changeHash(e.page)};this.changePage(this.page);c()}
PageController.prototype.checkSlide=function(a){if("left"!==a||this.page!==publicationData.pageCount||this.rtl){if("right"===a&&this.page===publicationData.pageCount&&this.rtl||"right"===a&&1===this.page&&!this.rtl||"left"===a&&1===this.page&&this.rtl)return!1}else return!1;return!0};
PageController.prototype.changePage=function(a){0>=a&&(a=1);a>publicationData.pageCount&&(a=publicationData.pageCount);var b=fbUtils.findArr(pageTable.doubleFlipList,a);"undefined"==typeof b&&(publicationData.rtlMode?0===a%2?b=fbUtils.findArr(pageTable.doubleFlipList,a-1):0!=a%2&&(b=fbUtils.findArr(pageTable.doubleFlipList,a+1)):0===a%2?b=fbUtils.findArr(pageTable.doubleFlipList,a+1):0!=a%2&&(b=fbUtils.findArr(pageTable.doubleFlipList,a-1)));a==publicationData.pageCount&&(b=1*pageTable.doubleFlipList.length-
1);0>=a&&(b=0);this.dubleCounter=b;this.previousPage=this.page;this.page=a;"undefined"===typeof this.page&&(this.page=this.previousPage||1)};PageController.prototype.changeHash=function(a){if(0<a&&a<=publicationData.pageCount){if(!PUBL&&GAEnable){var b=window.location.pathname.split("/");_trackPageview(b[b.length-4]+"-"+pageTable.getUserIDFromFileID(a))}window.location.hash="#"+pageTable.getUserIDFromFileID(a)}};PageController.prototype.addListener=function(a,b){b?this._listeners.unshift(a):this._listeners.push(a)};
PageController.prototype.fire=function(){this.page=1>this.page?1:this.page;this.page=this.page>publicationData.pageCount?publicationData.pageCount:this.page;this.changeHash(this.page);Modernizr.hashchange||this.hashChangeHandler()};PageController.prototype.removeListener=function(a){for(i in this._listeners)this._listeners[i].toString()==a.toString()&&this._listeners.splice(i,1)};
PageController.prototype.right=function(){this.previousPage=this.page;if(this.rtl&&1>1*this.page-1||!this.rtl&&1*this.page+1>publicationData.pageCount)return!1;this.page=this.rtl?1*this.page-1:1*this.page+1;this.fire()};PageController.prototype.left=function(){this.previousPage=this.page;if(!this.rtl&&1>1*this.page-1||this.rtl&&1*this.page+1>publicationData.pageCount)return!1;this.page=this.rtl?1*this.page+1:1*this.page-1;this.fire()};
PageController.prototype.goToPage=function(a){this.changePage(a);this.fire()};PageController.prototype.maxLeft=function(){this.previousPage=this.page;this.page=this.rtl?publicationData.pageCount:1;this.fire()};PageController.prototype.maxRight=function(){this.previousPage=this.page;this.page=this.rtl?1:publicationData.pageCount;this.fire()};
PageController.prototype.isLast=function(){return 2!=orientationObserver.typeBook||orientationObserver.zoom?this.page===publicationData.pageCount?!0:!1:1*this.dubleCounter===1*pageTable.doubleFlipList.length-1?!0:!1};
var PagerLite=function(a){this.div=a.pagerDiv;this.currentPageDiv=a.currentPageDiv;this.lastPageDiv=a.lastPageDiv;this.currentPageDiv.innerHTML=pageTable.getCaption(pageMediator.page);this.lastPageDiv.innerHTML=" / "+publicationData.pageUserCount;var b=this;pageMediator.addListener(function(a){b.changeLabel(a)});!0==a.connectSlider&&customEvents.addListener(SLIDER_TO_PAGER_CHANGE_LABEL,function(a){b.changeLabel(a.data.page)})};
PagerLite.prototype.changeLabel=function(a){this.currentPageDiv.firstChild.data=pageTable.getCaption(a)};
PagerLite.create=function(a){var b=workspace.createElement({id:a.parent.id+"PagerField",cssClassName:"pagerField",parent:a.parent,insertBefore:a.insertBefore}),d=workspace.createElement({id:a.parent.id+"PagerCurrentPage",cssClassName:"pagerFont",parent:b}),e=workspace.createElement({id:a.parent.id+"PagerLastPage",cssClassName:"pagerFont",parent:b});return new PagerLite({pagerDiv:b,currentPageDiv:d,lastPageDiv:e,connectSlider:a.connectSlider})};
function PageTable(){var a=0;this.captionToID=[];this.IDToDoubleCaption=[];this.IDToCaption=[];this.userIDToFileID=[];this.fileIDTouserID=[];this.doubleFlipList=[];publicationData.pageUserCount=publicationData.pageCount;var b=1,d=1;for(page in publicationData.page)if("defaults"!=page){var e=1*page+a;publicationData.page[page].wide&&(this.userIDToFileID[1*page+a]=1*page,this.fileIDTouserID[1*page+a]=1*page,a++,e=1*page+a-1+"-"+(1*page+a));this.userIDToFileID[1*page+a]=1*page;this.fileIDTouserID[1*
page]=1*page+a;this.captionToID[e]=1*page;this.IDToCaption[page]="one"!=publicationData.wideas?e:page;1==page?(this.IDToDoubleCaption[1]=1,this.doubleFlipList.push(1*page)):1==b?(d++,e=d,publicationData.page[page].wide?"one"!=publicationData.wideas&&(d++,e=e+"-"+d):(d++,e=e+"-"+d),this.IDToDoubleCaption[page]=e,publicationData.page[page].wide?b=1:b++,this.doubleFlipList.push(1*page)):(this.IDToDoubleCaption[page]=this.IDToDoubleCaption[page-1],b=1)}"one"!=publicationData.wideas&&(publicationData.pageUserCount+=
a);1!=this.IDToDoubleCaption[publicationData.pageCount]&&1*this.IDToDoubleCaption[publicationData.pageCount].split("-")[1]>publicationData.pageUserCount&&(this.IDToDoubleCaption[publicationData.pageCount]=this.IDToDoubleCaption[publicationData.pageCount].split("-")[0]);this.getCaption=function(a){if(orientationObserver.zoom||1===orientationObserver.getType())return publicationData.rtlMode?(this.IDToCaption[a]+"").split("-").reverse().join("-"):this.IDToCaption[a];if(2===orientationObserver.getType())return publicationData.rtlMode?
(this.IDToDoubleCaption[a]+"").split("-").reverse().join("-"):this.IDToDoubleCaption[a]};this.getFileID=function(a){return this.captionToID[a]};this.getFileIDFromUserID=function(a){a=(a+"").split("-")[0];return this.userIDToFileID[a]};this.getUserIDFromFileID=function(a){return this.fileIDTouserID[a]}}function SearchResult(a,b,d,e,c,f){this.id=pageTable.getCaption(a);search.pages[a]=!0;this.realID=a;this.text=b;this.relevant=d;this.startPos=e;this.stopPos=c;this.fullText=f}
function initSearchEvent(){customEvents.addListener(START_SEARCH,function(a){var b=function(){var b=eval("("+this.responseText+")");search.search(a.data.data,b.pages)};if(PUBL)publ.getData(ASSETS_FOLDER+"/search/searchtext.js",b);else{var d=new XMLHttpRequest;d.open("GET",ASSETS_FOLDER+"/search/searchtext.js");d.onload=b;d.onerror=function(){document.write("Error: can`t load xml3")};d.send();delete d}})}
var search={active:!1,result:[],pages:{},query:"",maxTextResultLength:90,getBold:function(a,b){return a.replace(RegExp(b,"ig"),function(a){return"<b>"+a+"</b>"})},buildSearchText:function(a,b,d){d=d||[];b-=this.maxTextResultLength/2;a=a.substr(0>b?0:b,1*this.maxTextResultLength+6);a=fbUtils.screening("..."+a+"...");if(0<d.length)for(b=0;b<d.length;b++)a=search.getBold(a,d[b]);else a=search.getBold(a,search.query);return a},buildIndexes:function(a,b,d){for(var e=[],c=0;c<b;c++){for(var f=[],h=a[c],
g=-publicationData.search.lim;-1!=g;)g=d.indexOf(h,g+publicationData.search.lim),-1!=g&&f.push(g);0<f.length&&e.push(f)}return e},searchFullCoincidence:function(a,b,d,e){for(var c=-1,f=-1,h=b.toLowerCase();0<=(c=h.indexOf(a,c+1));)if(f=c,-1!=c&&(0==c||fbUtils.isSplitter(h.charAt(c-1)))&&(c+a.length==h.length||fbUtils.isSplitter(h.charAt(c+a.length))))return this.result.push(new SearchResult(d,this.buildSearchText(b,c,[a]),e?0:1,c,c+a.length,e)),!0;if(0<=f&&!publicationData.search.exactMatch)return this.result.push(new SearchResult(d,
this.buildSearchText(b,f,[a]),e?2:3,f,f+a.length,e)),!0;delete null;return!1},searchPartiallyCoincidence:function(a,b,d,e,c){c=b.toLowerCase();c=this.buildIndexes(a,e,c);if(null==c||0==c.length)return!1;for(var f=0,h=Array(c.length),g=0;g<c.length;g++)h[g]=c[g][0];for(g=0;g<c.length-1;g++){var l=1E3,s=c[g],k=c[g+1];if(null==s||null==k)break;for(var t=s.length,m=k.length,r=0;r<t;r++)for(var p=0;p<m;p++){var n=s[r],u=k[p],q=(u>n?u-n:n-u)*(u>n?1:2);q<l&&(h[g]=n,h[g+1]=u,l=q)}f+=l}g=1E4;for(s=l=0;null!=
h&&s<h.length;s++)g=Math.min(g,h[s]),l=Math.max(l,h[s]);f+=1E3*(e-c.length);delete null;this.result.push(new SearchResult(d,this.buildSearchText(b,g,a),f+4,g,l,!1));return!0},search:function(a,b){this.active&&search.stop();this.result=[];this.query=a=a.toLowerCase();var d=fbUtils.split(a,publicationData.search.lim),e=d.length,c;for(c in b.page){var f=b.page[c];null==f["#text"]||search.searchFullCoincidence(a,f["#text"],f["@ID"],!0)||publicationData.search.exactMatch||(1<e?this.searchPartiallyCoincidence(d,
f["#text"],f["@ID"],e,a.length):1===e&&this.searchFullCoincidence(d[0],f["#text"],f["@ID"],!1))}this.result.sort(this.sortFunc);search.active=!0;var d={name:"searchTest",children:{}},h;for(h in search.result)e=search.result[h],d.children[h]={},d.children[h].name=e.text,d.children[h].page=e.id,d.children[h].realID=e.realID;customEvents.fireEvent(SHOW_SEARCH_RESULTS,{data:d})},sortFunc:function(a,b){return a.relevant<b.relevant?-1:a.relevant>b.relevant?1:a.id<b.id?-1:a.id>b.id?1:0},clear:function(){this.query=
""},stop:function(){this.active=!1;this.query="";search.result=[]}};timer={state:!0,blockTime:0,endFX:0,startTime:Date.now(),setBlockTime:function(a,b){this.endFX=b||a;this.blockTime=a;this.startTime=Date.now()},check:function(a){a=a||"standart";if("standart"==a)return Date.now()-this.startTime>this.blockTime?!0:!1;if("high"==a)return!0;if("fx"==a)return Date.now()-this.startTime>this.endFX?!0:!1}};
var Toolbar=function(a){this.isVisible=!1;this.div=el.id(a.divID);this.isActive="undefined"!=typeof a.isActive?a.isActive:!1;setClickEvents(this.div,"dp")};Toolbar.prototype.show=function(){workspace.delCssClass(this.div,"hidden");this.isVisible=!0};Toolbar.prototype.hide=function(){workspace.addCssClass(this.div,"hidden");with(workspace.pager)isEdit&&hideInputField();this.isVisible=!1};
Toolbar.prototype.toggle=function(){workspace.changeCssClass(this.div,"hidden");with(workspace.pager)isEdit&&hideInputField();this.isVisible=!this.isVisible};
Toolbar.create=function(a){var b=workspace.createElement({type:"aside",id:a.divID,cssClassName:"toolbar",parent:el.id("body")});"top"!=a.position&&"bottom"!=a.position||workspace.addCssClass(b,"horizontalToolbar");"left"!=a.position&&"right"!=a.position||workspace.addCssClass(b,"verticalToolbar");workspace.addCssClass(b,a.position+"Toolbar "+a.divID+" hidden");return new Toolbar({divID:a.divID,isActive:a.isActive})};
var video={getVideoImageUrl:function(a){return COMMON_FOLDER+"/pages-content/"+a},inject:function(a,b){var d=a.getContext("2d");d.fillStyle="rgba(0,0,0,1)";var e=a.width/(publicationData.page[b].width||publicationData.page.defaults.width),c=function(a){with(publicationData.page[b].videos[a])var h=(width*e).toFixed(0),g=(height*e).toFixed(0),l=x*e,s=y*e,k=video.getVideoImageUrl(imageUri),t=showImage;t&&d.fillRect(l,s,h,g);var m=new Image;changeUrlWhenPubl(k,function(a){m.src=a});m.onload=function(){var e=
new Image,k=50<g?50:0.8*g;e.src=video.getPlayImage();e.onload=function(){if(t){var n=(m.width/m.height).toFixed(1),u=(h/g).toFixed(1);if(n<=u)n=Math.abs((m.height-m.width/u)/2),u=m.height-2*n,d.drawImage(m,0,n,m.width,u,l,s,h,g),delete null,delete null;else{var q=Math.abs((m.height/u-m.width)/2),v=m.width-2*q;d.drawImage(m,q,0,v,m.height,l,s,h,g);q=null;delete q;v=null;delete v}delete q;delete v}d.drawImage(e,l+(h/2-k/2),s+(g/2-k/2),k,k);a<publicationData.page[b].videos.length-1&&c(a+1)}}};c(0)},
getPlayImage:function(){return"data:image/png;base64, "},
play:function(a,b,d,e){var c=el.add("div");c.id="videoDiv";c.style.width="100%";c.style.height="100%";c.style.position="absolute";c.style.top="0px";c.style.display="block";c.style.zIndex="1000000";c.style.webkitTransform="translate3d(0px,0px,300px)";c.style.backgroundColor="rgba(0,0,0,0.7)";el.id("body").appendChild(c);setClickEvents(c,!1);c.addEventListener(SINGLE_CLICK,function(a){"function"==typeof d&&d();el.del("videoDiv");customEvents.removeListener(ROTATE_DEVICE,h);a.preventDefault();a.stopPropagation()});
var f=el.add("div");f.id="videoPlayer";f.style.position="relative";f.style.marginLeft="auto";f.style.marginRight="auto";f.style.top="50%";f.style.backgroundColor="rgba(0,0,0,1)";c.appendChild(f);e=el.add("iframe");f.appendChild(e);e.className="youtube-player";e.type="text/html";e.width="100%";e.height="100%";e.frameBorder="0";e.style.display="inline-block";"youtube"==a?(e.className="youtube-player",e.src="http://www.youtube.com/embed/"+b+"?autoplay=1&html5=1"):"vimeo"==a&&(e.src="http://player.vimeo.com/video/"+
b+"?title=0&amp;byline=0&amp;portrait=0&amp;color=da4541");var h=function(){workspace.handleResize();window.setTimeout(function(){var a=c.offsetWidth-50;640<a&&(a=640);var b=a/1.64;b>0.9*(c.offsetHeight-50)&&(b=0.9*(c.offsetHeight-50),a=1.64*b);"mobile"!==system.device.type&&(a*=window.devicePixelRatio||1,b*=window.devicePixelRatio||1);f.style.width=a+"px";f.style.height=b+"px";f.style.marginTop=-(b/2)+"px"},system.platform.android?600:0)};h();customEvents.addListener(ROTATE_DEVICE,h)}};
function FBWindow(a){this.label=a}
FBWindow.prototype={show:function(a,b){b=b||"";if(GAEnable){var d=window.location.pathname.split("/");_trackEvent(d[d.length-4]+"","Open "+a,b)}this.showWindow()},hide:function(a,b){b=b||"";if(GAEnable){var d=window.location.pathname.split("/");_trackEvent(d[d.length-4]+"","Close "+a,b)}window.location.hash=window.location.hash.split("/")[0];this.scrollObject.destroy();el.del(this.mainContainer)},showWindow:function(){this.mainContainer=el.createElement("div",{"class":"productInfoContainer"},"body");
var a=el.createElement("div",{"class":"blackOut"},this.mainContainer),b=this;Hammer(a).on("tap",function(){b.hide.call(b)});this.mainWindowEl=el.createElement("div",{"class":"mainProductWindow"},this.mainContainer);a=window.devicePixelRatio||1;a=1<a?"mobile"===system.device.type?a/1.4:a/1.1:a;this.labelHeight=50*a;system.publisher.isOn&&(this.labelHeight=20);a=el.createElement("h3",{"class":"productWindowLabel",styles:{height:this.labelHeight+"px",lineHeight:this.labelHeight+"px",fontSize:this.labelHeight/
2+"px"}},this.mainWindowEl);a.innerText=this.label;a=el.createElement("span",{"class":"productWindowCloseIcon"},a);Hammer(a).on("tap",function(){b.hide.call(b)});a=el.createElement("div",{"class":"productWindowContent",styles:{top:this.labelHeight+1+"px",height:"100%"}},this.mainWindowEl);this.contentScroller=el.createElement("div",{"class":"productWindowContentScr",styles:{paddingBottom:3*this.labelHeight+"px"}},a);this.scrollObject=new iScroll(a,{hScrollbar:!1,vScrollbar:!1,zoom:!1});this.scrollObject.refresh();
b=this;window.addEventListener("resize",function(){b.scrollObject.refresh()});this.buttonsBottomPanel=el.createElement("div",{"class":"productWindowButtonsBottomPanel",styles:{height:this.labelHeight+"px",marginTop:-this.labelHeight+"px"}},this.mainWindowEl)},addButton:function(a,b,d,e){b=el.createElement("cartWindowButton"===b?"a":"div",{"class":b,styles:{"line-height":this.labelHeight-5+"px",fontSize:this.labelHeight/3+"px"}},this.buttonsBottomPanel);b.innerText=a;Hammer(b).on("tap",function(){d.call(e)});
return b}};function ProductInfoWindow(a){this.idProduct=a;var b=this;cart.getItems(function(a){b.product=a[0]},function(){},a);this.qty=1;this.options={};this.finalPrice=this._calcFinalPrice();this.height=0}
ProductInfoWindow.prototype={show:function(){this.window=new FBWindow(LOCALS.ADD_TO_CART);this.window.show("Product",this.idProduct);window.location.hash=window.location.hash+"/"+this.idProduct;if(publicationData.shopInfo.usePublicationCart)this.window.addButton(LOCALS.CHECKOUT,"productWindowButton lft",this.checkout,this),this.window.addButton(LOCALS.CANCEL,"productWindowButton cnt",this.cancel,this),this.window.addButton(LOCALS.ADD,"productWindowButton rgt",this.add,this);else{var a=this.window.addButton(LOCALS.VIEW_ON_WEBSITE,
"undefined"!==typeof this.product.url?"cartWindowButton":"cartWindowButtonDSBL",this.website,this);a.href="undefined"===typeof this.product.url?"":this.product.url;a.target="_blank"}this.window.mainWindowEl.style.top="10%";this.window.mainWindowEl.style.height="80%";this.setProductInfo()},website:function(){},setProductInfo:function(){this.setTextInfo()},setPhotos:function(){if(this.product.media&&0!==this.product.media.length){var a=el.createElement("div",{"class":"productWindowPhotoContainer"},
this.window.contentScroller),b=el.createElement("img",{"class":"productWindowMainPhoto",src:this.product.media[0].url},a);b.onload=function(){d.window.scrollObject.refresh()};var a=el.createElement("div",{"class":"productWindowPhotostream"},a),d=this;if(1<this.product.media.length)for(var e=0,c=this.product.media.length;e<c;e++){var f=el.createElement("img",{"class":"productWindowMainPhotoStream",src:this.product.media[e].url},a);Hammer(f).on("tap",function(){b.src=this.src;d.window.scrollObject.refresh()})}this.window.scrollObject.refresh()}},
setTextInfo:function(){var a=el.createElement("div",{"class":"productWindowInfoContainer"},this.window.contentScroller);"undefined"!==typeof this.product.name&&(el.createElement("h4",{"class":"productWindowProductName"},a).innerText=this.product.name);"undefined"!==typeof this.product.sku&&(el.createElement("p",{"class":"productWindowProductSKU"},a).innerText=LOCALS.SKU+": "+this.product.sku);el.createElement("p",{"class":"productWindowProductPrice",id:"productWindowPrice"},a).innerText=fbUtils.formatPrice(this.finalPrice/
this.qty);"undefined"!==typeof this.product.description&&(el.createElement("p",{"class":"productWindowProductDescription"},a).innerText=this.product.description);this.product.media&&0!==this.product.media.length&&a.setAttribute("data-image","true");this.height+=a.getBoundingClientRect().height;this.window.scrollObject.refresh();this.setPhotos();this.setOptions()},setOptions:function(){if(publicationData.shopInfo.usePublicationCart){var a=el.createElement("div",{"class":"productWindowOptionsContainer"},
this.window.contentScroller);el.createElement("hr",{"class":"productWindowHR"},a);var b=el.createElement("p",{"class":"productWindowQTYLabel"},a);b.innerText=LOCALS.QTY+": ";var d=el.createElement("div",{"class":"productWindowQTYButton"},b),b=el.createElement("span",{"class":"productWindowQTYArrow rgtarrow"},d);b.innerText=" + ";var e=el.createElement("input",{"class":"inpECommerceQTY",type:"text",disabled:"disabled",value:this.qty},d),d=el.createElement("span",{"class":"productWindowQTYArrow lftarrow"},
d);d.innerText=" - ";var c=this;e.addEventListener("blur",function(){this.value=c.qty});e.addEventListener("keydown",function(a){13===a.keyCode&&this.blur()});e.addEventListener("input",function(){""!==this.value&&(isNaN(parseInt(this.value))?this.value=c.qty:this.value=parseInt(this.value),c.qty=this.value,c._calcFinalPrice.call(c))});Hammer(d).on("tap",function(){var a=parseInt(e.value);--a;1>a&&(a=1);c.qty=a;e.value=a;c._calcFinalPrice.call(c)});Hammer(b).on("tap",function(){var a=parseInt(e.value);
++a;c.qty=a;e.value=a;c._calcFinalPrice.call(c)});for(optID in this.product.options){b=el.createElement("p",{"class":"productWindowSelectLabel"},infoDiv);b.innerText=this.product.options[optID].name+": ";b=el.createElement("select",{"class":"productWindowSelect",id:optID},b);Hammer(b).on("change",function(){c.options[this.id]=this.value;c._calcFinalPrice.call(c)});for(valID in this.product.options[optID].values)el.createElement("option",{"class":"productWindowInput",value:valID,label:this.product.options[optID].values[valID].name},
b);this.options[optID]=b.value}this._calcFinalPrice();this.window.scrollObject.refresh();this.height+=a.getBoundingClientRect().height}else this._calcFinalPrice(),this.height+=200*window.devicePixelRatio},cancel:function(){this.destroy()},add:function(){cart.addItem(this.idProduct,this.qty,this.options);this.destroy()},checkout:function(){cart.addItem(this.idProduct,this.qty,this.options);cartWindow.show();this.destroy()},hide:function(){this.window.hide("Product",this.idProduct);delete this.window},
destroy:function(){this.hide()},_calcFinalPrice:function(){var a=parseFloat(this.product.price),b;for(b in this.options)a+=parseInt(this.product.options[b].values[this.options[b]].price);a*=this.qty;el.id("productWindowPrice")&&(el.id("productWindowPrice").innerText=fbUtils.formatPrice(a/this.qty));return this.finalPrice=a}};
var cartWindow={show:function(){this.totalQTY=this.totalPrice=0;this.window=new FBWindow(LOCALS.SHOPPING_CART);this.window.show("Cart");this.window.addButton(LOCALS.CHECKOUT,"cartWindowButton",this.checkout,this);this.window.mainWindowEl.style.top="10%";this.window.mainWindowEl.style.height="80%";this.cartItem=cart.getCart(publicationId)[0];this.addCartInfo()},addCartInfo:function(){var a=function(a,b,c){var f=el.createElement("div",{"class":"cartTableTR"},this.window.contentScroller),h=this;if(a.media&&
0!==a.media.length){var g=el.createElement("div",{"class":"cartTableImage"},f);el.createElement("img",{src:a.media[0].url},g).onload=function(){h.window.scrollObject.refresh()}}g=el.createElement("p",{"class":"cartTableTDName"},f);a.media&&0!==a.media.length||(f.setAttribute("data-image","none"),g.setAttribute("data-image","none"));g.innerText=a.name;a=el.createElement("div",{"class":"cartTableTDQTY"},f);a=el.createElement("div",{"class":"productWindowQTYButton"},a);var l=el.createElement("span",
{"class":"productWindowQTYArrow rgtarrow"},a);l.innerText=" + ";var s=el.createElement("input",{id:"qty"+b,"class":"inpECommerceQTY",type:"text",value:c.qty},a),k=el.createElement("span",{"class":"productWindowQTYArrow lftarrow"},a);k.innerText=" - ";(function(a,b,c){s.addEventListener("blur",function(){this.value=b.qty});s.addEventListener("input",function(){""!==this.value&&(isNaN(parseInt(this.value))?this.value=b.qty:this.value=parseInt(this.value),cart.changeQuantity(a,this.value),c.refreshWindow())});
Hammer(k).on("tap",function(){1!==b.qty&&(cart.changeQuantity(a,b.qty-1),c.refreshWindow())});Hammer(l).on("tap",function(){cart.changeQuantity(a,parseInt(b.qty)+1);c.refreshWindow()})})(b,c,h);(function(a,b,c){c.getItemPrice(b,function(b){a.innerText=fbUtils.formatPrice(b)})})(el.createElement("p",{id:"price"+b,"class":"cartTableTDPrice"},f),b,h);(function(a,b,c,d){Hammer(a).on("tap",function(){cart.delItem(c)===c&&(el.del(b),d.refreshWindow())})})(el.createElement("span",{"class":"cartTableSpanDel"},
f),f,b,h)},b;for(b in this.cartItem)(function(d,e){cart.getItems(function(c){a.call(e,c[0],b,d)},function(){},[d.itemID])})(this.cartItem[b],this);0!==fbUtils.objectSize(this.cartItem)&&(el.createElement("div",{id:"totalQTY","class":"totalItemsDiv"},this.window.contentScroller).innerText=LOCALS.ITEMS+": "+1*this.totalQTY,el.createElement("div",{id:"totalPrice","class":"totalPriceDiv"},this.window.contentScroller).innerText=LOCALS.TOTAL+": "+fbUtils.formatPrice(this.totalPrice))},refreshWindow:function(){this.totalQTY=
this.totalPrice=0;this.cartItem=cart.getCart(publicationId)[0];var a=this,b=function(b,d,e){a.getItemPrice(d,function(a){el.id("price"+d).innerText=fbUtils.formatPrice(a)});el.id("qty"+d).value=e.qty},a=this;0===fbUtils.objectSize(this.cartItem)&&(el.del("totalQTY"),el.del("totalPrice"));var d=0,e;for(e in this.cartItem)d++,function(a,d){cart.getItems(function(h){b.call(d,h[0],e,a)},function(){},[a.itemID])}(this.cartItem[e],a),el.id("totalQTY").innerText=this.totalQTY+" "+LOCALS.ITEMS,el.id("totalPrice").innerText=
LOCALS.TOTAL+": "+fbUtils.formatPrice(this.totalPrice);d||this.window.hide();this.window.scrollObject.refresh()},getItemPrice:function(a,b){var d=this;cart.getItems(function(e){e=e[0];var c=e.price,f;for(f in d.cartItem[a].options)c+=e.options[f].values[d.cartItem[a].options[f]].price;c*=d.cartItem[a].qty;d.totalQTY+=parseInt(d.cartItem[a].qty);d.totalPrice+=c;el.id("totalQTY")&&(el.id("totalQTY").innerText=1*this.totalQTY+" "+LOCALS.ITEMS);el.id("totalQTY")&&(el.id("totalPrice").innerText=LOCALS.TOTAL+
": "+fbUtils.formatPrice(d.totalPrice));b.call(b,c)},function(){},[this.cartItem[a].itemID])},checkout:function(){for(var a in publicationData.shopInfo.providers);this.window.hide("Cart");"demo"==a?window.confirm(LOCALS.SHOP_DEMOCHECKOUT)&&(location.href="http://flippingbook.com/help/publisher-2/docs/quick-start/ecommerce-integration/?src=demo"):cart.checkout(cart.extend({type:a},publicationData.shopInfo),function(){},function(){})}};
