function RTrim(testo)
{
	var i;
	for (i = testo.length - 1; i >= 0; i--)
	{
		if (testo.charAt(i) != " ")
			break;
	}
	if ( (i == 0) && (testo.charAt(0) == " ") )
		return "";
	return testo.substring(0, i+1);
}
function LTrim(testo)
{
	var i;
	for (i = 0; i <= testo.length - 1;  i++)
	{
		if (testo.charAt(i) != " ")
			break;
	}
	if ( (i == testo.length - 1) && (testo.charAt(i) == " ") )
		return "";
	return testo.substring(i, testo.length);
}
function Trim(testo)
{
	return LTrim(RTrim(testo));
}
// Controlla che un campo non sia vuoto
function isEmpty(inputStr) 
{
	if (Trim(inputStr).length == 0) 
	{
		return true;
	}
	return false;
}

// Effettua un primo controllo sulla data immessa tramite tre combo (giorno, mese e anno)
function CheckDate(gg, mm, aa, cmbgg, cmbmm)
{
	if (aa.length == 0)		//Manca l'anno --> Errore a meno che non manchino anche sia il giorno che il mese
		if ( (gg.length == 0) && (mm.length == 0) )	
			return true;
		else
			return false;
	else					//L'anno è presente --> Se manca il giorno lo forzo a 01; se manca anche il mese lo forzo a 01; se manca solo il mese segnalo errore
		if (gg.length == 0)
		{
			cmbgg.value = '01';	
			if (mm.length == 0)
				cmbmm.value = '01';	
			return true;
		}
		else
			if (mm.length == 0)
				return false;
			else
				return true;
}

