// JavaScript Document

//FUNCTIONALITY
var jjc_ri_galleryTimer;
var jjc_ri_fadeSteps=25;
var jjc_ri_stepSpeed=50;
var jjc_ri_picDuration=4000;
var jjc_ri_blankDuration=10;

var jjc_ri_fadeIncrement=1/jjc_ri_fadeSteps;
var jjc_ri_fadeLevel=1;
var jjc_ri_currImage=0;
var jjc_ri_imageAmount=jjc_ri_array.length;
var jjc_ri_imageRef;
var jjc_ri_textRef;

/* V2 Additions */

var jjc_ri_testimonialImage="jjc-recent-clients-image";

/* End V2 Additions */

//Fade step function
function jjc_ri_fadeStep(step,functionAfter){
	//Step the opacity
	jjc_ri_fadeLevel-=jjc_ri_fadeIncrement;
	jjc_ri_imageRef.style.opacity=jjc_ri_fadeLevel;
	jjc_ri_imageRef.style.filter="alpha(opacity="+(jjc_ri_fadeLevel*100)+")";
	//Determine if we need another step
	if(step<=jjc_ri_fadeSteps){
		//If so, call myself again
		jjc_ri_galleryTimer=setTimeout("jjc_ri_fadeStep("+(step+1)+",\""+functionAfter+"\")",jjc_ri_stepSpeed);
	}
	else{
		//If not, call following function
		jjc_ri_galleryTimer=setTimeout(functionAfter,jjc_ri_stepSpeed);
		step=0;
		if(jjc_ri_fadeIncrement<0)jjc_ri_fadeIncrement=(-jjc_ri_fadeIncrement);
	}
}
//Start the fade to transparency
function jjc_ri_slideShow(){
	jjc_ri_imageRef=document.getElementById(jjc_ri_testimonialImage);
	//Start fade to transparency
	jjc_ri_galleryTimer=setTimeout("jjc_ri_fadeStep(1,\"jjc_ri_fadeToView()\")",jjc_ri_picDuration);
}
function jjc_ri_getStarted(){
	jjc_ri_imageRef=document.getElementById(jjc_ri_testimonialImage);
	setTimeout("jjc_ri_delayedStart()",jjc_ri_picDuration);
}
function jjc_ri_delayedStart(){
	//Start fade to transparency
	jjc_ri_fadeStep(1,"jjc_ri_fadeToView()");
}
//Change the image (and link) and start the fade to opacity
function jjc_ri_fadeToView(){
	var imagevars=jjc_ri_array[jjc_ri_currImage].split("|");
	//Change image
	jjc_ri_imageRef.src=imagevars[0];
	//Start fade to opaque
	jjc_ri_fadeIncrement=(-jjc_ri_fadeIncrement);
	jjc_ri_currImage++;
	if(jjc_ri_currImage==jjc_ri_imageAmount){
		jjc_ri_currImage=0;
	}
	jjc_ri_galleryTimer=setTimeout("jjc_ri_fadeStep(1,\"jjc_ri_slideShow()\")",jjc_ri_blankDuration);
}

