// JavaScript Document
// 	Requirements:
//		2 image tags named SwapImage1 and SwapImage2 
//		An array of images named imgArray
//		An array of text named txtArray
var curOpacity=0;
var curPhoto=-1;
var curTest=-1;
var cycleInterval=0;
var fadeInterval=0;
var cycleTimeout;
var imgPhoto1;
var imgPhoto2;
var txtBlock;
var nextPhoto=-1;

function FadeIn()
	{
	curOpacity += .03;
	imgPhoto1.style.opacity = (1-curOpacity);
	imgPhoto1.style.MozOpacity = (1-curOpacity);
	imgPhoto1.style.KhtmlOpacity = (1-curOpacity);
	imgPhoto1.style.filter = "alpha(opacity=" + ((1-curOpacity)*100) + ")";
	imgPhoto2.style.opacity = (curOpacity);
	imgPhoto2.style.MozOpacity = (curOpacity);
	imgPhoto2.style.KhtmlOpacity = (curOpacity);
	imgPhoto2.style.filter = "alpha(opacity=" + curOpacity*100 + ")";
	if (curOpacity >= 1)
		{
		clearInterval(fadeInterval);
		fadeInterval=0;	//Not fading
		if (nextPhoto != -1)	{clearTimeout(cycleTimeout);CycleSlideShow(nextPhoto);}
		}
	}
function SelectPhoto(selectedPhoto)
	{
	nextPhoto = selectedPhoto;
	if (fadeInterval == 0) {clearTimeout(cycleTimeout);CycleSlideShow();}
	}
function CycleSlideShow()
	{
	var tmp;
	curOpacity = 0;
	if (curPhoto==-1)
		{
		imgPhoto1.src = "images/blank.gif";
		imgPhoto2.src = imgArray[0];
		curPhoto=0;
		}
		else
		{
		tmp = document.getElementById("img"+curPhoto);
		if (tmp != null) tmp.src="images/TrackingButtonOff.jpg";
		imgPhoto1.src = imgArray[curPhoto];
		if (nextPhoto == -1)	curPhoto = (curPhoto>=imgArray.length-1)?0:curPhoto+1;
		else	curPhoto = nextPhoto;
		imgPhoto2.src = imgArray[curPhoto];
		tmp = document.getElementById("img"+curPhoto);
		if (tmp != null) tmp.src="images/TrackingButtonOn.jpg";
		}
	imgPhoto1.style.opacity = (1-curOpacity);
	imgPhoto1.style.MozOpacity = (1-curOpacity);
	imgPhoto1.style.KhtmlOpacity = (1-curOpacity);
	imgPhoto1.style.filter = "alpha(opacity=" + ((1-curOpacity)*100) + ")";
	imgPhoto2.style.opacity = (curOpacity);
	imgPhoto2.style.MozOpacity = (curOpacity);
	imgPhoto2.style.KhtmlOpacity = (curOpacity);
	imgPhoto2.style.filter = "alpha(opacity=" + curOpacity*100 + ")";
	if (nextPhoto == -1)	txtBlock.innerHTML = txtArray[curPhoto];
	else	
		{
		txtBlock.innerHTML = txtArray[curPhoto];
		clearInterval(cycleInterval);
		cycleTimeout = setTimeout("cycleInterval = setInterval('CycleSlideShow()', 6000);",2000);
		}
	nextPhoto=-1;
	fadeInterval = setInterval("FadeIn()", 30);
	}
function SlideshowInit()
	{
	curOpacity = 0;
	txtBlock = document.getElementById("SwapPhotoTextDiv");
	txtBlock.innerHTML = txtArray[0];
	imgPhoto1 = document.getElementById("SwapImage1");
	imgPhoto1.style.opacity = (curOpacity);
	imgPhoto1.style.MozOpacity = (curOpacity);
	imgPhoto1.style.KhtmlOpacity = (curOpacity);
	imgPhoto1.style.filter = "alpha(opacity=" + curOpacity*100 + ")";
	imgPhoto2 = document.getElementById("SwapImage2");
	imgPhoto2.style.opacity = (curOpacity);
	imgPhoto2.style.MozOpacity = (curOpacity);
	imgPhoto2.style.KhtmlOpacity = (curOpacity);
	imgPhoto2.style.filter = "alpha(opacity=" + curOpacity*100 + ")";
	CycleSlideShow();
	cycleInterval = setInterval("CycleSlideShow()", 6000);
	}
