var timer = setInterval(fadeBackground, 5000);
var idx   = 0;
var nodes = ["bread-background-1", "bread-background-2", "bread-background-3", "bread-background-4"];
var stylefx = {visibility:"visible", opacity:0};
dojo.addOnLoad(function(){
	for( var i=1; i<nodes.length; i++ ) { dojo.style(nodes[i], stylefx); }
/*
	dojo.style("bread-background-2", stylefx);
	dojo.style("bread-background-3", stylefx);
	dojo.style("bread-background-4", stylefx);
*/
});

// fade in the next background and fade out the current
// background
function fadeBackground()
{
	var random_idx = getRandomNode();
	if( random_idx == idx ) { fadeBackground(); return; }	// this makes sure we get a different image
	
	dojo.fadeIn({node:nodes[random_idx],duration:1000}).play();
	dojo.fadeOut({node:nodes[idx],duration:1000}).play();
	
	idx = random_idx;
}
function getRandomNode() { return Math.floor(nodes.length * Math.random()); }
