 //=======================================================================================================
//-------------------------------------------------------------------------------------------------------
//	Custom Javascript functions
//-------------------------------------------------------------------------------------------------------
//=======================================================================================================
var currentAnimationItem = new Array();
currentAnimationItem[1] = 1;
currentAnimationItem[2] = 2;
currentAnimationItem[3] = 3;
currentAnimationItem[4] = 4;

function rotateHomeAnimation( q )
{
	lastItem = animationItems[ currentAnimationItem[q] ];
	
	//	Get the next testimonial
	currentAnimationItem[q]++;
		
	//	Reset if we've hit the end
	if( currentAnimationItem[q] > animationCount )
	{
		currentAnimationItem[q] = 1;
	}

	showItem	 = animationItems[ currentAnimationItem[q] ];
	
	// big image is when q = 1
	if( q == 1)
	{
		showItem_IMG = showItem[0];
	}
	else
	{
		showItem_IMG = showItem[1];
	}

	showItem_URL = showItem[2];

	//	Has the box been rendered yet? Place the new testimonial
	var animation_id = 'animation-image' + q;
	if (document.getElementById( animation_id ))
	{
		setTimeout( "changeOpacity( '"+ animation_id  + "', 10 );", 40 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 9 );",  80 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 8 );",  120 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 7 );",  160 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 6 );",  200 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 5 );",  240 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 4 );",  280 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 3 );",  320 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 2 );",  360 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 1);",   400 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 0);",   440 );
		
		
		setTimeout( "document.getElementById( '"+ animation_id  + "' ).innerHTML = '<a href="+showItem_URL+"><img src="+showItem_IMG+"></a>';", 450 );
	
		setTimeout( "changeOpacity( '"+ animation_id  + "', 1 );",  460 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 2 );",  500 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 3 );",  540 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 4 );",  580 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 5 );",  620 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 6 );",  660 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 7 );",  700 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 8 );",  740 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 9 );",  780 );
		setTimeout( "changeOpacity( '"+ animation_id  + "', 10);",  820 );
		
	}

	//	Set the slide to change
		setTimeout( "rotateHomeAnimation("+q+")", 6700 );

}
function changeOpacity( id, opacity )
{
	document.getElementById( id ).style.opacity = opacity/10;
	document.getElementById( id ).style.filter = 'alpha(opacity=' +  (opacity*10) + ')';	
}
