<!-- this page is part of the 'beeftodd.co.uk' website -->
<!-- page layout and design by mark winfield (c) y2k -->

/////////////////////////////
// Global variables.
/////////////////////////////
var m_enlargeWindow	= null;			// The 'Enlargement' window handle.
var g_nID		= -1;			// Array position of current selection.
var g_imageCounter	= 0;			// Image counter.
var tickdelay		= 5000;			// For slideshow.

///////////////////
// Browser sniffing - what web browser am I?  What version?
///////////////////
var common				= {};

common.browser				= {};
common.browser.isDOM			= document.getElementById;
common.browser.isIE			= (navigator.userAgent.indexOf("MSIE")  > 0);
common.browser.isNS			= (navigator.userAgent.indexOf("Gecko") > 0);
common.browser.isMac			= (navigator.userAgent.indexOf("Mac")   > 0);
common.browser.colors 			= Math.pow(2, window.screen.colorDepth);
common.browser.width 			= window.screen.width;
common.browser.height 			= window.screen.height;
common.browser.javaEnabled		= navigator.javaEnabled();
common.browser.platform			= navigator.platform;
common.browser.version			= 0.0;

if (common.browser.isIE) 
{
	var nPos			= navigator.appVersion.indexOf("MSIE");

	common.browser.version		= parseFloat(navigator.appVersion.substring(nPos + 5, nPos + 8));
}

if (common.browser.isNS)
{
	common.browser.version		= ((navigator.userAgent.indexOf("Netscape6" ) > 0)	    ||
					  (navigator.userAgent.indexOf("rv:0.") > 0))
						? 6
						: ((navigator.userAgent.indexOf("Netscape/7" ) > 0) ||
						   (navigator.userAgent.indexOf("rv:1.") > 0))
							? 7
							: 0.0;
}

///////////////////
// Scripts to change the background colour of a table row.
///////////////////
function changeto(highlightcolor, event)
{

	// First routine changes the cell background colour to 'highlightcolor' (eg, YELLOW).
	source 					= (common.browser.isIE)
							? event.srcElement
							: event.target;

	if (source.tagName == "TABLE")
		return;

	while (source.tagName != "TR")
		source = (common.browser.isIE)
				? source.parentElement
				: source.parentNode;

	if (source.style.backgroundColor != highlightcolor && source.id != "ignore")
		source.style.backgroundColor 	= highlightcolor;
}

///////////////////
function onClickThumbnail(nPhotoID)
{

	// User has clicked on a thumbnail - show an enlargement and relevant details.
	g_nID		= nPhotoID;
	m_enlargeWindow	= window.open("Enlarge.htm", "EnlargementWindow", "titlebar=no,scrollbars=yes,height=500,width=600");
	m_enlargeWindow.focus();
}

///////////////////
function CloseAllChildWindows()
{

	// Make sure all child windows are closed if the user closes me.
	if (m_enlargeWindow != null && !m_enlargeWindow.closed)
		m_enlargeWindow.close();
}

///////////////////
function Visibility(strObj, bShow)
{

	var objID		= document.getElementById(strObj);

	objID.style.display	= (bShow) ? "inline" : "none";
}

///////////////////
function CacheImages(strPrefix)
{
	var strImages						= '';
	var nCounter						= 0;

	for (var nItem = 0; nItem < aryPhotoName.length; nItem++)
	{
		strImages					+= '<img src="Photos/' + strPrefix + aryPhotoName[nItem] + '.jpg" width="1" height="1" onload="CountImage()"></img>';
	}

	document.getElementById('hiddenimages').innerHTML	= strImages;
}

///////////////////
function CountImage()
{
	document.getElementById('imagecounter').innerHTML	= "<h1>Loading image " + (++g_imageCounter) + " of " + aryPhotoName.length + "...</h1>";

	if (g_imageCounter == aryPhotoName.length)
	{
		Visibility('content', true);
		Visibility('loading', false);
	}
}
