function calculate()
{
  var price = parseInt(document.getElementById('vehicle-price').value);
  var location_tax = parseInt(document.getElementById('location').value);
  var virtual_bid_tax = 30;
  var gate_tax = 35;
  var klaipeda_transport_tax = 1700;
  var auction_tax;
  var total_sum;
  var regex = /^([\d]+)$/;
  var i;
  var j = 0;

  if ((regex.test(price) != true) || (price <= 0))
  {
    alert('Please enter vehicle price');
    return;
  }
  
  prices = new Array(12);

  prices[0] = 1;
  prices[1] = 100;
  prices[2] = 200;
  prices[3] = 400;
  prices[4] = 600;
  prices[5] = 800;
  prices[6] = 1000;
  prices[7] = 1200;
  prices[8] = 1400;
  prices[9] = 1700;
  prices[10] = 2000;
  prices[11] = 2500;

  taxes = new Array(12);

  taxes[0] = 20;
  taxes[1] = 45;
  taxes[2] = 65;
  taxes[3] = 85;
  taxes[4] = 105;
  taxes[5] = 125;
  taxes[6] = 145;
  taxes[7] = 165;
  taxes[8] = 185;
  taxes[9] = 205;
  taxes[10] = 225;
  taxes[11] = 350;

/*  for (i = 0; i < prices.length; i++)
  {
    if ((prices[i] > price) && (i != prices.length - 1))
    {
      auction_tax = taxes[i-1];
      break;
    } else
    if ((prices[i] == price) || (i == prices.length - 1))
    {
      auction_tax = taxes[i];
      break;
    }
  }  */

  for (i = 0; i < prices.length; i++)
  {
    if ((price > prices[i]) && (i < prices.length - 1))
    {
      j = i;
    } else
    if (price < prices[i])
    {
      auction_tax = taxes[j];
      break;
    } else
    {
      auction_tax = taxes[i];
      break;
    }
  }

  total_sum = price + location_tax + auction_tax + virtual_bid_tax + gate_tax + klaipeda_transport_tax;

  document.getElementById('auction-tax').innerHTML = '$' + auction_tax;
  document.getElementById('virtual-bid-tax').innerHTML = '$' + virtual_bid_tax;
  document.getElementById('gate-tax').innerHTML = '$' + gate_tax;
  document.getElementById('container-transport').innerHTML = '$' + location_tax;
  document.getElementById('klaipeda-transport').innerHTML = '$' + klaipeda_transport_tax;
  document.getElementById('total').innerHTML = '$' + total_sum;
}