function NumberFormat(num)
{
	this.num;
	this.numOriginal;
	this.isCommas;
	this.isCurrency;
	this.currencyPrefix;
	this.places;
	this.setNumber = setNumberNF;
	this.toUnformatted = toUnformattedNF;
	this.setCommas = setCommasNF;
	this.setCurrency = setCurrencyNF;
	this.setCurrencyPrefix = setCurrencyPrefixNF;
	this.setPlaces = setPlacesNF;
	this.toFormatted = toFormattedNF;
	this.getOriginal = getOriginalNF;
	this.getRounded = getRoundedNF;
	this.preserveZeros = preserveZerosNF;
	this.justNumber = justNumberNF;
	this.setNumber(num);
	this.setCommas(true);
	this.setCurrency(true);
	this.setCurrencyPrefix('$');
	this.setPlaces(2);
}
function setNumberNF(num)
{
	this.numOriginal = num;
	this.num = this.justNumber(num);
}
function toUnformattedNF(){return (this.num);}
function getOriginalNF(){return (this.numOriginal);}
function setCommasNF(isC){this.isCommas = isC;}
function setCurrencyNF(isC){this.isCurrency = isC;}
function setCurrencyPrefixNF(cp){this.currencyPrefix = cp;}
function setPlacesNF(p){this.places = p;}
function toFormattedNF()
{
	var pos;
	var nNum = this.num;
	var nStr;
	nNum = this.getRounded(nNum);
	nStr = this.preserveZeros(Math.abs(nNum));
	if (this.isCommas)
	{
		pos = nStr.indexOf('.');
		if (pos == -1){pos = nStr.length;}
		while (pos > 0)
		{
			pos -= 3;
			if (pos <= 0) break;
			nStr = nStr.substring(0,pos) + ',' + nStr.substring(pos, nStr.length);
		}
	}
	nStr = (nNum < 0) ? '-' + nStr : nStr; // v1.0.1

	if (this.isCurrency){nStr = this.currencyPrefix + nStr;}
	return (nStr);
}
function getRoundedNF(val)
{
	var factor;
	var i;
	factor = 1;
	for (i=0; i<this.places; i++)
	{	factor *= 10; }
	val *= factor;
	val = Math.round(val);
	val /= factor;
	return (val);
}
function preserveZerosNF(val)
{
	var i;
	val = val + '';
	if (this.places <= 0) return val;
	var decimalPos = val.indexOf('.');
	if (decimalPos == -1)
	{
		val += '.';
		for (i=0; i<this.places; i++){val += '0';}
	}
	else
	{
		var actualDecimals = (val.length - 1) - decimalPos;
		var difference = this.places - actualDecimals;
		for (i=0; i<difference; i++){val += '0';}
	}
	return val;
}
function justNumberNF(val)
{
    var newVal;
	val = (val==null) ? 0 : val;
	if (isNaN(val))
	{
		 newVal = parseFloat(val.replace(/[^\d\.\-]/g, ''));
		 return (isNaN(newVal) ? 0 : newVal); 
	}
	else if (!isFinite(val)){return 0;}
	return val;
}