// JavaScript Document

//PRELOAD IMAGES
var rotator_img1=new Image();
var rotator_img2=new Image();
var rotator_img3=new Image();
var rotator_img4=new Image();
var rotator_img5=new Image();
var rotator_img6=new Image();

/*rotator_img1.src="wp-content/themes/ice2/images/splash/ICE_Bike_270x900.jpg";
rotator_img3.src="wp-content/themes/ice2/images/splash/ICE_Fire_270x900.jpg";
rotator_img4.src="wp-content/themes/ice2/images/splash/ICE_Flip_270x900.jpg";
rotator_img5.src="wp-content/themes/ice2/images/splash/ICE_Shatter_270x900.jpg";
rotator_img6.src="wp-content/themes/ice2/images/splash/first_splash.jpg";
*/
//ARRAY OF IMAGES TO USE
/*var ri_array=new Array();
ri_array[0]="first_splash.jpg|Collision";
ri_array[1]="ICE_Bike_270x900.jpg|Bike";
ri_array[2]="ICE_Fire_270x900.jpg|Fire";
ri_array[3]="ICE_Flip_270x900.jpg|Flip";
ri_array[4]="ICE_Shatter_270x900.jpg|Shatter";
*/

rotator_img1.src="wp-content/themes/ice2/images/splash/new_images/ICE_Bike_270x900.jpg";
rotator_img3.src="wp-content/themes/ice2/images/splash/new_images/ICE_Fire_270x900.jpg";
rotator_img4.src="wp-content/themes/ice2/images/splash/new_images/ICE_Flip_270x900.jpg";
rotator_img5.src="wp-content/themes/ice2/images/splash/new_images/ICE_Shatter_270x900.jpg";
rotator_img6.src="wp-content/themes/ice2/images/splash/new_images/ICE_Flip_270x900.jpg";

var ri_array=new Array();
ri_array[0]="ICE_Flip_270x900.jpg|Flip";
ri_array[1]="ICE_Bike_270x900.jpg|Bike";
ri_array[2]="ICE_Fire_270x900.jpg|Fire";
ri_array[3]="ICE_Flip_270x900.jpg|Flip";
ri_array[4]="ICE_Shatter_270x900.jpg|Shatter";

//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=5;
var ri_imageRef;
var ri_textRef;
var ri_root_folder="wp-content/themes/ice2/images/splash/new_images/";

/* V2 Additions */

var ri_testimonialImage="ice-splash";

/* 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.src=ri_root_folder+imagevars[0];
	//Change title and alt
	ri_imageRef.alt=imagevars[1];
	ri_imageRef.title=imagevars[1];
	//Change heading
//	document.getElementById(ri_testimonialText).firstChild.data=imagevars[2];
	//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);
}

