prices = new Array();
prices[0] = 14;
prices[1] = 7;
prices[2] = 60;
prices[3] = 18;

function calculatePrice()
{
  var total = 0;
  for(var i=0; i<prices.length; i++)
  {
    var amount = document.gutscheinform["num_" + i].value;
    if(!validateInt(amount))
    {
      amount = 0;
      document.gutscheinform["num_" + i].value = amount;
    }
    // calculate TASTE OF DARKNESS (number tickets times number persons)
    if(i == 2)
    {
      var numPersons = document.gutscheinform["num_" + i + "_p"].value;
      if(!validateInt(numPersons))
      {
        numPersons = 0;
        document.gutscheinform["num_" + i + "_p"].value = numPersons;
      }
      amount = amount * numPersons;
    }
      
    var price = amount * prices[i];
    var priceField = document.getElementById("preis_" + i);
    priceField.innerHTML = price;
    total += price;
  }
  // add 2 EUR Versandkosten
  if(total > 0)
    total += 2;
  var totalField = document.getElementById("preis_gesamt");
  totalField.innerHTML = total;
  document.gutscheinform["total"].value = total;
}

function validateInt(iString)
{
  // no leading 0s allowed
  return (("" + parseInt(iString)) == iString);
}

