	var risultato1 = 0;
	
function form1(){
	if (isNaN(document.calcolo1.importo.value))		{alert("Il campo IMPORTO DI MASSIMO UTILIZZO DEL TRIMESTRE deve essere numerico!");		document.calcolo1.importo.focus();return false;};
	if (isNaN(document.calcolo1.scoperto.value))	{alert("Il campo COMMISSIONE DI MASSIMO SCOPERTO TRIMESTRALE deve essere numerico!");	document.calcolo1.scoperto.focus();return false;};
	
/*  inizio  */
	var importo = parseFloat(document.getElementById('importo').value);
	var scoperto = parseFloat(document.getElementById('scoperto').value);
	var cmst = importo * scoperto;
	risultato1 = cmst / 100;

	document.getElementById('risultato1').innerHTML = '<strong>' + Math.round(risultato1 * 100) / 100 + '</strong>';
}

	var somma_numeri = 0;

function numerize(string) {
	if ((string == '') || (string == 'undefined')) {
		return 0;
	} else {
		return parseInt(string);
	}
}
	
function result1(){
/*  primo  */
	if (isNaN(document.calcolo1.affidamento1.value))	{alert("Il campo IMPORTO deve essere numerico!");	document.calcolo1.affidamento1.focus();return false;};
	if (isNaN(document.calcolo1.giorni1.value))			{alert("Il campo GIORNI deve essere numerico!");	document.calcolo1.giorni1.focus();return false;};

	var affidamento1 = numerize(document.getElementById('affidamento1').value);
	var giorni1 = numerize(document.getElementById('giorni1').value);
	var numeri1 = affidamento1 * giorni1;
	
	document.getElementById('numeri1').innerHTML = '<strong>' + numeri1 + '</strong>';


/*  secondo  */
	if (isNaN(document.calcolo1.affidamento2.value))	{alert("Il campo IMPORTO deve essere numerico!");	document.calcolo1.affidamento2.focus();return false;};
	if (isNaN(document.calcolo1.giorni2.value))			{alert("Il campo GIORNI deve essere numerico!");	document.calcolo1.giorni2.focus();return false;};

	var affidamento2 = numerize(document.getElementById('affidamento2').value);
	var giorni2 = numerize(document.getElementById('giorni2').value);
	var numeri2 = affidamento2 * giorni2;

	document.getElementById('numeri2').innerHTML = '<strong>' + numeri2 + '</strong>';

/*  terzo  */
	if (isNaN(document.calcolo1.affidamento3.value))	{alert("Il campo IMPORTO deve essere numerico!");	document.calcolo1.affidamento3.focus();return false;};
	if (isNaN(document.calcolo1.giorni3.value))			{alert("Il campo GIORNI deve essere numerico!");	document.calcolo1.giorni3.focus();return false;};

	var affidamento3 = numerize(document.getElementById('affidamento3').value);
	var giorni3 = numerize(document.getElementById('giorni3').value);
	var numeri3 = affidamento3 * giorni3;

	document.getElementById('numeri3').innerHTML = '<strong>' + numeri3 + '</strong>';

/*  quarto  */
	if (isNaN(document.calcolo1.affidamento4.value))	{alert("Il campo IMPORTO deve essere numerico!");	document.calcolo1.affidamento4.focus();return false;};
	if (isNaN(document.calcolo1.giorni4.value))			{alert("Il campo GIORNI deve essere numerico!");	document.calcolo1.giorni4.focus();return false;};

	var affidamento4 = numerize(document.getElementById('affidamento4').value);
	var giorni4 = numerize(document.getElementById('giorni4').value);
	var numeri4 = affidamento4 * giorni4;

	document.getElementById('numeri4').innerHTML = '<strong>' + numeri4 + '</strong>';

/*  quinto  */
	if (isNaN(document.calcolo1.affidamento5.value))	{alert("Il campo IMPORTO deve essere numerico!");	document.calcolo1.affidamento5.focus();return false;};
	if (isNaN(document.calcolo1.giorni5.value))			{alert("Il campo GIORNI deve essere numerico!");	document.calcolo1.giorni5.focus();return false;};

	var affidamento5 = numerize(document.getElementById('affidamento5').value);
	var giorni5 = numerize(document.getElementById('giorni5').value);
	var numeri5 = affidamento5 * giorni5;

	document.getElementById('numeri5').innerHTML = '<strong>' + numeri5 + '</strong>';
	
/*  somma  */
	somma_numeri = eval(numeri1 + numeri2 + numeri3 + numeri4 + numeri5);
	
	document.getElementById('somma_numeri').innerHTML = '<strong>Tot ' + somma_numeri + '</strong>';
}

	var risultato2 = 0;

