$(function() {
	$('.bar_week').sparkline('html', {
		type: 'bar',
		height: '40',
		barWidth: 5,
		barColor: '#2574A9',
		negBarColor: '#B9493E'
	});

	$(".sortableTable").tablesorter({sortList: [[1,1]]});

});

	// Load the Visualization API and the piechart package.
	google.load('visualization', '1', {'packages':['corechart']});

	// Set a callback to run when the Google Visualization API is loaded.
	google.setOnLoadCallback(drawAdsChart);
	google.setOnLoadCallback(drawSalesChart);

	function drawAdsChart() {

		$.getJSON( "index.php?dashboard&chartdata&ad", function(jsonData) {
			var data = new google.visualization.DataTable(jsonData);

			var options = {
				legend: { position: 'bottom',textStyle: {fontSize: '10'} },
				backgroundColor: '#E5E5E5',
				pointSize: 4,
				fontName: 'Open Sans',
				chartArea: {width: '85%', height: '70%'},
				vAxis: {minValue: 0, format: '0', viewWindow: {min: 0}, gridlines: {count: -1}},
				colors: ['#2574A9','#70757B','#B9493E']
			};

			var chart = new google.visualization.AreaChart(document.getElementById('dashboard_chart_ad'));
			chart.draw(data, options);
		});

	}
	function drawSalesChart() {

		$.getJSON( "index.php?dashboard&chartdata&sale", function(jsonData) {
			var data = new google.visualization.DataTable(jsonData);

			var options = {
				legend: { position: 'bottom',textStyle: {fontSize: '10'} },
				backgroundColor: '#E5E5E5',
				pointSize: 4,
				fontName: 'Open Sans',
				chartArea: {width: '85%', height: '70%'},
				vAxis: {minValue: 0, format: '0', viewWindow: {min: 0}, gridlines: {count: -1}},
				colors: ['#239D58','#2574A9']
			};

			var chart = new google.visualization.AreaChart(document.getElementById('dashboard_chart_sale'));
			chart.draw(data, options);
		});

	}

	$(document).ready(function () {
$(window).resize(function(){
	drawAdsChart();
	drawSalesChart();
});
});
