//********************************************************//
//The following section is for the image transition effect//
//********************************************************//
var currentPhoto = 0;
var secondPhoto = 1;

var currentPhoto2 = 0;
var secondPhoto2 = 1;

var currentPhoto3 = 0;
var secondPhoto3 = 1;

var currentPhoto4 = 0;
var secondPhoto4 = 1;

var currentPhoto5 = 0;
var secondPhoto5 = 1;

var currentOpacity = new Array();
 var imageArray = new Array("skin1/images/fade/0.gif","skin1/images/fade/1.gif","skin1/images/fade/1.gif","skin1/images/fade/1.gif","skin1/images/fade/1.gif","skin1/images/fade/1.gif");
 var currentOpacity2 = new Array();
 var imageArray2 = new Array("skin1/images/fade/0.gif","skin1/images/fade/0.gif","skin1/images/fade/2.gif","skin1/images/fade/2.gif","skin1/images/fade/2.gif","skin1/images/fade/2.gif");
 var currentOpacity3 = new Array();
 var imageArray3 = new Array("skin1/images/fade/0.gif","skin1/images/fade/0.gif","skin1/images/fade/0.gif","skin1/images/fade/3.gif","skin1/images/fade/3.gif","skin1/images/fade/3.gif");
 var currentOpacity4 = new Array();
 var imageArray4 = new Array("skin1/images/fade/0.gif","skin1/images/fade/0.gif","skin1/images/fade/0.gif","skin1/images/fade/0.gif","skin1/images/fade/4.gif","skin1/images/fade/4.gif");
 var currentOpacity5 = new Array();
 var imageArray5 = new Array("skin1/images/fade/0.gif","skin1/images/fade/0.gif","skin1/images/fade/0.gif","skin1/images/fade/0.gif","skin1/images/fade/0.gif","skin1/images/fade/5.gif");

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

