// Add a method to the String object's prototype that removes any leading 
// and trailing spaces and/or carriage returns/linefeeds from a String object.
String.prototype.trim = function()
{
	// Declare local variables...
	var temp;											// work variable
	var whiteSpace = 32;					// ASCII code for a space
	var lineFeed = 10;						// ASCII code for a linefeed
	var carriageReturn = 13;			// ASCII code for a carriage return

	// Assign strStringToTrim to a temporary work variable.
	temp = this.valueOf();
								
	// Remove any leading spaces/linefeeds/carriage returns from the string.
	while ((temp.charCodeAt(0) == whiteSpace) || (temp.charCodeAt(0) == lineFeed) || (temp.charCodeAt(0) == carriageReturn))
	{			
		temp = temp.substr(1);
	}
					
	// Now remove any trailing spaces/linefeeds/carriage returns.
	while((temp.charCodeAt(temp.length - 1) == whiteSpace) || (temp.charCodeAt(temp.length - 1) == lineFeed) || (temp.charCodeAt(temp.length - 1) == carriageReturn))
	{
		temp = temp.substr(0, temp.length - 1);
	}
	
	return temp;
}	


