
/*
Eelko Potters
Version: 0.2, 2006-12-11


******************************************************************************/
	
	
function ProgressBar(id, width, activityName, total) {

	this.progressBarEl = document.getElementById(id);
	this.progressEl = this.progressBarEl.firstChild;
	this.activityEl = this.progressBarEl.parentNode.firstChild;
		
	this.barWidth = width;
	this.activityName = activityName;
	this.total = total;
	this.current = 0;

	// Update the progressbar
	this.showProgress = function(current) {
		this.current = current;
		
		this.progressEl.style.width = Math.floor(this.barWidth * this.current / this.total) + "px";
		
		this.activityEl.innerHTML = activityName + ": " + this.current + " van " + this.total;
		
		if (this.current >= this.total) {
			// alert("Complete!");
			// this.hide();
		}
	};
	
	this.showProgress(this.current);
		
	this.hide = function() {
		this.progressBarEl.parentNode.style.display = "none";
	};

	// Set the progress bar length in pixels
	this.setBarWidth = function(newWidth) {
		this.barWidth = newWidth;
		this.progressBarEl.style.width = this.barWidth + "px";
		this.showProgress(this.current);
	};
}
