// JavaScript Document
/**
* My trim functions
*/

/**
* The right trim function will trim all the white space to the right of the string
* it will return the str with the white space removed.
* "white space       "  string passed as parameter to function "white space" string returned.
*/
function rightTrim(str){
	while(str.substring(str.length-1,str.length) == ' '){
		str = str.substring(0,str.length-1);
	}
	return str;
}

/**
* The reft trim function will trim all the white space to the left of the string
* it will return the str with the white space removed.
* "      white space"  string passed as variable to function "white space" string returned.
*/
function leftTrim(str){
	while(str.substring(0,1) == ' '){
		str = str.substring(1,str.length);
	}	
	return str;
}

/**
* The  trim function will trim all the white space to the left and to the right  of the string
* it will return the str with the white space removed.
* "      white space         "  string passed as variable to function "white space" string returned.
*/
function trim(str){
	while(str.substring(str.length-1,str.length) == ' '){
		str = str.substring(0,str.length-1);
	}
	while(str.substring(0,1) == ' '){
		str = str.substring(1,str.length);
	}	
	return str;
}