// JavaScript Document

//FUNCTIONALITY
var ri3_galleryTimer;
var ri3_fadeSteps=15;
var ri3_stepSpeed=20;
var ri3_picDuration=4000;
var ri3_blankDuration=100;

var ri3_fadeIncrement=1/ri3_fadeSteps;
var ri3_fadeLevel=1;
//var ri3_currImage=1;
var ri3_imageAmount=ri3_array.length;
var ri3_imageRef;

/* V2 Additions */

var ri3_testimonialImage="ice-testimonial-text";

/* End V2 Additions */

//Fade step function
function ri3_fadeStep(step,functionAfter){
	//Step the opacity
	ri3_fadeLevel-=ri3_fadeIncrement;
	ri3_imageRef.style.opacity=ri3_fadeLevel;
	ri3_imageRef.style.filter="alpha(opacity="+(ri3_fadeLevel*100)+")";
	ri3_imageRef.style.filter="alpha(opacity="+(ri3_fadeLevel*100)+")";
	//Determine if we need another step
	if(step<=ri3_fadeSteps){
		//If so, call myself again
		ri3_galleryTimer=setTimeout("ri3_fadeStep("+(step+1)+",\""+functionAfter+"\")",ri3_stepSpeed);
	}
	else{
		//If not, call following function
		ri3_galleryTimer=setTimeout(functionAfter,ri3_stepSpeed);
		step=0;
		if(ri3_fadeIncrement<0)ri3_fadeIncrement=(-ri3_fadeIncrement);
	}
}
//Start the fade to transparency
function ri3_slideShow(){
	ri3_imageRef=document.getElementById(ri3_testimonialImage);
	//Start fade to transparency
	ri3_galleryTimer=setTimeout("ri3_fadeStep(1,\"ri3_fadeToView()\")",ri3_picDuration);
}
function ri3_getStarted(){
	ri3_imageRef=document.getElementById(ri3_testimonialImage);
	ri3_fadeToView();
//	setTimeout("ri3_delayedStart()",ri3_picDuration);
}
function ri3_delayedStart(){
	//Start fade to transparency
	ri3_fadeStep(1,"ri3_fadeToView()");
}
//Change the image (and link) and start the fade to opacity
function ri3_fadeToView(){
	ri3_currImage=Math.floor(Math.random()*(ri3_imageAmount));
	var imagevars=ri3_array[ri3_currImage].split("|");
	var node=document.createTextNode(imagevars[0]);
	var parag=document.createElement("P");
	parag.appendChild(node);
	var i=0;
	while(i<ri3_imageRef.childNodes.length){
		ri3_imageRef.removeChild(ri3_imageRef.childNodes[i]);
	}
	ri3_imageRef.appendChild(parag);
	node=document.createTextNode("- "+imagevars[1]);
	parag=document.createElement("P");
	var attrib=document.createAttribute("class");
	attrib.value="testimonial-source";
	parag.setAttributeNode(attrib);
	parag.appendChild(node);
	ri3_imageRef.appendChild(parag);
	//Start fade to opaque
//	ri3_fadeIncrement=(-ri3_fadeIncrement);
//	ri3_currImage++;
//	if(ri3_currImage==ri3_imageAmount){
//		ri3_currImage=0;
//	}
//	ri3_galleryTimer=setTimeout("ri3_fadeStep(1,\"ri3_slideShow()\")",ri3_blankDuration);
}

