function checkTopMenu() { var tmp1 = document.getElementById("topRightBG"); var ww1 = document.getElementById("fullVersionLink").offsetWidth; if (ww1 > tmp1.offsetWidth) { tmp1.style.width = (ww1 + 10) + "px"; document.getElementById("topLine").style.right = (ww1 + 10 + 4) + 'px'; document.getElementById("topLeftBG").style.right = (ww1 + 10 + 4) + 'px'; document.getElementById("topLeft").style.right = (ww1 + 10 + 4 + 117) + 'px'; } var tmp2 = document.getElementById("topLeftBG"); var ww2 = document.getElementById("tocLink").offsetWidth; if (ww2 > tmp2.offsetWidth) { tmp2.style.width = (ww2 + 10) + "px"; document.getElementById("topLeft").style.right = (4 + ww1 + 10 + ww2 + 10) + 'px'; } var tmp3 = document.getElementById("prewKnob"); var ww3 = document.getElementById("prewKnobTxt").offsetWidth; if (ww3 > tmp3.offsetWidth) { tmp3.style.width = ww3 + 'px'; tmp3.style.left = (-ww3 - 5) + 'px'; } } function checkTocHeight() { var hh = document.getElementById("divTree").offsetHeight; if (hh > document.getElementById("divPage").offsetHeight - 150) { document.getElementById("divPage").style.height = (1 * hh + 150) + 'px'; document.getElementById("divMain").style.height = (1 * hh + 250) + 'px'; document.getElementById("divBG").style.height = (1 * hh) + 'px'; if (hh <= (document.body.clientHeight - 120)) { document.getElementById("nextKnob").style.top = ((hh + 120) / 2) + 'px'; document.getElementById("prewKnob").style.top = ((hh + 120) / 2) + 'px'; } else { document.getElementById("nextKnob").style.top = '275px'; document.getElementById("prewKnob").style.top = '275px'; } } } function checkTocMinWidth() { var ww = document.getElementById("divMain").offsetWidth; minWidth = 300; if (ww < minWidth) { document.getElementById("divTitleHeader").style.width = minWidth + 'px'; document.getElementById("fontTitle").style.width = (minWidth - 250) + 'px'; document.getElementById("divPage").style.width = minWidth + 'px'; document.getElementById("divMain").style.width = minWidth + 'px'; document.getElementById("topRight").style.right = '0px'; document.getElementById("topRightBG").style.right = '4px'; document.getElementById("topLine").style.right = '121px'; document.getElementById("topLeftBG").style.right = '121px'; document.getElementById("topLeft").style.right = '238px'; document.getElementById("nextKnob").style.left = (minWidth + 5) + 'px'; if(document.getElementById("divCopy")){ document.getElementById("divCopy").style.right = '0px'; } } var www = document.getElementById("divTitleHeader").offsetWidth; if (www > (ww - 250)) { document.getElementById("fontTitle").style.padding = "40px 0 40px 0"; document.getElementById("fontTitle").style.width = (www) + "px"; } } function checkTocWidth() { var ww = document.getElementById("divMain").offsetWidth; ww = 1.2 * ww; document.getElementById("divTitleHeader").style.width = ww + 'px'; document.getElementById("fontTitle").style.width = (ww - 250) + 'px'; document.getElementById("divPage").style.width = ww + 'px'; document.getElementById("divMain").style.width = ww + 'px'; document.getElementById("fontTitle").style.width = (ww - 250) + 'px'; document.getElementById("divTOCHeader").style.width = (ww - 120) + 'px'; document.getElementById("divTree").style.width = (ww - 140) + 'px'; document.getElementById("topRight").style.right = '0px'; document.getElementById("topRightBG").style.right = '4px'; document.getElementById("topLine").style.right = '121px'; document.getElementById("topLeftBG").style.right = '121px'; document.getElementById("topLeft").style.right = '238px'; document.getElementById("nextKnob").style.left = (ww + 5) + 'px'; if(document.getElementById("divCopy")){ document.getElementById("divCopy").style.right = '0px'; } } function checkPageWidthInit() { var ww = document.getElementById("divMain").offsetWidth; //document.getElementById("divTitleHeader").style.width = ww+'px'; document.getElementById("fontTitle").style.width = (ww - 250) + 'px'; document.getElementById("topRight").style.right = '0px'; document.getElementById("topRightBG").style.right = '4px'; document.getElementById("topLine").style.right = '121px'; document.getElementById("topLeftBG").style.right = '121px'; document.getElementById("topLeft").style.right = '238px'; document.getElementById("nextKnob").style.left = (ww + 5) + 'px'; if(document.getElementById("divCopy")){ document.getElementById("divCopy").style.right = '0px'; } } function checkPageHeight() { var hh = document.getElementById("divBookPage").offsetHeight; document.getElementById("divPage").style.height = (1 * hh) + 'px'; document.getElementById("divMain").style.height = (1 * hh + 100) + 'px'; document.getElementById("divBG").style.height = (1 * hh - 150) + 'px'; document.getElementById("nextKnob").style.top = ((hh - 70) / 2) + 'px'; document.getElementById("prewKnob").style.top = ((hh - 70) / 2) + 'px'; } function checkPageWidth() { var ww = document.getElementById("divBookPage").offsetWidth; document.getElementById("divTitleHeader").style.width = ww + 'px'; document.getElementById("fontTitle").style.width = (ww - 250) + 'px'; document.getElementById("divPage").style.width = ww + 'px'; document.getElementById("divMain").style.width = ww + 'px'; document.getElementById("topRight").style.right = '0px'; document.getElementById("topRightBG").style.right = '4px'; document.getElementById("topLine").style.right = '121px'; document.getElementById("topLeftBG").style.right = '121px'; document.getElementById("topLeft").style.right = '238px'; document.getElementById("nextKnob").style.left = (ww + 5) + 'px'; if(document.getElementById("divCopy")){ document.getElementById("divCopy").style.right = '0px'; } var www = document.getElementById("divTitleHeader").offsetWidth; if (www > (ww - 250)) { document.getElementById("fontTitle").style.padding = "40px 0 40px 0"; document.getElementById("fontTitle").style.width = (www) + "px"; } } function zoom() { var step = 1.2; // scale text divs var item = document.getElementById('divBookPage'); var elems = item.childNodes; for (var i = 0; i < elems.length; i++) { if (elems[i].tagName == "DIV") { elems[i].style.top = (Math.abs(elems[i].style.top.replace("px", "")) * step) + "px" elems[i].style.left = (Math.abs(elems[i].style.left.replace("px", "")) * step) + "px" elems[i].style.width = (Math.abs(elems[i].style.width.replace("px", "")) * step) + "px" elems[i].style.height = (Math.abs(elems[i].style.height.replace("px", "")) * step) + "px" } } // scale font size elems = item.getElementsByTagName('span') for (var i = 0; i < elems.length; i++) { var computedStyle = elems[i].currentStyle || window.getComputedStyle(elems[i], null); var divCont = (elems[i].parentNode.tagName == "DIV") ? elems[i].parentNode : elems[i].parentNode.parentNode; if (elems[i].style.fontSize) { scale = (Math.abs(elems[i].style.fontSize.replace("px", "")) * step); } else { scale = (Math.abs(computedStyle.fontSize.replace("px", "")) * step); } elems[i].style.fontSize = scale + "px"; while ((elems[i].offsetWidth > divCont.offsetWidth) && (scale > 1)) { scale = scale - 1; elems[i].style.fontSize = scale + "px"; } var diff = ((divCont.offsetHeight - elems[i].offsetHeight) / 2); diff = diff.toFixed(); if (diff > 0) { elems[i].style.padding = diff + "px 0px"; } elems[i].style.top = ((divCont.offsetHeight - elems[i].offsetHeight) / 2) + "px"; } // scale image size elems = item.getElementsByTagName('img') for (var i = 0; i < elems.length; i++) { var computedStyle = elems[i].currentStyle || window.getComputedStyle(elems[i], null); elems[i].style.width = (1 * elems[i].style.width.replace("px", "") * step) + "px" elems[i].style.height = (1 * elems[i].style.height.replace("px", "") * step) + "px" } // scale page size computedStyle = item.currentStyle || window.getComputedStyle(item, null); if (item.style.width) { item.style.width = (1 * item.style.width.replace("px", "") * step) + "px" } else { item.style.width = (1 * computedStyle.width.replace("px", "") * step) + "px" } if (item.style.height) { item.style.height = (1 * item.style.height.replace("px", "") * step) + "px" } else { item.style.height = (1 * computedStyle.height.replace("px", "") * step) + "px" } checkPageWidth(); checkPageHeight(); } function checkPublCom() { if (document.domain.indexOf('publ.com') != -1) { var parts = document.URL.split('/'); var prevpart = ''; for (var i = 0; i < parts.length; i++) { if (prevpart.toLowerCase() == 'bookdata') return replaceBackLink(parts[i]); if (parts[i].toLowerCase() == 'seo') return replaceBackLink(prevpart); prevpart = parts[i]; } } } function replaceBackLink(id) { var link = document.getElementById('full-version-link'); if (link) { var hash = link.href.indexOf('#'); if (hash != -1) link.href = 'http://' + document.domain + '/' + id + link.href.substr(hash); else link.href = 'http://' + document.domain + '/' + id; } }