if (tkGallo_container==null) var tkGallo_container = "imageContainer";
if (tkGallo_labelContainer==null) var tkGallo_labelContainer = "labelContainer";

function tkGallo() {
	this.images = new Array();
	this.container = document.getElementById(tkGallo_container);
	this.labelContainer = document.getElementById(tkGallo_labelContainer);
	this.currentIndex = 0;
	this.add = function (element) {
	 	if (element.isGalloElement==true) {
	 	 	this.images.push(element); return true;
		} else {return false;}
	}
	this.next = function() {
		this.currentIndex +=1;
		if (this.currentIndex>=this.images.length) this.currentIndex = 0;
		this.refreshImage();
	}
	this.previous = function() {
		this.currentIndex -=1;
		if (this.currentIndex<0) this.currentIndex = (this.images.length-1);
		this.refreshImage();
	}
	this.refreshImage= function() {
		this.container.src = this.images[this.currentIndex].immagine;
		this.labelContainer.innerHTML = this.images[this.currentIndex].didascalia;
		return true;
	}
}

function tkGalloElement(imageUrl,didascalia) {
	this.id = null;
 	this.riferimento = null;
 	this.timestamp = null;
 	this.data = null;
 	this.immagine = imageUrl;
 	this.didascalia = didascalia;
 	this.tags = null;
 	this.isGalloElement = true;
}