(function($){
	
	//Create a new chart in the specified <div> element with the supplied options.
	function AFGChart(domNode,options){
		this._el = $(domNode);
		this._init(options || {});
		this.draw();
	}
	
	//Define class prototype for AFGChart
	AFGChart.prototype = {
			
			//Initialisation function - prepare our chart for display
			_init: function(options){
		
				//Hold chart data
				this._dataSets = {};
			
				//set the range of the chart
				if(options.range) this._setRange(options.range);
				if(options.data) this.addData(options.data);
			
			},
			//Function to set the range of the display range of the chart
			_setRange: function(range){
				
				//If range is an array i.e. [1,45]
				if($.isArray(range)){
					this._dataRangeMin = range[0];
					this._dataRangeMax = range[1];
				}
				else{
					this._dataRangeMin = range.min || 0;
					this._dataRangeMax = range.max;
				}
				this._isBounded = true;
			},
			//Function to add data to our chart
			addData: function(data){
				
				if($.isArray(data)){
					if(this._isMultiSet == null){
						this._isMultiSet = false;
						this._addDataSet("1",data);
					}
				}
				else if(this._isMultiSet != false){
					this._isMultiSet = true;
					var self = this;
					$.each(data,
							function(i,ds){
								self._addData(i,ds);
							} 
					);
				}
			
			
			}
	
	
	};
	
})(jQuery);
