// JavaScript Document
var ProgressBar = Class.create();

ProgressBar._ParenContainer  = null;
ProgressBar._ResizeHandler   = new function() { } ;
ProgressBar._ImageID   = new function() { } ;


ProgressBar.prototype = {

  initialize: function(ParentContainer, imgID ) {
    
  		this._ParenContainer = ParentContainer;
		this._ResizeHandler = this.ResizeWin.bind(this);
		this._ImageID = imgID;
		//
		if (!$(this._ImageID)) {
		
			document.write("<img id='" + imgID + "' src='images/indicator.gif' style ='display:none' />");
			$(imgID).setStyle({position:"absolute"});
			
			Event.observe(window, "resize", this._ResizeHandler );
		}
    },
	
	ResizeWin: function () {

		if ($(this._ImageID)) {
		
			if ($(this._ImageID).visible()) { 
				this.ShowIndicator();  		
			}
			
		}	
			
	},
		
	ShowIndicator: function() {

		if ($(this._ImageID)) {
	
			var dimContainer = $(this._ParenContainer).getDimensions(); 
			var dimImg = $(this._ImageID).getDimensions();	
					
			var _top = Math.round(  $(this._ParenContainer).cumulativeOffset().top 
										 + ((dimContainer.height - dimImg.height) / 2) ) +  "px";
										 
			var _left = Math.round($(this._ParenContainer).cumulativeOffset().left + ( (dimContainer.width - dimImg.width)/2))  +  "px";	 
			//alert ($("img_indicator").cumulativeOffset().top);			
			$(this._ImageID).setStyle({top: _top, left : _left }); 
			$(this._ImageID).show();
		}	
	},
	
	
	HideIndicator: function () {

		if ($(this._ImageID)) {
			//$("img_indicator").setStyle({top: this._topInit, left : this._LeftInit });
			$(this._ImageID).hide();
		}
		
	},
	
	Destroy: function () {

		if ($(this._ImageID)) {
		
			Event.stopObserving(window, "resize", this._ResizeHandler);
			$(this._ImageID).remove();
		
		}
	}	
			
}	


