<!--

// Global constants.
var strTopNormalFile = "images/gallery/top.gif";
var strTopOverFile = "images/gallery/top_ov.gif";
var strTopDisabledFile = "images/gallery/top_dis.gif";
var strBottomNormalFile = "images/gallery/bot.gif";
var strBottomOverFile = "images/gallery/bot_ov.gif";
var strBottomDisabledFile = "images/gallery/bot_dis.gif";

var strSideOverFile = "images/gallery/film_ov.gif";

var strThumbNAFile = "images/gallery/nasmall.gif";
var strBigNAFile = "images/gallery/nabig.gif";

var lScrollInterval = 200;


// Class for gallery images. 
function PhotoImage() {
	// Constructor. Set all properties to default values.
	this.thumbSrc = "";
	this.mainSrc = "";
	this.title = "";
	this.description = "";
}


// Initializes the photo gallery with the array of images passed in.
function initializeGallery(pics) {
	// Preload menu images.
	preloadImages("images/menus/main1_ov.gif", "images/menus/main2_ov.gif",
		"images/menus/main3_ov.gif", "images/menus/main4_ov.gif",
		"images/menus/main5_ov.gif", "images/menus/main6_ov.gif",
		"images/menus/arr1_ov.gif", "images/menus/arr2_ov.gif",
		"images/menus/arr3_ov.gif", "images/menus/arr4_ov.gif",
		"images/menus/arr5_ov.gif", "images/menus/arr6_ov.gif",
		"images/menus/subD1_ov.gif", "images/menus/subD2_ov.gif",
		"images/menus/subD3_ov.gif");
		
	// Preload gallery images.
	preloadImages("images/gallery/top.gif", "images/gallery/top_ov.gif",
		"images/gallery/top_dis.gif", "images/gallery/bot.gif",
		"images/gallery/bot_ov.gif", "images/gallery/bot_dis.gif",
		"images/gallery/film_ov.gif", "images/gallery/nasmall.gif",
		"images/gallery/nabig.gif");
		
	// Preload thumbnail images.
	var i;
	for (i = 0; i < pics.length; i++) {
		preloadImages(pics[i].thumbSrc);
	}
	
	
	// Check if the scrollbar needs to enabled or disabled.
	var imgTopButton, imgBottomButton;
	if (pics.length > 5) {
		// Enable the scrollbar.
		document.g_scrollEnabled = true;
		
		// Top button is disabled because it is at the top.
		var imgTopButton = getObjectReference("imgTop");
		if (imgTopButton != null) {
			imgTopButton.src = strTopDisabledFile;
		}
		// Bottom button is normal.
		var imgBottomButton = getObjectReference("imgBottom");
		if (imgBottomButton != null) {
			imgBottomButton.src = strBottomNormalFile;
		}
	}
	else {
		// Disable the scrollbar.
		document.g_scrollEnabled = false;
		
		// Top button is disabled.
		var imgTopButton = getObjectReference("imgTop");
		if (imgTopButton != null) {
			imgTopButton.src = strTopDisabledFile;
		}
		// Bottom button is disabled.
		var imgBottomButton = getObjectReference("imgBottom");
		if (imgBottomButton != null) {
			imgBottomButton.src = strBottomDisabledFile;
		}
	}
	
	// Set the index of the thumb that appears at the top of the scrollbar.
	document.g_topIndex = 0;

	// Loop through the five images on the scrollbar and update them.
    var strThumbName, imgThumbObject, strIndexName, txtIndexObject, lLoopIndex, lThumbsIndex;
  	for (lLoopIndex = 0; lLoopIndex < 5; lLoopIndex++) {
  		// Assemble the image name and find it.
      	strThumbName = "imgSmall" + lLoopIndex;
      	imgThumbObject = getObjectReference(strThumbName);
  		
  		// Assemble the index name and find it.
  		strIndexName = "txtIndex" + lLoopIndex;
  		txtIndexObject = getObjectReference(strIndexName);
  		
        // Set the index into the thumbs array.
        lThumbsIndex = lLoopIndex + document.g_topIndex;
		
		// Check if there is a thumbnail to put in it.
      	if (imgThumbObject != null) {
      		if (lThumbsIndex < pics.length) {
      			imgThumbObject.src = pics[lThumbsIndex].thumbSrc;
      			imgThumbObject.title = pics[lThumbsIndex].title;
  				// Set the index of the thumbnail.
  				if (txtIndexObject != null) {
  					txtIndexObject.innerHTML = lThumbsIndex + 1;
  				}
      		}
      		else {
      			imgThumbObject.src = strThumbNAFile;
  				imgThumbObject.title = "";
  				// Clear the index of the thumbnail.
  				if (txtIndexObject != null) {
  					txtIndexObject.innerHTML = "";
  				}
      		}
		}
  	}
	
	// Select the first thumb if there is one.
	var imgBigObject, txtTitleObject, txtDescObject; 
	if (pics.length >= 1) {
		// Find the big image and set the source.
		imgBigObject = getObjectReference("imgBig");
		if (imgBigObject != null) {
			imgBigObject.src = pics[0].mainSrc;
			imgBigObject.title = pics[0].title;
		}
		
		// Find the image title and set the text.
		txtTitleObject = getObjectReference("txtTitle");
		if (txtTitleObject != null) {
			txtTitleObject.innerHTML = pics[0].title;
		}
		
		// Find the image description and set the text.
		txtDescObject = getObjectReference("txtDesc");
		if (txtDescObject != null) {
			txtDescObject.innerHTML = pics[0].description;
		}
	}
	else {
		// Find the big image and set the source.
		imgBigObject = getObjectReference("imgBig");
		if (imgBigObject != null) {
			imgBigObject.src = strBigNAFile;
			imgBigObject.title = ""
		}
		
		// Find the image title and set the text.
		txtTitleObject = getObjectReference("txtTitle");
		if (txtTitleObject != null) {
			txtTitleObject.innerHTML = ""
		}
		
		// Find the image description and set the text.
		txtDescObject = getObjectReference("txtDesc");
		if (txtDescObject != null) {
			txtDescObject.innerHTML = ""
		}
	}		
}



