// 作用：去除字符串首末空格
function str_Trim(str){ 
	str = str.replace(/(^\s*)/g, "");
	str = str.replace(/(\s*$)/g, "");
	return str;
}

// 作用：文本字符解码
// 说明：调用页面使用 str_UnTextReplace(true||false, string)
//		 将编码的 '"<>& 替换回原字符
function str_UnTextReplace(base, str){
	if(base){
		str=str_UnBaseReplace(str);
	}
	return str;
}
function str_UnBaseReplace(str){
	str=str.replace("&amp;","&");
	str=str.replace("&quot;","\"");
	str=str.replace("&#39;","'");
	str=str.replace("&lt;","<");
	str=str.replace("&gt;",">");
	return str;
}

// 作用：文本字符编码
// 说明：调用页面使用 str_TextReplace(true||false, true||false, string)
//		 替换掉指定字符串内的 '"<>& 或HTML标记，在传递时，这些标记将影响
//		 到程序
function str_TextReplace(base, blank, str){
	if(base){
		str=str_BaseReplace(str);
	}
	if(blank){
		str=str_AllReplace(str);
	}
	return str;
}
function str_BaseReplace(str){
	str=str.replace(/\&/g,"&amp;");
	str=str.replace(/\"/g,"&quot;");
	str=str.replace(/'/g,"&#39;");
	str=str.replace(/</g,"&lt;");
	str=str.replace(/>/g,"&gt;");
	return str;
}
function str_AllReplace(str){
	str=str.replace(/\s/g,"");
	return str;
}

// 作用：调用 Ajax 方法传递值时，替换 "&" 为 "^"
// 原因：传递使用 Variable1=Value1&Variable2=Value2 时，
//		 如果值内带有 "&" 将与传递的分隔符产生冲突，在接
//		 收页面需要使用 str_UnSendReplace(str) 方法替换
//		 回原值
function str_SendReplace(str){
	str = str.replace(/\&/g,"^");
	return str;
}
