function ltrim(str) {
	if (str) {
		return str.replace(/^[ \t\n\r]+/g, "");
	}
	return str;
}

function doAlert(ajax) {
	alert(ltrim(ajax.getResponseText()));
}

/**
 * @deprecated
 */
function alertByXmlHttp(url) {
	var req = new com.trs.cds.js.ajax.AjaxRequest();
	req.setUrl(url);
	req.setOnLoad(doAlert, req);
	req.load();
}

/**
 * Ajax Util.
 * @author ls, 2006-0920
 * @requires Prototype
 */
 function AjaxUtil() {
 }
 
 AjaxUtil.prototype = {
 	
 	/**
 	 * @param {String} url XMLHTTP URL
 	 * @param {String} eleId HTML ID
 	 * @param {String} params XMLHTTP Params
 	 * @param {boolean} isPost true means post, otherwise get.
 	 */
 	loadText: function(url, eleId, params, isPost) {
		var el = $(eleId);
		if (el == null) {
			return;
		}
		
		this.el = el;
	    new Ajax.Request( url,
                        {method: (isPost) ? "post" : "get", 
                        parameters: params, 
                        onComplete: this.updateElement.bind(this)} );
 	},
 	
 	updateElement: function(request) {
 		this.el.innerHTML = request.responseText;
 	},
 	
 	alertXHRText: function(url, params, isPost) {
	    new Ajax.Request( url,
                        {method: (isPost) ? "post" : "get", 
                        parameters: params, 
                        onComplete: this.alertText.bind(this)} );
 	},
 	
 	alertText: function(request) {
 		alert( ltrim(request.responseText) );
 	}
 	
 }