// Changes the top button to an over state (only if it is enabled).
function enterTopButton() {
	// Get a reference to the object.
	var imgObject = getObjectReference("imgTop");
	
	if (imgObject != null) {
		// Check if the scrollbar is enabled.
		if ((document.g_scrollEnabled == true) && (document.g_topIndex > 0)) {
			
    		// Change the mouse cursor.
			imgObject.style.cursor = "Pointer";
		
    		// Set the over image.
    		imgObject.src = strTopOverFile;
    	}
		else {
			// Reset the mouse cursor.
			imgObject.style.cursor = "Default";
		
			// Set the disabled image.
			imgObject.src = strTopDisabledFile;
		}
	}
}

// Changes the top button to a normal state (only if it is enabled).
function leaveTopButton() {
	// Get a reference to the object.
	var imgObject = getObjectReference("imgTop");
	
	if (imgObject != null) {
		// Reset the mouse cursor.
		imgObject.style.cursor = "Default";
		
		// Check if the scrollbar is enabled.
		if ((document.g_scrollEnabled == true) && (document.g_topIndex > 0)) {
    		// Set the normal image.
    		imgObject.src = strTopNormalFile;
    	}
		else {
			// Set the disabled image.
			imgObject.src = strTopDisabledFile;
		}
	}
	// Stop scrolling if it is.
	clearInterval(document.g_timeout);
}



// Changes the top button to an over state (only if it is enabled).
function enterBottomButton() {
	// Get a reference to the object.
	var imgObject = getObjectReference("imgBottom");
	
	if (imgObject != null) {
		// Check if the scrollbar is enabled.
		if ((document.g_scrollEnabled == true) && (document.g_topIndex < (document.g_thumbsInfo.length - 5))) {
    		// Change the mouse cursor.
			imgObject.style.cursor = "Pointer";
		
    		// Set the over image.
    		imgObject.src = strBottomOverFile;
    	}
		else {
			// Reset the mouse cursor.
			imgObject.style.cursor = "Default";
		
			// Set the disabled image.
			imgObject.src = strBottomDisabledFile;
		}
	}
}

// Changes the top button to a normal state (only if it is enabled).
function leaveBottomButton() {
	// Get a reference to the object.
	var imgObject = getObjectReference("imgBottom");
	
	if (imgObject != null) {
		// Reset the mouse cursor.
		imgObject.style.cursor = "Default";
		
		// Check if the scrollbar is enabled.
		if ((document.g_scrollEnabled == true) && (document.g_topIndex < (document.g_thumbsInfo.length - 5))) {
    		// Set the normal image.
    		imgObject.src = strBottomNormalFile;
    	}
		else {
			// Set the disabled image.
			imgObject.src = strBottomDisabledFile;
		}
	}
	// Stop scrolling if it is.
	clearInterval(document.g_timeout);
}
	
	
	
