// JavaScript Document
/*
img1.src="images/home_features/cwc2.jpg";
img2.src="images/home_features/helpcare.jpg";
img3.src="images/home_features/resultssystems.jpg";
img4.src="images/home_features/ottawameditation.jpg";
--*/
//PRELOAD IMAGES
var img1=new Image();
var img2=new Image();
var img3=new Image();
var img4=new Image();
img1.src="images/home_features/moxymaus.jpg";
img2.src="images/home_features/mobilerv.jpg";
img3.src="images/home_features/dgs.jpg";
img4.src="images/home_features/pao.jpg";
//img4.src="images/home_features/parliament.jpg";
//ARRAY OF IMAGES TO USE
var image_array=new Array();
image_array[0]="pao.jpg|PA Ottawa|Who do you envision when you think of a...";
image_array[1]="moxymaus.jpg|MoxyMaüs|A classy urban online sock store. They specialize...";
image_array[2]="mobilerv.jpg|Ottawa Valley Mobile RV Service|Ottawa Valley Mobile RV Service provides...";
image_array[3]="dgs.jpg|DGS Project Management|DGS Solutions provides a suite of training...";
//image_array[3]="parliament.jpg|Parliament Cleaning Group|The Parliament Cleaning Group services eastern...";

//FUNCTIONALITY
var galleryTimer;
var fadeSteps=10;
var stepSpeed=50;
var picDuration=8000;
var blankDuration=100;

var fadeIncrement=1/fadeSteps;
var fadeLevel=1;
var currImage=0;
var imageAmount=4;
var imageRef;
//Fade step function
function fadeStep(step,functionAfter){
	//Step the opacity
	fadeLevel-=fadeIncrement;
	imageRef.style.opacity=fadeLevel;
	imageRef.style.filter="alpha(opacity="+(fadeLevel*100)+")";
	//Determine if we need another step
	if(step<=fadeSteps){
		//If so, call myself again
		galleryTimer=setTimeout("fadeStep("+(step+1)+",\""+functionAfter+"\")",stepSpeed);
	}
	else{
		//If not, call following function
		galleryTimer=setTimeout(functionAfter,stepSpeed);
		step=0;
		if(fadeIncrement<0)fadeIncrement=(-fadeIncrement);
	}
}
//Start the fade to transparency
function slideShow(){
	imageRef=document.getElementById("featured-client-image");
	//Start fade to transparency
	galleryTimer=setTimeout("fadeStep(1,\"fadeToView()\")",picDuration);
}
function getStarted(){
	imageRef=document.getElementById("featured-client-image");
	//Start fade to transparency
	fadeStep(1,"fadeToView()");
}
//Change the image (and link) and start the fade to opacity
function fadeToView(){
	var imagevars=image_array[currImage].split("|");
	//Change image
	imageRef.src="images/home_features/"+imagevars[0];
	//Change title and alt
	imageRef.alt=imagevars[1];
	imageRef.title=imagevars[1];
	//Change heading
	document.getElementById("featured-client-title").firstChild.data=imagevars[1];
	//Change description
	document.getElementById("featured-client-description").firstChild.data=imagevars[2];
	//Start fade to opaque
	fadeIncrement=(-fadeIncrement);
	currImage++;
	if(currImage==imageAmount){
		currImage=0;
	}
	galleryTimer=setTimeout("fadeStep(1,\"slideShow()\")",blankDuration);
}
