function punta(Numero) {
	e =0
	PuntatoInv = ""
	Lung = Numero.toString().length
	for(u = 0; u <= Lung; u++, e++){
	PuntatoInv +=Numero.toString().charAt(Lung - u)
	if (e == 3 && u < Lung){
	PuntatoInv +="." 
	e = 0
	}
	}

	Puntato = ""
	Lung = PuntatoInv.length
	for(u = 0; u <= Lung; u++){
	Puntato +=PuntatoInv.charAt(Lung - u)
	}

	return Puntato;
}

	function CRata(){
		if (document.Mutuo.TotMutuo.value   == "") {alert("Il campo IMPORTO RICHIESTO è obbligatorio!");       document.Mutuo.TotMutuo.focus();return false;};
		if (isNaN(document.Mutuo.TotMutuo.value))  {alert("Il campo IMPORTO RICHIESTO deve essere numerico!"); document.Mutuo.TotMutuo.focus();return false;};
		if (document.Mutuo.NAnni.value    == "")   {alert("Il campo DURATA DEL MUTUO è obbligatorio!");        document.Mutuo.NAnni.focus();return false;};
		if (isNaN(document.Mutuo.NAnni.value))     {alert("Il campo DURATA DEL MUTUO deve essere numerico!");  document.Mutuo.NAnni.focus();return false;};
		if (document.Mutuo.Int.value   == "")      {alert("Il campo TASSO INTERESSE è obbligatorio!");         document.Mutuo.Int.focus();return false;};
		if (isNaN(document.Mutuo.Int.value))       {alert("Il campo TASSO INTERESSE deve essere numerico!");   document.Mutuo.Int.focus();return false;};

	
	IntMese = (document.Mutuo.Int.value / 12);
	NRate = (document.Mutuo.NAnni.value * 12);
	Potenza = (1 + (IntMese/100));
	Base = (1 + (IntMese/100));
	for(i=1; i < (document.Mutuo.NAnni.value * 12); i++){
	Potenza = Potenza * Base
	}

	ImpRata = ((document.Mutuo.TotMutuo.value * (IntMese * Potenza)/(Potenza - 1)) *10000);

	Tabella = "<span class='puntatore'>SIMULAZIONE RATA MUTUO</span>"
	Importo = document.Mutuo.TotMutuo.value * 1000000
	CapRes = Importo
	e = 0
	TotInteressi = 0
	TotCap = 0
	for(i=1; i <= NRate; i++){
	Interessi =  CapRes * IntMese/100
	TotInteressi =TotInteressi + Interessi
	QuotaCap = ImpRata - Interessi
	TotCap = TotCap + QuotaCap
	CapRes = CapRes - QuotaCap;
	}

	Tabella = Tabella +"<table cellPadding='3' cellspacing='3'><tr class='sfondo01'><td>La rata del tuo mutuo sar&agrave; di Euro:</td><td><strong>" + Math.round(ImpRata/10000)/100 + "&nbsp;&euro;</strong></td></tr><tr class='sfondo02'><td>Il montante (Capitale + Interessi) sar&agrave; di Euro:</td><td><strong>" + Math.round((ImpRata * NRate)/10000)/100 + "&nbsp;&euro;</strong></td></tr><tr class='sfondo01'><td>Gli Interessi saranno di Euro:</td><td><strong>" + Math.round(TotInteressi/10000)/100 + "&nbsp;&euro;</strong></td></tr></table>";
	  if (Tabella != null) {
	                document.getElementById('risultato_mutuo').innerHTML = Tabella;
		}
	
	return false;

	}

	function CPiano(){
	
		if (document.Mutuo.TotMutuo.value   == "") {alert("Il campo IMPORTO RICHIESTO è obbligatorio!");       document.Mutuo.TotMutuo.focus();return false;};
		if (isNaN(document.Mutuo.TotMutuo.value))  {alert("Il campo IMPORTO RICHIESTO deve essere numerico!"); document.Mutuo.TotMutuo.focus();return false;};
		if (document.Mutuo.NAnni.value    == "")   {alert("Il campo DURATA DEL MUTUO è obbligatorio!");        document.Mutuo.NAnni.focus();return false;};
		if (isNaN(document.Mutuo.NAnni.value))     {alert("Il campo DURATA DEL MUTUO deve essere numerico!");  document.Mutuo.NAnni.focus();return false;};
		if (document.Mutuo.Int.value   == "")      {alert("Il campo TASSO INTERESSE è obbligatorio!");         document.Mutuo.Int.focus();return false;};
		if (isNaN(document.Mutuo.Int.value))       {alert("Il campo TASSO INTERESSE deve essere numerico!");   document.Mutuo.Int.focus();return false;};

	IntMese = (document.Mutuo.Int.value / 12);
	NRate = (document.Mutuo.NAnni.value * 12);
	Potenza = (1 + (IntMese/100));
	Base = (1 + (IntMese/100));
	for(i=1; i < (document.Mutuo.NAnni.value * 12); i++){
	Potenza = Potenza * Base
	}

	ImpRata = ((document.Mutuo.TotMutuo.value * (IntMese * Potenza)/(Potenza - 1)) *10000);

	Tabella = "<span class='puntatore'>SIMULAZIONE PIANO AMMORTAMENTO MUTUO</span><table><tr class='sfondo01'><td><strong>N.Rata</strong></td><td><strong>Quota Interessi</strong></td><td><strong>Quota Capitale</strong></td><td><strong>Importo Rata</strong></td><td><strong>Capitale Residuo</strong></td></tr>"
	Importo = document.Mutuo.TotMutuo.value * 1000000
	CapRes = Importo
	e = 0
	TotInteressi = 0
	TotCap = 0
	for(i=1; i <= NRate; i++){
	Interessi =  (CapRes * IntMese/100)
	TotInteressi = TotInteressi + Interessi
	QuotaCap = (ImpRata - Interessi)
	TotCap = TotCap + QuotaCap
	CapRes = (CapRes - QuotaCap)
	
	if(e==0){
	sTrBg=" class='sfondo02'";
	e = 1;
	}
	else{
	sTrBg=" class='sfondo01'";
	e = 0;
	}

	Tabella = Tabella +"<tr" + sTrBg + "><td>" + i + "</td><td>" + Math.round(Interessi/10000)/100 + "&nbsp;&euro;</td><td>" + Math.round(QuotaCap/10000)/100 + "&nbsp;&euro;</td><td>" + Math.round(ImpRata/10000)/100 + "&nbsp;&euro;</td><td>" + Math.round(CapRes/10000)/100 + "&nbsp;&euro;</td></tr>";
	}

	Tabella = Tabella +"<tr class='risultato'><Td>&nbsp;</Td><Td><B>" + Math.round(TotInteressi/10000)/100 + "&nbsp;&euro;</Td><Td><B>" + Math.round(TotCap/10000)/100 + "&nbsp;&euro;</Td><Td><B>" + Math.round((ImpRata * NRate)/10000)/100 + "&nbsp;&euro;</Td><Td>&nbsp</Td></Tr>";
	Tabella = Tabella +"</table>"
		 if (Tabella != null) {
	                document.getElementById('risultato_mutuo').innerHTML = Tabella;
		}
		return false;		
	}