function ViewAdditionalImage(strFilename)
{
	// Try to access image element to update
	var objImg = document.getElementById('productImage');
	if (!objImg)
	{
		var objImgCont = document.getElementById('featureImage');
		for (var intIndex = 0; intIndex < objImgCont.childNodes.length; intIndex++)
		{
			var objEle = objImgCont.childNodes[intIndex];
			if ((typeof(objEle.tagName) !== "undefined") && (String(objEle.tagName) === "IMG"))
			{
				objImg = objEle;
				break;
			}
		}
	}
	if (!objImg)
		return;
	
	// Try to set new image
	objImg.src = strFilename;
	
	// Try to scroll to ensure image in view
	ElementScrollTo(objImg);
		
	// Return false to end click event
	return false;
}

function ElementScrollTo(objEleSrc)
{
	// Ensure scroll function and image element available
	if ((!window.scroll) || (!objEleSrc))
		return false;

	// Ensure we can retrieve image position
	var intImageStart = AnchorPosition_getWindowOffsetTop(objEleSrc);
	if (isNaN(parseInt(intImageStart)))
		return false;

	// If need to scroll, leave some space above image
	var OFFSET_TOP = 16;

	// Ensure we can retrieve image height, window scroll pos and viewable area's height
	var intImageHeight = parseInt(objEleSrc.height);
	if (isNaN(intImageHeight) || (intImageHeight <= 0))
		intImageHeight = parseInt(objEleSrc.offsetHeight);
	var intScrollPosY = GetScrollPosY();
	var intViewHeight = GetViewHeight();
	if (isNaN(intImageHeight) || (intImageHeight <= 0)
	|| (intScrollPosY == null)
	|| (intViewHeight == null))
	{
		// If not, scroll to image anyway and return success
		var intScrollToY = intImageStart - OFFSET_TOP;
		if (intScrollToY < 0)
			intScrollToY = 0;
		scroll(0, intScrollToY);
		return true;
	}

	// As all info was available, only scroll if image not fully in view
	var intImageEnd = intImageStart + objEleSrc.height;
	if ((intScrollPosY > intImageStart) || (intScrollPosY + intViewHeight < intImageEnd))
	{
		var intScrollToY = intImageStart - OFFSET_TOP;
		if (intScrollToY < 0)
			intScrollToY = 0;
		scroll(0, intScrollToY);
	}
	return true;

	function GetScrollPosY()
	{
		var intScrollY = null;
		if (document.all)
		{
			if (!document.documentElement.scrollTop)
				intScrollY = document.body.scrollTop;
			else
				intScrollY = document.documentElement.scrollTop;
		}
		else
			intScrollY = window.pageYOffset;
		if (isNaN(parseInt(intScrollY)))
			intScrollY = null;
		return intScrollY;
	}

	function GetViewHeight()
	{
		if (document.documentElement && document.documentElement.clientWidth)
		{
			return document.documentElement.clientHeight;
		}
		else if (document.body)
		{
			return document.body.clientHeight;
		}
		return null;
	}
}

function AnchorPosition_getWindowOffsetTop(el){return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;}
function AnchorPosition_getPageOffsetTop(el){var ot=el.offsetTop;while((el=el.offsetParent) != null){ot += el.offsetTop;}return ot;}
