var loading = "<img src='img/ajax-loader.gif' alt='loading...'>";
var bigloading = "<div style='margin:0 auto;text-align:center;'><div><img style=\"\" src='img/tmrealtime.png' alt='logo' /></div><div><img style=\"margin-top:50px;\" src='img/loading.gif' alt='loading...' /></div></div>";

function sendPost(url, data, ref_id, load_id, script, callback, params) {

	var req = new Request.HTML({
		evalScripts:!script,
		url:url,
		method: 'post',
		data:data,
		onRequest: function() {
			if(load_id) document.getElementById(load_id).innerHTML = loading;
		},
		onComplete: function(responseTree, responseElements, responseHTML, responseJavaScript) {
			document.getElementById(ref_id).innerHTML = responseHTML;
			if(script) eval(responseJavaScript);
			if((load_id) && load_id!=ref_id) document.getElementById(load_id).innerHTML = '';
			if(callback) callback(params);
		}
	}).send();
}

/* per POST che non restituiscono niente */
function sendPostAction(url, data) {

	var req = new Request.HTML({
		url:url,
		method: 'post',
		data:data,							
		onComplete: function(responseTree, responseElements, responseHTML, responseJavaScript) {
		}
	}).send();
}

function sendPostMap(url, data, ref_id, load_id, script, callback, params) {

	var req = new Request.HTML({
		evalScripts:!script,
		url:url,
		method: 'post',
		data:data,
		onRequest: function() {
			if(load_id) document.getElementById(load_id).innerHTML = bigloading;
		},
		onComplete: function(responseTree, responseElements, responseHTML, responseJavaScript) {
			document.getElementById(ref_id).innerHTML = responseHTML;
			if(script) eval(responseJavaScript);
			if((load_id) && load_id!=ref_id) document.getElementById(load_id).innerHTML = '';
			if(callback) callback(params);
		}
	}).send();
}

