<!--  Activate Cloaking Device
//***************************************************************************
//
//                          Formatting Money Values
//
//                by Tim Wallace   (timothy@essex1.com)
//
//    [ fmtPrice() function  by Rolf Howarth  (rolf@paralax.co.uk) ]
//
//***************************************************************************

function fmtPrice(value)
   {
   result="€"+Math.floor(value)+".";
   var cents=100*(value-Math.floor(value))+0.5;
   result += Math.floor(cents/10);
   result += Math.floor(cents%10);
   return result;
   }

// Called by the COMPUTE button; computes and displays the values in the lower table.
function compute()
   {
   // computes and displays the unformatted tax value.
   var unformatted_tax = (document.forms[5].cost.value)*(document.forms[5].tax.value);
   document.forms[5].unformatted_tax.value=unformatted_tax;

   // computes and displays the formatted tax value.
   var formatted_tax = fmtPrice(unformatted_tax);
   document.forms[5].formatted_tax.value=formatted_tax;

   // computes and displays the formatted total cost value.
   var cost3= eval( document.forms[5].cost.value );   
   cost3 += eval( (document.forms[5].cost.value)*(document.forms[5].tax.value) ); 
   var total_cost = fmtPrice(cost3);
   document.forms[5].total_cost.value=total_cost;
   }

//  Called by Reset button - sets original values.
function resetIt()
   {
   document.forms[5].cost.value="19.95";
   document.forms[5].tax.value=".06";
   document.forms[5].unformatted_tax.value="";
   document.forms[5].formatted_tax.value="";
   document.forms[5].total_cost.value="";   
   }

// Called by About button - info on example.
function about1()
   {
   alert("\nQuesta è una versione dimostrativa per calcolare la tassazione in Euro.\n\nInserisci i valori del costo e della tassa (x es. inserisci .06 o 0.06 che sono uguali al 6%) e premi Calcola.\n\nQuesto schema utilizza la funzione fmtPrice() di Rolf Howarth.");
   }

//-->