// ===================================
// Check Input For Contatti.asp
// ===================================


	// ---------------------------------------------------------------
	// Consente l'inserimento SOLO dei caratteri permessi
	// ---------------------------------------------------------------

	function CheckInput (obj, cStr, nTipo)
	{
		var ckStringa = " 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzàéèìòù<=>#@°'*/+.-_,!?^(&%$£)";
		var ckNumber = "0123456789";
		var ckTelefonNumber = " 0123456789./-";
		var ckEMail = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_@";
		var ckFiscale = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
		var ckFloat = "0123456789.";

		var ckOK = "";
		var ckStr = obj.value;

		ckOK = ckStringa;
		if (nTipo == 1) ckOK = ckStringa;			// Campo Tipo Stringa
		if (nTipo == 2) ckOK = ckNumber;			// Campo Numero Generico
		if (nTipo == 3) ckOK = ckTelefonNumber;		// Campo Numero Telefonico
		if (nTipo == 4) ckOK = ckEMail;				// Campo E-mail
		if (nTipo == 5) ckOK = ckFiscale;			// Campo Dati Fiscali
		if (nTipo == 6) ckOK = ckFloat;				// Campo Numero Decimale

		// alert(ckStr + '\n' + ckOK);

		if (ckStr.length > 0) 
		{
			var ok = true;

			for (i=0; i < ckStr.length;  i++)  
			{
				for (j=0; j < ckOK.length;  j++)
				{
					if (ckStr.charAt(i) == ckOK.charAt(j)) 
					{
						ok = true;
						break;
					}
					else 
					{
						ok=false;
					}
				}

				if (!ok)  break;
			}

			if (!ok)
			{
				alert ("E' stato inserito un carattere non valido nel campo: " + cStr + " !");
				return (false);
			}
		}

		return (true);
	}
	// ===============================================================


	// ---------------------------------------------------------------
	// Controlla che il contenuto del Campo specificato non sia vuoto
	// ---------------------------------------------------------------

	function IsEmpty(obj, cStr) {

		if (obj.value == '') 
		{
			alert ("Specificare un Valore  nel campo: " + cStr + " !");
			obj.focus();
			return true;
		}
		return false;
	}
	// ===============================================================


	// ---------------------------------------------------------------
	// Controlla il contenuto del Campo specificato prima di procedere
	// ---------------------------------------------------------------

	function FieldIsOK(obj, cStr, nTipo) {

		if (!CheckInput (obj, cStr, nTipo))
		{
			obj.select();
			obj.focus();
		}
		else if (obj.value == '')
		{
			alert ("Specificare un Valore  nel campo: " + cStr + " !");
			obj.focus();
		}
		else
		{
			return true;
		}
		
		return false;
	}
	// ===============================================================


	// ---------------------------------------------------------------
	// Controlla l'inserimento dei Campi Obbligatori
	// ---------------------------------------------------------------

	function CheckField()
	{
		// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
		// Controllo quei Campi che NON debbono essere vuoti (quindi obbligatori), 
		// indipendentemente da cosa contengono !
		// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
		if (IsEmpty (document.frmInfo.Nome, 'Nome e cognome')) return false;
		// if (IsEmpty (document.frmInfo.RagioneSociale, 'Ragione Sociale')) return false;
		// if (IsEmpty (document.frmInfo.Mansione, 'Mansione')) return false;
		// if (IsEmpty (document.frmInfo.Indirizzo, 'Indirizzo')) return false;
		// if (IsEmpty (document.frmInfo.Citta, 'Città')) return false;
		if (IsEmpty (document.frmInfo.Info, 'Informazioni richieste')) return false;
		if (IsEmpty (document.frmInfo.EMail, 'E-mail', 4)) return false;
		// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

		// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
		// Controllo che i Campi obbligatori non siano vuoti e contengano dei dati corretti
		// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
		// if (!FieldIsOK (document.frmInfo.Cap, 'C.A.P.', 2)) return false;
		// if (!FieldIsOK (document.frmInfo.Telefono, 'Telefono', 3)) return false;
		// if (!FieldIsOK (document.frmInfo.DatiFiscali, 'Cod. Fisc. o P. Iva', 5)) return false;
		// if (!FieldIsOK (document.frmInfo.EMail, 'E-mail', 4)) return false;
		// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

		// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
		// Controllo che i Campi NON obbligatori (ma compilati), contengano dei dati corretti
		// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
		if (!CheckInput (document.frmInfo.Fax, 'Fax', 3))
		{
			document.frmInfo.Fax.select();
			document.frmInfo.Fax.focus();
			return false;
		}
		if (!CheckInput (document.frmInfo.Cap, 'C.A.P.', 2))
		{
			document.frmInfo.Cap.select();
			document.frmInfo.Cap.focus();
			return false;
		}
		if (!CheckInput (document.frmInfo.Telefono, 'Telefono', 3))
		{
			document.frmInfo.Telefono.select();
			document.frmInfo.Telefono.focus();
			return false;
		}
		if (!CheckInput (document.frmInfo.DatiFiscali, 'Cod. Fisc. o P. Iva', 5))
		{
			document.frmInfo.DatiFiscali.select();
			document.frmInfo.DatiFiscali.focus();
			return false;
		}
		// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

		return true;
	}
	// ===============================================================


	// ---------------------------------------------------------------
	// Trasforma i Caratteri in Maiuscolo
	// ---------------------------------------------------------------

	function Upper(TextField) 
		{TextField.value = TextField.value.toUpperCase();}
	// ===============================================================


// ===================================
// EOF: Contatti.js
// ===================================
