// JavaScript Document
//PRELOAD IMAGES
var rotator_img1=new Image();
var rotator_img2=new Image();
var rotator_img3=new Image();

rotator_img1.src="wp-content/themes/dekker/images/structure/dt_background_scroller_1.jpg";
rotator_img2.src="wp-content/themes/dekker/images/structure/dt_background_scroller_2.jpg";
rotator_img3.src="wp-content/themes/dekker/images/structure/dt_background_scroller_3.jpg";

var ri_array=new Array();
ri_array[0]="dt_background_scroller_1.jpg";
ri_array[1]="dt_background_scroller_2.jpg";
ri_array[2]="dt_background_scroller_3.jpg";

//FUNCTIONALITY
var ri_galleryTimer;
var ri_fadeSteps=25;
var ri_stepSpeed=50;
var ri_picDuration=6000;
var ri_blankDuration=10;

var ri_fadeIncrement=1/ri_fadeSteps;
var ri_fadeLevel=1;
var ri_currImage=1;
var ri_imageAmount=3;
var ri_imageRef;
var ri_textRef;
var ri_root_folder="wp-content/themes/dekker/images/structure/";

/* V2 Additions */

var ri_testimonialImage="dt-container-home-background";

/* End V2 Additions */

//Fade step function
function ri_fadeStep(step,functionAfter){
	//Step the opacity
	ri_fadeLevel-=ri_fadeIncrement;
	ri_imageRef.style.opacity=ri_fadeLevel;
	ri_imageRef.style.filter="alpha(opacity="+(ri_fadeLevel*100)+")";
	//Determine if we need another step
	if(step<=ri_fadeSteps){
		//If so, call myself again
		ri_galleryTimer=setTimeout("ri_fadeStep("+(step+1)+",\""+functionAfter+"\")",ri_stepSpeed);
	}
	else{
		//If not, call following function
		ri_galleryTimer=setTimeout(functionAfter,ri_stepSpeed);
		step=0;
		if(ri_fadeIncrement<0)ri_fadeIncrement=(-ri_fadeIncrement);
	}
}
//Start the fade to transparency
function ri_slideShow(){
	ri_imageRef=document.getElementById(ri_testimonialImage);
	//Start fade to transparency
	ri_galleryTimer=setTimeout("ri_fadeStep(1,\"ri_fadeToView()\")",ri_picDuration);
}
function ri_getStarted(){
	ri_imageRef=document.getElementById(ri_testimonialImage);
	setTimeout("ri_delayedStart()",ri_picDuration);
}
function ri_delayedStart(){
	//Start fade to transparency
	ri_fadeStep(1,"ri_fadeToView()");
}
//Change the image (and link) and start the fade to opacity
function ri_fadeToView(){
	var imagevars=ri_array[ri_currImage].split("|");
	//Change image
	ri_imageRef.style.background="url('"+ri_root_folder+imagevars[0]+"') top center no-repeat";
	//Start fade to opaque
	ri_fadeIncrement=(-ri_fadeIncrement);
	ri_currImage++;
	if(ri_currImage==ri_imageAmount){
		ri_currImage=0;
	}
	ri_galleryTimer=setTimeout("ri_fadeStep(1,\"ri_slideShow()\")",ri_blankDuration);
}

