!function(t){"use strict";var e,a="",r=Math.PI,n=r/2,i="PointerEvent"in window,s="ontouchstart"in window,o=!i&&s,p=i?{start:"pointerdown",move:"pointermove",end:"pointerup pointercancel"}:o?{start:"touchstart",move:"touchmove",end:"touchend"}:{start:"mousedown",move:"mousemove",end:"mouseup"},l=window.performance&&window.performance.now?function(){return window.performance.now()}:function(){return(new Date).getTime()},h=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){return window.setTimeout(function(){t(l())},16)},d=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||function(t){window.clearTimeout(t)},g=".turn",f=".turnFlip",u={backward:["bl","tl"],forward:["br","tr"],all:["tl","bl","tr","br"]},c=["single","double"],v={page:1,gradients:!0,duration:600,acceleration:!0,display:"double",when:null},y={folding:null,corners:"forward",cornerSize:100,gradients:!0,duration:600,acceleration:!0},w={0:{top:0,left:0,right:"auto",bottom:"auto"},1:{top:0,right:0,left:"auto",bottom:"auto"}},m="turn-js-base-css",b=[".turn-page{position:absolute;}",".turn-page-wrapper,.turn-flip-wrapper,.turn-fold-wrapper,.turn-shadow{position:absolute;overflow:hidden;}",".turn-fold-parent{position:absolute;overflow:visible;pointer-events:none;}",".turn-fold-inner{position:absolute;overflow:visible;}",".turn-fold-page{cursor:default;}",".turn-back-shadow{overflow:hidden;}"].join(""),P=function(){document.getElementById(m)||t("",{id:m,type:"text/css"}).text(b).appendTo(document.head||document.documentElement)},_=function(t,e,a){return{css:{top:t,left:e,"z-index":a||"auto"}}},x=function(t,e,a,r,n){var i=1-n,s=i*i*i,o=n*n*n;return O(Math.round(s*t.x+3*n*i*i*e.x+3*n*n*i*a.x+o*r.x),Math.round(s*t.y+3*n*i*i*e.y+3*n*n*i*a.y+o*r.y))},M=function(t){return t/r*180},O=function(t,e){return{x:t,y:e}},W=function(t,a,r){return e&&r?" translate3d("+t+"px,"+a+"px, 0px) ":" translate("+t+"px, "+a+"px) "},S=function(t){return" rotate("+t+"deg) "},j=function(t,e){return Object.prototype.hasOwnProperty.call(e,t)},F=function(e,a){return t.map(e.split(" "),function(t){return t+a}).join(" ")},z=function(t,e,a){return t=parseFloat(t),Math.max(e,Math.min(a,isNaN(t)?e:t))},T=function(t){return t.data()},k=function(t){return t.data().f},A={createWrapper:function(e,a,r){return t("
",t.extend({class:e},a||{})).css(r||{})},applyStyles:function(t,e){return t.css(e)},removeNode:function(t){t&&t.remove()},append:function(t,e){return t.append(e)},prepend:function(t,e){return t.prepend(e)},transformProperties:function(t,e){var r={};return e&&(a&&(r[a+"transform-origin"]=e),r["transform-origin"]=e),a&&(r[a+"transform"]=t),r.transform=t,r},applyTransform:function(t,e,a){return A.applyStyles(t,A.transformProperties(e,a))}},D=function(t){var e,a,i,s,o,p,l=0,h=0,d=O(0,0),g=O(0,0),f=O(0,0),u=t.width,c=t.height,v=t.wrapperHeight,y=t.origin,w=O(t.point.x,t.point.y),m="t"==t.point.corner.substr(0,1),b="l"==t.point.corner.substr(1,1);w.corner=t.point.corner,w.x=b?Math.max(w.x,1):Math.min(w.x,u-1);var P=function(){var _,x=O(y.x?y.x-w.x:w.x,y.y?y.y-w.y:w.y),W=Math.atan2(x.y,x.x);h=M(l=n-W),_=O(b?u-x.x/2:w.x+x.x/2,x.y/2);var S=l-Math.atan2(_.y,_.x),j=Math.max(0,Math.sin(S)*Math.sqrt(Math.pow(_.x,2)+Math.pow(_.y,2)));if(f=O(j*Math.sin(l),j*Math.cos(l)),l>n&&(f.x=f.x+Math.abs(f.y*Math.tan(W)),f.y=0,Math.round(f.x*Math.tan(r-l))=i-p))return!1;s.corner="b"}if(s.x<=p)s.corner+="l";else{if(!(s.x>=n-p))return!1;s.corner+="r"}return-1!=t.inArray(s.corner,l)&&s},_c:function(t,e){return{tl:O(e=e||0,e),tr:O(this.width()-e,e),bl:O(e,this.height()-e),br:O(this.width()-e,this.height()-e)}[t]},_c2:function(t){return{tl:O(2*this.width(),0),tr:O(-this.width(),0),bl:O(2*this.width(),this.height()),br:O(-this.width(),this.height())}[t]},_foldingPage:function(t){var e=this.data().f.opts;if(e.folding)return e.folding;if(e.turn){var a=e.turn.data();return"single"==a.display?a.pageObjs[e.next]?a.pageObjs[0]:null:a.pageObjs[e.next]}},_backGradient:function(){var t=this.data().f,e=t.opts.turn,a=t.opts.backGradient&&(!e||"single"==e.data().display||2!=t.opts.page&&t.opts.page!=e.data().totalPages-1);return a&&!t.bshadow&&(t.bshadow=A.createWrapper("turn-back-shadow",null,{width:this.width(),height:this.height()}).appendTo(t.parent)),a},_createFoldParent:function(){var e=k(this),a=t("
",{class:"turn-fold-parent"}).hide();return a.data().flips=0,e.opts.turn?(A.applyStyles(a,_(-e.opts.turn.offset().top,-e.opts.turn.offset().left,"auto").css).appendTo(e.opts.turn),T(e.opts.turn).fparent=a):A.applyStyles(a,_(0,0,"auto").css).attr("id","turn-fwrappers").appendTo(t("body")),a},resize:function(t){var e=this.data().f,a=this.width(),r=this.height(),n=Math.round(Math.sqrt(Math.pow(a,2)+Math.pow(r,2)));t&&(A.applyStyles(e.wrapper,{width:n,height:n}),A.applyStyles(e.fwrapper,{width:n,height:n}).children(":first-child").css({width:a,height:r}),A.applyStyles(e.fpage,{width:r,height:a}),e.opts.frontGradient&&A.applyStyles(e.ashadow,{width:r,height:a}),N._backGradient.call(this)&&A.applyStyles(e.bshadow,{width:a,height:r})),e.parent.is(":visible")&&(A.applyStyles(e.fwrapper,{top:e.parent.offset().top,left:e.parent.offset().left}),e.opts.turn&&A.applyStyles(e.fparent,{top:-e.opts.turn.offset().top,left:-e.opts.turn.offset().left})),this.flip("z",e.opts["z-index"])},_addPageWrapper:function(){var e=this.data().f,a=this.parent();if(!e.wrapper){this.css("left"),this.css("top");var r=this.width(),n=this.height();Math.round(Math.sqrt(Math.pow(r,2)+Math.pow(n,2)));e.parent=a,e.fparent=e.opts.turn?T(e.opts.turn).fparent:t("#turn-fwrappers"),e.fparent||(e.fparent=N._createFoldParent.call(this)),A.applyStyles(this,{top:0,left:0,bottom:"auto",right:"auto"}),e.wrapper=A.createWrapper("turn-flip-wrapper",null,_(0,0,this.css("z-index")).css).appendTo(a).prepend(this),e.fwrapper=A.createWrapper("turn-fold-wrapper",null,_(a.offset().top,a.offset().left).css).hide().appendTo(e.fparent),e.fpage=A.createWrapper("turn-fold-page").appendTo(A.createWrapper("turn-fold-inner",null,_(0,0,0).css).appendTo(e.fwrapper)),e.opts.frontGradient&&(e.ashadow=A.createWrapper("turn-shadow",null,_(0,0,1).css).appendTo(e.fpage)),N.setData.call(this,e),N.resize.call(this,!0)}},_fold:function(t){var e,a,r,n,i,s=this,o=O(0,0),p=O(0,0),l=O(0,0),h=this.width(),d=this.height(),g=N._foldingPage.call(this),f=this.data().f,u=f.opts.acceleration,c=f.wrapper.height(),v=N._c.call(this,t.corner),y=N._backGradient.call(this),w=D({point:t,width:h,height:d,wrapperHeight:c,origin:v,endingPoint:N._c2.call(this,t.corner),frontGradient:f.opts.frontGradient,backGradient:y}),m="t"==t.corner.substr(0,1),b="l"==t.corner.substr(1,1),P=function(t,e,l,g){var v=["0","auto"],w=(h-c)*l[0]/100,P=(d-c)*l[1]/100,_={left:v[e[0]],top:v[e[1]],right:v[e[2]],bottom:v[e[3]]},x=90!=g&&-90!=g?b?-1:1:0;l=l[0]+"% "+l[1]+"%",A.applyStyles(s,_).transform(S(g)+W(t.x+x,t.y,u),l),A.applyStyles(f.fpage.parent(),_),f.wrapper.transform(W(-t.x+w-x,-t.y+P,u)+S(-g),l),f.fwrapper.transform(W(-t.x+o.x+w,-t.y+o.y+P,u)+S(-g),l),f.fpage.parent().transform(S(g)+W(t.x+p.x-o.x,t.y+p.y-o.y,u),l),f.opts.frontGradient&&E(f.ashadow,O(b?100:0,m?100:0),O(a.x,a.y),[[n,"rgba(0,0,0,0)"],[.9*(1-n)+n,"rgba(0,0,0,"+.12*i+")"],[1,"rgba(0,0,0,0)"]],3),y&&E(f.bshadow,O(b?0:100,m?0:100),O(r.x,r.y),[[.7,"rgba(0,0,0,0)"],[.9,"rgba(0,0,0,"+.18*i+")"],[1,"rgba(0,0,0,0)"]],3)};switch(t.x=w.point.x,t.y=w.point.y,w.alpha,e=w.angle,l=w.tr,o=w.move,p=w.df,m=w.top,b=w.left,a=w.gradient.endPointA,r=w.gradient.endPointB,n=w.gradient.startV,i=w.gradient.opacity,t.corner){case"tl":P(l,[1,0,0,1],[100,0],e),f.fpage.transform(W(-d,-h,u)+S(90-2*e),"100% 100%"),g.transform(S(90)+W(0,-d,u),"0% 0%");break;case"tr":P(O(-l.x,l.y),[0,0,0,1],[0,0],-e),f.fpage.transform(W(0,-h,u)+S(2*e-90),"0% 100%"),g.transform(S(270)+W(-h,0,u),"0% 0%");break;case"bl":P(O(l.x,-l.y),[1,1,0,0],[100,100],-e),f.fpage.transform(W(-d,0,u)+S(2*e-90),"100% 0%"),g.transform(S(270)+W(-h,0,u),"0% 0%");break;case"br":P(O(-l.x,-l.y),[0,1,1,0],[0,100],e),f.fpage.transform(S(90-2*e),"0% 0%"),g.transform(S(90)+W(0,-d,u),"0% 0%")}f.point=t},_moveFoldingPage:function(t){var e=this.data().f,a=N._foldingPage.call(this);a&&(t?e.fpage.children()[e.ashadow?"1":"0"]||(N.setData.call(this,{backParent:a.parent()}),A.prepend(e.fpage,a)):e.backParent&&A.prepend(e.backParent,a))},_showFoldedPage:function(e,a){var r=N._foldingPage.call(this),n=this.data(),i=n.f;if(!i.point||i.point.corner!=e.corner){var s=t.Event("start");if(this.trigger(s,[i.opts,e.corner]),s.isDefaultPrevented())return!1}if(r){if(a){var o=this,p=i.point&&i.point.corner==e.corner?i.point:N._c.call(this,e.corner,1);this.animatef({from:[p.x,p.y],to:[e.x,e.y],duration:500,frame:function(t){e.x=Math.round(t[0]),e.y=Math.round(t[1]),N._fold.call(o,e)}})}else N._fold.call(this,e),n.effect&&!n.effect.turning&&this.animatef(!1);return i.fwrapper.is(":visible")||(i.fparent.show().data().flips++,N._moveFoldingPage.call(this,!0),i.fwrapper.show(),i.bshadow&&i.bshadow.show()),!0}return!1},hide:function(){var t=this.data().f,e=N._foldingPage.call(this);return 0===--t.fparent.data().flips&&t.fparent.hide(),A.applyStyles(this,{left:0,top:0,right:"auto",bottom:"auto"}).transform("","0% 100%"),t.wrapper.transform("","0% 100%"),t.fwrapper.hide(),t.bshadow&&t.bshadow.hide(),e.transform("","0% 0%"),this},hideFoldedPage:function(t){var e=this.data().f;if(e.point){var a=this,r=e.point,n=function(){e.point=null,a.flip("hide"),a.trigger("end",[!1])};if(t){var i=N._c.call(this,r.corner),s="t"==r.corner.substr(0,1)?Math.min(0,r.y-i.y)/2:Math.max(0,r.y-i.y)/2,o=O(r.x,r.y+s),p=O(i.x,i.y-s);this.animatef({from:0,to:1,frame:function(t){var e=x(r,o,p,i,t);r.x=e.x,r.y=e.y,N._fold.call(a,r)},complete:n,duration:800,hiding:!0})}else this.animatef(!1),n()}},turnPage:function(t){var e=this,a=this.data().f;t={corner:a.corner?a.corner.corner:t||N._cAllowed.call(this)[0]};var r=a.point||N._c.call(this,t.corner,a.opts.turn?a.opts.turn.data().opts.elevation:0),n=N._c2.call(this,t.corner);this.trigger("flip").animatef({from:0,to:1,frame:function(a){var i=x(r,r,n,n,a);t.x=i.x,t.y=i.y,N._showFoldedPage.call(e,t)},complete:function(){e.trigger("end",[!0])},duration:a.opts.duration,turning:!0}),a.corner=null},moving:function(){return"effect"in this.data()},isTurning:function(){return this.flip("moving")&&this.data().effect.turning},_eventStart:function(t){var e=this.data().f;if(!e.disabled&&!this.flip("isTurning")){if(e.corner=N._cornerActivated.call(this,t),e.corner&&N._foldingPage.call(this,e.corner))return N._moveFoldingPage.call(this,!0),this.trigger("pressed",[e.point]),!1;e.corner=null}},_eventMove:function(t){var e=this.data().f;if(!e.disabled)if(t=o?t.originalEvent.touches:[t],e.corner){var a=e.parent.offset();e.corner.x=t[0].pageX-a.left,e.corner.y=t[0].pageY-a.top,N._showFoldedPage.call(this,e.corner)}else if(!this.data().effect&&this.is(":visible")){var r=N._cornerActivated.call(this,t[0]);if(r){var n=N._c.call(this,r.corner,e.opts.cornerSize/2);r.x=n.x,r.y=n.y,N._showFoldedPage.call(this,r,!0)}else N.hideFoldedPage.call(this,!0)}},_eventEnd:function(){var e=this.data().f;if(!e.disabled&&e.point){var a=t.Event("released");this.trigger(a,[e.point]),a.isDefaultPrevented()||N.hideFoldedPage.call(this,!0)}e.corner=null},disable:function(t){return N.setData.call(this,{disabled:t}),this}},q=function(t,e,a){if(a[0]&&"object"!=typeof a[0]){if(e[a[0]]&&"_"!=a[0].toString().substr(0,1))return e[a[0]].apply(t,Array.prototype.slice.call(a,1));throw a[0]+" is an invalid value"}return e.init.apply(t,a)};t.extend(t.fn,{flip:function(t,e){return q(this,N,arguments)},turn:function(t){return q(this,H,arguments)},transform:function(t,e){return A.applyTransform(this,t,e)},animatef:function(t){var e=this.data();if(e.effect&&d(e.effect.handle),t){t.to.length||(t.to=[t.to]),t.from.length||(t.from=[t.from]),t.easing||(t.easing=function(t,e,a,r,n){return r*Math.sqrt(1-(e=e/n-1)*e)+a});var a,r=[],n=t.to.length,i=this,s=l(),o=function(a){if(i.data().effect===t){a=a||l();var p,d=Math.min(t.duration,Math.max(0,a-s)),g=[];for(p=0;p