


function fnTrim(strString)
{
// white space consist of (blank,tab,newline)
	var intLeftIndex = 0; //Store position of first non-white space from leftmost side
	var intRightIndex = 0; //Store position of first non-white space from rightmost side
	var blnFound = false; //Check for any non-white space character
	var regExp = /\S+/; 
	var intCount;
	if (strString.search(regExp) == -1) //Check for non-white space character
	{
		strString = ""; //Valid character not found then return empty string
		return(strString);
	}

	//If  atleast one non-white space character found.
	for (intCount=0;intCount < strString.length; intCount++)
	{
		if (strString.charAt(intCount) != " ") // Checking for first non-white spaces 
											// from left side
		{
			intLeftIndex = intCount - 1;
			break;
		}
	}
	for (intCount=strString.length - 1;intCount >= 0; intCount--)
	{
		if (strString.charAt(intCount) != " ") // Checking for first non-white spaces 
											// from Right most side
		{
			intRightIndex = intCount + 1;
			break;
		}
	}

	strString=strString.substring(intLeftIndex+1,intRightIndex); //Remove leading and trailing
														// spaces
	return (strString);
}

