function ajax_debug(text){	if (AJAX_DEBUG_MODE){alert("RSD: " + text);}}function ajax_init_object(){
	ajax_debug("ajax_init_object() called..");	var A;
	var msxmlhttp = new Array('Msxml2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0','Msxml2.XMLHTTP.3.0','Msxml2.XMLHTTP','Microsoft.XMLHTTP');	for(var i = 0; i < msxmlhttp.length; i++){		try{A = new ActiveXObject(msxmlhttp[i]);}catch (e){A = null;}	}	if(!A && typeof XMLHttpRequest != "undefined"){A = new XMLHttpRequest();}	if(!A){ajax_debug("Could not create connection object.");}	return A;}var ajax_requests = new Array();function ajax_cancel() {
	for(var i = 0; i < ajax_requests.length; i++){ajax_requests[i].abort();}}function ajax_do_call(func_name, args){	var i, x, n;	var uri;	var post_data;	var target_id;	ajax_debug("in ajax_do_call().." + AJAX_REQUEST_TYPE + "/" + AJAX_TARGET_ID);	target_id = AJAX_TARGET_ID;	if(typeof(AJAX_REQUEST_TYPE) == "undefined" || AJAX_REQUEST_TYPE == ""){AJAX_REQUEST_TYPE = "GET";}	uri = AJAX_REMOTE_URI;    if(AJAX_REQUEST_TYPE == "GET"){		if(uri.indexOf("?") == -1){uri += "?rs=" + escape(func_name);}		else{uri += "&rs=" + escape(func_name);}		uri += "&rst=" + escape(AJAX_TARGET_ID);		uri += "&rsrnd=" + new Date().getTime();		for(i = 0; i < args.length-1; i++){			uri += "&rsargs[]=" + encodeURI(args[i]); //encodeURIComponent(args[i]); //escape(args[i]);		}		post_data = null;	}else if(AJAX_REQUEST_TYPE == "POST") {
		post_data = "rs=" + escape(func_name);
		post_data += "&rst=" + escape(AJAX_TARGET_ID);
		post_data += "&rsrnd=" + new Date().getTime();		for (i = 0; i < args.length-1; i++){			post_data = post_data + "&rsargs[]=" + escape(args[i]);		}
	}else{		alert("Lenh yeu cau khong hop le: " + AJAX_REQUEST_TYPE);	}	x = ajax_init_object();	if(x == null){		if (AJAX_FAILURE_REDIRECT != ""){location.href = AJAX_FAILURE_REDIRECT;return false;}		else{ajax_debug("Trinh duyet khong ho tro javascript:\n" + navigator.userAgent);return false;}	}else{
		x.open(AJAX_REQUEST_TYPE, uri, true);		ajax_requests[ajax_requests.length] = x;		if (AJAX_REQUEST_TYPE == "POST"){
			x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
			x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		}		x.onreadystatechange = function(){
			ajax_debug("Du lieu tra ve " + x.responseText);
			var status;			var data;			var txt = x.responseText.replace(/^\s*|\s*$/g,"");			status = txt.charAt(0);			data = txt.substring(2);			if (status == ""){	}			else if (status == "-"){alert("Error: " + data);}			else{				if (target_id != ""){document.getElementById(target_id).innerHTML = data;}				else{					try{						var callback;						var extra_data = false;						if (typeof args[args.length-1] == "object"){							callback = args[args.length-1].callback;							extra_data = args[args.length-1].extra_data;						}else{							callback = args[args.length-1];						}						callback(data, extra_data);					}catch (e){						ajax_debug("Loi duoc tim thay " + e + ": Khong the thuc thi code " + data );					}				}			}		}	}	ajax_debug(func_name + " uri = " + uri + "/post = " + post_data);
	x.send(post_data);	ajax_debug(func_name + " loading...");
	delete x;	return true;
}
