function calcolaICI(form, type) {
	if (type == 1) {
		var rivalutato = form.valorecatastale.value * 1.05;
		var aliquota = rivalutato * form.aliquota.value / 1000;
		var detrazionefissa = aliquota - form.detrazionecomplessiva.value;
		//var detr2 = rivalutato * 1.33 / 1000;
		
		//if (detr2 > 200) detr2 = 200;
		
		var ici = (detrazionefissa)*form.possesso.value/100*form.mesi.value/12;
		
		form.rivalutato.value = rivalutato.toFixed(2);
		//form.det2.value = detr2.toFixed(2);
		
		return ici;
		
		//return (form.valorecatastale.value*100*1.05*form.aliquota.value/1000-form.detrazionecomplessiva.value)*
				//form.possesso.value/100*form.mesi.value/12
	}
	else if (type == 2)
		return (form.valorecatastale.value*form.aliquota.value/1000)*
			  form.possesso.value/100*form.mesi.value/12
	else if (type == 3)
		return (form.valorecatastale.value*50*1.05*form.aliquota.value/1000)*
			  form.possesso.value/100*form.mesi.value/12
	else if (type == 4)
		return (form.valorecatastale.value*34*1.05*form.aliquota.value/1000)*
			  form.possesso.value/100*form.mesi.value/12
}

function accontoesaldo(form, type) {
	form.icidovuta.value = Math.round(calcolaICI(form,type)*100)/100
}

function acconto(form, type) {
	form.giugno.value = Math.round(calcolaICI(form,type)*0.50*100)/100
}

function saldo(form, type) {
	form.dicembre.value = Math.round(calcolaICI(form,type)*0.50*100)/100
}