// FusionCharts.js is needed for the following to work.
			
if( window.console == null ) {
	window.console       = new Object();
	window.console.debug = function() {};
	window.console.info  = function() {};
	window.console.log   = function() {};
}
	
window.rendered = new Object();

function exportChart(chartDiv) {
    var chartId = chartDiv.attr('id') + '_Id';

    if(window.rendered[chartId]) {
        var chartToExport = getChartFromId(chartId);
        chartToExport.exportChart();
	}
}

function exportECRChart(chartId) {
    if(window.rendered[chartId]) {
        var chartToExport = getChartFromId(chartId);
        chartToExport.exportChart();
	}
}

function printChart(chartId) {
	if(window.rendered[chartId]) {
	    var chartToPrint = getChartFromId(chartId);
		chartToPrint.print();
	}
}

/**
 * Fusion Charts callback functions.
 * These functions are called by Fusion Charts.
 */
function FC_Loaded(chartId) {
	console.info("Chart with id [" + chartId + "] has loaded.");
}

function FC_DataLoaded(chartId) {
	console.info("Chart with id [" + chartId + "] has loaded data.");
}

/**
 * This function is called by Fusion Charts when they have finished rendering.
 */
function FC_Rendered(chartId) {
	console.info("Chart with id [" + chartId + "] has rendered.");
    window.rendered[chartId] = true;
}

function FC_DataLoadError(chartId) {
	console.info("Chart with id [" + chartId + "] has error loading data.");
	var chart = getChartFromId(chartId);
	console.info(chart.getXML());
}

function FC_NoDataToDisplay(chartId) {
	console.info("Chart with id [" + chartId + "] has no data to display.");
	var chart = getChartFromId(chartId);
	console.info(chart.getXML());
}

function FC_DataXMLInvalid(chartId) {
	console.info("Chart with id [" + chartId + "] has invalid data XML.");
	var chart = getChartFromId(chartId);
	console.info(chart.getXML());
}
