
	/* functions.js */
	
function RTrim(String)
{
	var i = 0;
	var j = String.length - 1;

	if (String == null)
		return (false);

	for(j = String.length - 1; j >= 0; j--)
	{
		if (String.substr(j, 1) != ' ' &&
			String.substr(j, 1) != '\t')
		break;
	}

	if (i <= j)
		return (String.substr(i, (j+1)-i));
	else
		return ('');
}

function LTrim(String)
{
	var i = 0;
	var j = String.length - 1;

	if (String == null)
		return (false);

	for (i = 0; i < String.length; i++)
	{
		if (String.substr(i, 1) != ' ' &&
		    String.substr(i, 1) != '\t')
			break;
	}

	if (i <= j)
		return (String.substr(i, (j+1)-i));
	else
		return ('');
}
function TrimAll(String)
{
	if (String == null)
		return (false);

	return RTrim(LTrim(String));
}

function format(expr, decplaces)
{
	// raise incoming value by power of 10 times the
	// number of decimal places; round to an integer; convert to string
	var str = "" + Math.round (eval(expr) * Math.pow(10,decplaces));

	// pad small value strings with zeros to the left of rounded number
	while (str.length <= decplaces)
	{
		str = "0" + str;
	}
	
	// establish location of decimal point
	var decpoint = str.length - decplaces;
	
	// assemble final result from: (a) the string up to the position of
	// the decimal point; (b) the decimal point; and (c) the balance
	// of the string. Return finished product.
	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}

function isNumber(inputstr)
{
	var txt = TrimAll(inputstr);
	var len = txt.length;
	if (len > 0){
		var intFlag = 0;
		for (var i = 0; i < len; i++){
			var theChar = txt.substring(i, i+1);
			if (theChar < "0" || theChar > "9"){
				intFlag = 1;
				break;
			}
		}
		if (intFlag == 1){
			return 0;
		}
	}
	return 1;
}