/*
	Ajax and XML RPC Tool
	Author : Chonlasith Jucksriporn

	Requirement :	Javascript 1.1

	Description : Use for Ajax/XMLRPC calls.
	
	Revision :
	8/8/2549 - U/Release
	23/8/2549 - U/Add RPCCall function
	26/9/2549 - U/Add Text mode for RPCCall function
*/
function clsAjaxMini()
{
	var ajx = {
		LoadSync : function(method, url, parameters, textmode)
		{
			var xmlh = new ActiveXObject("MSXML2.XMLHTTP");
			var curl = "";
			var getmethod = (method.toLowerCase()=="get");
			if (getmethod)
			{
				if (url.charAt(url.length - 1) == "?")
				{
					curl = url + (parameters?parameters:"");
				}
				else
				{
					curl = url + (url.match(/\?/) ? '&' : '?') + parameters;
				}
			}
			else
				curl = url;
			xmlh.open(method, curl, false);
			//if (!getmethod && !nonform)
			if (!getmethod)
			{
				xmlh.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			}
			xmlh.send((!getmethod)?parameters:null);
			if (textmode==true)
			{
				return (xmlh.responseText);
			}
			return (xmlh.responseXML);
		},
		RPCCall : function(url, parameters, textmode)
		{
			var xmlh = new ActiveXObject("MSXML2.XMLHTTP");
			xmlh.open("POST", url, false);
			xmlh.send(parameters);
			if (textmode==true)
			{
				return (xmlh.responseText);
			}
			return (xmlh.responseXML);
		}
	};
	return ajx;
}

