// Trim string
function Trim(FormInfo,Collapse)
{

	TestString = FormInfo.value
	TestString = TestString.replace(/^\s+/,"")
	TestString = TestString.replace(/\s+$/,"")
	
	if (Collapse)
	{TestString = TestString.replace(/\s+/g," ")}
	
	FormInfo.value = TestString

}

// ****************************************************************

// Remove all spaces
function RemoveSpaces(FormInfo)
{

	FormInfo.value = FormInfo.value.replace(/\s+/g,"")

}

// ****************************************************************

// Check length of string
function CheckLength(FormInfo,MinLength,MaxLength,FormDesc,ApplyFocus)
{

	if (ApplyFocus == null)
	{ApplyFocus = true}
	
	if (MinLength != "" && FormInfo.value.length < MinLength)
	{
	alert(FormDesc + " must be at least " + MinLength + " character\(s\) in length.")
	if (ApplyFocus) {FormInfo.focus()}
	return false
	}
	
	if (MaxLength != "" && FormInfo.value.length > MaxLength)
	{
	OverMax = FormInfo.value.length - MaxLength
	alert(FormDesc + " can not exceed " + MaxLength + " characters in length. The field is " + OverMax + " character(s) too long.")
	if (ApplyFocus) {FormInfo.focus()}
	return false
	}
	
	return true

}