function init() {
	currentOpacity[0]=99;


//ARRAY 1//
	for(i=1;i<imageArray.length;i++)currentOpacity[i]=0;
	mHTML="";
	for(i=0;i<imageArray.length;i++)mHTML+="<div id=\"photo\" name=\"photo\" class=\"mPhoto\"><img src=\"" + imageArray[i]  +"\"></div>";
	document.getElementById("mContainer").innerHTML = mHTML;

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

//ARRAY 2//
	for(b=1;b<imageArray2.length;b++)currentOpacity2[b]=0;
	mHTML="";
	for(b=0;b<imageArray2.length;b++)mHTML+="<div id=\"photo2\" name=\"photo2\" class=\"mPhoto2\"><img src=\"" + imageArray2[b]  +"\"></div>";
	document.getElementById("mContainer2").innerHTML = mHTML;

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

//ARRAY 3//

	for(c=1;c<imageArray3.length;c++)currentOpacity3[c]=0;
	mHTML="";
	for(c=0;c<imageArray3.length;c++)mHTML+="<div id=\"photo3\" name=\"photo3\" class=\"mPhoto3\"><img src=\"" + imageArray3[c]  +"\"></div>";
	document.getElementById("mContainer3").innerHTML = mHTML;

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

//ARRAY 4//
	for(d=1;d<imageArray4.length;d++)currentOpacity4[d]=0;
	mHTML="";
	for(d=0;d<imageArray4.length;d++)mHTML+="<div id=\"photo4\" name=\"photo4\" class=\"mPhoto4\"><img src=\"" + imageArray4[d]  +"\"></div>";
	document.getElementById("mContainer4").innerHTML = mHTML;

	if(document.all) {
		document.getElementsByName("photo4")[currentPhoto4].style.filter="alpha(opacity=100)";
	} else {
		document.getElementsByName("photo4")[currentPhoto4].style.MozOpacity = .99;
	}
/////////

//ARRAY 5//
	for(e=1;e<imageArray5.length;e++)currentOpacity5[e]=0;
	mHTML="";
	for(e=0;e<imageArray5.length;e++)mHTML+="<div id=\"photo5\" name=\"photo5\" class=\"mPhoto5\"><img src=\"" + imageArray5[e]  +"\"></div>";
	document.getElementById("mContainer5").innerHTML = mHTML;

	if(document.all) {
		document.getElementsByName("photo5")[currentPhoto5].style.filter="alpha(opacity=100)";
	} else {
		document.getElementsByName("photo5")[currentPhoto5].style.MozOpacity = .99;
	}
///////

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

function crossFade() {

	///ARRAY 1//
	if(pause)return;

	currentOpacity[currentPhoto]-=FADE_STEP;
	currentOpacity[secondPhoto] += FADE_STEP;

	if(document.all) {
		document.getElementsByName("photo")[currentPhoto].style.filter = "alpha(opacity=" + currentOpacity[currentPhoto] + ")";
		document.getElementsByName("photo")[secondPhoto].style.filter = "alpha(opacity=" + currentOpacity[secondPhoto] + ")";
	} else {
		document.getElementsByName("photo")[currentPhoto].style.MozOpacity = currentOpacity[currentPhoto]/100;
		document.getElementsByName("photo")[secondPhoto].style.MozOpacity =currentOpacity[secondPhoto]/100;
	}

	if(currentOpacity[secondPhoto]/100>=.98) {
		currentPhoto = secondPhoto;
		secondPhoto++;
		if(secondPhoto == imageArray.length)
		pause = true;
	}


	///ARRAY 2//
	if(pause)return;

	currentOpacity2[currentPhoto2]-=FADE_STEP;
	currentOpacity2[secondPhoto2] += FADE_STEP;

	if(document.all) {
		document.getElementsByName("photo2")[currentPhoto2].style.filter = "alpha(opacity=" + currentOpacity2[currentPhoto2] + ")";
		document.getElementsByName("photo2")[secondPhoto2].style.filter = "alpha(opacity=" + currentOpacity2[secondPhoto2] + ")";
	} else {
		document.getElementsByName("photo2")[currentPhoto2].style.MozOpacity = currentOpacity2[currentPhoto2]/100;
		document.getElementsByName("photo2")[secondPhoto2].style.MozOpacity =currentOpacity2[secondPhoto2]/100;
	}

	if(currentOpacity2[secondPhoto2]/100>=.98) {
		currentPhoto2 = secondPhoto2;
		secondPhoto2++;
		if(secondPhoto2 == imageArray2.length)
		pause = true;
	}



	///ARRAY 3//
	if(pause)return;

	currentOpacity3[currentPhoto3]-=FADE_STEP;
	currentOpacity3[secondPhoto3] += FADE_STEP;

	if(document.all) {
		document.getElementsByName("photo3")[currentPhoto3].style.filter = "alpha(opacity=" + currentOpacity3[currentPhoto3] + ")";
		document.getElementsByName("photo3")[secondPhoto3].style.filter = "alpha(opacity=" + currentOpacity3[secondPhoto3] + ")";
	} else {
		document.getElementsByName("photo3")[currentPhoto3].style.MozOpacity = currentOpacity3[currentPhoto3]/100;
		document.getElementsByName("photo3")[secondPhoto3].style.MozOpacity =currentOpacity3[secondPhoto3]/100;
	}

	if(currentOpacity3[secondPhoto3]/100>=.98) {
		currentPhoto3 = secondPhoto3;
		secondPhoto3++;
		if(secondPhoto3 == imageArray3.length)
		pause = true;
	}


	///ARRAY 4//
	if(pause)return;

	currentOpacity4[currentPhoto4]-=FADE_STEP;
	currentOpacity4[secondPhoto4] += FADE_STEP;

	if(document.all) {
		document.getElementsByName("photo4")[currentPhoto4].style.filter = "alpha(opacity=" + currentOpacity4[currentPhoto4] + ")";
		document.getElementsByName("photo4")[secondPhoto4].style.filter = "alpha(opacity=" + currentOpacity4[secondPhoto4] + ")";
	} else {
		document.getElementsByName("photo4")[currentPhoto4].style.MozOpacity = currentOpacity4[currentPhoto4]/100;
		document.getElementsByName("photo4")[secondPhoto4].style.MozOpacity =currentOpacity4[secondPhoto4]/100;
	}

	if(currentOpacity4[secondPhoto4]/100>=.98) {
		currentPhoto4 = secondPhoto4;
		secondPhoto4++;
		if(secondPhoto4 == imageArray4.length)
		pause = true;
	}


	///ARRAY 5//
	if(pause)return;

	currentOpacity5[currentPhoto5]-=FADE_STEP;
	currentOpacity5[secondPhoto5] += FADE_STEP;

	if(document.all) {
		document.getElementsByName("photo5")[currentPhoto5].style.filter = "alpha(opacity=" + currentOpacity5[currentPhoto5] + ")";
		document.getElementsByName("photo5")[secondPhoto5].style.filter = "alpha(opacity=" + currentOpacity5[secondPhoto5] + ")";
	} else {
		document.getElementsByName("photo5")[currentPhoto5].style.MozOpacity = currentOpacity5[currentPhoto5]/100;
		document.getElementsByName("photo5")[secondPhoto5].style.MozOpacity =currentOpacity5[secondPhoto5]/100;
	}
	if(currentOpacity[secondPhoto5]/100>=.98) {
		currentPhoto5 = secondPhoto5;
		secondPhoto5++;
		if(secondPhoto5 == imageArray5.length)
		pause = true;
		
	}
}

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