function initializeCalculator()
{
  setTimeout('updateCalculator()', 10);
}

function updateCalculator()
{
 price = Math.round(document.getElementById('txtPrice').value * 100) / 100;
 brokeragePercentStr = document.getElementById('txtBrokerPercent').value;
 
 brokerage = Math.round(document.getElementById('txtBrokerPercent').value.replace(/,/,'.') * document.getElementById('txtPrice').value) / 100;
 
 if(price>0 || brokerage>0)
 {
   tax1 = Math.round(price * 2) / 100;
   document.getElementById('roTax1').value = tax1;
   if(price <= 3000) tax2 = 100;
   else if(price <= 10000) tax2 = 100 + ((price-3000) * 0.03);
   else if(price <= 30000) tax2 = 310 + ((price-10000) * 0.02);
   else if(price <= 60000) tax2 = 710 + ((price-30000) * 0.01);
   else if(price <= 1000000) tax2 = 1010 + ((price-60000) * 0.005);
   else tax2 = (5710 + ((price - 1000000)*0.0025));
   tax2 = Math.round(tax2 * 100) / 100;
   if(document.getElementById('sbKind').value<3) tax2 = tax2 / 2;
   document.getElementById('roTax2').value = tax2;
   vat = Math.round(tax2 * 22) / 100;
   document.getElementById('roVat').value = vat;
   document.getElementById('roBrokerPercent').value = brokerage;
   brokerage_vat = Math.round(document.getElementById('roBrokerPercent').value * 22) / 100;
   document.getElementById('roBrokerVat').value = brokerage_vat;
   if(document.getElementById('sbKind').value==1) payment = 0;
   else payment = 200;
   document.getElementById('roGovernPayment').value = payment;
   ap = Math.round((tax1 + tax2 + vat + brokerage + brokerage_vat + payment + 100) * 100) / 100;
   document.getElementById('roAdditionalPayments').value = ap;
   sum = Math.round((price + ap) * 100) / 100;
   document.getElementById('roSum').value = sum;
 }
 
 setTimeout('updateCalculator()', 10);
}
