// Volume Converter 

VolumeConverter = Class.create();

VolumeConverter.prototype = {
	initialize : function(unit, value){
		this.uv = new Array(); 
		this.uv = {
			"cubic_meters" : 1, // ref unit
			"cubic_decimeters" : 1000,
			"cubic_centimeters" : 1000000,
			"cubic_millimeters" : 1000000000,
			"hectoliters" : 10,
			"liters" : 1000,
			"centiliters" : 100000,
			"milliliters" : 1000000,
			"cubic_inches" : 61024,
			"cubic_feet" : 35.3147,
			"cubic_yards" : 1.30795,
			"us_liquid_gallons" : 264.172052,
			"us_dry_gallons" : 227.021,
			"imp_liquid_gallons" : 219.969,
			"barrels_(oil)" : 6.2898,
			"cups" : 4226.75,
			"fluid_ounces_(UK)" : 35195.08,
			"fluid_ounces_(US)" : 33814.023,
			"pints_(UK)" : 1759.75
		}
		this.unit = unit; // unit to convert from
		this.value = value; // value to convert
		this.ref = 1 / this.uv[this.unit] * this.value;
	},
	cV : function(unitTo){ // returns value for singel unit
		return this.ref * this.uv[unitTo];
	},
	cVs : function(){ // returns values for all units
		var msg = this.value + " " + this.unit + " => \n";
		Box.ajaxReq('/docs/scripts/conv.js',false);
		for (var i in this.uv) {
			msg += Conv.rounding(this.ref * this.uv[i]) + "  " + i + "\n";
		}  
		return msg;
	},
	c : function(){ // returns an array with calculated values for all units
		var vs = new Array();
		var n = 0;
		for (var i in this.uv) {
			vs[n] = new Array(i,this.ref * this.uv[i]);
			n++;
		}  
		return vs;
	}
}
// Copyright engineeringtoolbox.com