/* ======================================================================
FUNCTION:	FormatMoneyStr - Copyright (c) 1997-98. NetObjects, Inc. All Rights Reserved.

INPUT:		str (string) - a string representing a money value in dollars
								   or dollars and cents

RETURNS:		a string representing the input value in dollars
				with two decimal places for cents;
				returns null if invalid arguments were passed

DESC:			This function ensures all values of dollars and cents appear with two
				decimal places representing cents after the dollar amount, e.g. $12.00.
				This prevents oddly formatted values such as $12.5 by replacing it with
				$12.50.  Note that this function does not add the '$' character.
====================================================================== */
function FormatMoneyStr( str ) {
	resultStr = "";

	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str+"" == "null")	
		return null;
	
	// Make sure argument is a string
	str += "";
	
	// Get the index of the decimal point.
	idx = str.indexOf(".");
	
	// If there is no decimal point, add ".00"
	if (idx < 0)
		resultStr = str + ".00";
	else
	{
		resultStr = str.substring(0, idx + 3);
		if (resultStr.length < (idx + 3)) 
			resultStr += "0";
	}
	
	return resultStr;
} // end FormatMoneyStr

