function isIE()
{
	// get browser info. 
	appName = navigator.appName;
	appLongVer = navigator.appVersion;
	appVer = appLongVer.substring(0, 1); 

	// check for IE ver 4+. 
	if((appName == "Microsoft Internet Explorer") && (appVer >= 4))
	{
		return true;
	}

	return false;
} 

function MaskNumber(obj)
{
	var keyCode;
	var keyStr;

	if(isIE())
	{
		keyCode = event.keyCode;
	}
	else
	{
		keyCode = event.which;
	}
	keyStr = String.fromCharCode(keyCode);

	var validChars = /[\d\.]/;
	var keyboardChars = /[\x00\x03\x08\x0D\x16\x18\x1A]/;

	if(!validChars.test(keyStr) && !keyboardChars.test(keyStr))
	{
		return false;
	}

	return true;
}

function FormatNumber(value)
{
	return parseFloat(value).toFixed(2);
}

function FormatCurrency(value)
{
	if(value != null)
	{
		var formatValue = value == "" ? 0 : value;
		var minussign = false;
		if(value < 0)
		{
			formatValue = Math.abs(value);
			minussign = true;
		}

		return (minussign ? "-" : "") + "$" + FormatNumber(formatValue);
	}

	return "";
}

function DisplayCurrency(value)
{
	if(value != null)
	{
		var formatValue = value == "" ? 0 : value;
		var minussign = false;
		if(value < 0)
		{
			formatValue = Math.abs(value);
			minussign = true;
		}
		return (minussign ? "-" : "") + "$" + parseFloat(formatValue).toLocaleString('en-US', {minimumFractionDigits: 2});
	}

	return "";
}

function FormatCurrencyAbs(value)
{
	return FormatCurrency(Math.abs(value));
}

function RemoveCurrency(value)
{
	var output = value.replace("$", "");
	output = output.replace("(", "-");
	output = output.replace(")", "");
	return output;
}

function FormatCurrencyEdit(obj)
{
	if(obj.value != "")
	{
		obj.value = FormatCurrency(obj.value);
	}
}

function FormatCurrencyAbsEdit(obj)
{
	if(obj.value != "")
	{
		obj.value = FormatCurrencyAbs(obj.value); 
	}
}

function RemoveCurrencyEdit(obj)
{
	if(obj.value != "")
	{
		obj.value = RemoveCurrency(obj.value); 
	}
}
