//
// Slow fade background colour change
//

//Returns a random number that is different to the specified one 
//and between 0 and the total
function different_random(different_to, total) {
	
	var next = different_to
	while(next === different_to) {
		next = Math.floor(Math.random()*total);
	}
	return next;
}

function colour_fade(currentNum) {

	//colour sequence
	var colours = [
					"#48293a",	//First colour must be black
					"#312948",	//Orange
					"#1c031a",	//Purple
					"#482929",	//Blue
					"#484129"	//Green
				  ];
				  
	var ranNum = different_random(currentNum, colours.length);

	//fade in a random color
	$("body").animate({ backgroundColor: colours[ranNum] }, 20000, function() {
		colour_fade(ranNum);
	});

}

$(document).ready(function() {
	colour_fade(0);
});