// JScript File
// Script file for photo gallery viewer
//
// Created on October 5, 2007
// Author: Glenn Bulat
//

// Function used to set a image to a specified image object
function SetGalleryImage(img, sCaption, idx)
{ 
	var obj, objName;
	
	objName = "GalleryImage";
	//DisplayMessage("SetGalleryImage: Object Name = " + img);
	obj = MM_findObj(objName);
	if (null != obj)
	{
		// Set current image
		obj.src = img;
	}
	
	// Set appropriate title
	objName = "GalleryImageTitle";
	obj = MM_findObj(objName);
	if (null != obj)
	{
		//DisplayMessage("Title Object = " + obj.innerHTML);
		obj.innerHTML = sCaption;
	}
	
	// Update the gallery index tracking value
	objName = "GalleryImageIndex";
	obj = MM_findObj(objName);
	if (null != obj)
	{
		//DisplayMessage("Image Index Object = " + obj.innerHTML);
		obj.value = idx;
	}

}

function QuickViewSelectedPhoto(ctrl, rootPath)
{
	var obj;
	var curImage;
	var previewImage;
	
	//DisplayMessage("QuickViewSelectedPhoto: Image Argument = " + ctrl);
	
	// Validate input argument
	if ( (ctrl == null) || (ctrl.length == 0) )
		return;
	
	// Set object name to find to display the preview image	
	obj = MM_findObj(ctrl);
	if (null != obj)
	{
		// Get the current thumbnail source image and convert to reference for preview image
		curImage = obj.title;

		// Find the preview panel image and set the source image
		obj = MM_findObj("QuickViewPreviewImage");
		if (null != obj)
		{
			// Set the image source value
			obj.src = rootPath + "/images/" + curImage;
			
			// Unhide the preview panel
			DisplayPreviewPanel("QuickViewPreviewImagePanel", true)
		}
	}
}

function DisplayPreviewPanel(idPanel, bVisible)
{
	//DisplayMessage("Hide Panel = " + idPanel + " : " + bVisible);

	// Get panel object
	var objPanel = MM_findObj(idPanel);
	if (objPanel != null) {
		// Set the visibility attribute
		if (bVisible == true)
			objPanel.style.visibility = "visible";
		else
			objPanel.style.visibility = "hidden";
		}
		// Set the position on the screen
		//objPanel.style.top = (window.outerHeight - objPanel.width)/2;
	
}
