// JavaScript Document

var currentPhoto = 0;
var secondPhoto = 1;

var currentOpacity1 = new Array();
var currentOpacity2 = new Array();
var currentOpacity3 = new Array();

var imageArray1 = new Array('/LSI/images/slideshow/rImg_001.jpg','/LSI/images/slideshow/rImg_002.jpg','/LSI/images/slideshow/rImg_003.jpg','/LSI/images/slideshow/rImg_004.jpg','/LSI/images/slideshow/rImg_005.jpg','/LSI/images/slideshow/rImg_006.jpg','/LSI/images/slideshow/rImg_007.jpg','/LSI/images/slideshow/rImg_008.jpg','/LSI/images/slideshow/rImg_009.jpg','/LSI/images/slideshow/rImg_010.jpg');

var imageArray2 = new Array('/LSI/images/slideshow/rImg_101.jpg','/LSI/images/slideshow/rImg_102.jpg','/LSI/images/slideshow/rImg_103.jpg','/LSI/images/slideshow/rImg_104.jpg','/LSI/images/slideshow/rImg_105.jpg','/LSI/images/slideshow/rImg_106.jpg','/LSI/images/slideshow/rImg_107.jpg','/LSI/images/slideshow/rImg_108.jpg','/LSI/images/slideshow/rImg_109.jpg','/LSI/images/slideshow/rImg_110.jpg');

var imageArray3 = new Array('/LSI/images/slideshow/rImg_201.jpg','/LSI/images/slideshow/rImg_202.jpg','/LSI/images/slideshow/rImg_203.jpg','/LSI/images/slideshow/rImg_204.jpg','/LSI/images/slideshow/rImg_205.jpg','/LSI/images/slideshow/rImg_206.jpg','/LSI/images/slideshow/rImg_207.jpg','/LSI/images/slideshow/rImg_208.jpg','/LSI/images/slideshow/rImg_209.jpg', '/LSI/images/slideshow/rImg_205.jpg');

var FADE_STEP = 2;
var FADE_INTERVAL = 10;
var pause = false;

function init() {
	currentOpacity1[0]=99;
	currentOpacity2[0]=99;
	currentOpacity3[0]=99;
	for(i=1;i<imageArray1.length;i++)currentOpacity1[i]=0;
	for(i=1;i<imageArray2.length;i++)currentOpacity2[i]=0;
	for(i=1;i<imageArray3.length;i++)currentOpacity3[i]=0;
	mHTML1="";
	mHTML2="";
	mHTML3="";
	for(i=0;i<imageArray1.length;i++)mHTML1+="<div id=\"photo1\" name=\"photo1\" class=\"mPhoto1\"><img src=\"" + imageArray1[i]  +"\"></div>";
	for(i=0;i<imageArray2.length;i++)mHTML2+="<div id=\"photo2\" name=\"photo2\" class=\"mPhoto2\"><img src=\"" + imageArray2[i]  +"\"></div>";
	for(i=0;i<imageArray3.length;i++)mHTML3+="<div id=\"photo3\" name=\"photo3\" class=\"mPhoto3\"><img src=\"" + imageArray3[i]  +"\"></div>";

	document.getElementById("mContainer1").innerHTML = mHTML1;
	document.getElementById("mContainer2").innerHTML = mHTML2;
	document.getElementById("mContainer3").innerHTML = mHTML3;

	if(document.all) {
		document.getElementsByName("photo1")[currentPhoto].style.filter="alpha(opacity=100)";
		document.getElementsByName("photo2")[currentPhoto].style.filter="alpha(opacity=100)";
		document.getElementsByName("photo3")[currentPhoto].style.filter="alpha(opacity=100)";
	} else {
		document.getElementsByName("photo1")[currentPhoto].style.MozOpacity = .99;
		document.getElementsByName("photo2")[currentPhoto].style.MozOpacity = .99;
		document.getElementsByName("photo3")[currentPhoto].style.MozOpacity = .99;
	}

	mInterval = setInterval("crossFade()",FADE_INTERVAL);
}

function crossFade() {
	if(pause)return;

	currentOpacity1[currentPhoto]-=FADE_STEP;
	currentOpacity1[secondPhoto] += FADE_STEP;
	
	currentOpacity2[currentPhoto]-=FADE_STEP;
	currentOpacity2[secondPhoto] += FADE_STEP;
	
	currentOpacity3[currentPhoto]-=FADE_STEP;
	currentOpacity3[secondPhoto] += FADE_STEP;

	if(document.all) {
		document.getElementsByName("photo1")[currentPhoto].style.filter = "alpha(opacity=" + currentOpacity1[currentPhoto] + ")";
		document.getElementsByName("photo2")[currentPhoto].style.filter = "alpha(opacity=" + currentOpacity2[currentPhoto] + ")";
		document.getElementsByName("photo3")[currentPhoto].style.filter = "alpha(opacity=" + currentOpacity3[currentPhoto] + ")";
		
		document.getElementsByName("photo1")[secondPhoto].style.filter = "alpha(opacity=" + currentOpacity1[secondPhoto] + ")";
		document.getElementsByName("photo2")[secondPhoto].style.filter = "alpha(opacity=" + currentOpacity2[secondPhoto] + ")";
		document.getElementsByName("photo3")[secondPhoto].style.filter = "alpha(opacity=" + currentOpacity3[secondPhoto] + ")";
	} else {
		document.getElementsByName("photo1")[currentPhoto].style.MozOpacity = currentOpacity1[currentPhoto]/100;
		document.getElementsByName("photo2")[currentPhoto].style.MozOpacity = currentOpacity2[currentPhoto]/100;
		document.getElementsByName("photo3")[currentPhoto].style.MozOpacity = currentOpacity3[currentPhoto]/100;
		
		document.getElementsByName("photo1")[secondPhoto].style.MozOpacity =currentOpacity1[secondPhoto]/100;
		document.getElementsByName("photo2")[secondPhoto].style.MozOpacity =currentOpacity2[secondPhoto]/100;
		document.getElementsByName("photo3")[secondPhoto].style.MozOpacity =currentOpacity3[secondPhoto]/100;
	}

	if(currentOpacity1[secondPhoto]/100>=.98) {
		currentPhoto = secondPhoto;
		secondPhoto++;
		if(secondPhoto == imageArray1.length)secondPhoto=0;
		pause = true;
		xInterval = setTimeout("pause=false",2000);
	}
}

function doPause()  {
	if(pause) {
		pause = false;
		document.getElementById("pauseBtn").value = "pause";
	} else {
		pause = true;
		document.getElementById("pauseBtn").value = "play";
	}
}
