/*functions to set the text feilds numeric
  triggered when the value change*/

function setNumeric(obj1)
	{
	val=obj1.value
	val = val.replace(/[^0-9.-]/g, ''); // strip non-digit chars
	val = stripDuplicateChars(val, '.', 1, 0); // strip excess decimals
	val = stripDuplicateChars(val, '-', 0, 1); // strip excess minus signs
//	val=Math.round(val)
	obj1.value = val> 0 ? val: "" ; // replace textbox value

	if (!isFloatingPointNumber(val))
		{ alert('This is not a valid number, please correct it...');}

	}
function isFloatingPointNumber(val)
	{
	var fpnum = /^-{0,1}\d*\.{0,1}\d*$/g;
	if (fpnum.test(val))
		{return true;} 
	else {return false;}
	}
function stripDuplicateChars(str, strip, n, s)
	{
	var count=0; var stripped=str.substring(0, s); var chr;
	for (var i=s; i<str.length; i++)
		{ 
		chr = str.substring(i, i+1);
		if (chr == strip)
			{ 
			count++; 
			if (count<n+1)
				{ 
				stripped = stripped + chr;
				}
			}
		else 
			{
			stripped = stripped + chr;}
		} 
	return stripped;
	}

