var UNDEFINED;
var album = new Array;

function getObj(objname) {

	if (document.getElementById) {
		return document.getElementById(objname);
	}
	return document.all[objname];
}

function addPicture(relativePath, width, height, description){

	var theImage = new Image(width, height);
	theImage.src = /*domain name + */ relativePath;
	theImage.border = 0;
	theImage.name = "photo";
	theImage.id = "photo";
	theImage.description = description;
	theImage.number = album.length;

	album[album.length] = theImage;
}

function nextPicture(){
	var theImage = getObj("photo");
	if (theImage == UNDEFINED) return;

	var number = 0;
	if (theImage.number != UNDEFINED) number = parseInt(theImage.number)+1;
	if (number >= album.length) number = 0;
	replaceImage(theImage, album[number]);

	var theDescription = getObj("description");
	if (theDescription == UNDEFINED) return;
	if (theDescription.innerHTML == UNDEFINED) return;
	theDescription.innerHTML = '<font color="#ffffff" face="Helvetica, Arial" size="2">' + theImage.description + '</font>';
}

function previousPicture(){
	var theImage = getObj("photo");
	if (theImage == UNDEFINED) return;

	var number = 0;
	if (theImage.number != UNDEFINED) number = parseInt(theImage.number)-1;
	if (number < 0) number = album.length-1;
	replaceImage(theImage, album[number]);

	var theDescription = getObj("description");
	if (theDescription == UNDEFINED) return;
	if (theDescription.innerHTML == UNDEFINED) return;
	theDescription.innerHTML = '<font color="#ffffff" face="Helvetica, Arial" size="2">' + theImage.description + '</font>';
}

function replaceImage(img1, img2) {
	img1.src = img2.src;
	img1.width = img2.width;
	img1.height = img2.height;
	img1.number = img2.number;
	img1.description = img2.description;
}

