var AjaxLoader = new Class({
	initialize: function(image) {
		this.image = new Asset.image(image, { onload: this.create.bind(this) });
		this.arrayOfIDs = new Array();
	},

	create: function() {
		delta = window.getScroll()['y']+10;
		this.image.setStyles({'position': 'absolute', 'top':delta+'px', 'right':'10px', 'display':'block', 'opacity': 0}).inject(document.body, "inside");
	},

	show: function(id) {
		if (!this.arrayOfIDs.contains(id)) {
			this.arrayOfIDs.push(id);
			this.image.morph({opacity:1});
			$(id).setStyle('position', 'relative');
			this.overlay = new Element('div', {
				id: 'Overlay',
				height: 6000,
				styles: {opacity: 0.5}
			});
			this.overlay.inject($(id), "inside");
		}
	},

	hide: function(id) {
		if (this.arrayOfIDs.contains(id)) {
			this.image.morph({opacity:0});
			this.overlay.destroy();
			$(id).setStyle('position', 'static');
			this.arrayOfIDs.erase(id);
		}
	}
});
