// Angle Converter 
AngleConverter = Class.create();

AngleConverter.prototype = {
	initialize : function(unit, value){
		this.uv = new Array(); 
		this.uv = {
			"degrees" : 1, // ref unit
			"radians" : 0.017453293,
			"grades" : 1.11111111,
			"gons" : 1.11111111,
			"minutes" : 60,
			"seconds" : 3600,
			"signs" : 0.0333333,
			"mils" : 17.7777778,
			"revolutions" : 0.002777778,
			"circles" : 0.002777778,
			"turns" : 0.002777778,
			"quadrants" : 0.01111111,
			"right_angles" : 0.01111111,
			"sextants" : 0.01666667
		}
		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;
	},
	cVHTML : function(){ // returns html formatted values for all units
		var msg = "<h2>Angle Converter</h2>";
		msg += "<p>" + this.value + " " + this.unit + " => </p>";
		msg += "<ul>";
		Box.ajaxReq('/docs/scripts/conv.js',false);
		for (var i in this.uv) {
			msg += "<li>" + Conv.rounding(this.ref * this.uv[i]) + " " + i + "</li>";
		}  
		msg += "</ul>";
		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
