$(function() {
	$.post('/virtualmarch10/callmap.pl', {}, drawVisualization, "json");
});


function drawVisualization(d) {
	// Data for Demo Map
	var data = new google.visualization.DataTable();
	data.addRows(d.length);
	data.addColumn('string', 'State');
	data.addColumn('number', 'People calling right now');
	data.addColumn('string', 'State Name');

	for (var row in d) {
		var count = parseInt(row);
		data.setValue(count, 0, 'US-' + d[row].user_state);
		data.setValue(count, 1, parseInt(d[row].total));
		data.setValue(count, 2, d[row].state);
	}

	// Create a new geomap visualization object

	var callVolume = new google.visualization.GeoMap(document.getElementById('callVolume'));

	// Set options for the geomap
	
	var optionsSmall = {};
	optionsSmall['dataMode'] = 'regions';
	optionsSmall['region'] = 'US';
	optionsSmall['showLegend'] = 0;
	optionsSmall['width'] = document.getElementById('callVolume').offsetWidth;
	optionsSmall['height'] = document.getElementById('callVolume').offsetHeight;
	
	// Draw the geomap
	
	callVolume.draw(data, optionsSmall);
}

// Draw the Geomap once the page is loaded

// google.setOnLoadCallback(drawVisualization);


