// Energy Converter 

function EnergyConverter(unit, value){
	this.uv = new Array(); 
	this.uv = {
		"joule" : 1, // ref unit
		"kjoule" : 0.001,
		"kwh" : 0.0000002778,
		"nm3_naturalgas" : 0.000000025,
		"ft3_naturalgas" : 0.000000947,
		"tce" : 0.0000000000349,
		"toe" : 0.00000000002204248,
		"boe" : 0.00000000016339869,
		"cal" : 0.2388,
		"kcal" : 0.0002388,
		"btu" : 0.0009477
	}
	this.unit = unit; // unit to convert from
	this.value = value; // value to convert
	this.ref = 1 / this.uv[this.unit] * this.value;
}

// returns value for singel unit
EnergyConverter.prototype.cV = function(unitTo){
	return this.ref * this.uv[unitTo];
}
// returns values for all units
EnergyConverter.prototype.cVs = function(){
	var msg = this.value + " " + this.unit + " => \n";
	for (var i in this.uv) {
		msg += this.ref * this.uv[i] + " " + i + "\n";
	}  
	return msg;
}

// Copyright engineeringtoolbox.com