var thumbnailCells = document.getElementsByTagName("td");
var currentCell = 0;
function nextImage()
{
     currentCell++;
     if(currentCell >= thumbnailCells.length) {
	currentCell = 0;
     }
     thumbnailCells[currentCell].onclick();
}
function previousImage()
{
     currentCell--;
     if(currentCell < 0) {
	currentCell = thumbnailCells.length - 1;
     }
     thumbnailCells[currentCell].onclick();

}
function setCurrentCell(clickedObject)
{
	if(thumbnailCells[currentCell] == clickedObject) { return; }

	for(i = 0; i < thumbnailCells.length; i++) {
		if(thumbnailCells[i] == clickedObject) {

			currentCell = i;
			break;
		}
	}
}

function updateFullImage(imageURL, imageTitle, imageMedium, imageDate, imageDimensions, imagePrice)
{
	if(!imagePrice) { imagePrice = ''; }

	document.getElementById("MainImage").src = imageURL;
	if(document.getElementById("imageTitle").firstChild) {
		document.getElementById("imageTitle").removeChild( document.getElementById("imageTitle").firstChild);
	}

	if(document.getElementById("imageMedium").firstChild) {
		document.getElementById("imageMedium").removeChild( document.getElementById("imageMedium").firstChild);
	}

	if(document.getElementById("imageDimensions").firstChild) {
		document.getElementById("imageDimensions").removeChild( document.getElementById("imageDimensions").firstChild);
	}
	if(document.getElementById("imagePrice").firstChild) {
		document.getElementById("imagePrice").removeChild( document.getElementById("imagePrice").firstChild);
	}

	document.getElementById("imageTitle").appendChild(document.createTextNode(imageTitle));
	if(imageDate != '') {
		imageMedium = imageMedium + ", " + imageDate;
	}
	document.getElementById("imageMedium").appendChild(document.createTextNode(imageMedium));
	document.getElementById("imageDimensions").appendChild(document.createTextNode(imageDimensions));
	document.getElementById("imagePrice").appendChild(document.createTextNode(imagePrice));
}

function mailinglistThanks()
{
	document.getElementById("thanksText").innerText = "Thank you for signing up for the mailing list.";
}
