// Copyright 2008 ProjectWizards GmbH. All rights reserved.

//console.log("MERate.js");

var MERate = WRLObject.extend({
	constructor: function(json)
	{
		this.base();
		this.amount = json.a == null || typeof(json.a) == "undefined" ? null : json.a;
		this.denominatorUnit = json.d == null || typeof(json.d) == "undefined" ? null : json.d;
		this.denominatorUnitIsFloating = json.f == null || typeof(json.f) == "undefined" ? null : json.f;
	},

	className: "MERate",
		
    toJSON: function() {
        return '{"a":' + this.amount + ', "d":' + this.denominatorUnit + ', "f":' + this.denominatorUnitIsFloating + '}';
    }
},{ // Class methods
	  RateWithAmountUnitUnitIsFloating: function(amount, unit, unitIsFloating){
			var dict = {a:amount, d:unit};
			if(unitIsFloating)
				dict.f = true;
			return new MERate(dict);
	  }
});