/** Removes leading spaces */ 
function ltrim(string)
{
	var newString=string;
	
	if (newString.charAt(0)==' ')
	{
		var pos;
		for (pos=0;pos<newString.length&&newString.charAt(pos)==' ';++pos);
		newString=newString.substring(pos);
	}
	
	return newString;
}

/** Removes trailing spaces */
function rtrim(string)
{
	var newString=string;
	
	if (newString.charAt(newString.length-1)==' ')
	{
		var pos;
		for (pos=newString.length-1;pos>=0&&newString.charAt(pos)==' ';--pos);
		newString=newString.substring(0,pos+1);
	}
	
	return newString;
}

/** Removes leading and trailing spaces */
function trim(string)
{
	return rtrim(ltrim(string));
}