var FADE_STEP = 9;
var FADE_INTERVAL = 10;
var crossFadePauseMS = 3000;

var imageArrayH = new Array(
	image_root+"_dv052037c.jpg",
	image_root+"_dv052039a.jpg",
	image_root+"_imsev109-052.jpg",
	image_root+"_pha043000064.jpg",
	image_root+"_pha043000065.jpg",
	image_root+"_pha157000065.jpg",
	image_root+"_rbmb_09.jpg"
);
var altArrayH = new Array(
	"",
	"",
	"",
	"",
	"",
	"",
	""
);

var imageArrayF = new Array(
	image_root+"excellence.gif",
	image_root+"succeed.gif",
	image_root+"serve.gif",
	image_root+"expectations.gif"
);
var altArrayF = new Array(
	"Committed to Excellence",
	"Determined to Succeed",
	"Striving to Serve",
	"Exceeding Expectations"
);

var currentOpacityH = new Array();
var currentOpacityF = new Array();
var pause = false;

function init() {

	for(i=0;i<imageArrayH.length;i++)currentOpacityH[i]=0;
	mHTML="";
	for(i=0;i<imageArrayH.length;i++)mHTML+="<div id=\"photoH\" name=\"photoH\" class=\"mPhotoH\"><img src=\"" + imageArrayH[i]  +"\" alt=\"" + altArrayH[i]  +"\"></div>";
	document.getElementById("mContainerH").innerHTML = mHTML;

	for(i=0;i<imageArrayF.length;i++)currentOpacityF[i]=0;
	mHTML="";
	for(i=0;i<imageArrayF.length;i++)mHTML+="<div id=\"photoF\" name=\"photoF\" class=\"mPhotoF\"><img src=\"" + imageArrayF[i]  +"\" alt=\"" + altArrayF[i]  +"\"></div>";
	document.getElementById("mContainerF").innerHTML = mHTML;
	
	currentOpacityH[currentPhotoH]=99;
	currentOpacityF[currentPhotoF]=99;
	
	if(document.all) {
		document.getElementsByName("photoH")[currentPhotoH].style.filter="alpha(opacity=100)";
		document.getElementsByName("photoF")[currentPhotoF].style.filter="alpha(opacity=100)";
	} else {
		document.getElementsByName("photoH")[currentPhotoH].style.MozOpacity = .99;
		document.getElementsByName("photoF")[currentPhotoF].style.MozOpacity = .99;

	}

	mInterval = setInterval("crossFade()",FADE_INTERVAL);
}

function crossFade() {
	if(pause)return;

	currentOpacityH[currentPhotoH]-=FADE_STEP;
	currentOpacityH[secondPhotoH] += FADE_STEP;
	
	currentOpacityF[currentPhotoF]-=FADE_STEP;
	currentOpacityF[secondPhotoF] += FADE_STEP;

	if(document.all) {
		document.getElementsByName("photoH")[currentPhotoH].style.filter = "alpha(opacity=" + currentOpacityH[currentPhotoH] + ")";
		document.getElementsByName("photoH")[secondPhotoH].style.filter = "alpha(opacity=" + currentOpacityH[secondPhotoH] + ")";
		document.getElementsByName("photoF")[currentPhotoF].style.filter = "alpha(opacity=" + currentOpacityF[currentPhotoF] + ")";
		document.getElementsByName("photoF")[secondPhotoF].style.filter = "alpha(opacity=" + currentOpacityF[secondPhotoF] + ")";
	} else {
		document.getElementsByName("photoH")[currentPhotoH].style.MozOpacity = currentOpacityH[currentPhotoH]/100;
		document.getElementsByName("photoH")[secondPhotoH].style.MozOpacity =currentOpacityH[secondPhotoH]/100;
		document.getElementsByName("photoF")[currentPhotoF].style.MozOpacity = currentOpacityF[currentPhotoF]/100;
		document.getElementsByName("photoF")[secondPhotoF].style.MozOpacity =currentOpacityF[secondPhotoF]/100;
	}

	if(currentOpacityH[secondPhotoH]/100>=.98) {
		currentPhotoH = secondPhotoH;
		secondPhotoH++;
		if(secondPhotoH == imageArrayH.length)secondPhotoH=0;
		pause = true;
		xInterval = setTimeout("pause=false",crossFadePauseMS);
	}

	if(currentOpacityF[secondPhotoF]/100>=.98) {
		currentPhotoF = secondPhotoF;
		secondPhotoF++;
		if(secondPhotoF == imageArrayF.length)secondPhotoF=0;
		pause = true;
		xInterval = setTimeout("pause=false",crossFadePauseMS);
	}

}

function doPause()  {
	if(pause) {
		pause = false;
	} else {
		pause = true;
	}
}
