function imageRotator( first, last ) {
	var index = $("#splash").find(".image").find("img").attr("class");
	index++;
	$("#splash").css( "background", "white" );
	var images = new Array( 
		"images/splash/autumn-stone.jpg",
		"images/splash/banked-exterior.jpg",
		"images/splash/bathroom.jpg", 
		"images/splash/bedroom.jpg", 
		"images/splash/exterior-closeup.jpg", 
		"images/splash/grey-brick-exterior.jpg", 
		"images/splash/kitchen.jpg", 
		"images/splash/kitchen-counter-and-cabinets.jpg", 
		"images/splash/kitchen-quality-appliances.jpg", 
		"images/splash/livingroom-fireplace-lake.jpg", 
		"images/splash/new-kitchen.jpg", 
		"images/splash/red-brick-home-in-fall.jpg", 
		"images/splash/regal-bookcase.jpg",
		"images/splash/roof-lines.jpg",
		"images/splash/triple-garage-home.jpg",
		"images/splash/wide-bungalow.jpg"
		);
	var count = images.length;
	if( first ) {
		output = "<div id=\"preload-rotator\" style=\"width: 0px; height: 0px; line-height: 0px; font-size: 0px; overflow: hidden;\">";
		for( var index in images ) {
			output += "<img src=\""+ images[ index ] +"\" alt=\"preloaded-image\" class=\"" + index + "\">";
		} // end foreach
		output += "</div><div id=\"last-shown\" style=\"display: none;\">This div is for debugging output.</div>\n";
		first = false;
		$("#splash").append( output );
	} // end if
	index = parseInt( Math.random() * count );
	lastShown = "<ul>";
	for( i in last ) {
		if( index == last[i] ) index = parseInt( Math.random() * count );
		lastShown += "<li>" + last[i] + "</li>";
	} // end for
	lastShown += "</ul>\n";
	$("#last-shown").html( lastShown );
	if( last.length <= images.length / 2 ) {
		last[ last.length++ ] = index; /* keep storing the last few entries */
	} else {
		last[0] = index; /* keep storing the last few selected entries */
		last.length = 1;
	} // end if
	if( index >= count ) index = 0; /* Don't go past the end of the list */
	var URIs = new Array( 
		"", 
		"", 
		"", 
		"", 
		"", 
		"", 
		"", 
		"", 
		"", 
		"", 
		"", 
		"", 
		"", 
		""
		);
	
	var imageDescription = new Array( 
		"", 
		"", 
		"", 
		"", 
		"", 
		"", 
		"", 
		"", 
		"", 
		"", 
		"", 
		"", 
		"", 
		""
		);
	
	/* Fade out with a callback to a function which fades back in */
	$("#splash .image").fadeOut( "slow", function() {
		$("#splash").find(".image").find("img").attr( "src", images[ index ] );
		$("#splash").find(".image").find("img").attr( "class", index );
		if( imageDescription[ index ] != undefined ) { $("#splash").find(".description").html( "" + imageDescription[ index ] ); }
		$("#splash").find(".image").fadeIn("fast");
		$("#splash").find(".image").css("display", "block");
	} );
	
	return first;
} // end imageRotator



$(function() {
	var first = true;
	var last = Array( 0 );
	setInterval( function() { first = imageRotator( first, last ); }, "5000" );
});
