/**
 * Ensemble des fonctions pour le remote scripting
 */
function rsClient(server_url)
{
	this.server = server_url;
	this.xmlhttp = (window.XMLHttpRequest) ? new XMLHttpRequest() : false ;

	// Le premier argument doit être le nom de la fonction
	this.query = function (args) {
		var xmlh = (! this.xmlhttp) ? new ActiveXObject('Microsoft.XMLHTTP') : this.xmlhttp;

		xmlh.open('POST', this.server, false);
		xmlh.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

		var query = "__rs_function=" + args[0];
		for(var i = 1; i < args.length; i += 2)
		{
			query += "&" + args[i] + "=" + escape(args[i + 1].toString());
		}

		xmlh.send(query);
		return xmlh.responseText;
	};

	this.query_xml = function () {
		var node = document.createElement('rs_answer');
		node.innerHTML = this.query(arguments);
		return node;
	};

	this.query_text = function () {
		return this.query(arguments);
	};
}