// Changes the side over image associated with each index.
function enterThumb(Index) {
	// Create the control names.
	var strThumbImage = "imgSmall" + Index;
	var strSideImage = "imgOver" + Index;
	
	// Get references to the objects.
	var imgThumbImage = getObjectReference(strThumbImage);
	var imgSideImage = getObjectReference(strSideImage);
	
	// Check if this thumb is valid.
	var lThumbIndex = document.g_topIndex + Index;
	if (lThumbIndex < document.g_thumbsInfo.length) {
    	// Change the mouse cursor.
    	if (imgThumbImage != null) {
    		imgThumbImage.style.cursor = "Pointer";
    	}
    	
    	// Save the original source.
    	if (imgSideImage != null) {
    		if (imgSideImage.origSrc == null) {
    			imgSideImage.origSrc = imgSideImage.src;
    		}
    		// Set the new image.
    		imgSideImage.src = strSideOverFile;
    	}
	}
	else {
		// Reset the mouse cursor and don't change the side image.
		if (imgThumbImage != null) {
			imgThumbImage.style.cursor = "Default";
		}
	}
}

// Restores the side over image associated with each index. 
function leaveThumb(Index) {
	// Create the control names.
	var strThumbImage = "imgSmall" + Index;
	var strSideImage = "imgOver" + Index;
	
	// Get references to the objects.
	var imgThumbImage = getObjectReference(strThumbImage);
	var imgSideImage = getObjectReference(strSideImage);
	
	// Reset the mouse cursor.
	if (imgThumbImage != null) {
		imgThumbImage.style.cursor = "Default";
	}

	// Check if this thumb is valid.
	var lThumbIndex = document.g_topIndex + Index;
	if (lThumbIndex < document.g_thumbsInfo.length) {
		// Set back the original source.
		if (imgSideImage != null) {
			if (imgSideImage.origSrc != null) {
				imgSideImage.src = imgSideImage.origSrc;
			}
		}
	}
}



// Scrolls the scrollbar and thumbs up.
function clickTopButton() {
	// Check if scrollbar is enabled.
	if ((document.g_scrollEnabled == true) && (document.g_topIndex > 0)) {
		// Decrement the top index.
		document.g_topIndex--;
		
		// Loop through the five images on the scrollbar and update them.
		var strThumbName, imgThumbObject, strIndexName, txtIndexObject, lLoopIndex, lThumbsIndex;
    	for (lLoopIndex = 0; lLoopIndex < 5; lLoopIndex++) {
    		// Assemble the image name and find it.
        	strThumbName = "imgSmall" + lLoopIndex;
        	imgThumbObject = getObjectReference(strThumbName);
    		
    		// Assemble the index name and find it.
    		strIndexName = "txtIndex" + lLoopIndex;
    		txtIndexObject = getObjectReference(strIndexName);
    		
			// Set the index into the thumbs array.
			lThumbsIndex = lLoopIndex + document.g_topIndex;
			
    		// Check if there is a thumbnail to put in it.
        	if (imgThumbObject != null) {
        		if (lThumbsIndex < document.g_thumbsInfo.length) {
        			imgThumbObject.src = document.g_thumbsInfo[lThumbsIndex].thumbSrc;
        			imgThumbObject.title = document.g_thumbsInfo[lThumbsIndex].title;
    				// Set the index of the thumbnail.
    				if (txtIndexObject != null) {
    					txtIndexObject.innerHTML = lThumbsIndex + 1;
    				}
        		}
        		else {
        			imgThumbObject.src = strThumbNAFile;
    				imgThumbObject.title = "";
    				// Clear the index of the thumbnail.
    				if (txtIndexObject != null) {
    					txtIndexObject.innerHTML = "";
    				}
        		}
			}
    	}
		
    	// Update the top button if necessary.
		// Get a reference to the object.
    	var imgTopObject = getObjectReference("imgTop");
    	if (imgTopObject != null) {
    		// Check if the scrollbar is at the top.
    		if (document.g_topIndex > 0) {
				// Reset the mouse cursor.
    			imgTopObject.style.cursor = "Pointer";
        		
				// Set the over image.
        		imgTopObject.src = strTopOverFile;
        	}
    		else {
				// Reset the mouse cursor.
    			imgTopObject.style.cursor = "Default";
    			
				// Set the disabled image.
    			imgTopObject.src = strTopDisabledFile;
    		}
    	}
		
		// Update the bottom button if necessary.
		// Get a reference to the object.
    	var imgBottomObject = getObjectReference("imgBottom");
    	if (imgBottomObject != null) {
    		// Check if there are more images at the bottom of the scrollbar.
    		if (document.g_topIndex < (document.g_thumbsInfo.length - 5)) {
        		// Set the normal image.
        		imgBottomObject.src = strBottomNormalFile;
        	}
    		else {
    			// Set the disabled image.
    			imgBottomObject.src = strBottomDisabledFile;
    		}
    	}
	}
}



