//** Checks to see if the form element is numeric
//** eobj=field,eid=error text,comma=true allow commas,Pos=Numeric Positions allowed,Future Sign Allowed 0=no

function IntegerCheckField(eobj, eid, length, comma, sign) 
{
	message = '';
	if (!IntegerCheck(eobj, eid, length, comma, sign))
	{
		alert(message);
		return (false);
	}
	return (true);
}

function IntegerCheckDefField(eobj, eid, length, comma, sign) 
{
	if (eobj.value.length == 0)
		eobj.value = 0;
	
	message = '';
	if (!IntegerCheck(eobj, eid, length, comma, sign))
	{
		alert(message);
		return (false);
	}
	return (true);
}	


//*******************
//** Function - IntegerCheck
//**            
//** Checks to see if the form element is numeric
//** eobj=field,eid=error text,comma=true allow commas,Pos=Numeric Positions allowed,Future Sign Allowed 0=no
//*******************

function IntegerCheck(eobj, eid, Pos, comma, sign)
{
	estring=eobj.value;
    errormsg = '';
	x=0;
	var ostring= new String();
	var rstring='';
	
	for (j=0; j < estring.length; j++)
	{
		if ((estring.substring(j, j+1) < "0") ||
		    (estring.substring(j, j+1) > "9"))
		 	if ((estring.substring(j, j+1) != ",") ||
			    ((estring.substring(j, j+1) == ",") && (!comma)))
				{
				errormsg = ' must be numeric.';
				break;
				}
			else;
		else
		{
			ostring = ostring + estring.substring(j, j+1);
			x++;
		}
	}


	if ((estring.length > 0) && (x == 0))
		errormsg = ' must be numeric.';
	else
	{
	    if (x > Pos)
		{
			errormsg = ' exceeds size allowed. Maximum size is ('
			for (j=0; j < Pos; j++)
			{
				if (comma && (Pos-j)%3 == 0 && (j > 0))
					errormsg = errormsg + ',';
				errormsg = errormsg + '9';
			}
			errormsg = errormsg + ').';
		}
	}
	
	if (errormsg != '')  
	{
		if (message == '')
		    eobj.focus();
		message = message + '\n  * ' + eid + errormsg;
		return (false);
	}


	if (eobj.value.length > 0 && comma)
	{
		for (j=0; j < x; j++)
		{
			if (((x-j)%3 == 0) && (j > 0))
				rstring = rstring + ',';
			rstring = rstring + ostring.substring(j, j+1);
		}
		eobj.value = rstring;
	}
	return (true);
}
