<!-- formutils.vm -->
function FormUtils()
{
	// Constants
	this.SUCCESS = 0
	this.INVALID_CHAR_ENCOUNTERED = 1;
	this.MAX_LENGTH_EXCEEDED = 2;
	this.MIN_LENGTH_EXCEEDED = 3;
	
}

#if ($includeStringValidator)
#if (false)
/*----------------------------------------------------------------*\
| This method determines if the specified string is formatted      |
| properly.														   |
|																   |
| @param validator The validator to use.						   |
| @param s The username.								   		   |
| @param allowEmpty Flag indicating whether empty is alllowed.	   |
| @return Error code indicating the result of the operation.	   |
|         Possible Values:										   |
|							SUCCESS = 0							   |
|							INVALID_CHAR_ENCOUNTERED = 1;		   |
|							MAX_LENGTH_EXCEEDED = 2;			   |
|							MIN_LENGTH_EXCEEDED = 3;			   |
\*----------------------------------------------------------------*/
#end
	FormUtils.prototype.isStringFormatValid = function (validator,s,allowEmpty)
	{
		var result = this.SUCCESS;
		if (s.length > 32)
		{
			result = this.MAX_LENGTH_EXCEEDED;
		}
	    else if (s.length > 0)
	    {
		    for (var i = 0; i < s.length; i++)
		    {
		        // Check that current character is a valid password character.
		        var c = s.charAt(i);
				
		        if (!validator(c))
		        {
		        	result = this.INVALID_CHAR_ENCOUNTERED;
		        	break;
		        }
		    }
		}
		else if (!allowEmpty)
		{	
			result = this.MIN_LENGTH_EXCEEDED;
		}
		
	    return result;
	}

#if (false)
/*----------------------------------------------------------------*\
| This method determines if the specified char is a letter.		   |
|																   |
| @param c A character.								   			   |
| @return true if the character is a letter; otherwise false.	   |
\*----------------------------------------------------------------*/
#end
	FormUtils.prototype.isLetter = function (c)
	{	
		return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) );
	}
	
#if (false)
/*----------------------------------------------------------------*\
| This method determines if the specified char is a digit.		   |
|																   |
| @param c A character.								   			   |
| @return true if the character is a digit; otherwise false.	   |
\*----------------------------------------------------------------*/
#end
	FormUtils.prototype.isDigit = function (c)
	{	
		return ((c >= "0") && (c <= "9"))
	}
	
#end