/* ====================================================================

	File Name:	Decimal_round.js
	Purpose:	This will correctly round any number.
				Normal java math library truncates numbers
	Developer:	Bill Quinlan AG Consulting ADP National Hosting Center
	Copyright:	August 2000
   	Modifications:
	  Date		Developer	Change
	------------	---------------	----------------------------
	Auguust 2000	Bill Quinlan	Genisis
   =================================================================	
*/
/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
	PURPOSE: Round a number field
	INPUT  : Field Value,  decimals to round to
	RETURNS: properly rounded number
	NOTES  : 
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* */	
function DecimalRound(fVal, nDecimals)
{
	if (fVal >= 0)
		var s1 = Math.round(fVal*Math.pow(10,nDecimals+1)) + 5;
	else
		var s1 = Math.round(fVal*Math.pow(10,nDecimals+1)) - 5;


	s1 = "" + s1;
	if (fVal < 0)
		s1 = s1*-1;
		
	while (s1.length <= nDecimals+1)
	{
		s1 = "0" + s1;
	}
	
	if (fVal < 0)
		s1 = "-0"+s1;

	var nDec = s1.length - nDecimals - 1;

	return s1.substring(0,nDec) + "." + s1.substring(nDec,s1.length-1);
}
