function aggiorna() {
  var quantita = 0;
  var elenco_prodotti = '';
  
  quantita = quantita + eval(document.getElementById("quantita_MECLA").value);
  somma_MECLA = document.getElementById("quantita_MECLA").value * document.getElementById("prezzo_MECLA").value;
  iva_MECLA = somma_MECLA * 0.2;
  totale_MECLA = somma_MECLA * 1.2;
  document.getElementById("somma_MECLA").value = somma_MECLA.toFixed(2);
  document.getElementById("iva_MECLA").value = iva_MECLA.toFixed(2);
  document.getElementById("totale_MECLA").value = totale_MECLA.toFixed(2);
  if ( document.getElementById("quantita_MECLA").value != 0 ) {
	elenco_prodotti = 'n.' + document.getElementById("quantita_MECLA").value + ' Merlot Doc, rosso secco (2006)'; }
  
  quantita = quantita + eval(document.getElementById("quantita_CFCLA").value);
  somma_CFCLA = document.getElementById("quantita_CFCLA").value * document.getElementById("prezzo_CFCLA").value ;
  iva_CFCLA = somma_CFCLA * 0.2;
  totale_CFCLA = somma_CFCLA * 1.2;
  document.getElementById("somma_CFCLA").value = somma_CFCLA.toFixed(2);
  document.getElementById("iva_CFCLA").value = iva_CFCLA.toFixed(2);
  document.getElementById("totale_CFCLA").value = totale_CFCLA.toFixed(2);
  if ( document.getElementById("quantita_CFCLA").value != 0 ) {
	elenco_prodotti = elenco_prodotti + '<br>n.' + document.getElementById("quantita_CFCLA").value + ' Cabernet Franc Doc, rosso secco (2006)'; }

  quantita = quantita + eval(document.getElementById("quantita_CHCLA").value);
  somma_CHCLA = document.getElementById("quantita_CHCLA").value * document.getElementById("prezzo_CHCLA").value;
  iva_CHCLA = somma_CHCLA * 0.2;
  totale_CHCLA = somma_CHCLA * 1.2;
  document.getElementById("somma_CHCLA").value = somma_CHCLA.toFixed(2);
  document.getElementById("iva_CHCLA").value = iva_CHCLA.toFixed(2);
  document.getElementById("totale_CHCLA").value = totale_CHCLA.toFixed(2);
  if ( document.getElementById("quantita_CHCLA").value != 0 ) {  
	elenco_prodotti = elenco_prodotti + '<br>n.' + document.getElementById("quantita_CHCLA").value + ' Chardonnay Doc, bianco secco (2007)'; }

  quantita = quantita + eval(document.getElementById("quantita_TFCLA").value);
  somma_TFCLA = document.getElementById("quantita_TFCLA").value * document.getElementById("prezzo_TFCLA").value;
  iva_TFCLA = somma_TFCLA * 0.2;
  totale_TFCLA = somma_TFCLA * 1.2;
  document.getElementById("somma_TFCLA").value = somma_TFCLA.toFixed(2);
  document.getElementById("iva_TFCLA").value = iva_TFCLA.toFixed(2);
  document.getElementById("totale_TFCLA").value = totale_TFCLA.toFixed(2);
  if ( document.getElementById("quantita_TFCLA").value != 0 ) {
	elenco_prodotti = elenco_prodotti + '<br>n.' + document.getElementById("quantita_TFCLA").value + ' Tocai Friulano Doc, bianco secco (2007)'; }
 
  quantita = quantita + eval(document.getElementById("quantita_VFCLA").value);
  somma_VFCLA = document.getElementById("quantita_VFCLA").value * document.getElementById("prezzo_VFCLA").value;
  iva_VFCLA = somma_VFCLA * 0.2;
  totale_VFCLA = somma_VFCLA * 1.2;
  document.getElementById("somma_VFCLA").value = somma_VFCLA.toFixed(2);
  document.getElementById("iva_VFCLA").value = iva_VFCLA.toFixed(2);
  document.getElementById("totale_VFCLA").value = totale_VFCLA.toFixed(2);
  if ( document.getElementById("quantita_VFCLA").value != 0 ) {
	elenco_prodotti = elenco_prodotti + '<br>n.' + document.getElementById("quantita_VFCLA").value + ' Verduzzo Friulano Doc, bianco dolce (2004)'; }
  
  quantita = quantita + eval(document.getElementById("quantita_MECRU").value);
  somma_MECRU = document.getElementById("quantita_MECRU").value * document.getElementById("prezzo_MECRU").value;
  iva_MECRU = somma_MECRU * 0.2;
  totale_MECRU = somma_MECRU * 1.2;
  document.getElementById("somma_MECRU").value = somma_MECRU .toFixed(2);
  document.getElementById("iva_MECRU").value = iva_MECRU .toFixed(2);
  document.getElementById("totale_MECRU").value = totale_MECRU .toFixed(2);
  if ( document.getElementById("quantita_MECRU").value != 0 ) {
	elenco_prodotti = elenco_prodotti + '<br>n.' + document.getElementById("quantita_MECRU").value + ' Merlot Doc, rosso secco strutturato (2004)'; }
 
  quantita = quantita + eval(document.getElementById("quantita_CFCRU").value);
  somma_CFCRU = document.getElementById("quantita_CFCRU").value * document.getElementById("prezzo_CFCRU").value;
  iva_CFCRU = somma_CFCRU * 0.2;
  totale_CFCRU = somma_CFCRU * 1.2;
  document.getElementById("somma_CFCRU").value = somma_CFCRU .toFixed(2);
  document.getElementById("iva_CFCRU").value = iva_CFCRU .toFixed(2);
  document.getElementById("totale_CFCRU").value = totale_CFCRU .toFixed(2);
  if ( document.getElementById("quantita_CFCRU").value != 0 ) {
	elenco_prodotti = elenco_prodotti + '<br>n.' + document.getElementById("quantita_CFCRU").value + ' Cabernet Franc Doc, rosso secco strutturato (2004)'; }
  
  quantita = quantita + eval(document.getElementById("quantita_TFCRU").value);
  somma_TFCRU = document.getElementById("quantita_TFCRU").value * document.getElementById("prezzo_TFCRU").value;
  iva_TFCRU = somma_TFCRU * 0.2;
  totale_TFCRU = somma_TFCRU * 1.2;
  document.getElementById("somma_TFCRU").value = somma_TFCRU .toFixed(2);
  document.getElementById("iva_TFCRU").value = iva_TFCRU .toFixed(2);
  document.getElementById("totale_TFCRU").value = totale_TFCRU .toFixed(2);
  if ( document.getElementById("quantita_TFCRU").value != 0 ) {
	elenco_prodotti = elenco_prodotti + '<br>n.' + document.getElementById("quantita_TFCRU").value + ' Tocai Friulano Doc, bianco secco strutturato (2004)'; }

  quantita = quantita + eval(document.getElementById("quantita_CHCRU").value);
  somma_CHCRU = document.getElementById("quantita_CHCRU").value * document.getElementById("prezzo_CHCRU").value;
  iva_CHCRU = somma_CHCRU * 0.2;
  totale_CHCRU = somma_CHCRU * 1.2;
  document.getElementById("somma_CHCRU").value = somma_CHCRU .toFixed(2);
  document.getElementById("iva_CHCRU").value = iva_CHCRU .toFixed(2);
  document.getElementById("totale_CHCRU").value = totale_CHCRU .toFixed(2);
   if ( document.getElementById("quantita_CHCRU").value != 0 ) {
	elenco_prodotti = elenco_prodotti + '<br>n.' + document.getElementById("quantita_CHCRU").value + ' Chardonnay Doc, bianco secco strutturato (2004)'; }

  quantita = quantita + eval(document.getElementById("quantita_PGFT").value);
  somma_PGFT = document.getElementById("quantita_PGFT").value * document.getElementById("prezzo_PGFT").value;
  iva_PGFT = somma_PGFT * 0.2;
  totale_PGFT = somma_PGFT * 1.2;
  document.getElementById("somma_PGFT").value = somma_PGFT.toFixed(2);
  document.getElementById("iva_PGFT").value = iva_PGFT.toFixed(2);
  document.getElementById("totale_PGFT").value = totale_PGFT.toFixed(2);
   if ( document.getElementById("quantita_PGFT").value != 0 ) {
	elenco_prodotti = elenco_prodotti + '<br>n.' + document.getElementById("quantita_PGFT").value + ' Finis Terrae Grigio Igt, bianco secco ramato (2002)'; }
 
  quantita = quantita + eval(document.getElementById("quantita_BIFT").value);
  somma_BIFT = document.getElementById("quantita_BIFT").value * document.getElementById("prezzo_BIFT").value;
  iva_BIFT = somma_BIFT * 0.2;
  totale_BIFT = somma_BIFT * 1.2;
  document.getElementById("somma_BIFT").value = somma_BIFT.toFixed(2);
  document.getElementById("iva_BIFT").value = iva_BIFT.toFixed(2);
  document.getElementById("totale_BIFT").value = totale_BIFT.toFixed(2);
   if ( document.getElementById("quantita_BIFT").value != 0 ) {
	elenco_prodotti = elenco_prodotti + '<br>n.' + document.getElementById("quantita_BIFT").value + ' Finis Terrae Bianco Igt, bianco secco aff.legno (2002)'; }
  
  quantita = quantita + eval(document.getElementById("quantita_ROFT").value);
  somma_ROFT = document.getElementById("quantita_ROFT").value * document.getElementById("prezzo_ROFT").value;
  iva_ROFT = somma_ROFT * 0.2;
  totale_ROFT = somma_ROFT * 1.2;
  document.getElementById("somma_ROFT").value = somma_ROFT.toFixed(2);
  document.getElementById("iva_ROFT").value = iva_ROFT.toFixed(2);
  document.getElementById("totale_ROFT").value = totale_ROFT.toFixed(2);
   if ( document.getElementById("quantita_ROFT").value != 0 ) {
	elenco_prodotti = elenco_prodotti + '<br>n.' + document.getElementById("quantita_ROFT").value + ' Finis Terrae Rosso Igt, rosso secco aff.legno (2002)'; }

  quantita = quantita + eval(document.getElementById("quantita_NEFT").value); 
  somma_NEFT = document.getElementById("quantita_NEFT").value * document.getElementById("prezzo_NEFT").value;
  iva_NEFT = somma_NEFT * 0.2;
  totale_NEFT = somma_NEFT * 1.2;
  document.getElementById("somma_NEFT").value = somma_NEFT.toFixed(2);
  document.getElementById("iva_NEFT").value = iva_NEFT.toFixed(2);
  document.getElementById("totale_NEFT").value = totale_NEFT.toFixed(2);  
   if ( document.getElementById("quantita_NEFT").value != 0 ) {
	elenco_prodotti = elenco_prodotti + '<br>n.' + document.getElementById("quantita_NEFT").value + ' Finis Terrae Nero Igt, rosso secco aff.legno (2002)'; }

  quantita = quantita + eval(document.getElementById("quantita_PASSI").value); 
  somma_PASSI = document.getElementById("quantita_PASSI").value * document.getElementById("prezzo_PASSI").value;
  iva_PASSI = somma_PASSI * 0.2;
  totale_PASSI = somma_PASSI * 1.2;
  document.getElementById("somma_PASSI").value = somma_PASSI.toFixed(2);
  document.getElementById("iva_PASSI").value = iva_PASSI.toFixed(2);
  document.getElementById("totale_PASSI").value = totale_PASSI.toFixed(2);  
   if ( document.getElementById("quantita_PASSI").value != 0 ) {
	elenco_prodotti = elenco_prodotti + '<br>n.' + document.getElementById("quantita_PASSI").value + ' Finis Terrae Oro Igt, bianco dolce passito (2002)'; }

  quantita = quantita + eval(document.getElementById("quantita_SPUM").value); 
  somma_SPUM = document.getElementById("quantita_SPUM").value * document.getElementById("prezzo_SPUM").value;
  iva_SPUM = somma_SPUM * 0.2;
  totale_SPUM = somma_SPUM * 1.2;
  document.getElementById("somma_SPUM").value = somma_SPUM.toFixed(2);
  document.getElementById("iva_SPUM").value = iva_SPUM.toFixed(2);
  document.getElementById("totale_SPUM").value = totale_SPUM.toFixed(2);  
   if ( document.getElementById("quantita_SPUM").value != 0 ) {
	elenco_prodotti = elenco_prodotti + '<br>n.' + document.getElementById("quantita_SPUM").value + ' Spumante, metodo champenois (2007)'; }
	
  quantita = quantita + eval(document.getElementById("quantita_GRAP").value); 
  somma_GRAP = document.getElementById("quantita_GRAP").value * document.getElementById("prezzo_GRAP").value;
  iva_GRAP = somma_GRAP * 0.2;
  totale_GRAP = somma_GRAP * 1.2;
  document.getElementById("somma_GRAP").value = somma_GRAP.toFixed(2);
  document.getElementById("iva_GRAP").value = iva_GRAP.toFixed(2);
  document.getElementById("totale_GRAP").value = totale_GRAP.toFixed(2);  
   if ( document.getElementById("quantita_GRAP").value != 0 ) {
	elenco_prodotti = elenco_prodotti + '<br>n.' + document.getElementById("quantita_GRAP").value + ' Grappa, bianca secca'; }

	somme_somma = somma_MECLA + somma_CFCLA + somma_CHCLA + somma_TFCLA + somma_VFCLA + somma_MECRU + somma_CFCRU + somma_TFCRU + somma_CHCRU + somma_PGFT + somma_BIFT + somma_ROFT + somma_NEFT + somma_PASSI + somma_GRAP + somma_SPUM;
	somme_iva = somme_somma * 0.2; 
	somme_totale = somme_somma * 1.2;
	document.getElementById("somme_quantita").value = quantita;
	document.getElementById("somme_somma").value = somme_somma.toFixed(2);  
	document.getElementById("somme_iva").value = somme_iva.toFixed(2);  
	document.getElementById("somme_totale").value = somme_totale.toFixed(2);

//	sconto_somma = somme_somma * document.getElementById("sconto").value;
//	sconto_iva = somme_iva * document.getElementById("sconto").value;
	sconto_totale = somme_totale * document.getElementById("sconto").value;
//	document.getElementById("sconto_somma").value = sconto_somma.toFixed(2);  
//	document.getElementById("sconto_iva").value = sconto_iva .toFixed(2);  
	document.getElementById("sconto_totale").value = sconto_totale.toFixed(2);    

	document.getElementById("elenco_prodotti").innerHTML = elenco_prodotti;
	totale_lordo = somme_totale - sconto_totale + eval(document.getElementById("spese").value);
	document.getElementById("totale_lordo").value = totale_lordo.toFixed(2); 	
	document.getElementById("htotale_lordo").innerHTML = totale_lordo.toFixed(2); 	
}

