// JSAjaxRequest class
JSAjaxDoc = function(owner, callback, user_word) {
	this.m_owner = owner;
	this.m_callback = callback;
	this.m_userword = user_word;
	this.m_url = '';
	this.m_method = 'POST';
	this.m_async = true;
	this.m_data = {};
}
JSAjaxDoc.prototype = new Object;

/*
**	static declarations
*/
JSAjaxDoc.s_xmlObject = null;			// the xml object match to the browser
JSAjaxDoc.s_requests = new Object();
JSAjaxDoc.s_canSend = true;
JSAjaxDoc.s_pendingRequests = new Array();
JSAjaxDoc.s_defaultTimeout = 25000;

/*
**	statuses
**/
var STATUS_TIMEOUT = 1;
var STATUS_FAILED = 2;
var STATUS_READY = 3;

JSAjaxDoc.prototype.clearParams = function() {
	this.m_data = {};
}

JSAjaxDoc.prototype.addParam = function(key, value) {
	//this.m_data.set(key, value);
	this.m_data[key] = value;
}

JSAjaxDoc.prototype.getParams = function() {
	return this.m_data;
}

JSAjaxDoc.prototype.send = function(url, method, async) {
	try {
		var loader = $("meemix-loading");
		loader.style.display = "block";
		document.body.style.cursor = "wait";
	} catch( e ) {};

	if (typeof async == "undefined") async = true;
	if (typeof method == "undefined") method = 'post';
	if (method == "get" || method == "GET") rp_adsRefresh('ajax');
	
//	for (var i in this.m_data) {alert(i+": "+this.m_data[i]);}
	new Ajax.Request(url,	
	  {
		user_word: this.m_userword,
		asynchronous: async,
		method: method,
		parameters:this.m_data, 
		onSuccess:  this.m_owner[this.m_callback]	    
	  });	
}