<!--
/*
	CHECK P.IVA -------------------------------------------------------------- v. 1.0 --
	DESCRIPTION:			CONTROLLO CAMPO DI TESTO
	FACTORY:					VisualTech S.r.l.
	AUTOR:					Andrea Bassani
	VERSION:					1.01 for ADV
	DATE:						2001/07/30
	FILE NAME:				vtCheckText.js
	FUNCTION NAME:			fnCheckText
	FUNCTIONS CALLED:		nessuna
								
							
	ARGOMENTI DELLA FUNZIONE
	Alla funzione vengono passati i tre seguenti argomenti:

			formObj			L'oggetto form di cui fa parte l'elemento elName
			elName			Il nome dell'elemento di input da controllare
			strErr			Rilascio messaggio di errore se impostato a 1
	
	CONTROLLI
	** CONTROLLO 1
	Se il campo è uguale a '' (vuoto) o ' ' (spazio) la funzione ritorna true e, a seconda
	che il flag "flgErr" sia impostato a 0, 1 o 2 modifica o meno la variabile "msgStr"
	con il messaggio relativo.
	
	** CONTROLLO 2
	Il secondo controllo verifica attraverso un ciclo "while", la presenza di spazi consecu-
	tivi iniziali prima del testo digitato.
	Se viene trovato dopo n spazi un carattere, il campo viene modificato eliminando gli spazi
	iniziali e considerato valido.
	Se non viene trovato alcun carattere valido il campo viene considerato vuoto.
*/


// CHECK EMPTY TEXT FIELD ---------------------- INCLUDE --- OK ---
function fnCheckText(formObj, elName, elDesc, errFlg, ucFlg)	{
	if (formObj[elName].value == '' || formObj[elName].value == ' ')	{
		//alert('VUOTO A');
		if (errFlg == 1 || errFlg == 2 || errFlg == 3)	{
			msgStr = msgStr + elDesc + errMsg[0];
			blnStr = true;
		}
		return true;
	}
	else if (formObj[elName].value.length > 1)	{
		elStr  = formObj[elName].value;
		elLng  = elStr.length;
		spcStr = '';
		cnt = 0;
		while (cnt < elLng)	{
			if (elStr.slice(cnt,(cnt + 1)) != ' ')	{
				//alert('VALIDO');
				newStr = elStr.replace(spcStr, '');
				lngStr = newStr.length;
				if (ucFlg == 1) newStr = newStr.slice(0,1).toUpperCase() + newStr.slice(1,lngStr).toLowerCase();
				formObj[elName].value = newStr;
				if (errFlg == 1 || errFlg == 2)	{
					msgStr = msgStr + elDesc + errMsg[100];
				}
				return false;
				break;
			}
			else if (elStr.slice(cnt,(cnt + 1)) == ' ' && cnt == (elLng - 1))	{
				//alert('VUOTO B');
				if (errFlg == 1 || errFlg == 2 || errFlg == 3)	{
					msgStr = msgStr + elDesc + errMsg[0];
				}
				formObj[elName].value = '';
				blnStr = true;
				return true;
				break;
			}
			else return false;
			spcStr = spcStr + elStr.slice(cnt,(cnt + 1));
			cnt++;
		}
	}
	else return false;
}
// -->