
var index = -1;

function GoForward() {
	index++;
	if (index >= images.length) {
		index = 0;
	}
	showIt(images[index]);
}

function GoBack() {
  index--;
  if (index < 0) {
      index = images.length - 1;
  }
  showIt(images[index]);
}

function showIt(item) {
	document.title = item.url;
	document.getElementById("image").innerHTML = "<img src='" + item.url + "'><br>" + (index + 1) + " of " + images.length;
	document.getElementById("caption").innerHTML = item.caption;
}

function item(caption, url) {
  this.caption = caption;
  this.url = url;
  return this;
}

