var pattern = /((\w|\-)*\.)+html$/;
var result = pattern.exec(window.location.pathname);
var thisID;
var pathbase;
if (result) {
  thisID = result[0];
  pathbase = window.location.pathname.substring(0,window.location.pathname.indexOf(thisID));
  }
else {
  thisID = 'index.html';
  pathbase = window.location.pathname;
}

function findID() {
 for (var i = 0; i < resultset.length; i++) {
  if (resultset[i] == thisID) return i;
  }
 return 0;
 alert("currentID not found: "+thisID);
}

function prevID() {
 var i = findID();
 if (i < 1) {i = resultset.length - 1;} else {i--;}
 return resultset[i];
}

function nextID() {
 var i = findID();
 i++;
 if (i >= resultset.length) {i = 0;}
 return resultset[i];
}

function doNext() {
 location.pathname = pathbase+nextID();
 return true;
}

function doBack() {
 location.pathname = pathbase+prevID();
 return true;
}

function doFirst() {
 location.pathname = pathbase+resultset[0];
 return true;
}

function doLast() {
 location.pathname = pathbase+resultset[resultset.length - 1];
 return true;
}

function doUp() {
 location.pathname = pathbase+parentloc;
 return true;
}
