function checkinput() {
  if (!clients.value || isNaN(clients.value)) {
    clients.focus();
    clients.select();
    alert("You entered an invalid value");
    return false;
  }
  if (!playerfraction.value || isNaN(playerfraction.value)) {
    playerfraction.focus();
    playerfraction.select();
    alert("You entered an invalid value");
    return false;
  }
  if (!priceperplayer.value || isNaN(priceperplayer.value)) {
    priceperplayer.focus();
    priceperplayer.select();
    alert("You entered an invalid value");
    return false;
  }
  if (!pppcost.value || isNaN(pppcost.value)) {
    pppcost.focus();
    pppcost.select();
    alert("You entered an invalid value");
    return false;
  }
  if (!btw.value || isNaN(btw.value)) {
    btw.focus();
    btw.select();
    alert("You entered an invalid value");
    return false;
  }
  if (!vests.value || isNaN(vests.value)) {
    vests.focus();
    vests.select();
    alert("You entered an invalid value");
    return false;
  }
  return true;
}

function computeplayers() {
  var fPlayers = parseFloat(clients.value);
  fPlayers = fPlayers * parseFloat(playerfraction.value) / 100.0;
  players.value = Math.round(fPlayers);
  return;
}

function computerevenue() {
  if (!checkinput()) {
    players.value = " ";
    revenue.value = " ";
    time.value = " ";
    return;
  }
  computeplayers();
  var fPrice = parseFloat(priceperplayer.value);
  var fBTW = parseFloat(btw.value);
  var fPPPcosts = parseFloat(pppcost.value);
  
  var fRevenue = parseFloat(players.value) * ((fPrice * (100.0 - fBTW) /100.0) - fPPPcosts);
  revenue.value = Math.round(fRevenue);
  time.value = Math.round((parseFloat(players.value) / parseFloat(vests.value)) / 3.0);
  return false;
}

function resetrevenue() {
  clients.value = "5000";
  playerfraction.value = "100";
  priceperplayer.value = "8.50";
  btw.value = "6.0";
  pppcost.value = "1.29";
  vests.value = "20";
  players.value = " ";
  revenue.value = " ";
  time.value = " ";
  return false;
}

function explainppp() {
  alert("If your LaserMaxx system is financed through our Pay-Per-Play financing program, \
then this is the price that you pay for each player. \
Usually, this is EURO 1,29. If you have purchased the LaserMaxx system, then this cost is zero.");
}

function explaintax() {
  alert("Every country has its own sales-tax percentage, also known as Value Added Tax. \
this determines how much tax you must pay over each retail transaction. \
In Europe this tax must be included in the retail asking price for your product or service.");
}