function trimString(str) {
	//	Remove leading whitespaces
	var strwork = str;
	while (strwork.charAt(0) == ' '  || strwork.charAt(0) == '\t' ||
		   strwork.charAt(0) == '\r' || strwork.charAt(0) == '\n') {
		strwork = strwork.substring(1,strwork.length);
	}
	return strwork;
}

function replaceAll(str, strremove, stradd)  {

	var strwork = str;
    while (strwork != strwork.replace(strremove, stradd))  {
       strwork = strwork.replace(strremove, stradd);
    }
    return strwork;
}

function FixStringQuotes(str)  {

   var strwork = replaceAll(str, "\'", "\\SQ\\");
   strwork = replaceAll(strwork,"\\SQ\\", "\\\'");
   strwork = replaceAll(strwork,"\"", "&quot;");
   return strwork
   
}
