//自定字串的trim()
String.prototype.Trim  = function(){return this.replace(/(^s*)|(s*$)/g,"");}
String.prototype.Ltrim = function(){return this.replace(/(^s*)/g,"");}
String.prototype.Rtrim = function(){return this.replace(/(s*$)/g,"");}

//檢查字串長度，中文字算二個字元
function LenC(str1) {
	str1=str1.replace(/[^\u0000-\u00ff]/g," a a ");
	str1=str1.replace(/\b([a-z0-9]+)\b/gi," a ");
	str1=str1.replace(/\s/g,"");
	result = str1.length;
}

//檢查字串是否由數字組成
function IsNum(str) {return str.match(/D/)==null}

//建立XML物件
//因應各Browser版本產生XMLHTTP的方式不同
function GlobalXMLHttpRequestCreator() {
	var XmlHttpReqObj = null;
	try
	{
		XmlHttpReqObj = new XMLHttpRequest();
	}
	catch( ex1 )
	{
		try
		{
			XmlHttpReqObj = new ActiveXObject("MSXML2.XMLHTTP");
		}
		catch( ex2 )
		{
			try
			{
				XmlHttpReqObj = new ActiveXObject("Microsoft.XMLHTTP.1");
			}
			catch( ex3 )
			{
				XmlHttpReqObj = null;
			}
		}
	}
	return XmlHttpReqObj;
}