	function swap (immagine,nuova)
	{
		document.images[immagine].src = "images/" + nuova;
	}
	
	function check_telefono (telefono)
	{
		var telefonopattern = /^(0|3)\d{1,10}$/;
		if (! telefonopattern.test (telefono))
		{
			alert ("Il campo telefono è errato o assente (ricordarsi di inserire anche il prefisso).");
			return false;
		}
		return true; 
	}
	
	function check_cap (cap)
	{
		var cappattern = /^(\d){5}$/;
		if (! cappattern.test (cap))
		{
			alert ("Il campo CAP è errato o assente.");
			return false;
		}
		return true; 
	}
	
	function check_null (da_testare,campo)
	{
		if (da_testare == "")
		{
			alert ("Il campo " + campo + " è obbligatorio.");
			return false;
		}
		return true;
	}
	
	function check_mail (mail)
	{
		var mailpattern = /^([^@])+@([^@])+(.([^@])+)+$/;
		if (! mailpattern.test (mail))
		{
			alert ("Il campo mail è errato o assente.");
			return false;
		}
		return true; 
	}
	
	function check_codfiscale (codice)
	{
		var codicepattern = /^([a-zA-Z]){6}(\d){2}[a-zA-Z](\d){2}[a-zA-Z](\d){3}[a-zA-Z]$/;
		if (! codicepattern.test (codice))
		{
			alert ("Il campo codice fiscale è errato o assente.");
			return false;
		}
		return true; 
	}
	
	function check_piva (piva)
	{
		var pivapattern = /^(\d){11}$/;
		if (! pivapattern.test (piva))
		{
			alert ("Il campo partita IVA è errato o assente.");
			return false;
		}
		return true; 
	}
	
	function check_consenso (valore)
	{
		if (!valore)
		{
			alert ("E' necessario consentire al trattamento dei dati personali per completare l'operazione richiesta.");
			return false;
		}
		return true;
	}
	
	function isNumber (numero)
	{
		var numpattern = /^(\d)+$/;
		if (! numpattern.test (numero)) return false;
		return true; 
	}
	
	function checkform ()
	{
		with (document.forms["ordine"])
		{
			var temp = true;
			//temp = temp && check_mail (email.value);
			temp = temp && check_cap (cap.value);
			temp = temp && check_telefono (telefono.value);
			temp = temp && check_null (nome.value);
			temp = temp && check_null (cognome.value);
			temp = temp && check_null (indirizzo.value);
			temp = temp && check_null (citta.value);
			temp = temp && check_null (provincia.value);
		}
		return temp;
	}