// Scrolls the scrollbar and thumbs down.
function clickBottomButton() {
	// Check if scrollbar is enabled.
	if ((document.g_scrollEnabled == true) && (document.g_topIndex < (document.g_thumbsInfo.length - 5))) {
		// Decrement the top index.
		document.g_topIndex++;
		
		// Loop through the five images on the scrollbar and update them.
		var strThumbName, imgThumbObject, strIndexName, txtIndexObject, lLoopIndex, lThumbsIndex;
    	for (lLoopIndex = 0; lLoopIndex < 5; lLoopIndex++) {
    		// Assemble the image name and find it.
        	strThumbName = "imgSmall" + lLoopIndex;
        	imgThumbObject = getObjectReference(strThumbName);
    		
    		// Assemble the index name and find it.
    		strIndexName = "txtIndex" + lLoopIndex;
    		txtIndexObject = getObjectReference(strIndexName);
    		
			// Set the index into the thumbs array.
			lThumbsIndex = lLoopIndex + document.g_topIndex;
			
    		// Check if there is a thumbnail to put in it.
        	if (imgThumbObject != null) {
        		if (lThumbsIndex < document.g_thumbsInfo.length) {
        			imgThumbObject.src = document.g_thumbsInfo[lThumbsIndex].thumbSrc;
        			imgThumbObject.title = document.g_thumbsInfo[lThumbsIndex].title;
    				// Set the index of the thumbnail.
    				if (txtIndexObject != null) {
    					txtIndexObject.innerHTML = lThumbsIndex + 1;
    				}
        		}
        		else {
        			imgThumbObject.src = strThumbNAFile;
    				imgThumbObject.title = "";
    				// Clear the index of the thumbnail.
    				if (txtIndexObject != null) {
    					txtIndexObject.innerHTML = "";
    				}
        		}
			}
    	}
		
    	// Update the top button if necessary.
		// Get a reference to the object.
    	var imgTopObject = getObjectReference("imgTop");
    	if (imgTopObject != null) {
    		// Check if the scrollbar is at the top.
    		if (document.g_topIndex > 0) {
				// Set the normal image.
        		imgTopObject.src = strTopNormalFile;
        	}
    		else {
				// Set the disabled image.
    			imgTopObject.src = strTopDisabledFile;
    		}
    	}
		
		// Update the bottom button if necessary.
		// Get a reference to the object.
    	var imgBottomObject = getObjectReference("imgBottom");
    	if (imgBottomObject != null) {
    		// Check if there are more images at the bottom of the scrollbar.
    		if (document.g_topIndex < (document.g_thumbsInfo.length - 5)) {
        		// Reset the mouse cursor.
    			imgBottomObject.style.cursor = "Pointer";
				
				// Set the over image.
        		imgBottomObject.src = strBottomOverFile;
        	}
    		else {
				// Reset the mouse cursor.
    			imgBottomObject.style.cursor = "Default";
				
    			// Set the disabled image.
    			imgBottomObject.src = strBottomDisabledFile;
    		}
    	}
	}
}



// Shows the thumb in the big image and the title & description.
function clickThumb(Index) {
	// Set the index into the thumbs array.
	var lThumbsIndex = Index + document.g_topIndex;
	
	// Check if the thumb is valid.
	if (lThumbsIndex < document.g_thumbsInfo.length) {
		var imgBigObject, txtTitleObject, txtDescObject; 
		// Find the big image and set the source.
		imgBigObject = getObjectReference("imgBig");
		if (imgBigObject != null) {
			imgBigObject.src = document.g_thumbsInfo[lThumbsIndex].mainSrc;
			imgBigObject.title = document.g_thumbsInfo[lThumbsIndex].title;
		}
		
		// Find the image title and set the text.
		txtTitleObject = getObjectReference("txtTitle");
		if (txtTitleObject != null) {
			txtTitleObject.innerHTML = document.g_thumbsInfo[lThumbsIndex].title;
		}
		
		// Find the image description and set the text.
		txtDescObject = getObjectReference("txtDesc");
		if (txtDescObject != null) {
			txtDescObject.innerHTML = document.g_thumbsInfo[lThumbsIndex].description;
		}
	}
}

-->
