var UNDEFINED;
var album = new Array;


var pleaseWaitImage = new Image(1, 1);
pleaseWaitImage.src = "/images/spacer.gif";
pleaseWaitImage.border = 0;
pleaseWaitImage.name = "photo";
pleaseWaitImage.id = "photo";


function getObj(objname) {

	if (document.getElementById) {
		return document.getElementById(objname);
	}
	return document.all[objname];
}

function addPicture(relativePath, width, height, description){

	var theImage = new Object();
	theImage.width = width;
	theImage.height = height;
	theImage.src = /*domain name + */ relativePath;
	theImage.description = description;
	theImage.number = album.length;

	album[album.length] = theImage;
}

function getPicture(index){

	if (index >= album.length) return new Image();

	var albumItem = album[index];
	var theImage = new Image(albumItem.width, albumItem.height);
	theImage.src = albumItem.src;
	theImage.border = 0;
	theImage.name = "photo";
	theImage.id = "photo";
	theImage.description = albumItem.description;
	theImage.number = albumItem.number;
	
	return 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, pleaseWaitImage);
	replaceImage(theImage, getPicture(number));
	return;
	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, pleaseWaitImage);
	replaceImage(theImage, getPicture(number));
	return;
	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.width = img2.width;
	img1.height = img2.height;
	img1.src = img2.src;
	img1.number = img2.number;
	img1.description = img2.description;
}

