var currentPageNo = 1;
function prev() { prevPage().style.display = 'block'; currentPage().style.display = 'none'; currentPageNo = prevPageNo(); }
function next() { nextPage().style.display = 'block'; currentPage().style.display = 'none'; currentPageNo = nextPageNo(); }
function getPageCount() { var x = 1; while (document.getElementById('page' + x)) x++; return --x; }
function currentPage() { return document.getElementById('page' + currentPageNo); }
function nextPageNo() { var p = currentPageNo; if (p == getPageCount()) p = 1; else p = p + 1; return p; }
function nextPage() { return document.getElementById('page' + nextPageNo()); }
function prevPageNo() { var p = currentPageNo; if (p == 1) { p = getPageCount(); } else { p = p - 1; } return p; }
function prevPage() { return document.getElementById('page' + prevPageNo()); }
function gotoPage(x) { if (x != currentPageNo) document.getElementById('page' + x).style.display = 'block'; currentPage().style.display = 'none'; currentPageNo = prevPageNo(); }