
function isInteger(InString)
    {
    //Returns true if value is a number 
    //otherwise returns false   

    if ( InString.length == 0)
        return false;

    //Returns true if value is an integer defined as
    //   having an optional leading + or -.
    //   otherwise containing only the characters 0-9.
        var decimal_format = ".";
        var check_char;

    //The first character can be + -  blank or a digit.
        check_char =  InString.indexOf(decimal_format)
    //Was it a decimal?

    if (check_char < 1)
        return isNumberString( InString);
    else
        return false;
    }
    
function isWithinRange (InString, RangeMin, RangeMax)  {

        if ((InString == null) || (InString == "")) 
                return (false) 

        if (!isNumberString(InString))
                return (false)  

    // check minimum
    if (RangeMin != null)
        {
        if (InString < RangeMin)
                return false;
        }

    // check maximum
    if (RangeMax != null)
        {
        if (InString > RangeMax)
                return false;
        }
        
    //All tests passed, so...
    return true;

}


function isNumberString( InString)
    {
    //Returns true if value is a number 
    //otherwise returns false   

    if ( InString.length == 0)
        return false;

    //Returns true if value is a number defined as
    //   having an optional leading + or -.
    //   having at most 1 decimal point.
    //   otherwise containing only the characters 0-9.
        var start_format = " .+-0123456789";
        var number_format = " .0123456789";
        var check_char;
        var decimal = false;
        var trailing_blank = false;
        var digits = false;

    //The first character can be + - .  blank or a digit.
        check_char = start_format.indexOf( InString.charAt(0))
    //Was it a decimal?
        if (check_char == 1)
            decimal = true;
        else if (check_char < 1)
                return false;
        
        //Remaining characters can be only . or a digit, but only one decimal.
        for (var i = 1; i <  InString.length; i++)
        {
                check_char = number_format.indexOf( InString.charAt(i))
                if (check_char < 0)
                        return false;
                else if (check_char == 1)
                {
                        if (decimal)            // Second decimal.
                                return false;
                        else
                                decimal = true;
                }
                else if (check_char == 0)
                {
                        if (decimal || digits)  
                                trailing_blank = true;
        // ignore leading blanks

                }
                else if (trailing_blank)
                        return false;
                else
                        digits = true;
        }       
    //All tests passed, so...
    return true
    }
    

function isNumOrChar (InString)  {

        if(InString.length!=1) 

                return (false);

        InString=InString.toLowerCase();

        RefString="1234567890abcdefghijklmnopqrstuvwxyz";

        if (RefString.indexOf (InString, 0)==-1)  

                return (false);

        return (true);

}
    
function DecimalPlace( InString, Place)
{
  Temp = (""+InString)
  if (Temp.indexOf(".") == -1)
     SLen = Temp.length
  else
     SLen = Temp.indexOf(".") + Place + 1
  return Temp.substring(0,SLen)
}

// JavaScript sees numbers with leading zeros as octal values, so strip zeros
function stripZeros(inputStr) {
	var result = inputStr
	while (result.substring(0,1) == "0") {
		result = result.substring(1,result.length)
	}
	return result
}