//
// 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 = [
					"#1fa2b2",	//Aqua
					"#0b8c8f",	//Turquoise
					"#83d14a",	//Green
					"#e5d445",	//Gold
					"#d4902f",  //Orange
					"#e1381c",  //Red
					"#d6156c",  //Pink
					"#9051e7",  //Purple
					"#3f8ceb"  // Blue
				  ];
				  
	var lightColours = [
				"#c7e8ec",	//Aqua
				"#c2e2e3",	//Turquoise
				"#e0f3d2",	//Green
				"#f8f4d0",	//Gold
				"#f4e3cb",  //Orange
				"#f7cdc6",  //Red
				"#f5c4da",  //Pink
				"#e3d3f9",  //Purple
				"#d3e2f9"  // Blue
			  ];
				  
	var ranNum = different_random(currentNum, colours.length);
	var ranNum2 = different_random(currentNum, lightColours.length);
	
	//fade in a random color
	$("body, #logo").animate({ backgroundColor: colours[ranNum] }, 18000, function() {
		colour_fade(ranNum);
	});
	$("h2, ul.errors, .contactDetails").animate({ color: colours[ranNum] }, 18000, function() {
		colour_fade(ranNum);
	});
	$(".bodyLink").animate({ backgroundColor: lightColours[ranNum] }, 18000, function() {
		colour_fade(ranNum);
	});
}

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