function OnPhotoChange(filespec, offset, excludes, x, y)
{
		var bitmap = excludes.split(",");
		
		//alert(bitmap);

		var index = document.all.thumbnail.index;

		if(offset == 1)
		{
			if(typeof index == "undefined")
			{
				 index = 1;
			}
			else
			{
				index++;
			}
	
			while(index >= 0 && index < 15 && bitmap[index] == 0)
			{
				index++;
			}
		 
		 if(index >= 15)
			{
				index = 0;
			}
			//alert("F: " + index);			
		}
		else
		{
			if(typeof index == "undefined")
			{
				index = 14;
			}
			else
			{
				if(index <= 0)
				{
					index = 14
				}
				else
				{
					index--;
				}
			}

			while(index >= 0 && bitmap[index] == 0)
			{
				index--;
			}

			//alert("R: " + index);			
		}
		
		document.all.thumbnail.index = index;	
		
		//document.all.NextPhoto.innerHTML = "&nbsp;" + "Next Photo:&nbsp; " + index + " of " +  count + "&nbsp;&nbsp;";

		var fileName = unescape(filespec);

		if(index > 0)
		{
			fileName += "p" + (index < 10 ? "0" : "") + index;
		}

		fileName += ".jpg";
		
		//alert(fileName);

		var oImg = new Image();
		oImg.src = fileName;
		oImg.onload = ImageLoaded;
		// oImg.onerror = ImageNotFound;
		oImg.x = x;
		oImg.y = y;
//		alert("1: " + fileName + " : " + oImg.width + " : " + oImg.height);

		document.all.thumbnail.src = fileName;
		document.all.thumbnail.width  = Math.min(oImg.width, x);
		document.all.thumbnail.height  = Math.min(oImg.height, y);
		
		
		return false;
}

function ImageLoaded()
{
		//alert(this.x + "-222-" + this.y);
//		document.all.thumbnail.style.visibility = 'hidden';
		document.all.thumbnail.src = this.src;
		document.all.thumbnail.width  = Math.min(this.width, this.x);
		document.all.thumbnail.height  = Math.min(this.height, this.y);
//		document.all.thumbnail.style.visibility = 'visible';
}

function ImageNotFound()
{
}

