/*
Class: DataRevrieval
	
	
Note:
	The DataRevrieval requires an XHTML doctype.

Arguments:
	element - the knob container
	knob - the handle
	numberOfSteps - the number of steps
	options - see Options below

Options:
	mode - either 'horizontal' or 'vertical'. defaults to horizontal.
	offset - relative offset for knob position. default to 0.
	
Events:
	onComplete - a function to fire when you're done retrieving data.
*/
var DataRetrieval = new Class({
	
	options: {
		retrievalType: Class.empty,
		elementsPerPage: 0
		//onComplete: Class.empty,
		//onError: Class.empty
	},
	
	initialize : function(pageNumber , options) {
		this.setOptions(options);
		this.pageNumber = pageNumber;
		this.retriever = new AjaxDataRetriever(pageNumber,{elementsPerPage:this.options.elementsPerPage});
		this.retriever.addEvent('onComplete', function(text) { this.dataRetrievalComplete(text); }.bind(this)); 
		this.retriever.addEvent('onError', function(err) { this.dataRetrievalError(err); }.bind(this));
	},
	
	
	// this method will use the retrieverMethod to get the raw html data  
	// and fire an event passing the raw data.
	retrieveData : function ( page ) {
		this.retriever.retrieveData();
	},
	
	// this is the callback method for the oncomplete event from the specific dataretreiver
	// this method will need to fire a oncomplete event to notify any interested parties.
	dataRetrievalComplete : function(text) {
		this.fireEvent('onComplete',text);
	},
	
	//this method will handle and error processing that will be needed.
	dataRetrievalError : function(err) {
		this.fireEvent('onError',err);
	}
});

DataRetrieval.implement(new Options);
DataRetrieval.implement(new Events);

