var AjaxIndicator = Class.create();
AjaxIndicator.prototype = {
	options:[],
	element:null,
	blockElement: null,
	
	initialize: function(element, options) {
		this.element = $(element);

		//Merge the options with user specified options
		this.options = $H({
			blockElementZIndex: 200,
			blockElementColor: "#FFFFFF",
			blockElementOpacity: 0.75,
			indicatorImageSrc: "/css/theme_default/i/indicator_ico16.gif",
			indicatorImageWidth: 16,
			indicatorImageHeight: 16
		}).merge(options || {});

		this.blockElement();
		this.showIndicator();
	},
	
	blockElement: function() {
		this.blockElement = document.createElement("div");
		this.blockElement.style.backgroundColor = this.options.blockElementColor;
		$(this.blockElement).setOpacity(this.options.blockElementOpacity);
		this.blockElement.style.position = "absolute";
		this.element.parentNode.appendChild(this.blockElement);
		
		Position.clone(this.element, this.blockElement);
	},
		
	showIndicator: function() {
		var indicator = document.createElement("img");
		indicator.className = "indicator";
		indicator.src = this.options.indicatorImageSrc;
		indicator.width = this.options.indicatorImageWidth;
		indicator.height = this.options.indicatorImageHeight;
		indicator.alt = "Loading...";
		indicator.title = "Loading...";
		
		indicator.style.position = "absolute";
		indicator.style.top = "50%";
		indicator.style.left = "50%";
		indicator.style.marginLeft = "-" + (this.options.indicatorImageWidth/2) + "px";
		indicator.style.marginTop = "-" + (this.options.indicatorImageHeight/2) + "px";
		
		this.blockElement.appendChild(indicator);
	},
	
	close: function() {
		Element.remove(this.blockElement);
	}
}
