if (typeof(window['CarbonCulture']) === "undefined") {
    window.CarbonCulture = {
        on_load_callbacks: []
    };
    var widget = document.getElementById('graph-widget')
    // Hide the default text to prevent a flicker
    widget.innerHTML = '';
    var head = document.getElementsByTagName('head')[0];
    var script = document.createElement('script');
    script.type = 'text/javascript';
    var COMPRESSED_JS = function(url) {
        return '/static/'+url;
    }
    script.src = COMPRESSED_JS('graph/graph-widget.js');
    head.appendChild(script);
}

CarbonCulture.on_load_callbacks.push(function() {
    var settings = {
        // Global settings
        realtime: false,
        period: true,
        animation: true,
        history: true,
        name:  'carbonculture-widget-set-1',
        disable_paging: true,
        disable_month: false,
        disable_gas: false,
        offset_history: true,
        // Setting used only below
        div:  'graph-widget',
        feedback_url: 'http://data.carbonculture.net/orgs/',
        cc_url: 'http://www.carbonculture.net/orgs/',
        graph_width: 615,
        graph_height: 364,
        default_show: 'total',
        default_period: 168
    };

    // merge any settings from the template
    jQuery.extend(settings, carbonculture_graph_settings);
    CarbonCulture.org_graph(settings);
});

