function SendMail(form)
{
	nome = form.nome.value;
	email = form.email.value;
	telefono = form.telefono.value;
	richiesta = form.richiesta.value;
	Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	if (Filtro.test(trim(email)) && trim(richiesta)!= "")
	{
		LoadGeneric("richiesta-info.php?nome="+nome+"&telefono="+telefono+"&email="+email+"&richiesta="+richiesta,"result_email");
	}
	else
	{
		document.getElementById("result_email").innerHTML = "Inserire una richiesta ed un indirizzo valido.";	
	}
}

function LoadGeneric(page,mycontent)
{
	var content = document.getElementById(mycontent);
    var url = page;
    var preloadText = "Caricamento in corso...";
    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) 
    {
		content.innerHTML = preloadText;
        x.onreadystatechange = function() 
		{
			if (x.readyState == 4 && (x.status == 200))
            {
            	content.innerHTML = x.responseText;
            }
        }
        x.open("GET", url, true);
        x.send(null);
    }
}

function trim(stringa)
{
	return stringa.replace(/^\s*/, "").replace(/\s*$/, "");
}
