//=======================================================================================================
//-------------------------------------------------------------------------------------------------------
//	Custom Javascript functions
//-------------------------------------------------------------------------------------------------------
//=======================================================================================================
currentAnimationItem = 1;

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

	showItem	 = animationItems[ currentAnimationItem ];
	showItem_IMG = showItem[0];
	showItem_URL = showItem[1];

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

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

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

function over_row( id )
{
	
	setObjectStyle( id, 'backgroundColor', "#f6f6f6");
	//setObjectStyle( id, 'border', "1px solid red");

	// for 2 <td>
	var td1			= id + '_td_1';
	var td2			= id + '_td_2'
	var b_color		= '1px solid #a0a0a0';
	
	setObjectStyle( td1, 'borderLeft', b_color);
	setObjectStyle( td1, 'borderBottom', b_color);
	setObjectStyle( td1, 'borderTop', b_color);

	setObjectStyle( td2, 'borderBottom', b_color);
	setObjectStyle( td2, 'borderTop', b_color);
	setObjectStyle( td2, 'borderRight', b_color);
	
}	

function out_row( id )
{
	
	// for 2 <td>
	var td1			= id + '_td_1';
	var td2			= id + '_td_2';
	var b_color		= '1px solid white';

	setObjectStyle(  id, 'backgroundColor', "white" );
	//setObjectStyle( id, 'border', "1px solid white");

	setObjectStyle( td1, 'borderLeft', b_color);
	setObjectStyle( td1, 'borderBottom', b_color);
	setObjectStyle( td1, 'borderTop', b_color);

	setObjectStyle( td2, 'borderBottom', b_color);
	setObjectStyle( td2, 'borderTop', b_color);
	setObjectStyle( td2, 'borderRight', b_color);
}

function setObjectStyle( objectid, stylename, stylevalue )
{
	object = document.getElementById( objectid );

	if ( object )
	{
		object.style[stylename] = stylevalue;
	//}else{alert(objectid);}
	}else{}
}