function inviaRichiesta(url,formName)
{
	element = document.getElementById("result");
	res = checkCampiInfo();
	if(res)
	{
		if(typeof XMLHttpRequest != "undefined") 
		{ 
				x = new XMLHttpRequest();
		}
		else 
		{ 
			try { x = new ActiveXObject("Msxml2.XMLHTTP");} 
			catch (e) { try { x = new ActiveXObject("Microsoft.XMLHTTP");} catch (e){x = null;}}
		}
		if (x) 
		{
			element.innerHTML = "Invio richiesta in corso...";
			x.onreadystatechange = function() 
			{
				if (x.readyState == 4 && (x.status == 200))
				{
					element.innerHTML = x.responseText;
				}
			}
			x.open("GET", url + caricaForm(formName), true);
			x.send(null);
		}
	}
}

function checkCampiInfo()
{
	resdiv = document.getElementById("result");
	var res = true;
	if(trim(document.informazioni.email.value)==""&&trim(document.informazioni.telefono.value)=="")
	{
		resdiv.innerHTML = 'Inserire Indirizzo Email o Telefono.';
		res = false;
	}
	else if(trim(document.informazioni.nome.value)==""||trim(document.informazioni.cognome.value)=="")
	{
		resdiv.innerHTML = 'Inserire Nome e Cognome.';
		res = false;
	}
	else if(trim(document.informazioni.dal.value)==""||trim(document.informazioni.al.value)=="")
	{
		resdiv.innerHTML = 'Inserire Periodo Richiesta.';
		res = false;
	}
	return res;
}

function caricaForm(formName)
{
	returnString = "";
    formElements=document.forms[formName].elements;
    returnString += "?" +formElements[0].name+"="+formElements[0].value;
    for(i=1;i<formElements.length;i++) {
		if(formElements[i].type != "button" && formElements[i].type != "reset")
                returnString+="&"+formElements[i].name+"="+formElements[i].value;
     }
     return returnString;
}

function trim(stringa)
{
	return stringa.replace(/^\s*/, "").replace(/\s*$/, "");
}
