function checkNumber(a, b)
{
	if (a.value == "" ) { return true;}
  if (b == null) { b = "The number you entered is invalid. Please enter a valid number.";}
	n = EditNumeric(a.value);
	if ( n == null )
	{ window.alert(b); a.focus(); return false; }
	else { a.value = n; return true; }
}

function EditNumeric(num) {
	var l = num.length; n = ""; p = 0; d = 0;
	for(i = 0; i < l; i++)
	{
		c = num.charAt(i);
		if ((c >= "0" && c <= "9") || c == "," || c == "." || c == "-" || c == "+")
		{
			if (c == ".") { p++; }
			if (c == "-") { d++; }
			if ((c >= "0" && c <= "9") || c == "." ) { n = n + c; }
		}
		else
		{ return null; }
	}
	if ( n == "" || p > 1 || d > 1 ) { return null; }
	if ( d > 0 ) { n = n * -1; }
	return n;
}
