function calcola(lingua) {
		prz_ult = document.getElementById('prezzo').value;
		quantita = document.getElementById('qta').value;
		prz_acq = document.getElementById('acq').value;
		quantita = converti(quantita.toString());
		prz_acq = converti(prz_acq.toString());
			if ((isValidNumber(quantita)) && (isValidNumber(prz_acq))) {
				utile = (prz_ult - prz_acq) * quantita;
				document.getElementById('utl').value = Math.round(utile * 100) / 100;
			}
			else {
				if (lingua == 'ita'){
				alert('I valori immessi non sono validi.');
				}
				else {
				alert('Invalid input values.');
				}  
			}
}

function converti(value) {
	value = value.replace(',','.');	
	while (value.indexOf(',') > 0) {
		value = value.replace(',','');
	}
	return value;
}

function isValidNumber(strString) {
	var strValidChars = "0123456789.";
  	var strChar;
  	var blnResult = true;
  	if (strString.length == 0) return false;
  	for (i = 0; i < strString.length && blnResult == true; i++)
  	{
    		strChar = strString.charAt(i);
    		if (strValidChars.indexOf(strChar) == -1)
    		{
      			blnResult = false;
    		}
  	}
  	return blnResult;
}

	
function cancella() {
	document.getElementById('qta').value = '';
	document.getElementById('acq').value = '';
	document.getElementById('utl').value = '';
}	