function cmut(){
if 	(
	(document.calcolo1.affidamento1.value   == "") &&
	(document.calcolo1.affidamento2.value   == "") &&
	(document.calcolo1.affidamento3.value   == "") &&
	(document.calcolo1.affidamento4.value   == "") &&
	(document.calcolo1.affidamento5.value   == "")
	) {alert("Il campo IMPORTO è obbligatorio!"); document.calcolo1.affidamento1.focus();return false;};
	
if 	(
	(document.calcolo1.giorni1.value   == "") &&
	(document.calcolo1.giorni2.value   == "") &&
	(document.calcolo1.giorni3.value   == "") &&
	(document.calcolo1.giorni4.value   == "") &&
	(document.calcolo1.giorni5.value   == "")
	) {alert("Il campo GIORNI è obbligatorio!"); document.calcolo1.giorni1.focus();return false;};
	
	if (document.calcolo1.commissione.value   == "") {alert("Il campo COMMISSIONE DI MANCATO UTILIZZO TRIMESTRALE è obbligatorio!");     		document.calcolo1.commissione.focus();return false;};
	if (isNaN(document.calcolo1.commissione.value))		{alert("Il campo COMMISSIONE DI MANCATO UTILIZZO TRIMESTRALE deve essere numerico!");	document.calcolo1.commissione.focus();return false;};

	/*  CMUT  */
	var commissione = parseFloat(document.getElementById('commissione').value);
	var percentuale = somma_numeri * commissione;
	var cmut = percentuale / 100;
	risultato2 = cmut / 36500;
	
	document.getElementById('risultato2').innerHTML = '<strong>' + Math.round(risultato2 * 100) / 100 + '</strong>';
}

	var risultato6 = 0;

function cigr(){
	if (isNaN(document.calcolo1.cigr1.value))	{alert("Il campo IMPORTO AFFIDAMENTO CONCESSO deve essere numerico!");	document.cigr1.importo.focus();return false;};
	if (isNaN(document.calcolo1.cigr2.value))	{alert("Il campo ALIQUOTA SCAGLIONE DI RIFERIMENTO AFFIDAMENTO CONCESSO deve essere numerico!");	document.cigr2.scoperto.focus();return false;};
	
/*  CIGR  */
	var cigr1 = parseFloat(document.getElementById('cigr1').value);
	var cigr2 = parseFloat(document.getElementById('cigr2').value);
	var result = cigr1 * cigr2;
	var risult_cigr = result / 100;
	
	if (cigr1 == 500000) {
		return cigr2 == 0.10;
	} else {
		return 100000;
	}
	

	
	
	
	
	
//	risultato6 = risult_cigr / 4;
	risultato6 = risult_cigr;

	document.getElementById('risultato6').innerHTML = '<strong>' + Math.round(risultato6 * 100) / 100 + '</strong>';

}

	var risultato3 = 0;
	
