/************************************* pagination script *************************************/ /* expects a DOM id the dom id should contain children that will represent a 'page' // think of dom id as the id of a 'book' init_pagination will take the immediate children of the dom element (the 'pages') then it will re-format their ids (BE CAREFUL) to reflect the page sequencing it will grab and preserve the 'pages' style.display and use that as the on state it will create next and previous elements that'll use the provided target id it will pick the same element as the 'pages' are for the targetID-controls it will pick the same element as the 'page items' are for the targetID-{prev,count,next} it will put the textNodes in spans < Prev 1 2 Next > */ function init_pagination(targetID) { var count = 1; while (document.getElementById(targetID + "-page-" + pagecount)) { if (pagecount == 1) { document.getElementById(targetID + "-page-" + pagecount).style.display = "block"; } else { document.getElementById(targetID + "-page-" + pagecount).style.display = "none"; } pagecount++; } showPagecount(targetID); document.getElementById(targetID + "-prev").onclick = function(){page_flip(-1, targetID)}; document.getElementById(targetID + "-next").onclick = function(){page_flip(1, targetID)}; }