var images_to_swap 	= new Array('2010-IBS-LaLinda-450x236.jpg', 'BAIHPteam_450x236.jpg', 'TW-ZEH_450x236.jpg', 'MHlab_450x236.jpg');
var images_alts		= new Array('A picture of the BAIHP team.', 'A picture of the TW ZEH.','A picture of the La Linda at the 2010 International Builiders Show.', 'A picture of the manufactured housing lab.');
var i 				= 0;
var img_index		= 2;
var wait 			= 6000;

function swapImage( sContainerID, sImagePath ) 
{
	// Create a new element
	myE = createDOM( 'img', { 'id':sContainerID, 'src':sImagePath, 'width':'450', 'height':'236', 'alt':images_alts[img_index] } );

	// Swap the old element for the new one.
	swapDOM( sContainerID, myE );
	
	if( i == 0 )
	{
		// Increment i to 1.
		i = 1;
	}
	else
	{
		// Decrement i to 0.
		i = 0;
	}
	
	// Iterate image index with MOD 3.
	img_index++;
	if (img_index == 4) img_index = 0;
}

function swapfade() 
{
	if( i == 0 )
	{
		// fade 0 - appear 1
		fade('Image0Container', { duration:3, from:1.0, to:0.0 });
		appear('Image1Container', { duration:3, from:0.0, to:1.0, afterFinish: function (){ swapImage( 'Image0', ('index_images/' + images_to_swap[img_index]) ); } });
	}
	else
	{
		// fade 1 - appear 0
		fade('Image1Container', { duration:3, from:1.0, to:0.0 });
		appear('Image0Container', { duration:3, from:0.0, to:1.0, afterFinish: function(){ swapImage( 'Image1', ('index_images/' + images_to_swap[img_index]) ) ; } });
	}
}

function kickit()
{
	setInterval('swapfade()',wait);
}

addLoadEvent(kickit);