//>>built
define("dojox/mobile/pageTurningUtils","dojo/_base/kernel,dojo/_base/array,dojo/_base/connect,dojo/_base/event,dojo/dom-class,dojo/dom-construct,dojo/dom-style".split(","),function(q,m,p,r,j,s,f){q.experimental("dojox.mobile.pageTurningUtils");return function(){this.h=this.w=0;this.turnfrom="top";this.dogear=this.page=1;this.duration=2;this.alwaysDogeared=!1;this._styleParams={};this._transitionEndHandle=this._currentPageNode=this._catalogNode=null;this.init=function(a,c,d,e,b,g,f){this.w=a;this.h=
c;this.turnfrom=d?d:this.turnfrom;this.page=e?e:this.page;this.dogear="undefined"!==typeof b?b:this.dogear;this.duration="undefined"!==typeof g?g:this.duration;this.alwaysDogeared="undefined"!==typeof f?f:this.alwaysDogeared;if("bottom"===this.turnfrom)this.alwaysDogeared=!0;this._calcStyleParams()};this._calcStyleParams=function(){var a=Math.tan(58*Math.PI/180),c=Math.cos(32*Math.PI/180),d=Math.sin(32*Math.PI/180),e=Math.tan(32*Math.PI/180),b=this.w,g=this.h,f=this.page,j=this.turnfrom,i=this._styleParams,
h=fold=b*a,h=h*d+h*c*a,l=fold+b+b/a,o=0.11*b*this.dogear,n=b-o,m=n*c,k;switch(this.turnfrom){case "top":e=m*a;k=e/c;i.init={page:{top:-k+"px",left:-h+(2===f?b:0)+"px",width:h+"px",height:l+"px",webkitTransformOrigin:"100% 0%"},front:{width:b+"px",height:g+"px",webkitBoxShadow:"0 0"},back:{width:b+"px",height:g+"px",webkitBoxShadow:"0 0"},shadow:{display:"",left:h+"px",height:1.5*g+"px"}};i.turnForward={page:{webkitTransform:"rotate(0deg)"},front:{webkitTransform:"translate("+h+"px,"+k+"px) rotate(0deg)",
webkitTransformOrigin:"-110px -18px"},back:{webkitTransform:"translate("+(h-b)+"px,"+k+"px) rotate(0deg)",webkitTransformOrigin:"0px 0px"}};i.turnBackward={page:{webkitTransform:"rotate(-32deg)"},front:{webkitTransform:"translate("+(h-m)+"px,"+e+"px) rotate(32deg)",webkitTransformOrigin:"0px 0px"},back:{webkitTransform:"translate("+(h-o)+"px,"+(e+n/a-7)+"px) rotate(-32deg)",webkitTransformOrigin:"0px 0px"}};break;case "bottom":k=l-b/e-g;i.init={page:{top:-k+50+"px",left:-h+(2===f?b:0)+"px",width:h+
"px",height:l+"px",webkitTransformOrigin:"100% 100%"},front:{width:b+"px",height:g+"px",webkitBoxShadow:"0 0"},back:{width:b+"px",height:g+"px",webkitBoxShadow:"0 0"},shadow:{display:"none"}};i.turnForward={page:{webkitTransform:"rotate(0deg)"},front:{webkitTransform:"translate("+h+"px,"+k+"px) rotate(0deg)",webkitTransformOrigin:"-220px 35px"},back:{webkitTransform:"translate("+2*b+"px,"+k+"px) rotate(0deg)",webkitTransformOrigin:"0px 0px"}};i.turnBackward={page:{webkitTransform:"rotate(32deg)"},
front:{webkitTransform:"translate("+(h-(g*d+b*c)-2)+"px,"+(l-(g+b/e)*c)+"px) rotate(-32deg)",webkitTransformOrigin:"0px 0px"},back:{webkitTransform:"translate("+h+"px,"+(l-b/d-g)+"px) rotate(0deg)",webkitTransformOrigin:"0px 0px"}};break;case "left":e=n/e-2,a=n/d+o*d,i.init={page:{top:-e+"px",left:b+"px",width:h+"px",height:l+"px",webkitTransformOrigin:"0% 0%"},front:{width:b+"px",height:g+"px",webkitBoxShadow:"0 0"},back:{width:b+"px",height:g+"px",webkitBoxShadow:"0 0"},shadow:{display:"",left:"-4px",
height:(2===f?1.5*g:g)+50+"px"}},i.turnForward={page:{webkitTransform:"rotate(0deg)"},front:{webkitTransform:"translate("+-b+"px,"+e+"px) rotate(0deg)",webkitTransformOrigin:"160px 68px"},back:{webkitTransform:"translate(0px,"+e+"px) rotate(0deg)",webkitTransformOrigin:"0px 0px"}},i.turnBackward={page:{webkitTransform:"rotate(32deg)"},front:{webkitTransform:"translate("+-o+"px,"+a+"px) rotate(-32deg)",webkitTransformOrigin:"0px 0px"},back:{webkitTransform:"translate("+-n+"px,"+a+"px) rotate(32deg)",
webkitTransformOrigin:"top right"}}}i.init.catalog={width:(2===f?2*b:b)+"px",height:(2===f?1.5*g:g)+("top"==j?0:50)+"px"}};this.getChildren=function(a){return m.filter(a.childNodes,function(a){return 1===a.nodeType})};this.getPages=function(){return this._catalogNode?this.getChildren(this._catalogNode):null};this.getCurrentPage=function(){return this._currentPageNode};this.getIndexOfPage=function(a,c){c||(c=this.getPages());for(var d=0;d<c.length;d++)if(a===c[d])return d;return-1};this.getNextPage=
function(a){for(a=a.nextSibling;a;a=a.nextSibling)if(1===a.nodeType)return a;return null};this.getPreviousPage=function(a){for(a=a.previousSibling;a;a=a.previousSibling)if(1===a.nodeType)return a;return null};this.isPageTurned=function(a){return"rotate(0deg)"==a.style.webkitTransform};this._onPageTurned=function(a){r.stop(a);if(j.contains(a.target,"mblPageTurningPage"))this.onPageTurned(a.target)};this.onPageTurned=function(){};this.initCatalog=function(a){if(this._catalogNode!=a)this._transitionEndHandle&&
p.disconnect(this._transitionEndHandle),this._transitionEndHandle=p.connect(a,"webkitTransitionEnd",this,"_onPageTurned"),this._catalogNode=a;j.add(a,"mblPageTurningCatalog");f.set(a,this._styleParams.init.catalog);a=this.getPages();m.forEach(a,function(a){this.initPage(a)},this);this.resetCatalog()};this._getBaseZIndex=function(){return this._catalogNode.style.zIndex||0};this.resetCatalog=function(){for(var a=this.getPages(),c=a.length,d=this._getBaseZIndex(),e=c-1;0<=e;e--){var b=a[e];this.showDogear(b);
this.isPageTurned(b)?b.style.zIndex=d+c+1:(b.style.zIndex=d+c-e,!this.alwaysDogeared&&this.hideDogear(b),this._currentPageNode=b)}!this.alwaysDogeared&&this._currentPageNode!=a[c-1]&&this.showDogear(this._currentPageNode)};this.initPage=function(a,c){for(var d=this.getChildren(a);3>d.length;)a.appendChild(s.create("div",null)),d=this.getChildren(a);var e=!j.contains(a,"mblPageTurningPage");j.add(a,"mblPageTurningPage");j.add(d[0],"mblPageTurningFront");j.add(d[1],"mblPageTurningBack");j.add(d[2],
"mblPageTurningShadow");var b=this._styleParams.init;f.set(a,b.page);f.set(d[0],b.front);f.set(d[1],b.back);b.shadow&&f.set(d[2],b.shadow);c||(e&&this._currentPageNode?(this.getPages(),c=this.getIndexOfPage(a)<this.getIndexOfPage(this._currentPageNode)?1:-1):c=this.isPageTurned(a)?1:-1);this._turnPage(a,c,0)};this.turnToNext=function(a){var c=this.getNextPage(this._currentPageNode);if(c)this._turnPage(this._currentPageNode,1,a),this._currentPageNode=c};this.turnToPrev=function(a){var c=this.getPreviousPage(this._currentPageNode);
if(c)this._turnPage(c,-1,a),this._currentPageNode=c};this.goTo=function(a){var c=this.getPages();if(!(this._currentPageNode===c[a]||c.length<=a))for(var d=a<this.getIndexOfPage(this._currentPageNode,c);this._currentPageNode!==c[a];)d?this.turnToPrev(0):this.turnToNext(0)};this._turnPage=function(a,c,d){var e=this.getChildren(a),d=("undefined"!==typeof d?d:this.duration)+"s",b=1===c?this._styleParams.turnForward:this._styleParams.turnBackward;b.page.webkitTransitionDuration=d;f.set(a,b.page);b.front.webkitTransitionDuration=
d;f.set(e[0],b.front);b.back.webkitTransitionDuration=d;f.set(e[1],b.back);var e=this.getPages(),d=this.getNextPage(a),b=e.length,g=this._getBaseZIndex();if(1===c)a.style.zIndex=g+b+1,!this.alwaysDogeared&&d&&this.getNextPage(d)&&this.showDogear(d);else if(d)d.style.zIndex=g+b-this.getIndexOfPage(d,e),!this.alwaysDogeared&&this.hideDogear(d)};this.showDogear=function(a){var c=this.getChildren(a);f.set(a,"overflow","");c[1]&&f.set(c[1],"display","");c[2]&&f.set(c[2],"display","bottom"===this.turnfrom?
"none":"")};this.hideDogear=function(a){if("bottom"!==this.turnfrom){var c=this.getChildren(a);f.set(a,"overflow","visible");c[1]&&f.set(c[1],"display","none");c[2]&&f.set(c[2],"display","none")}}}});