$(document).ready(function(){
	$('.warning').remove();
	$.get("token.php",function(txt){
		$(".secure").append('<input type="hidden" name="sure" value="'+txt+'" />');
		$(".richiesta").append('<br /><br /><strong>Scrivi quanto fa la somma di: '+txt.charAt(7)+' + '+txt.charAt(9)+'<br /><span style="font-size: 12px">(Ci scusiamo ma questa operazione e\' necessaria<br />per evitare email di spam)</span></strong><br /><input type="text" name="captcha" value="" size="30" />');
	});
});

function checkTel(telefono)
{
if(telefono.length > 0)
	{
		if (isNaN(telefono)) document.getElementById("tel").innerHTML = "<b>  <img src=\"error.png\" width=\"18\" height=\"18\" />  Inserire un numero e non un testo</b>";
		else document.getElementById("tel").innerHTML = "<b>  <img src=\"ok.png\" width=\"18\" height=\"18\" /></b>";
	}
}

function checkEmail(email)
{
if(email.length > 0)
   {
		if (email.indexOf(' ') >= 0)
			document.getElementById("mail").innerHTML = "<b>  <img src=\"error.png\" width=\"18\" height=\"18\" />  Non si possono inserire spazi nella casella email</b>";
		else if (email.indexOf('@') == -1)
			document.getElementById("mail").innerHTML = "<b>  <img src=\"error.png\" width=\"18\" height=\"18\" />  Un indirizzo email valido deve contenere una '@'</b>";
		else if (email.indexOf('.') == -1)
			document.getElementById("mail").innerHTML = "<b>  <img src=\"error.png\" width=\"18\" height=\"18\" />  Un indirizzo email valido deve contenere almeno un '.'</b>";
		else document.getElementById("mail").innerHTML = "<b>  <img src=\"ok.png\" width=\"18\" height=\"18\" /></b>";
   }
}
