	function getEl(id){
		return document.getElementById(id);	
	}
	
	function swDiv(id,txt,ok){
		var obj = getEl(id);
		if(ok){
			obj.style.display='block';
			obj.innerHTML = txt;
		}else{
			obj.style.display='none';
		}
	} 

	function getXhr(){
		var xhr = null;
		if(window.XMLHttpRequest) // Firefox et autres
			xhr = new XMLHttpRequest();
		else if(window.ActiveXObject){ // Internet Explorer
			try {
				xhr = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		else {
			alert("Il vostro navigatore non sopporta gli oggetti XMLHTTPRequest...");
			xhr = false;
		}
		return xhr;
	}
	
	function doactionCapa(url,vars,out){
		var xhr = getXhr();
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){
				result = xhr.responseText;
				getEl('okCapa').value=result;
				swDiv(out,result,true);
			}
		}
		xhr.open("POST",url,true);
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr.send(vars);
	}
	
	function doactionSend(url,loc,vars,out){
		var xhr = getXhr();
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){
				result = xhr.responseText;
				location.href=loc+'?send=ok';
			}
		}
		xhr.open("POST",url,true);
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr.send(vars);
	}
	