var first = 1;
var last = 200;
var current = 0;
function setPageNum() {
var url = window.location;
// Grab the 3-digit number from current url
var page = url.match(/(\d{3})\.html$/)[0];
current = parseInt(page);
}
function Previous() {
// Check if at beginning
if (current <= first) { return ''; }
current -= 1;
var prev = '00' + current;
prev = prev.substr(-3);
return 'BTuT-'+ prev +'.html';
}
function Next() {
// Check if at end
if (current >= last) { return ''; }
current += 1;
var next = '00' + current;
next = prev.substr(-3);
return 'BTuT-'+ next +'.html';
}
function createNav() {
var nav = '';
var prevPage = Previous();
var nextPage = Next();
if (prevPage != '') {
nav += '<a href="'+ prevPage +'">Previous</a> ';
}
if (nextPage != '') {
nav += '<a href="'+ nextPage +'">Next</a>';
}
// Set the nav to the page
document.getElementById('galleryNav').innerHTML = nav;
}
// Run the setPageNum function when the page loads
try { // For browsers that know DOMContentLoaded (FF, Safari, Opera)
document.addEventListener("DOMContentLoaded", setPageNum, false);
}
catch (e) { // IE
window.attachEvent('onload', setPageNum);
}