function Gallery () {
	window.gallery = this;
	this.showing = false;
	this.gallery = document.getElementById("photogallery");
	this.photo = document.getElementById("photo");
	this.status = document.getElementById("status");
	this.title = document.getElementById("title");
	document.getElementById("close").onclick = function () {
		window.gallery.hide();
		return false;
	}
	document.getElementById("buttonprev").onclick = function () {
		window.gallery.previous();
		return false;
	}
	document.getElementById("buttonnext").onclick = function () {
		window.gallery.next();
		return false;
	}
}
Gallery.prototype.show = function (name, nrPhotos) {
	if (this.showing) return;
	this.showing = true;
	this.name = name;
	this.maximum = nrPhotos;
	this.index = (arguments[2]) ? arguments[2]-1 : 0;
	switch (name) {
		case "inside"  : this.title.innerHTML = "Inside Paraiso Perdido"; break;
		case "outside" : this.title.innerHTML = "Outside Paraiso Perdido"; break;
		case "nearby"  : this.title.innerHTML = "Nearby Paraiso Perdido"; break;
	}
	this.gallery.style.display="block";
	this.next();
}
Gallery.prototype.hide = function () {
	this.photo.src = "/common/static/images/backgrounds/white.gif";
	this.gallery.style.display="none";
	this.showing = false;
}
Gallery.prototype.next = function() {
	if (this.index != this.maximum) {
		this.index++;
		this.status.innerHTML = this.index+"&frasl;"+this.maximum;
		this.photo.src = this.getPath();	
	}
}
Gallery.prototype.previous = function () {
	if (this.index > 1) {
		this.index--;
		this.status.innerHTML = this.index+"&frasl;"+this.maximum;
		this.photo.src = this.getPath();
	}
}
Gallery.prototype.getPath = function () {
	return "./common/images/gallery/"+this.name+"/photo"+this.index+".jpg";
}