function aggiorna_ana() {
	var anagrafica = '';
	anagrafica = anagrafica + document.getElementById("nome_cliente").value + '<br>';
	anagrafica = anagrafica + document.getElementById("indirizzo_cliente").value + '<br>';
	anagrafica = anagrafica + document.getElementById("cap_cliente").value + ' ';
	anagrafica = anagrafica + document.getElementById("paese_cliente").value + ' ';
	if ( document.getElementById("provincia_cliente").value != '') {
		anagrafica = anagrafica + '(' + document.getElementById("provincia_cliente").value + ')';
	}
	if ( document.getElementById("telefono_cliente").value != '') {
		anagrafica = anagrafica + '<br>Telefono ' + document.getElementById("telefono_cliente").value;
	} 
	if ( document.getElementById("email_cliente").value != '') {
		anagrafica = anagrafica + '<br>Email ' + document.getElementById("email_cliente").value;
	} 
	document.getElementById("anagrafica").innerHTML = anagrafica;

	var spedizione = '<b>SPEDIZIONE</b><br>';
	spedizione = spedizione + document.getElementById("nome_spedizione").value + '<br>'; 
	spedizione = spedizione + document.getElementById("indirizzo_spedizione").value + '<br>'
	spedizione = spedizione + document.getElementById("cap_spedizione").value + ' ' + document.getElementById("paese_spedizione").value;
	if (document.getElementById("provincia_spedizione").value != '') {
		spedizione = spedizione + ' (' + document.getElementById("provincia_spedizione").value + ')'; }
	document.getElementById("dati_spedizione").innerHTML = spedizione;

	var pagamento = '<b>PAGAMENTO</b><br>';
	if ( document.getElementById("pagamento").checked ) { pagamento = pagamento + 'Alla consegna del corriere' }
	if ( document.getElementById("pagamento2").checked ) { pagamento = pagamento + 'Carta di credito' }
	if ( document.getElementById("pagamento3").checked ) { pagamento = pagamento + 'Bonifico bancario anticipato' }
	document.getElementById("dati_pagamento").innerHTML = pagamento;

	var note = '<b>NOTE</b><br>';
	note = note + document.getElementById("note").value;
	document.getElementById("dati_note").innerHTML = note;	
}
