var Reload = new Class({
	Implements : [Options, Events],
	options : {
		'usemask' : true,
		'maskcolor' : '#000',
		'maskopacity' : .6
	},
	initialize : function(options) {
		this.setOptions(options);
		return this;
	},
	loadBlock : function(element, uri, blockID) {
		var uri = (new URI(uri)).setData({
			'pid' : null,
			'bid' : blockID
		}, true);
		return this.load(element, uri.toString());
	},
	load : function(element, uri) {
		new Request.HTML({
			'evalScripts' : false,
			'evalResponse' : false,
			'onRequest' : (function() {
				if (this.options.usemask)
					$$(element).set('spinner', {
						'id' : 'reload-mask', 
						'class' : 'reload-mask',
						'style' : {
							'background-color' : this.options.maskcolor,
							'opacity' : this.options.maskopacity
						}, 
						'fxOptions' : {
							'duration' : 0
						}
					}).spin();
			}).bind(this),
			'onSuccess' : (function(responseTree, responseElements, responseHTML, responseJavaScript) {
				$$(element).unspin();
				$$(responseTree[0]).replaces(element);
			}).bind(this)
		}).get(uri);
		return true;
	}
});
