// Created 12/11/2013 12:56:20 PM
(function(a,b){function e(){if(!d.READY){d.event.determineEventTypes();for(var a in d.gestures)d.gestures.hasOwnProperty(a)&&d.detection.register(d.gestures[a]);d.event.onTouch(d.DOCUMENT,d.EVENT_MOVE,d.detection.detect);d.event.onTouch(d.DOCUMENT,d.EVENT_END,d.detection.detect);d.READY=!0}}var d=function(a,b){return new d.Instance(a,b||{})};d.defaults={stop_browser_behavior:{userSelect:"none",touchAction:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};
d.HAS_POINTEREVENTS=navigator.pointerEnabled||navigator.msPointerEnabled;d.HAS_TOUCHEVENTS="ontouchstart"in a;d.MOBILE_REGEX=/mobile|tablet|ip(ad|hone|od)|android/i;d.NO_MOUSEEVENTS=d.HAS_TOUCHEVENTS&&navigator.userAgent.match(d.MOBILE_REGEX);d.EVENT_TYPES={};d.DIRECTION_DOWN="down";d.DIRECTION_LEFT="left";d.DIRECTION_UP="up";d.DIRECTION_RIGHT="right";d.POINTER_MOUSE="mouse";d.POINTER_TOUCH="touch";d.POINTER_PEN="pen";d.EVENT_START="start";d.EVENT_MOVE="move";d.EVENT_END="end";d.DOCUMENT=document;
d.plugins={};d.READY=!1;d.Instance=function(a,b){var c=this;e();this.element=a;this.enabled=!0;this.options=d.utils.extend(d.utils.extend({},d.defaults),b||{});this.options.stop_browser_behavior&&d.utils.stopDefaultBrowserBehavior(this.element,this.options.stop_browser_behavior);d.event.onTouch(a,d.EVENT_START,function(a){c.enabled&&d.detection.startDetect(c,a)});return this};d.Instance.prototype={on:function(a,d){for(var b=a.split(" "),e=0;e<b.length;e++)this.element.addEventListener(b[e],d,!1);
return this},off:function(a,d){for(var b=a.split(" "),e=0;e<b.length;e++)this.element.removeEventListener(b[e],d,!1);return this},trigger:function(a,b){var e=d.DOCUMENT.createEvent("Event");e.initEvent(a,!0,!0);e.gesture=b;var c=this.element;d.utils.hasParent(b.currentContentElement,c)&&(c=b.currentContentElement);c.dispatchEvent(e);return this},enable:function(a){this.enabled=a;return this}};var c=null,f=!1,h=!1;d.event={_bindDom:function(a,d,b){d=d.split(" ");for(var e=0;e<d.length;e++)a.addEventListener(d[e],
b,!1)},onTouch:function(a,b,e){var k=this;this._bindDom(a,d.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&&(d.HAS_POINTEREVENTS&&b!=d.EVENT_END?r=d.PointerEvent.updatePointer(b,t):m.match(/touch/)?r=t.touches.length:h||(r=m.match(/up/)?0:1),0<r&&b==d.EVENT_END?b=d.EVENT_MOVE:r||(b=d.EVENT_END),r||null===c?c=t:t=c,e.call(d.detection,k.collectEventData(a,
b,t)),d.HAS_POINTEREVENTS&&b==d.EVENT_END&&(r=d.PointerEvent.updatePointer(b,t)));r||(c=null,h=f=!1,d.PointerEvent.reset())}})},determineEventTypes:function(){var a;a=d.HAS_POINTEREVENTS?d.PointerEvent.getEvents():d.NO_MOUSEEVENTS?["touchstart","touchmove","touchend touchcancel"]:["touchstart mousedown","touchmove mousemove","touchend touchcancel mouseup"];d.EVENT_TYPES[d.EVENT_START]=a[0];d.EVENT_TYPES[d.EVENT_MOVE]=a[1];d.EVENT_TYPES[d.EVENT_END]=a[2]},getTouchList:function(a){return d.HAS_POINTEREVENTS?
d.PointerEvent.getTouchList():a.touches?a.touches:[{identifier:1,pageX:a.pageX,pageY:a.pageY,currentContentElement:a.currentContentElement}]},collectEventData:function(a,b,e){a=this.getTouchList(e,b);var c=d.POINTER_TOUCH;if(e.type.match(/mouse/)||d.PointerEvent.matchType(d.POINTER_MOUSE,e))c=d.POINTER_MOUSE;return{center:d.utils.getCenter(a),timeStamp:(new Date).getTime(),currentContentElement:e.currentContentElement,touches:a,eventType:b,pointerType:c,srcEvent:e,preventDefault:function(){this.srcEvent.preventManipulation&&
this.srcEvent.preventManipulation();this.srcEvent.preventDefault&&this.srcEvent.preventDefault()},stopPropagation:function(){this.srcEvent.stopPropagation()},stopDetect:function(){return d.detection.stopDetect()}}}};d.PointerEvent={pointers:{},getTouchList:function(){var a=this,d=[];Object.keys(a.pointers).sort().forEach(function(b){d.push(a.pointers[b])});return d},updatePointer:function(a,b){a==d.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 e={};e[d.POINTER_MOUSE]=b.pointerType==b.MSPOINTER_TYPE_MOUSE||b.pointerType==d.POINTER_MOUSE;e[d.POINTER_TOUCH]=b.pointerType==b.MSPOINTER_TYPE_TOUCH||b.pointerType==d.POINTER_TOUCH;e[d.POINTER_PEN]=b.pointerType==b.MSPOINTER_TYPE_PEN||b.pointerType==d.POINTER_PEN;return e[a]},getEvents:function(){return["pointerdown MSPointerDown","pointermove MSPointerMove","pointerup pointercancel MSPointerUp MSPointerCancel"]},reset:function(){this.pointers=
{}}};d.utils={extend:function(a,d,e){for(var c in d)a[c]!==b&&e||(a[c]=d[c]);return a},hasParent:function(a,d){for(;a;){if(a==d)return!0;a=a.parentNode}return!1},getCenter:function(a){for(var d=[],b=[],e=0,c=a.length;e<c;e++)d.push(a[e].pageX),b.push(a[e].pageY);return{pageX:(Math.min.apply(Math,d)+Math.max.apply(Math,d))/2,pageY:(Math.min.apply(Math,b)+Math.max.apply(Math,b))/2}},getVelocity:function(a,d,b){return{x:Math.abs(d/a)||0,y:Math.abs(b/a)||0}},getAngle:function(a,d){return 180*Math.atan2(d.pageY-
a.pageY,d.pageX-a.pageX)/Math.PI},getDirection:function(a,b){var e=Math.abs(a.pageX-b.pageX),c=Math.abs(a.pageY-b.pageY);return e>=c?0<a.pageX-b.pageX?d.DIRECTION_LEFT:d.DIRECTION_RIGHT:0<a.pageY-b.pageY?d.DIRECTION_UP:d.DIRECTION_DOWN},getDistance:function(a,d){var b=d.pageX-a.pageX,e=d.pageY-a.pageY;return Math.sqrt(b*b+e*e)},getScale:function(a,d){return 2<=a.length&&2<=d.length?this.getDistance(d[0],d[1])/this.getDistance(a[0],a[1]):1},getRotation:function(a,d){return 2<=a.length&&2<=d.length?
this.getAngle(d[1],d[0])-this.getAngle(a[1],a[0]):0},isVertical:function(a){return a==d.DIRECTION_UP||a==d.DIRECTION_DOWN},stopDefaultBrowserBehavior:function(a,d){var b,e="webkit khtml moz ms o ".split(" ");if(d&&a.style){for(var c=0;c<e.length;c++)for(var f in d)d.hasOwnProperty(f)&&(b=f,e[c]&&(b=e[c]+b.substring(0,1).toUpperCase()+b.substring(1)),a.style[b]=d[f]);"none"==d.userSelect&&(a.onselectstart=function(){return!1})}}};d.detection={gestures:[],current:null,previous:null,stopped:!1,startDetect:function(a,
b){this.current||(this.stopped=!1,this.current={inst:a,startEvent:d.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,e=0,c=this.gestures.length;e<c;e++){var f=this.gestures[e];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==d.EVENT_END&&!a.touches.length-1&&this.stopDetect();
return a}},stopDetect:function(){this.previous=d.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 e=0,c=a.touches.length;e<c;e++)b.touches.push(d.utils.extend({},a.touches[e]))}var e=a.timeStamp-b.timeStamp,c=a.center.pageX-b.center.pageX,f=a.center.pageY-b.center.pageY,h=d.utils.getVelocity(e,c,f);d.utils.extend(a,{deltaTime:e,deltaX:c,
deltaY:f,velocityX:h.x,velocityY:h.y,distance:d.utils.getDistance(b.center,a.center),angle:d.utils.getAngle(b.center,a.center),direction:d.utils.getDirection(b.center,a.center),scale:d.utils.getScale(b.touches,a.touches),rotation:d.utils.getRotation(b.touches,a.touches),startEvent:b});return a},register:function(a){var e=a.defaults||{};e[a.name]===b&&(e[a.name]=!0);d.utils.extend(d.defaults,e,!0);a.index=a.index||1E3;this.gestures.push(a);this.gestures.sort(function(a,d){return a.index<d.index?-1:
a.index>d.index?1:0});return this.gestures}};d.gestures=d.gestures||{};d.gestures.Hold={name:"hold",index:10,defaults:{hold_timeout:500,hold_threshold:1},timer:null,handler:function(a,b){switch(a.eventType){case d.EVENT_START:clearTimeout(this.timer);d.detection.current.name=this.name;this.timer=setTimeout(function(){"hold"==d.detection.current.name&&b.trigger("hold",a)},b.options.hold_timeout);break;case d.EVENT_MOVE:a.distance>b.options.hold_threshold&&clearTimeout(this.timer);break;case d.EVENT_END:clearTimeout(this.timer)}}};
d.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==d.EVENT_END){var e=d.detection.previous,c=!1;a.deltaTime>b.options.tap_max_touchtime||a.distance>b.options.tap_max_distance||(e&&"tap"==e.name&&a.timeStamp-e.lastEvent.timeStamp<b.options.doubletap_interval&&a.distance<b.options.doubletap_distance&&(b.trigger("doubletap",a),c=!0),c&&!b.options.tap_always)||(d.detection.current.name=
"tap",b.trigger(d.detection.current.name,a))}}};d.gestures.Swipe={name:"swipe",index:40,defaults:{swipe_max_touches:1,swipe_velocity:0.7},handler:function(a,b){a.eventType!=d.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))}};d.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(d.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 d.EVENT_START:this.triggered=!1;this.counter=0;this.fbDirection=
"";this.fbNeverLock=this.fbLock=!1;break;case d.EVENT_MOVE:if(a.distance<b.options.drag_min_distance&&d.detection.current.name!=this.name)break;d.detection.current.name=this.name;if(d.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 e=d.detection.current.lastEvent.direction;a.drag_locked_to_axis&&e!==a.direction&&(d.utils.isVertical(e)?a.direction=0>a.deltaY?d.DIRECTION_UP:d.DIRECTION_DOWN:a.direction=
0>a.deltaX?d.DIRECTION_LEFT:d.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&&d.utils.isVertical(a.direction)||
b.options.drag_block_horizontal&&!d.utils.isVertical(a.direction))&&a.preventDefault();break;case d.EVENT_END:this.triggered&&b.trigger(this.name+"end",a),this.triggered=!1}}};d.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(d.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 d.EVENT_START:this.triggered=!1;break;case d.EVENT_MOVE:var e=Math.abs(1-a.scale),c=Math.abs(a.rotation);if(e<b.options.transform_min_scale&&c<b.options.transform_min_rotation)break;d.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);e>b.options.transform_min_scale&&(b.trigger("pinch",a),b.trigger("pinch"+(1>a.scale?"in":"out"),a));
break;case d.EVENT_END:this.triggered&&b.trigger(this.name+"end",a),this.triggered=!1}}};d.gestures.Touch={name:"touch",index:-Infinity,defaults:{prevent_default:!1,prevent_mouseevents:!1},handler:function(a,b){b.options.prevent_mouseevents&&a.pointerType==d.POINTER_MOUSE?a.stopDetect():(b.options.prevent_default&&a.preventDefault(),a.eventType==d.EVENT_START&&b.trigger(this.name,a))}};d.gestures.Release={name:"release",index:Infinity,handler:function(a,b){a.eventType==d.EVENT_END&&b.trigger(this.name,
a)}};"object"===typeof module&&"object"===typeof module.exports?module.exports=d:(a.Hammer=d,"function"===typeof a.define&&a.define.amd&&a.define("hammer",[],function(){return d}))})(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):e(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):e(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,e,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)*e);g=Math.round(g*e);return{width:b,height:g,ratio:b/a}},e=function(a,b,e){var h=window.innerWidth;b=b*h/a;h=Math.round(h*e);b=Math.round(b*e);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,e){function d(a,b,d){b.changedTouches&&(b=b.changedTouches[0]);a.initMouseEvent(d,!0,!0,window,1,b.screenX,b.screenY,b.clientX,b.clientY,b.ctrlKey,b.altKey,b.shiftKey,b.metaKey,0,null)}e=e?e:!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,e);a.removeEventListener(m,
n,e);a.removeEventListener("touchcancel",u)}var t;if(!(b.ctrlKey||b.altKey||b.shiftKey)){if("touchstart"==b.type){a.removeEventListener("mousedown",l,e);var m="touchend";t="touchmove"}else m="mouseup",t="mousemove",a.removeEventListener("touchstart",l,e);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"),
d(g,b,DOUBLE_CLICK),a.dispatchEvent(g));a.removeEventListener(m,r,e);k();f&&b.preventDefault();if(c)return b.stopPropagation(),!1};h&&a.addEventListener(m,r,e);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,e);var f=document.createEvent("MouseEvent");d(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,e);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,e)}}}};a.addEventListener(Modernizr.touch?"touchstart":"mousedown",l,e)}
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 e=[{screenX:a.screenX,screenY:a.screenY,clientX:a.clientX,clientY:a.clientY}],d=document.createEvent("MouseEvent");d.initMouseEvent(b,!0,!0,window,1,a.screenX,a.screenY,a.clientX,a.clientY,!1,!1,!1,!1,1,null);d.simulated=!0;d.touches=e;d.targetTouches=e;d.changedTouches=e;a.target.dispatchEvent(d);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 e=this._listeners[a].indexOf(b);if(-1!=e)this._listeners[a].splice(e,1);else return!1;return!0},fireEvent:function(a,b){if(void 0!=this._listeners[a])for(var e=0,d=this._listeners[a].length;e<
d;e++)void 0!=this._listeners[a][e]&&this._listeners[a][e].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 e=document.createElement("div");e.setAttribute("id",a);e.style.position="absolute";b&&(e.style.overflow="hidden");return e}var FCONSOLE_MAX_ROWS=33,LINE_BR="<br />";
function FBConsole(){function a(a){for(var b="",e=0;e<a.length;e++){switch(typeof a[e]){case "number":b+=d(a[e].toString(),"blue");break;default:b+=a[e]}e<a.length-1&&(b+=" ")}return b}function b(){e.innerHTML=h+(g?"":LINE_BR+LINE_BR+f)}var e=createDiv("fconsole"),d=function(a,b){return'<font color="'+b+'">'+a+"</font>"};e.style.left="0px";e.style.top="100px";e.style.width="100";e.style.height="100";e.style.opacity="0.7";e.style.backgroundColor="#e0efee";e.style.color="#11111f";e.style.fontSize="14px";
e.style.zIndex=100;e.style.webkitTransform="translate3d(0px,0px,500px)";e.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(e);b()};this.update=function(a,e){for(var f,g=0;g<c.length;g++)c[g].name==a&&(f=c[g]);"number"==typeof e&&(e=e.toString());f?f.value=e:c.push({name:a,value:e});h="";for(g=0;g<c.length;g++)h+=d(c[g].name,"green")+": "+d(c[g].value,"blue")+(g==c.length-1?"":LINE_BR);l&&b()};this.log=
function(d){f.length>FCONSOLE_MAX_ROWS-1&&f.shift();var e=a(arguments);f.push(e+LINE_BR);l&&b()};this.logAdd=function(d){var e=a(arguments);f[f.length-1]+=" "+e;l&&b()}}function HighlightItem(a,b,e,d){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===e?0:b[e-1]/10;b=b[e+(d-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,e){e=e||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(e,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,e,d){e&&this.claerPage(b,e);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,e,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,e,b)}d&&d()};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,e){var d=b.getContext("2d");d.fillStyle=window.highlight.getFillStyle();b=b.width/(publicationData.page[e].width||publicationData.page.defaults.width);e=a.x;var c=a.y,f=a.width,h=a.height;d.save();d.scale(b,b);d.translate(e,c);d.rotate(a.angle);d.clearRect(0,0,f,h);d.fillRect(0,0,f,h);d.restore();delete null},
getHighlights:function(a,b){var e=[];this.process(function(a){e.push(a)},a,null,function(){b(e)})}},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,e,d){b=b||0;e=e||0;a.style[this.browserPrefix+"Transform"]=Modernizr.csstransforms3d?"translate3d("+b+"px,"+
e+"px,"+(d||0)+"px)":"translate("+b+"px,"+e+"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,e){a=a||0;b=b||0;el.style[this.browserPrefix+"Transform"]=Modernizr.csstransforms3d?"scale3d("+a+","+b+","+(e||0)+")":"scale("+a+","+b+")"},rotate:function(a,b,e,d,c){e=e||0;a.style[this.browserPrefix+"Transform"]=Modernizr.csstransforms3d?"rotate3d("+e+","+e+","+
e+","+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,e){a.style[this.browserPrefix+"TransformOrigin"]="0px 0px";a.style[this.browserPrefix+"Transform"]="translate3d("+b+"px,"+e+"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,e,d){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+","+e+","+d+")"}};
(function(a,b){function e(a){if(""===f)return a;a=a.charAt(0).toUpperCase()+a.substr(1);return f+a}var d=Math,c=b.createElement("div").style,f=function(){for(var a=["t","webkitT","MozT","msT","OT"],b,d=0,e=a.length;d<e;d++)if(b=a[d]+"ransform",b in c)return a[d].substr(0,a[d].length-1);return!1}(),h=f?"-"+f.toLowerCase()+"-":"",g=e("transform"),l=e("transitionProperty"),s=e("transitionDuration"),k=e("transformOrigin"),t=e("transitionTimingFunction"),m=e("transitionDelay"),r=/android/gi.test(navigator.appVersion),
p=/iphone|ipad/gi.test(navigator.appVersion),n=/hp-tablet/gi.test(navigator.appVersion),u=e("perspective")in c,q="ontouchstart"in a&&!n,v=!1!==f,z=e("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(d,e){var c=this,f;c.wrapper="object"==typeof d?d:b.getElementById(d);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 e)c.options[f]=e[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 e;this[a+"Scrollbar"]?(this[a+"ScrollbarWrapper"]||(e=b.createElement("div"),this.options.scrollbarClass?e.className=this.options.scrollbarClass+a.toUpperCase():e.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"),e.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(e),this[a+"ScrollbarWrapper"]=e,e=b.createElement("div"),this.options.scrollbarClass||(e.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"),e.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&&(e.style.cssText+=";"+h+"transition-timing-function:cubic-bezier(0.33,0.66,0.66,1)"),this[a+"ScrollbarWrapper"].appendChild(e),this[a+"ScrollbarIndicator"]=e),"h"==a?(this.hScrollbarSize=this.hScrollbarWrapper.clientWidth,
this.hScrollbarIndicatorSize=d.max(d.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=d.max(d.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=d.round(a),b=d.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 e="h"==a?this.x:this.y;this[a+"Scrollbar"]&&(e*=this[a+"ScrollbarProp"],0>e?(this.options.fixedScrollbar||(e=this[a+"ScrollbarIndicatorSize"]+d.round(3*e),
8>e&&(e=8),this[a+"ScrollbarIndicator"].style["h"==a?"width":"height"]=e+"px"),e=0):e>this[a+"ScrollbarMaxScroll"]&&(this.options.fixedScrollbar?e=this[a+"ScrollbarMaxScroll"]:(e=this[a+"ScrollbarIndicatorSize"]-d.round(3*(e-this[a+"ScrollbarMaxScroll"])),8>e&&(e=8),this[a+"ScrollbarIndicator"].style["h"==a?"width":"height"]=e+"px",e=this[a+"ScrollbarMaxScroll"]+(this[a+"ScrollbarIndicatorSize"]-e))),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?e+"px,0)":"0,"+e+"px)")+w)},_start:function(b){var e=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=d.abs(b.touches[0].pageX-b.touches[1].pageX),
c=d.abs(b.touches[0].pageY-b.touches[1].pageY),this.touchesDistStart=d.sqrt(f*f+c*c),this.originX=d.abs(b.touches[0].pageX+b.touches[1].pageX-2*this.wrapperOffsetLeft)/2-this.x,this.originY=d.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=e.pageX,this.pointY=e.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,e=b.pageX-this.pointX,c=b.pageY-this.pointY,f=this.x+e,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=d.abs(a.touches[0].pageX-a.touches[1].pageX),h=d.abs(a.touches[0].pageY-a.touches[1].pageY),this.touchesDist=d.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+e/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+=e;this.distY+=c;this.absDistX=d.abs(this.distX);this.absDistY=d.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,e=0)),this.moved=!0,this._pos(f,h),this.dirX=0<e?-1:0>e?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(e){if(!q||0===e.touches.length){var c=this,f=q?e.changedTouches[0]:e,h,k,m={dist:0,time:0},l={dist:0,time:0},r=(e.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,e);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,e);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=d.max(d.max(m.time,l.time),10),c.options.snap&&(l=n-c.absStartX,r=p-c.absStartY,d.abs(l)<c.options.snapThreshold&&d.abs(r)<c.options.snapThreshold?c.scrollTo(c.absStartX,c.absStartY,200):(l=c._snap(n,p),n=l.x,p=l.y,
m=d.max(l.time,m))),c.scrollTo(d.round(n),d.round(p),m)):c.options.snap?(l=n-c.absStartX,r=p-c.absStartY,d.abs(l)<c.options.snapThreshold&&d.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,e),c.zoom(c.pointX,c.pointY,1==c.scale?c.options.doubleTapZoom:
1),c.options.onZoomEnd&&setTimeout(function(){c.options.onZoomEnd.call(c,e)},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,e.view,1,f.screenX,f.screenY,f.clientX,f.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.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,e)}}},_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,d;if("wheelDeltaX"in a)c=a.wheelDeltaX/12,d=a.wheelDeltaY/12;else if("wheelDelta"in a)c=d=a.wheelDelta/12;else if("detail"in a)c=d=3*-a.detail;else return;"zoom"==b.options.wheelAction?(d=b.scale*Math.pow(2,1/3*(d?d/Math.abs(d):0)),d<b.options.zoomMin&&(d=b.options.zoomMin),d>b.options.zoomMax&&(d=b.options.zoomMax),
d!=b.scale&&(!b.wheelZoomCount&&b.options.onZoomStart&&b.options.onZoomStart.call(b,a),b.wheelZoomCount++,b.zoom(a.pageX,a.pageY,d,400),setTimeout(function(){b.wheelZoomCount--;!b.wheelZoomCount&&b.options.onZoomEnd&&b.options.onZoomEnd.call(b,a)},400))):(c=b.x+c,d=b.y+d,0<c?c=0:c<b.maxScrollX&&(c=b.maxScrollX),d>b.minScrollY?d=b.minScrollY:d<b.maxScrollY&&(d=b.maxScrollY),0>b.maxScrollY&&b.scrollTo(c,d,0))},_transitionEnd:function(a){a.target==this.scroller&&(this._unbind(A),this._startAni())},_startAni:function(){var a=
this,b=a.x,c=a.y,e=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>=e+f.time?(a._pos(f.x,f.y),a.animating=!1,a.options.onAnimationEnd&&a.options.onAnimationEnd.call(a),a._startAni()):(l=(l-e)/f.time-1,g=d.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,e,f){b=d.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>e&&(e+=f/(6/(6E-4*(g/b))),b=b*e/g,g=e);return{dist:g*(0>a?-1:1),time:d.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,e,f;f=this.pagesX.length-1;c=0;for(e=this.pagesX.length;c<e;c++)if(a>=this.pagesX[c]){f=c;break}f==this.currPageX&&0<f&&0>this.dirX&&f--;a=this.pagesX[f];e=(e=d.abs(a-this.pagesX[this.currPageX]))?500*(d.abs(this.x-a)/e):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=d.abs(b-this.pagesY[this.currPageY]))?
500*(d.abs(this.y-b)/c):0;this.currPageY=f;f=d.round(d.max(e,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,e=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=d.round(this.scroller.offsetWidth*this.scale);this.scrollerH=
d.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++)e=this._offset(c[a]),e.left+=this.wrapperOffsetLeft,e.top+=this.wrapperOffsetTop,this.pagesX[a]=e.left<this.maxScrollX?this.maxScrollX:e.left*this.scale,this.pagesY[a]=e.top<this.maxScrollY?this.maxScrollY:e.top*this.scale;else if(this.options.snap){for(this.pagesX=
[];e>=this.maxScrollX;)this.pagesX[b]=e,e-=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=e=0;for(this.pagesY=[];e>=this.maxScrollY;)this.pagesY[b]=e,e-=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,d){var e=a;this.stop();e.length||(e=[{x:a,y:b,time:c,relative:d}]);a=0;for(b=e.length;a<b;a++)e[a].relative&&(e[a].x=this.x-e[a].x,e[a].y=this.y-e[a].y),this.steps.push({x:e[a].x,y:e[a].y,time:e[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?d.max(2*d.abs(c.left),2*d.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,e){var d=c/this.scale;this.options.useTransform&&(this.zoomed=!0,e=void 0===e?200:e,a=a-this.wrapperOffsetLeft-this.x,b=b-this.wrapperOffsetTop-this.y,this.x=a-a*d+this.x,this.y=b-b*d+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]=e+"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});e.length?c():d="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 e=[],d="standby";window.loadBuffers=[];var c=function(){var a=e.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"),e.length?c():d="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);if(r&&-1!==t.indexOf("js+"))if(t=PUBL?void 0:PAGES_JS_FOLDER+"/"+("page"+fill4Zero(g.position))+".js",-1!=f.indexOf(g.position)){g.waitingForVector=!1;g.vector=window.loadBuffers[g.position];if(g.onJSLoadComplete)g.onJSLoadComplete(window.loadBuffers[g.position]);a(g)}else g.waitingForVector=!0,b(t,g);else g.waitingForVector=!1;changeUrlWhenPubl(k,function(a){p.src!=a&&p.src!=qualifyURL(a)?p.src=
a:h()})}};this.addPageToQueue=function(a){e.push(a);"standby"==d&&(d="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==d.indexOf(c[b])){a=!1;break}a&&(customEvents.fireEvent(PAGE_CONTENT_DISPLAYED,{pages:c}),c=null)}}function b(b){d.push(b.data.page);6<d.length&&(d=d.slice(-6));a()}function e(b){c=b.data.page;a()}var d=[],c=null;customEvents.addListener(LOAD_MANAGER_PAGE_CONTENT_LOAD_COMPLETE,b);customEvents.addListener(ANDROID_PAGE_PREPARED,e);customEvents.addListener(BOOK_FLIPPING_END,e);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 e=window.location.hash.substring(1,window.location.hash.length).split("/"),d=1<e.length&&"z"!==e[1]?e[1]:2<e.length?e[2]:null,c=parseInt(e[0])}else c=1;c=pageTable.getFileIDFromUserID(c);void 0===c&&(c=1);pageMediator=new PageController(c,"single",publicationData.rtlMode);
null!==d&&"undefined"!==typeof d&&(new ProductInfoWindow(d)).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()},e=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",e);if(system.device.iphone&&"7"!==system.device.version&&
!system.publisher.isOn){var d=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",d);customEvents.addListener(ADD_BM,function(){system.browser.fullscreen&&d()})}customEvents.addListener(CHANGE_BOOK_TYPE,function(a){that.zoom=3==a.data.type?!0:!1})}
function PageController(a,b,e){this.page=1*a||1;this.previousPage=0;this.rtl=e||!1;this._listeners=[];var d=this;this.hashChangeHandler=function(a){var b=a.newURL.split("#")[1].split("/"),e=a.oldURL.split("#")[1].split("/");a=!1;if(1===b.length&&1<e.length||1<b.length&&1===e.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,e=d._listeners.length;a<e;a++)d._listeners[a].call(d,pageTable.getFileIDFromUserID(b))};Modernizr.hashchange&&window.addEventListener("hashchange",function(a){d.hashChangeHandler(a)});var c=function(a){"undefined"==typeof a||2!=a.data.type&&2!=a.data||d.changePage(d.page);d.changeHash(d.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},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)},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)}},addListener:function(a,b){b?this._listeners.unshift(a):this._listeners.push(a)},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()},removeListener:function(a){for(i in this._listeners)this._listeners[i].toString()==a.toString()&&
this._listeners.splice(i,1)},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()},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()},goToPage:function(a){this.changePage(a);this.fire()},maxLeft:function(){this.previousPage=
this.page;this.page=this.rtl?publicationData.pageCount:1;this.fire()},maxRight:function(){this.previousPage=this.page;this.page=this.rtl?1:publicationData.pageCount;this.fire()},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}),e=workspace.createElement({id:a.parent.id+"PagerCurrentPage",cssClassName:"pagerFont",parent:b}),d=workspace.createElement({id:a.parent.id+"PagerLastPage",cssClassName:"pagerFont",parent:b});return new PagerLite({pagerDiv:b,currentPageDiv:e,lastPageDiv:d,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,e=1;for(page in publicationData.page)if("defaults"!=page){var d=1*page+a;publicationData.page[page].wide&&(this.userIDToFileID[1*page+a]=1*page,this.fileIDTouserID[1*page+a]=1*page,a++,d=1*page+a-1+"-"+(1*page+a));this.userIDToFileID[1*page+a]=1*page;this.fileIDTouserID[1*
page]=1*page+a;this.captionToID[d]=1*page;this.IDToCaption[page]="one"!=publicationData.wideas?d:page;1==page?(this.IDToDoubleCaption[1]=1,this.doubleFlipList.push(1*page)):1==b?(e++,d=e,publicationData.page[page].wide?"one"!=publicationData.wideas&&(e++,d=d+"-"+e):(e++,d=d+"-"+e),this.IDToDoubleCaption[page]=d,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,e,d,c,f){this.id=pageTable.getCaption(a);search.pages[a]=!0;this.realID=a;this.text=b;this.relevant=e;this.startPos=d;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 e=new XMLHttpRequest;e.open("GET",ASSETS_FOLDER+"/search/searchtext.js");e.onload=b;e.onerror=function(){document.write("Error: can`t load xml3")};e.send();delete e}})}
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,e){e=e||[];b-=this.maxTextResultLength/2;a=a.substr(0>b?0:b,1*this.maxTextResultLength+6);a=fbUtils.screening("..."+a+"...");if(0<e.length)for(b=0;b<e.length;b++)a=search.getBold(a,e[b]);else a=search.getBold(a,search.query);return a},buildIndexes:function(a,b,e){for(var d=[],c=0;c<b;c++){for(var f=[],h=a[c],
g=-publicationData.search.lim;-1!=g;)g=e.indexOf(h,g+publicationData.search.lim),-1!=g&&f.push(g);0<f.length&&d.push(f)}return d},searchFullCoincidence:function(a,b,e,d){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(e,this.buildSearchText(b,c,[a]),d?0:1,c,c+a.length,d)),!0;if(0<=f&&!publicationData.search.exactMatch)return this.result.push(new SearchResult(e,
this.buildSearchText(b,f,[a]),d?2:3,f,f+a.length,d)),!0;delete null;return!1},searchPartiallyCoincidence:function(a,b,e,d,c){c=b.toLowerCase();c=this.buildIndexes(a,d,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*(d-c.length);delete null;this.result.push(new SearchResult(e,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 e=fbUtils.split(a,publicationData.search.lim),d=e.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<d?this.searchPartiallyCoincidence(e,
f["#text"],f["@ID"],d,a.length):1===d&&this.searchFullCoincidence(e[0],f["#text"],f["@ID"],!1))}this.result.sort(this.sortFunc);search.active=!0;var e={name:"searchTest",children:{}},h;for(h in search.result)d=search.result[h],e.children[h]={},e.children[h].name=d.text,e.children[h].page=d.id,e.children[h].realID=d.realID;customEvents.fireEvent(SHOW_SEARCH_RESULTS,{data:e})},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 e=a.getContext("2d");e.fillStyle="rgba(0,0,0,1)";var d=a.width/(publicationData.page[b].width||publicationData.page.defaults.width),c=function(a){with(publicationData.page[b].videos[a])var h=(width*d).toFixed(0),g=(height*d).toFixed(0),l=x*d,s=y*d,k=video.getVideoImageUrl(imageUri),t=showImage;t&&e.fillRect(l,s,h,g);var m=new Image;changeUrlWhenPubl(k,function(a){m.src=a});m.onload=function(){var d=
new Image,k=50<g?50:0.8*g;d.src=video.getPlayImage();d.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,e.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;e.drawImage(m,q,0,v,m.height,l,s,h,g);q=null;delete q;v=null;delete v}delete q;delete v}e.drawImage(d,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,e,d){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 e&&e();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);d=el.add("iframe");f.appendChild(d);d.className="youtube-player";d.type="text/html";d.width="100%";d.height="100%";d.frameBorder="0";d.style.display="inline-block";"youtube"==a?(d.className="youtube-player",d.src="http://www.youtube.com/embed/"+b+"?autoplay=1&html5=1"):"vimeo"==a&&(d.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 e=window.location.pathname.split("/");_trackEvent(e[e.length-4]+"","Open "+a,b)}this.showWindow()},hide:function(a,b){b=b||"";if(GAEnable){var e=window.location.pathname.split("/");_trackEvent(e[e.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,e,d){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(){e.call(d)});
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(){e.window.scrollObject.refresh()};var a=el.createElement("div",{"class":"productWindowPhotostream"},a),e=this;if(1<this.product.media.length)for(var d=0,c=this.product.media.length;d<c;d++){var f=el.createElement("img",{"class":"productWindowMainPhotoStream",src:this.product.media[d].url},a);Hammer(f).on("tap",function(){b.src=this.src;e.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 e=el.createElement("div",{"class":"productWindowQTYButton"},b),b=el.createElement("span",{"class":"productWindowQTYArrow rgtarrow"},e);b.innerText=" + ";var d=el.createElement("input",{"class":"inpECommerceQTY",type:"text",disabled:"disabled",value:this.qty},e),e=el.createElement("span",{"class":"productWindowQTYArrow lftarrow"},
e);e.innerText=" - ";var c=this;d.addEventListener("blur",function(){this.value=c.qty});d.addEventListener("keydown",function(a){13===a.keyCode&&this.blur()});d.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(e).on("tap",function(){var a=parseInt(d.value);--a;1>a&&(a=1);c.qty=a;d.value=a;c._calcFinalPrice.call(c)});Hammer(b).on("tap",function(){var a=parseInt(d.value);
++a;c.qty=a;d.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(e,d){cart.getItems(function(c){a.call(d,c[0],b,e)},function(){},[e.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 e=0,d;for(d in this.cartItem)e++,function(a,e){cart.getItems(function(h){b.call(e,h[0],d,a)},function(){},[a.itemID])}(this.cartItem[d],a),el.id("totalQTY").innerText=this.totalQTY+" "+LOCALS.ITEMS,el.id("totalPrice").innerText=
LOCALS.TOTAL+": "+fbUtils.formatPrice(this.totalPrice);e||this.window.hide();this.window.scrollObject.refresh()},getItemPrice:function(a,b){var e=this;cart.getItems(function(d){d=d[0];var c=d.price,f;for(f in e.cartItem[a].options)c+=d.options[f].values[e.cartItem[a].options[f]].price;c*=e.cartItem[a].qty;e.totalQTY+=parseInt(e.cartItem[a].qty);e.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(e.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(){})}};
