// Javascript to size the thumbnail pictures to the available screen size.
//
// This code assumes that the total size of the thumbnails, including white space, is 176 X 120.
//

var picCount = 0
var saveTitle = ''

function openTable(retString, title) 
{
	saveTitle = title

	retString = '\n<div class="top">\n<h1>' + title + '</h1>\n</div>\n\n' 
	retString += '<table align="center">\n<tbody>\n<tr>\n'

	return retString
}

function getScreenWidth(  )
{
	var screenWidth 	= (document.all) ? document.body.clientWidth : window.innerWidth;	// Internet Explorer : Netscape Navigator
	var screenChrome	= 50
		
	if (isNaN(screenWidth)) screenWidth = screen.width - screenChrome		// In case neither setting works
	
	return screenWidth
}

function fillTable(retString, picture, width, height, link)
{
	var thumbWidth		= 176
	var thumbHeight	= 120
	var thumbBorder	= 6
	var tableDataPad             = 6
	var screenWidth	= getScreenWidth(  )
		
	var thumbCount 		= Math.floor((screenWidth) / (thumbWidth + thumbBorder + tableDataPad))
	var hspace		= Math.floor((thumbWidth - width) / 2)
	var vspace		= Math.floor((thumbHeight - height) / 2)
		
	if (picCount >= thumbCount) 
	{
		retString += '</tr><tr>\n'
		picCount = 0
	}

	retString += '<td align="center"><a href="' + link + '"><img src="Thumbnails/TN_' + picture + '.JPG" '
	retString += 'alt="' + picture + '.jpg" hspace="' + hspace + '" vspace="' + vspace + '" border="3" '
	retString += 'width="' + width + '" height="' + height + '"></a></td>\n'

	picCount	= picCount + 1
	
	return retString
}  

function closeTable(retString, HTTPstring)
{
	retString += '</tr>\n</tbody>\n</table>\n'
	retString += '<p align="center">Click on one of the thumbnail pictures to see the full size picture.</p>\n'
	retString += '<p align="center">Click on the link for more information about <a href="' + HTTPstring
	retString += '">' + saveTitle + '</a></p>'
	
	return retString
}

