/*
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% QuotaBox %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
	/**
	 *	QuotaBox
	 *	This class provides a visual quota box
	 *
	 *	@param width The width of the quota box
	 *	@param height The height of the quota box
	 *	@param min The minimum value of the quota
	 *	@param max The maximum value of the quota
	 *	@param current The current vlaue of the quota
	 *	@param units (Optional) The units of the quota
	 *
	 *	@constructor
	 */
	function QuotaBox(width, height, min, max, current, units) {
		this.i_width = width;
		this.i_height = height;
		this.i_minimum = min;
		this.i_maximum = max;
		this.i_current = current;
		this.i_units = units;
	}
	
	/**
	 *	Get/Set the width of the quota box
	 *
	 *	@param width The new width of the quota box
	 *
	 *	@return the current width of the quota box
	 */
	QuotaBox.prototype.width = function(width) {
		if (width != undefined) {
			this.i_width = width
			if (this.i_box != undefined) {
				this.i_bar_status.style.width = ((this.width() - 12) * (this.value() / (this.maximum() - this.minimum()))) + "px";
				this.i_box.style.width = this.width() + "px";
				this.i_text.style.width = (this.width() - 115) + "px";
				this.i_progress.style.width = (this.width() - 2) + "px";
				this.i_bar_wrapper.style.width = (this.width() - 10) + "px";
				
			}
		}
		return this.i_width;
	}
	
	/**
	 *	Get/Set the height of the quota box
	 *
	 *	@param height (Optioanl) the new height of this quota box
	 *
	 *	@return the current height of the quota box
	 */
	QuotaBox.prototype.height = function(height) {
		if (height != undefined) {
			this.i_height = height;
			if (this.i_box != undefined) {
				this.i_box.style.height = this.height() + "px";
				this.i_progress.style.height = (this.height() - 20) + "px";
				this.i_bar_wrapper.style.height = (this.height() - 70) + "px";
				this.i_bar_status.style.height = (this.height() - 32) + "px";
				this.i_bar_wrapper.style.height = (this.height() - 30) + "px";
			}
		}
		return this.i_height;
	}
	
	/**
	 *	Get/Set the minimum value of this quota box
	 *
	 *	@param minimum (Optional) The new minimum value for this quota
	 *
	 *	@return the currnet minimum of this quota box
	 */
	QuotaBox.prototype.minimum = function(minimum) {
		if (minimum != undefined) {
			this.i_minimum = minimum;
			if (this.i_box != undefined) {
				this.i_bar_status.style.width = ((this.width() - 12) * (this.value() / (this.maximum() - this.minimum()))) + "px";
			}
		}
		return this.i_minimum;
	}
	
	/**
	 *	Get/Set the maximum value of this quota
	 *
	 *	@param maximum (Optional) The maximum value of this quota
	 *
	 *	@return the current maximum value of this quota
	 */
	QuotaBox.prototype.maximum = function(maximum) {
		if (maximum != undefined) {
			this.i_maximum = maximum;
			if (this.i_box != undefined) {
				this.i_bar_status.style.width = ((this.width() - 12) * (this.value() / (this.maximum() - this.minimum()))) + "px";
				this.i_text.innerHTML = this.value() + ((this.units() != undefined && this.units() != "") ? " " + this.units() : "") + " of " + this.maximum() + ((this.units() != undefined && this.units() != "") ? " " + this.units() : "");

			}
		}
		return this.i_maximum;
	}
	
	/**
	 *	Get/Set the current value of this quota
	 *
	 *	@param current (Optional) The new current value of the quota
	 *
	 *	@return the current value of this quota box
	 */
	QuotaBox.prototype.value = function(current) {
		if (current != undefined) {
			this.i_current = current;
			if (this.i_box != undefined) {
				this.i_bar_status.style.width = ((this.width() - 12) * (this.value() / (this.maximum() - this.minimum()))) + "px";
				this.i_text.innerHTML = this.value() + ((this.units() != undefined && this.units() != "") ? " " + this.units() : "") + " of " + this.maximum() + ((this.units() != undefined && this.units() != "") ? " " + this.units() : "");

			}
		}
		return this.i_current;
	}
	
	/**
	 *	Get/Set the units this quota box is in
	 *
	 *	@param units (Optional) The unit name
	 *
	 *	@return the current unit name
	 */
	QuotaBox.prototype.units = function(units) {
		if (units != undefined) {
			this.i_units = units;
			if (this.i_box != undefined) {
				this.i_text.innerHTML = this.value() + " of " + this.maximum() + ((this.units() != undefined && this.units() != "") ? " " + this.units() : "");
			}
		}
		return this.i_units;
	}
	
	/**
	 *	Get the DIV that contains this quota box
	 *
	 *	@return the DIV that contains this quota box
	 */
	QuotaBox.prototype.getBox = function() {
		if (this.i_box == undefined) {
			this.i_box = document.createElement('DIV');
			this.i_box.className = "QuotaBox";
			this.i_box.style.width = this.width() + "px";
			this.i_box.style.height = this.height() + "px";

				this.i_text = document.createElement('DIV');
				this.i_text.className = "QuotaBox_text";
				this.i_text.style.width = (this.width() - 115) + "px";
				this.i_text.style.height = "20px";
				this.i_text.innerHTML = this.value() +  " of " + this.maximum() + ((this.units() != undefined && this.units() != "") ? " " + this.units() : "");
				this.i_box.appendChild(this.i_text);
			
				this.i_name = document.createElement('DIV');
				this.i_name.className = "QuotaBox_name";
				this.i_name.style.width = "100px";
				this.i_name.style.height = "20px";
				this.i_name.innerHTML = "Quota";
				this.i_box.appendChild(this.i_name);
				
				
				this.i_progress = document.createElement('DIV');
				this.i_progress.className = "QuotaBox_progress";
				this.i_progress.style.width = (this.width() - 2) + "px";
				this.i_progress.style.height = (this.height() - 20) + "px";
				this.i_box.appendChild(this.i_progress);
				
					this.i_bar_wrapper = document.createElement('DIV');
					this.i_bar_wrapper.className = "QuotaBox_bar_wrapper";
					this.i_bar_wrapper.style.width = (this.width() - 10) + "px";
					this.i_bar_wrapper.style.height = (this.height() - 30) + "px";
					this.i_bar_wrapper.style.left = "5px";
					this.i_bar_wrapper.style.top = "5px";
					this.i_progress.appendChild(this.i_bar_wrapper);
					
						this.i_bar_status = document.createElement('DIV');
						this.i_bar_status.className = "QuotaBox_bar_status";
						this.i_bar_status.style.height = (this.height() - 32) + "px";
						this.i_bar_status.style.width = ((this.width() - 12) * (this.value() / (this.maximum() - this.minimum()))) + "px";
						this.i_bar_status.innerHTML = "&nbsp;";
						this.i_bar_wrapper.appendChild(this.i_bar_status);
		}
		return this.i_box;
	}
	 
	 
if (typeof loadQuotas != "undefined") {
	loadQuotas();
}
