function showDomains(months, year) {
	var url=LENOM_FORM_URL+"domains_js/sort/"+year;
	$.post(url,
		{months: months},
		function(data){
			var donnees = new google.visualization.DataTable(data);
			
			// Create and draw the visualization.
  			visualization = new google.visualization.Table(document.getElementById('txtHint'));
 			visualization.draw(donnees, {allowHtml: true});
 			
 			$("#txtHint").fadeIn(1000);
		},
		"json"
	);
}

function showListDomains(option) {
	document.getElementById('table').innerHTML = "";
	//document.getElementById('chart_div').innerHTML = "";
	document.getElementById('txtHint').innerHTML = "";
	
	if(isNaN(option.value)) {
		var d = new Date();
		year = d.getFullYear();
	}
	else
		year = option.value;

	var url=LENOM_FORM_URL+"domains_js/nosort/"+year;
	
	$.getJSON(url,
		{},
		function(data){
			var donnees = new google.visualization.DataTable(data);
			
			var table = new google.visualization.Table(document.getElementById('table'));
			table.draw(donnees, {allowHtml: true});
					
			google.visualization.events.addListener(table, 'select', function() {
				tSelection = table.getSelection();
				//cSelection = Array();
				//cSelection[0] = new google.visualization.DataTable();
				//cSelection[0].row = tSelection[0].row;
				//alert(tSelection[1].row);
				//cSelection[0].column = 1;
				//chart.setSelection(cSelection);
				showDomains(tSelection, year);
			});
			
			/*var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
			chart.draw(donnees, {width: 600, height: 300, min: 0, legend: 'bottom', isStacked: true, is3D: true, title: 'Nombre de domaines à Renouveller en ' + year});
			
			google.visualization.events.addListener(chart, 'select', function() {
				cSelection = chart.getSelection();
				tSelection = Array();
				tSelection[0] = new google.visualization.DataTable();
				tSelection[0].row = cSelection[0].row;
				tSelection[0].column = 1;
				table.setSelection(tSelection);
				showDomains(cSelection[0].row, year);
			});*/
		}
	);
	$("#chart_div").fadeIn(1500);
	$("#table").fadeIn(1500);
}
