function rivaluta()
{
coe=new Array (43.7954,42.8818,41.6896,38.2635,36.4691,34.2404,33.1710,31.4441,29.8989,29.9819,31.3472,2.3370,32.9166,33.2696,32.4027,32.2816,32.7021,32.9634,34.6383,33.2592,32.4633,32.9443,32.7263,32.4166,31.9719,32.1449,32.0030,31.5497,31.5791,31.9407,32.8543,32.4633,32.6225,33.3579,33.2748,
33.5309,
33.6607,
33.5759,
34.0396,
33.5413,
33.4859,
33.0464,
33.0412,
32.4667,
31.8334,
32.2228,
31.8957,
31.8196,
31.3732,
30.8229,
30.6551,
29.9785,
29.9421,
29.5476,
29.5580,
29.6636,
29.6757,
29.5943,
29.4127,
29.4282,
29.5199,
29.1964,
29.1098,
28.9714,
28.8607,
28.6721,
28.6029,
28.5873,
28.3831,
28.3312,
28.2948,
28.4021,
28.4437,
28.3900,
28.3935,
28.1184,
27.9522,
27.8726,
28.2948,
28.3762,
28.2499,
28.1408,
28.0041,
28.0699,
28.0318,
27.9142,
27.9972,
27.8225,
27.4712,
27.2462,
27.1476,
27.1736,
27.2134,
27.2584,
27.1355,
27.0957,
27.1061,
27.1667,
27.1061,
26.8829,
26.6389,
26.4624,
26.5593,
26.5143,
26.5956,
26.6026,
26.4901,
26.3153,
26.1319,
25.7876,
25.4847,
25.3307,
25.1975,
25.3031,
25.3584,
25.3480,
25.2806,
25.4190,
25.3913,
25.2546,
25.0089,
25.1594,
25.2823,
25.2996,
25.2096,
25.1594,
25.0054,
24.9847,
24.8687,
24.6680,
24.4950,
24.3548,
24.1108,
24.2112,
24.1783,
23.8011,
23.5571,
23.3979,
23.4568,
23.5640,
23.6402,
23.8703,
23.9551,
24.0745,
23.9811,
24.0503,
24.1160,
24.0728,
24.0070,
24.0122,
24.0399,
24.0036,
23.8876,
23.7302,
23.5813,
23.5069,
23.3218,
23.4152,
23.5000,
23.4585,
23.3599,
23.2682,
23.2059,
23.2439,
23.2630,
23.2560,
23.1488,
23.0882,
22.9065,
22.8944,
22.8806,
22.7421,
22.6625,
22.6262,
22.6539,
22.6106,
22.5431,
22.5085,
22.3407,
22.2369,
22.0379,
22.0171,
21.8891,
21.6174,
21.6174,
21.5136,
21.4322,
21.4738,
21.3717,
21.2921,
21.2125,
20.9962,
20.6501,
20.2798,
20.1898,
20.0826,
20.0826,
20.0826,
20.0999,
20.0653,
19.8715,
19.6811,
19.6811,
19.5617,
19.3783,
19.3281,
19.2451,
19.1637,
19.0841,
18.9076,
18.7986,
18.7675,
18.6896,
18.5823,
18.5062,
18.4301,
18.3418,
18.3124,
18.2674,
18.2224,
18.1653,
18.1203,
18.0632,
18.0494,
18.0200,
18.0061,
17.9906,
17.9196,
17.8642,
17.8642,
17.8487,
17.7933,
17.7518,
17.7656,
17.7518,
17.7656,
17.7656,
17.7102,
17.6549,
17.5995,
17.5289,
17.5465,
17.5113,
17.4773,
17.4421,
17.4082,
17.3743,
17.3404,
17.2726,
17.2902,
17.2902,
17.2902,
17.2224,
17.2387,
17.2224,
17.1885,
17.1722,
17.1885,
17.2061,
17.1885,
17.1559,
17.1397,
17.1220,
17.0569,
17.0081,
17.0081,
16.9430,
16.8616,
16.8304,
16.7667,
16.6568,
16.6094,
16.5633,
16.4860,
16.4249,
16.3490,
16.2595,
16.1415,
16.0967,
16.0249,
15.9665,
15.9381,
15.9096,
15.8662,
15.7401,
15.6709,
15.5882,
15.5204,
15.4450,
15.4001,
15.3249,
15.2812,
15.1938,
15.1501,
15.0918,
15.0639,
14.9643,
14.8939,
14.8527,
14.8248,
14.7422,
14.6609,
14.6196,
14.5796,
14.4861,
14.4072,
14.3429,
14.2652,
14.1256,
13.9399,
13.8427,
13.8063,
13.6400,
13.5126,
13.3985,
13.2419,
13.0574,
12.9712,
12.9081,
12.8462,
12.7831,
12.6410,
12.5014,
12.2987,
12.1385,
11.9382,
11.5971,
11.4551,
11.2924,
11.0800,
10.8154,
10.5993,
10.2631,
10.0555,
9.9050,
9.8188,
9.7047,
9.5931,
9.5821,
9.4510,
9.3891,
9.2957,
9.2423,
9.1937,
9.1087,
8.9958,
8.9194,
8.8356,
8.7482,
8.6050,
8.4278,
8.1838,
8.0466,
8.0102,
7.9629,
7.8949,
7.7565,
7.5028,
7.3474,
7.2564,
7.1574,
6.9985,
6.8944,
6.8222,
6.7349,
6.6723,
6.6217,
6.5772,
6.5068,
6.4375,
6.3442,
6.3135,
6.2533,
6.1895,
6.1269,
6.0607,
5.9963,
5.9464,
5.9018,
5.8753,
5.7977,
5.7345,
5.6845,
5.6436,
5.5365,
5.4558,
5.3890,
5.3017,
5.2349,
5.1831,
5.1356,
5.0862,
4.9640,
4.8509,
4.7889,
4.7118,
4.5613,
4.4837,
4.4428,
4.3742,
4.3356,
4.2953,
4.2237,
4.1809,
4.0943,
4.0250,
3.9426,
3.8920,
3.8206,
3.7524,
3.6997,
3.6482,
3.5984,
3.5617,
3.5318,
3.5083,
3.4595,
3.3922,
3.3360,
3.3019,
3.2585,
3.2160,
3.1867,
3.1581,
3.1227,
3.0931,
3.0481,
2.9941,
2.9520,
2.8950,
2.8577,
2.8384,
2.7989,
2.7619,
2.7368,
2.7085,
2.6828,
2.6674,
2.6423,
2.6323,
2.5982,
2.5558,
2.5294,
2.5175,
2.4876,
2.4615,
2.4442,
2.4274,
2.4133,
2.3995,
2.3914,
2.3847,
2.3673,
2.3435,
2.3293,
2.3139,
2.2898,
2.2663,
2.2506,
2.2316,
2.2187,
2.2071,
2.2001,
2.1956,
2.1862,
2.1605,
2.1451,
2.1309,
2.1210,
2.1068,
2.0987,
2.0928,
2.0849,
2.0770,
2.0770,
2.0731,
2.0674,
2.0557,
2.0481,
2.0424,
2.0292,
2.0218,
2.0144,
2.0090,
2.0016,
1.9943,
1.9889,
1.9837,
1.9695,
1.9520,
1.9469,
1.9434,
1.9333,
1.9282,
1.9198,
1.9131,
1.9082,
1.9016,
1.8967,
1.8886,
1.8788,
1.8647,
1.8490,
1.8427,
1.8291,
1.8141,
1.8051,
1.7933,
1.7861,
1.7775,
1.7731,
1.7704,
1.7618,
1.7451,
1.7382,
1.7301,
1.7194,
1.7078,
1.7013,
1.6948,
1.6899,
1.6835,
1.6771,
1.6661,
1.6568,
1.6431,
1.6325,
1.6265,
1.6147,
1.6001,
1.5958,
1.5886,
1.5830,
1.5746,
1.5718,
1.5677,
1.5608,
1.5485,
1.5378,
1.5337,
1.5219,
1.5179,
1.5114,
1.5050,
1.4974,
1.4924,
1.4898,
1.4886,
1.4836,
1.4750,
1.4665,
1.4640,
1.4589,
1.4532,
1.4503,
1.4447,
1.4391,
1.4323,
1.4268,
1.4255,
1.4241,
1.4146,
1.4080,
1.4080,
1.4000,
1.3948,
1.3921,
1.3883,
1.3831,
1.3806,
1.3767,
1.3742,
1.3705,
1.3629,
1.3580,
1.3531,
1.3482,
1.3373,
1.3266,
1.3196,
1.3115,
1.3046,
1.3035,
1.2989,
1.2955,
1.2888,
1.2810,
1.2788,
1.2773,
1.2736,
1.2699,
1.2625,
1.2577,
1.2553,
1.2577,
1.2565,
1.2529,
1.2517,
1.2481,
1.2469,
1.2445,
1.2433,
1.2422,
1.2410,
1.2375,
1.2375,
1.2375,
1.2375,
1.2351,
1.2316,
1.2282,
1.2282,
1.2247,
1.2213,
1.2213,
1.2190,
1.2167,
1.2156,
1.2156,
1.2145,
1.2134,
1.2111,
1.2100,
1.2100,
1.2089,
1.2066,
1.2044,
1.2000,
1.1978,
1.1978,
1.1956,
1.1956,
1.1923,
1.1902,
1.1859,
1.1848,
1.1837,
1.1784,
1.1752,
1.1741,
1.1710,
1.1668,
1.1647,
1.1647,
1.1627,
1.1596,
1.1545,
1.1534,
1.1484,
1.1444,
1.1434,
1.1394,
1.1364,
1.1344,
1.1344,
1.1344,
1.1334,
1.1305,
1.1286,
1.1276,
1.1227,
1.1189,
1.1160,
1.1132,
1.1113,
1.1094,
1.1085,
1.1066,
1.1047,
1.1019,
1.0992,
1.0982,
1.0936,
1.0918,
1.0882,
1.0864,
1.0855,
1.0846,
1.0819,
1.0801,
1.0774,
1.0765,
1.0739,
1.0739,
1.0721,
1.0686,
1.0678,
1.0651,
1.0634,
1.0608,
1.0600,
1.0583,
1.0583,
1.0583,
1.0557,
1.0557,
1.0557,
1.0523,
1.0506,
1.0472,
1.0456,
1.0439,
1.0414,
1.0397,
1.0389,
1.0373,
1.0373,
1.0356,
1.0332,
1.0307,
1.0291,
1.0267,
1.0235,
1.0227,
1.0203,
1.0187,
1.0187,1.0203,
1.0195,
1.0187,
1.0179,
1.0155,
1.0140,
1.0124,
1.0093,
1.0069,
1.0046,
1.0031,1.0031,1);
coe.reverse();

coe2=new Array (7949.2805,7901.1030,8137.8402,8367.6637,8509.6736,8421.7183,8219.9369,7901.1030,7853.5060,7741.5796,7509.6889,6644.6585,6267.7019,6120.5728,7147.3794,6754.8290,6492.4402,6740.8583,6825.5602,6584.2525,7039.3197,7210.6305,7449.6114,7597.2145,7432.6226,7441.1073,7458.1350,7365.4350,7242.6778,6994.0021,7016.5877,7077.5353,7234.6393,7266.9008,7307.6345,7340.5518,7357.1219,7307.6345,7424.1572,7390.4875,7382.1178,7432.6226,7218.6157,7131.7396,7123.9454,6994.0021,6678.6988,6747.8364,6941.8637,6754.8290,6590.9100,6531.4729,6518.4100,6518.4100,6091.9720,4868.1180,3441.6103,2468.1598,2431.3353,1850.2441,1563.9179,1573.3551,1582.5225,1528.7078,1360.8372,1261.5464,1379.8497,1488.9013,1465.4699,1513.4456,1675.2531,1720.3510,1828.4460,1927.9533,1900.9653,1767.4648,1614.6668,1499.5192,1436.0894,1230.5852,1063.5357,920.1595,548.6877,123.4688,62.6891,53.1178);
coe2.reverse();

lire=document.forms[0].lire[0].checked;
somma=parse(document.forms[0].somma.value+"");
anno=document.forms[0].anno.value;
mese=document.forms[0].mese.value;

if (somma&&isNum(anno))
	{
	document.forms[0].somma.value=punt(virg(somma+""));
	if ((anno>2007)||(anno<1861))
		{
		alert ("Inserire un anno dal 1861 al 2007");
		document.forms[0].reset();
		}
	else
		{
		if (anno>2001&&lire)
			{
			alert("Dal 2002 la lira non circola più\nImporto convertito in euro");
			document.forms[0].lire[1].checked=true;
			somma=round2(somma/1936.27);
			lire=false;
			document.forms[0].somma.value=punt(virg(somma));
			}
		if (anno<2002&&!lire)
			{
			alert("Prima del 2002 l'euro non circolava\nImporto convertito in lire");
			document.forms[0].lire[0].checked=true;
			somma=Math.round(somma*1936.27);
			lire=true;
			document.forms[0].somma.value=punt(somma+"");
			}
		if (anno < 1947) 
			{
			dif=1946-anno; 
			vallire=somma*coe2[dif]*1.0439;
			coef=coe2[dif]*1.0439;				
			}
		else
			{
			dif=(2007*12+10)-(anno*12+eval(mese));
			vallire=somma*coe[dif];
			coef=coe[dif];
			}
		document.forms[0].incre.value=virg(round4(coef));
		if (lire)
			{
			document.forms[0].vallire.value=punt(Math.round(vallire)+"");
			document.forms[0].valeuro.value=punt(virg(round2(vallire/1936.27)));
			}
		else 
			{
			document.forms[0].vallire.value="non disp.";
			document.forms[0].valeuro.value=round2(vallire);
			}

		}
	}
else 
	{
	alert("È presente un valore non numerico o scorretto\noppure c'è un errore nei separatori delle migliaia\nPremere OK per ricominciare");
	document.forms[0].reset();
	}
}