/* Centralisation des appels Ajax */

/* Objet Request : permet de faire une requete Ajax au serveur */
var Request = function Request() {
	Request.prototype.url = '';
	Request.prototype.method = 'GET';
	Request.prototype.params = {};
	Request.prototype.callback = {};
	Request.prototype.ajaxload = {};
	Request.prototype.ajaxcomplete = {};
	
	Request.prototype.send = function() {
	new Ajax.Request(this.url,{ 
			"method": this.method, 
			"parameters": this.params, 
			"onLoading": this.ajaxload,
			"onComplete": this.ajaxcomplete,			
			"onSuccess": this.callback,
			"onFailure": this.ajaxfailure
		});
	};

	Request.prototype.sendGetLite = function(url,callback) {
		this.url = url;
		this.method = 'GET';
		this.params = null;
		this.callback = callback;
		this.send();	
	};
	Request.prototype.sendGet = function(url,callback,ajaxload,ajaxcomplete,ajaxfailure) {
		this.url = url;
		this.method = 'GET';
		this.params = null;
		this.callback = callback;
		this.ajaxload = ajaxload;
		this.ajaxcomplete = ajaxcomplete;
		this.ajaxfailure = ajaxfailure;
		this.send();	
	};	

	Request.prototype.sendPost = function(url,params,callback) {
		this.url = url;
		this.method = 'POST';
		this.params = $H(params).toQueryString();
		this.callback = callback;
		this.send();
	};
		
	Request.prototype.ajaxfailure = function() {
		alert('AJAX CALL ERROR');
	};
	
};
/* Objet pceAjax, instanciation de la classe Request */
var pceAjax = new Request();

