// ===============
// Product Gallery
// ===============

var activeItem	= null;

function UpdateGallery(src,caption,aid,largeSrc)
{
	var a = document.getElementById(aid);
	CaptionText.innerHTML	= caption;
	
	if(activeItem) activeItem.className = "";
	activeItem = a;
	a.className = "active";
	
	hiResCaption		= a.title;
	hiResURL			= largeSrc;
	
	if(GalleryMainImg.filters != undefined && GalleryMainImg.filters.length>0)
	{
		GalleryMainImg.src = src;
		GalleryMainImg.filters[0].apply();
		GalleryMainImg.filters[0].play();
	} else {
		GalleryMainImg.src		= src;
	}
	
}


function GetHiRes (mediaPath)
{	
	var name = hiResCaption.replace(/[^a-zA-Z 0-9]+/g,"")+"."+(hiResURL.split(".")[1]);
	window.frames["FileDownload"].location.href = mediaPath+hiResURL;
	
	//TC Replace GetDoc by virtual directory
	//window.frames["FileDownload"].location.href = "Utilities/GetDoc.aspx?name="+name+"&file="+hiResURL;
	
	//Use this code now all galleries hi-res images have been updated to zips
	//window.frames["FileDownload"].location.href = hiResURL + "&uniq=" + new Date().getTime().toString();
}


// ======================
// Dynamic layout Gallery
// ======================
function UpdateDynamicLayoutGallery(currPos,galleryLargeSrc, caption)
{
	document.getElementById(galleryMainID).src		= galleryLargeSrc;
	document.getElementById(galleryMainID).alt		= caption;
	document.getElementById(galleryDescriptionID).innerHTML = caption;
	pos = currPos;
}

function UpdateMainImage(dir)
{
	if(dir>0)
	{
		if(pos<maxPos)
		{
			pos++;
			document.getElementById(galleryMainID).src				= arrGalleries[pos][1];
			document.getElementById(galleryMainID).alt				= arrGalleries[pos][2];
			document.getElementById(galleryDescriptionID).innerHTML = arrGalleries[pos][2];				
		}
	}
	else
	{
		if(pos>0)
		{
			pos--;
			document.getElementById(galleryMainID).src				= arrGalleries[pos][1];
			document.getElementById(galleryMainID).alt				= arrGalleries[pos][2];	
			document.getElementById(galleryDescriptionID).innerHTML = arrGalleries[pos][2];				
		}	
	}
}
