var retrieveWB = new Class ({
	Implements: [Options, Events],
	options: {
		url:'',
		back:true,
		type:'json',
		async:true,
		method:'post',
		nocache:true
	},
	initialize: function(options){
		this.setOptions(options);
		this.attempt = 0;
		this.getLocalRequest();
	},
	getLocalRequest: function (){
		var self=this;
		if ( this.options.type == 'json' )
		{
			new Request.JSON({
				url: this.options.url,
				method: this.options.method,
				async: this.options.async,
				nocache: this.options.nocache,
				onSuccess: this.setJSON.bind(self),
				onFailure: function ( xhr )
				{
					if ( self.attempt == 0 )
					{
						self.attempt = 1;
						self.options.url = self.options.url+".bak";
						return self.getLocalRequest();
					}
					else
					{
						return null;
					}
				}
			}).send();
		}
		else if ( this.options.type == 'rss' || this.options.type == 'xml' )
		{
			new Request({
				url: this.options.url,
				method: this.options.method,
				async: this.options.async,
				nocache: this.options.nocache,
				onSuccess: this.setXML.bind(self),
				onFailure: function ( xhr )
				{
					if ( self.attempt == 0 )
					{
						self.attempt = 1;
						self.options.url = self.options.url+".bak";
						return self.getLocalRequest();
					}
					else
					{
						return null;
					}
				}
			}).send();
		}
	},
	setJSON: function ( responseJSON, responseText )
	{
		this.JSON = responseJSON;
		this.Text = responseText;
		this.fireEvent('completeJSON');
	},
	setXML: function ( responseText, responseXML )
	{
		this.Text = responseText;
		this.XML = responseXML;
		this.fireEvent('completeXML');
	}
});