// April 25, 2006

//*******************************************************************************'
// remove any leading or trailing spaces

function trim(strValue) // as String
{
	// if a valid string was passed....
	if (strValue.length > 0)
	{
		// remove leading spaces
		strValue = removeLeadingSpaces(strValue);
	}
	
	// if a valid string was passed...
	if (strValue.length > 0)
	{
		// remove trailing spaces
		strValue = removeTrailingSpaces(strValue);
	}
	
	// return the trimmed string
	return strValue;
}

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
// syntax version
	
function Trim(string) // as String
{
	return trim(string)
}

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
// example

/*
<script type="text/javascript" language="javascript">
function validateForm1(formObj)
{
	if (Trim(formObj.FirstName.value) == "")
	{
		alert("Please enter your first name.");
		formObj.FirstName.focus();
		return false;
	}
	else
	{
		return true;
	}
}
</script>
*/

//*******************************************************************************'
// remove any leading spaces from a string

function removeLeadingSpaces(strValue) // as String
{
	// for each space at the beginning of a string
	while (strValue.substring(0, 1) == " ")
	{
		// the string = the string less 1 character at the beginning
		strValue = strValue.substring(1, strValue.length);
	}
	
	// return the new string
	return strValue;
}

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
// syntax version

function removeleadingspaces(strValue) // as String
{
	return removeLeadingSpaces(strValue)
}

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
// syntax version

function RemoveLeadingSpaces(strValue) // as String
{
	return removeLeadingSpaces(strValue)
}

//*******************************************************************************'
// remove any trailing spaces from a string

function removeTrailingSpaces(strValue)
{
	// for each space at the end of a string
	while (strValue.substring((strValue.length - 1), strValue.length) == " ")
	{
		// the string = the string less 1 character at the end
		strValue = strValue.substring(0, (strValue.length - 1));
	}
	
	// return the new string
	return strValue;
}

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
// syntax version

function removetrailingspaces(strValue) // as String
{
	return removeTrailingSpaces(strValue)
}

//-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -'
// syntax version

function RemoveTrailingSpaces(strValue) // as String
{
	return removeTrailingSpaces(strValue)
}