function cmst_cmut(){
	if (document.calcolo1.importo.value   == "") {alert("Il campo IMPORTO DI MASSIMO UTILIZZO DEL TRIMESTRE è obbligatorio!");     		document.calcolo1.importo.focus();return false;};
	if (document.calcolo1.scoperto.value   == "") {alert("Il campo COMMISSIONE DI MASSIMO SCOPERTO TRIMESTRALE è obbligatorio!");		document.calcolo1.scoperto.focus();return false;};
	if (document.calcolo1.commissione.value   == "") {alert("Il campo COMMISSIONE DI MANCATO UTILIZZO TRIMESTRALE è obbligatorio!");	document.calcolo1.commissione.focus();return false;};
	
	if (document.calcolo1.cigr1.value   == "") {alert("Il campo IMPORTO AFFIDAMENTO CONCESSO è obbligatorio!");	document.calcolo1.cigr1.focus();return false;};
	if (document.calcolo1.cigr2.value   == "") {alert("Il campo ALIQUOTA SCAGLIONE DI RIFERIMENTO AFFIDAMENTO CONCESSO è obbligatorio!");	document.calcolo1.cigr2.focus();return false;};

/*  calcolo finale  */
	risultato3 = risultato1 + risultato2 + risultato6;
	
	document.getElementById('risultato3').innerHTML = '<strong>' + Math.round(risultato3 * 100) / 100 + '</strong>';
}

	var risultato4 = 0;

function form2(){
	if (document.calcolo2.affidamento.value   == "")		{alert("Il campo IMPORTO DELL'AFFIDAMENTO IN C/C è obbligatorio!");				document.calcolo2.affidamento.focus();return false;};
	if (isNaN(document.calcolo2.affidamento.value))		{alert("Il campo IMPORTO DELL'AFFIDAMENTO IN C/C deve essere numerico!");			document.calcolo2.affidamento.focus();return false;};
	if (document.calcolo2.commissione1.value    == "")	{alert("Il campo COMMISSIONE MESSA A DISPOSIZIONE FONDI TRIMESTRALE è obbligatorio!");			document.calcolo2.commissione1.focus();return false;};
	if (isNaN(document.calcolo2.commissione1.value))		{alert("Il campo COMMISSIONE MESSA A DISPOSIZIONE FONDI TRIMESTRALE deve essere numerico!");	document.calcolo2.commissione1.focus();return false;};
	

/*  secondo  */
	var affidamento = parseFloat(document.getElementById('affidamento').value);
	var commissione1 = parseFloat(document.getElementById('commissione1').value);
	var cmdft = affidamento * commissione1;
	risultato4 = cmdft / 100;

	document.getElementById('risultato4').innerHTML = '<strong>' + Math.round(risultato4 * 100) / 100 + '</strong>';

}


function form3(){
/*  A meno B  */

	var risultato5 = risultato3 - risultato4

	document.getElementById('risultato5').innerHTML = '<strong>' + Math.round(risultato5 * 100) / 100 + '</strong>';

}



function addEvent(obj, evType, fn) {
	var fns = obj["__" + evType] || [];
	
	if (!obj["__" + evType]) {
		obj["__" + evType] = fns;
		
		var raiseEvent = function(e) {
			if (!e && window.event) {
				e = window.event;
			}
			if (!e.target) {
				e.target = e.srcElement;
			}
			if (!e.stopPropagation) {
				e.stopPropagation = function() {
					e.cancelBubble = true;
				};
			}
			for (var f in fns) {
				obj.__fn = fns[f];
				obj.__fn(e);
			}
			obj.__fn = null;
		}
		
		if (obj.addEventListener) {
			obj.addEventListener(evType, raiseEvent, false);
		} else if (obj.attachEvent) {
			obj.attachEvent("on" + evType, raiseEvent);
		} else {
			obj["on" + evType] = raiseEvent;
		}
	}

	for (var f in fns) {
		if (fns[f] == fn) {
			return;
		}
	}
	fns[fns.length] = fn;
}

function removeEvent(obj, evType, fn) {
	var fns = obj["__" + evType];
	if (fns) {
		for (var f in fns) {
			if (fns[f] == fn) {
				fns[f] = null;
				return;
			}
		}
	}
}

function addElement(figlio,padre) {
    elementofiglio = document.createElement(figlio);
	elementopadre = document.getElementById(padre);
    elementopadre.addElement(elementofiglio); 
}