var A = [
  { "src": "bilge_pump_1990-02-22.png", "name": "Bilge Pump 1990-02-22" },
  { "src": "bilge_pump_1990-02-26.png", "name": "Bilge Pump 1990-02-26" },
  { "src": "bilge_pump_1990-03-06.png", "name": "Bilge Pump 1990-03-06" },
  { "src": "bilge_pump_1990-03-26.png", "name": "Bilge Pump 1990-03-26" },
  { "src": "bilge_pump_april1_1990-03-30.png", "name": "Bilge Pump April Fool's 1990-03-30" },
  { "src": "bilge_pump_1990-04-02.png", "name": "Bilge Pump 1990-04-02" },
  { "src": "bilge_pump_1990-04-09.png", "name": "Bilge Pump 1990-04-09" },
  { "src": "bilge_pump_1990-04-23.png", "name": "Bilge Pump 1990-04-23" },
  { "src": "bilge_pump_1990-08-27.png", "name": "Bilge Pump 1990-08-27" },
  { "src": "bilge_pump_1990-09-03.png", "name": "Bilge Pump 1990-09-03" },
  { "src": "bilge_pump_1990-09-10.png", "name": "Bilge Pump 1990-09-10" },
  { "src": "bilge_pump_1990-09-17.png", "name": "Bilge Pump 1990-09-17" },
  { "src": "bilge_pump_1990-09-24.png", "name": "Bilge Pump 1990-09-24" },
  { "src": "bilge_pump_1990-10-01.png", "name": "Bilge Pump 1990-10-01" },
  { "src": "bilge_pump_1990-10-08.png", "name": "Bilge Pump 1990-10-08" },
  { "src": "bilge_pump_1990-10-22.png", "name": "Bilge Pump 1990-10-22" },
  { "src": "bilge_pump_1990-10-29.png", "name": "Bilge Pump 1990-10-29" },
  { "src": "bilge_pump_1990-11-05.png", "name": "Bilge Pump 1990-11-05" },
  { "src": "bilge_pump_1990-11-12.png", "name": "Bilge Pump 1990-11-12" },
  { "src": "bilge_pump_1990-11-19.png", "name": "Bilge Pump 1990-11-19" },
  { "src": "bilge_pump_1990-11-26.png", "name": "Bilge Pump 1990-11-26" },
  { "src": "bilge_pump_1990-12-03.png", "name": "Bilge Pump 1990-12-03" },
  { "src": "bilge_pump_buzz_1991-10.png", "name": "Bilge Pump (in Buzz) 1991-10" },
  { "src": "bilge_pump_buzz_1992-01.png", "name": "Bilge Pump (in Buzz) 1992-01" },
  { "src": "music_piece_buzz_1992-01.png", "name": "Buzz music essay 1992-01" }
];
var index = 0;
var max = A.length;

var preload = [ new Image(), new Image() ];

function next() {
  index = (index + 1) % max;
  show();
}

function prev() {
  index = (index + max - 1) % max;
  show();
}

function show() {
  var img = document.getElementById("image");
  var entry = A[index];
  img.src = "loadinfo.net.gif";
  img.src = entry.src;

  var name = document.getElementById("name");
  name.innerHTML = entry.name;

  // Preload next and prev images.
  preload[0].src = A[(index + 1) % max].src;
  preload[1].src = A[(index + max - 1) % max].src;

  var url = window.location.toString();
  var hash_index = url.indexOf("#");
  if (hash_index == -1) {
    window.location += "#" + index;
  } else {
    window.location = (url.substring(0, hash_index)) + "#" + index;
  }
}

if (document.location.hash) {
  index = (document.location.hash.substring(1)) % max;
  //  alert(index);
}
show();
