/*

ambilight function

parameters:		image DOM element and animation speed in milliseconds

*/

function ambilight(image, speed) {
	// make an AJAX request to average_values.php, passing the path of the image as "file" GET parameter
	$.getJSON("average.php?file="+$(image).attr('src'), function(data) {
		// animate the background colour of the image's parent to the returned "average" JSON property over 3 seconds
		$(image).parent().animate({backgroundColor: data.average},speed);
	});
}