$(document).ready(function() {
	$('#solar-power').html('Updating...');
	$('#solar-generation').html('Updating...');

	$('#wind-power').html('Updating...');
	$('#wind-generation').html('Updating...');

	$('#water-power').html('Updating...');
	$('#water-generation').html('Updating...');

	// Can not call getJSON because requires JSONP and the API does not wrap the callback in the retuern data
	//
	$.getJSON('tools/getsolardata.asp', function(data) {
		var index = 0;
		for (index = 0; index < data.length; index++) {
			if (isNaN(data[index].value))
				$('#solar-' + data[index].data_type).html(data[index].value + ' ' + data[index].unit);
			else
				$('#solar-' + data[index].data_type).html(data[index].value.toFixed(2) + ' ' + data[index].unit);
		}
	});

	$.getJSON('tools/getwinddata.asp', function(data) {
		var index = 0;
		for (index = 0; index < data.length; index++) {
			if (isNaN(data[index].value))
				$('#wind-' + data[index].data_type).html(data[index].value + ' ' + data[index].unit);
			else
				$('#wind-' + data[index].data_type).html(data[index].value.toFixed(2) + ' ' + data[index].unit);
		}
	});

	// Removed until data can be obtained
	//
	$.getJSON('tools/gethotwaterdata.asp', function(data) {
		var index = 0;
		for (index = 0; index < data.length; index++) {
			if (isNaN(data[index].value))
				$('#water-' + data[index].data_type).html(data[index].value + ' ' + data[index].unit);
			else
				$('#water-' + data[index].data_type).html(data[index].value.toFixed(2) + ' ' + data[index].unit);
		}
	});

	$('#scroller').simplyScroll({
		autoMode: 'loop',
		frameRate: 36,
		speed: 1,
		pauseOnHover: true,
		startOnLoad: true
	});
});
