function thumbnail(image, width, height, padsquare, altText)
{
	// Display a thumbnail of a picture to a set square size, 
	// and link to full size picture.
	//
	// Parameters:
	// image       - file name (without .ext) containing thumbnail / image / description
	// width       - width of thumbnail image
	// height      - height of thumbnail image
	// padsquare   - pad the thumbnail in to a square if true
	// altText     - alt text to display for image

	try
	{
		var biggest
		var multiplier
		var newWidth
		var newHeight
		var thumbSquare  = 100 // Size of square thumbnail
		var padWidth
		var padLeft
		var padRight
		var padHeight
		var padTop
		var padBottom
		var thumbLink
	
		biggest    = Math.max(width, height);
		multiplier = thumbSquare / biggest;

		newWidth   = Math.round(width  * multiplier);
		newHeight  = Math.round(height * multiplier);

		padWidth   = thumbSquare - newWidth;
		padLeft    = Math.floor(padWidth / 2);
		padRight   = padWidth - padLeft;
		
		padHeight  = thumbSquare - newHeight;
		padTop     = Math.floor(padHeight / 2);
		padBottom  = padHeight - padTop;


		thumbLink =               '<a href=\".\/photo.html?src='+image+'&alt='+altText+'\">'
		thumbLink = thumbLink   + '<img class=thumbnail '
		if (padsquare)
		{
			thumbLink = thumbLink + 'style=\"padding:'+padTop+'px '+padRight+'px '+padBottom+'px '+padLeft+'px;\" '
		}
		thumbLink = thumbLink   + 'src=\".\/images\/thumbnails\/t_'+image+'.jpg\" width=\"'+newWidth+'\" height=\"'+newHeight+'\" alt=\"'+altText+'\"\/><\/a>'

		document.write (thumbLink);

		// alert (thumbLink); //* For Debugging

		return true;
	}

	catch(e)
	{
		alert("thumbnail: " + e.name + ". Error message: " + e.message);
		return false;
	}
}

