var images = {
	current: 0,
	list: [],
	/* increase our position in the list of images, looping around if necessary */
	nextImage: function() {
		if (images.current + 1 < images.list.length)
		{
			images.current++;
		}
		else
		{
			images.current = 0;
		}
		return images.current;
	},
	/* decrease our position in the list of images, looping around if necessary */
	prevImage: function() {
		console.log(images.current);
		if (images.current - 1 >= 0)
		{
			images.current--;
		}
		else
		{
			images.current = images.list.length - 1;
		}
		return images.current;
	},
	next: function() {
		this.change(this.nextImage);
	},
	prev: function() {
		this.change(this.prevImage);
	},
	setList: function(l) {
		this.list = l;
	},
	/* takes a function to get the next image to show */
	change: function(f) {
		var oldImg = this.list[this.current];
		var newImg = this.list[f()];
		crossfade.change(oldImg.image_id, newImg.image_id);
	}
};

/* for events */
function imagesNext() {
	images.next();
}
function imagesPrev() {
	images.prev();
}