var arrImg = new Array();
var imgIndex = 0;

function setImg(path, link, id)
{
	var img = new Image();
	img.src = path;
	img.lowsrc = link;
	img.name = id;
	return img;
}

function replaceLightBoxLink(linkID, arrIndex)
{
	var link = document.getElementById('link' + linkID);
	link.href = arrImg[arrIndex].lowsrc;
	link.rel = 'lightbox[' + arrImg[arrIndex].name + ']';
}

function replaceImage(imgID)
{
	var img = document.getElementById('img' + imgID);
	var arrIndex = imgIndex % arrImg.length;

	img.src = arrImg[arrIndex].src;
	replaceLightBoxLink(imgID, arrIndex);
	Effect.Appear('img' + imgID, {duration: 1.0});;
	imgIndex++;
}

function replaceHomeGallery (numImg)
{
	for(i=1;i<=numImg;i++)
	{
		fadeTime = (i - 1) * 2000;
		replaceTime = fadeTime + 1100;
		setTimeout("Effect.Fade('img" + i + "', {duration: 1.0})", fadeTime);
		setTimeout("replaceImage('" + i + "')", replaceTime);
	}
}

function loadGalleryAnimation(numImg)
{
	setInterval("replaceHomeGallery(" + numImg + ")", 12000);
}



