// JavaScript Document

//PRELOAD IMAGES
var rotator2_img1=new Image();
var rotator2_img2=new Image();
var rotator2_img3=new Image();

rotator2_img1.src="/wp-content/themes/ice2/images/ice_products_backpack.png";
rotator2_img2.src="/wp-content/themes/ice2/images/ice_products_helmet.png";
rotator2_img3.src="/wp-content/themes/ice2/images/ice_products_shoe.png";

//ARRAY OF IMAGES TO USE
var ri2_array=new Array();
ri2_array[0]="ice_products_backpack.png|Backpack";
ri2_array[1]="ice_products_helmet.png|Helmet";
ri2_array[2]="ice_products_shoe.png|Shoe";

//FUNCTIONALITY
var ri2_galleryTimer;
var ri2_fadeSteps=25;
var ri2_stepSpeed=50;
var ri2_picDuration=6000;
var ri2_blankDuration=10;

var ri2_fadeIncrement=1/ri2_fadeSteps;
var ri2_fadeLevel=1;
var ri2_currImage=1;
var ri2_imageAmount=3;
var ri2_imageRef;
var ri2_textRef;
var ri2_root_folder="/wp-content/themes/ice2/images/";

/* V2 Additions */

var ri2_testimonialImage="ice-product-frame-middle-image";
var ri2_testimonialText="ice-product-frame-middle-text";

/* End V2 Additions */

//Fade step function
function ri2_fadeStep(step,functionAfter){
	//Step the opacity
	ri2_fadeLevel-=ri2_fadeIncrement;
	ri2_imageRef.style.opacity=ri2_fadeLevel;
	ri2_imageRef.style.filter="alpha(opacity="+(ri2_fadeLevel*100)+")";
	//Determine if we need another step
	if(step<=ri2_fadeSteps){
		//If so, call myself again
		ri2_galleryTimer=setTimeout("ri2_fadeStep("+(step+1)+",\""+functionAfter+"\")",ri2_stepSpeed);
	}
	else{
		//If not, call following function
		ri2_galleryTimer=setTimeout(functionAfter,ri2_stepSpeed);
		step=0;
		if(ri2_fadeIncrement<0)ri2_fadeIncrement=(-ri2_fadeIncrement);
	}
}
//Start the fade to transparency
function ri2_slideShow(){
	ri2_imageRef=document.getElementById(ri2_testimonialImage);
	//Start fade to transparency
	ri2_galleryTimer=setTimeout("ri2_fadeStep(1,\"ri2_fadeToView()\")",ri2_picDuration);
}
function ri2_getStarted(){
	ri2_imageRef=document.getElementById(ri2_testimonialImage);
	setTimeout("ri2_delayedStart()",ri2_picDuration);
}
function ri2_delayedStart(){
	//Start fade to transparency
	ri2_fadeStep(1,"ri2_fadeToView()");
}
//Change the image (and link) and start the fade to opacity
function ri2_fadeToView(){
	var imagevars=ri2_array[ri2_currImage].split("|");
	//Change image
	ri2_imageRef.src=ri2_root_folder+imagevars[0];
	//Change title and alt
	ri2_imageRef.alt=imagevars[1];
	ri2_imageRef.title=imagevars[1];
	//Change heading
	document.getElementById(ri2_testimonialText).firstChild.data=imagevars[1];
	//Start fade to opaque
	ri2_fadeIncrement=(-ri2_fadeIncrement);
	ri2_currImage++;
	if(ri2_currImage==ri2_imageAmount){
		ri2_currImage=0;
	}
	ri2_galleryTimer=setTimeout("ri2_fadeStep(1,\"ri2_slideShow()\")",ri2_blankDuration);
}

