+// twoPageGutter()
+//______________________________________________________________________________
+// Returns the position of the gutter (line between the page images)
+GnuBook.prototype.twoPageGutter = function() {
+ return this.twoPage.middle + this.gutterOffsetForIndex(this.twoPage.currentIndexL);
+}
+
+// twoPageTop()
+//______________________________________________________________________________
+// Returns the offset for the top of the page images
+GnuBook.prototype.twoPageTop = function() {
+ return this.twoPage.coverExternalPadding + this.twoPage.coverInternalPadding; // $$$ + border?
+}
+
+// twoPageCoverWidth()
+//______________________________________________________________________________
+// Returns the width of the cover div given the total page width
+GnuBook.prototype.twoPageCoverWidth = function(totalPageWidth) {
+ return totalPageWidth + this.twoPage.edgeWidth + 2*this.twoPage.coverInternalPadding;
+}
+
+// twoPageGetViewCenter()
+//______________________________________________________________________________
+// Returns the percentage offset into twopageview div at the center of container div
+// { percentageX: float, percentageY: float }
+GnuBook.prototype.twoPageGetViewCenter = function() {
+ var center = {};
+
+ var containerOffset = $('#GBcontainer').offset();
+ var viewOffset = $('#GBtwopageview').offset();
+ center.percentageX = (containerOffset.left - viewOffset.left + ($('#GBcontainer').attr('clientWidth') >> 1)) / this.twoPage.totalWidth;
+ center.percentageY = (containerOffset.top - viewOffset.top + ($('#GBcontainer').attr('clientHeight') >> 1)) / this.twoPage.totalHeight;
+
+ return center;
+}
+
+// twoPageCenterView(percentageX, percentageY)
+//______________________________________________________________________________
+// Centers the point given by percentage from left,top of twopageview
+GnuBook.prototype.twoPageCenterView = function(percentageX, percentageY) {
+ if ('undefined' == typeof(percentageX)) {
+ percentageX = 0.5;
+ }
+ if ('undefined' == typeof(percentageY)) {
+ percentageY = 0.5;
+ }
+
+ var viewWidth = $('#GBtwopageview').width();
+ var containerClientWidth = $('#GBcontainer').attr('clientWidth');
+ var intoViewX = percentageX * viewWidth;
+
+ var viewHeight = $('#GBtwopageview').height();
+ var containerClientHeight = $('#GBcontainer').attr('clientHeight');
+ var intoViewY = percentageY * viewHeight;
+
+ if (viewWidth < containerClientWidth) {
+ // Can fit width without scrollbars - center by adjusting offset
+ $('#GBtwopageview').css('left', (containerClientWidth >> 1) - intoViewX + 'px');
+ } else {
+ // Need to scroll to center
+ $('#GBtwopageview').css('left', 0);
+ $('#GBcontainer').scrollLeft(intoViewX - (containerClientWidth >> 1));
+ }
+
+ if (viewHeight < containerClientHeight) {
+ // Fits with scrollbars - add offset
+ $('#GBtwopageview').css('top', (containerClientHeight >> 1) - intoViewY + 'px');
+ } else {
+ $('#GBtwopageview').css('top', 0);
+ $('#GBcontainer').scrollTop(intoViewY - (containerClientHeight >> 1));
+ }
+}
+
+// twoPageFlipAreaHeight
+//______________________________________________________________________________
+// Returns the integer height of the click-to-flip areas at the edges of the book
+GnuBook.prototype.twoPageFlipAreaHeight = function() {
+ return parseInt(this.twoPage.height);
+}
+
+// twoPageFlipAreaWidth
+//______________________________________________________________________________
+// Returns the integer width of the flip areas
+GnuBook.prototype.twoPageFlipAreaWidth = function() {
+ var max = 100; // $$$ TODO base on view width?
+ var min = 10;
+
+ var width = this.twoPage.width * 0.15;
+ return parseInt(GnuBook.util.clamp(width, min, max));
+}
+
+// twoPageFlipAreaTop
+//______________________________________________________________________________
+// Returns integer top offset for flip areas
+GnuBook.prototype.twoPageFlipAreaTop = function() {
+ return parseInt(this.twoPage.bookCoverDivTop + this.twoPage.coverInternalPadding);
+}
+
+// twoPageLeftFlipAreaLeft
+//______________________________________________________________________________
+// Left offset for left flip area
+GnuBook.prototype.twoPageLeftFlipAreaLeft = function() {
+ return parseInt(this.twoPage.gutter - this.twoPage.scaledWL);
+}
+
+// twoPageRightFlipAreaLeft
+//______________________________________________________________________________
+// Left offset for right flip area
+GnuBook.prototype.twoPageRightFlipAreaLeft = function() {
+ return parseInt(this.twoPage.gutter + this.twoPage.scaledWR - this.twoPageFlipAreaWidth());
+}
+
+// twoPagePlaceFlipAreas
+//______________________________________________________________________________
+// Readjusts position of flip areas based on current layout
+GnuBook.prototype.twoPagePlaceFlipAreas = function() {
+ // We don't set top since it shouldn't change relative to view
+ $(this.twoPage.leftFlipArea).css({
+ left: this.twoPageLeftFlipAreaLeft() + 'px',
+ width: this.twoPageFlipAreaWidth() + 'px'
+ });
+ $(this.twoPage.rightFlipArea).css({
+ left: this.twoPageRightFlipAreaLeft() + 'px',
+ width: this.twoPageFlipAreaWidth() + 'px'
+ });
+}
+