<?php
$page_title = "Epoxy Chip Flooring Calculator | Epoxy.com";
$meta_description = "Epoxy chip flooring calculator. Enter square footage to estimate #315BC base coat, decorative chip pounds, and #315Top topcoat kits. Optional primer uses #315Top to avoid buying a third resin.";
include $_SERVER['DOCUMENT_ROOT'].'/includes/header.php';
?>

<!--
File: epoxy-chip-flooring-calculator.aspx
Purpose:
  Replace the existing chip flooring calculator without changing file name or location.

System assumptions:
  - #315BC base coat coverage: 216 SF per gallon
  - #315BC unit size: 3 gallons
  - Decorative chips usage: 55 lb per 650 SF
  - Chips sold as 40 lb boxes and 10 lb bags
  - #315Top two-coat combined coverage: 144 SF per gallon
  - #315Top unit size: 3 gallons
  - Optional primer using #315Top: 200 SF per gallon

Important:
  - No waste factor included
  - Customer should add allowance for jobsite conditions
-->

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "WebApplication",
  "name": "Epoxy Chip Flooring Calculator",
  "description": "Calculator to estimate Epoxy.com chip flooring materials: #315BC base coat, decorative chips, and #315Top for two topcoats and optional primer.",
  "applicationCategory": "Calculator",
  "operatingSystem": "All",
  "publisher": {
    "@type": "Organization",
    "name": "Epoxy.com"
  }
}
</script>

<h1>Epoxy Chip Flooring Calculator</h1>

<p>
Enter your total floor area in square feet to estimate material quantities for an Epoxy.com chip flooring system.
This calculator does not include waste.
</p>

<div class="container" style="max-width:760px;">

  <div style="margin:1em 0;">
    <label for="sqft"><strong>Total Area</strong> (square feet)</label><br />
    <input type="number" id="sqft" min="0" step="0.01" style="max-width:220px;" />
  </div>

  <div style="margin:1em 0;">
    <label>
      <input type="checkbox" id="includePrimer" />
      <strong>Include optional primer</strong> using #315Top (200 SF per gallon)
    </label>
    <div style="font-size:0.95em; margin-top:0.25em;">
      Primer is only needed when the job calls for it. Using #315Top as primer avoids buying a third resin.
    </div>
  </div>

  <div style="margin:1.25em 0;">
    <button type="button" onclick="calculateChipFlooring()">Calculate</button>
  </div>

  <div id="calcError" style="display:none; border:1px solid #f3c2c2; background:#fff5f5; padding:1em; border-radius:6px; margin-top:1em; color:#b00000;">
  </div>

  <div id="calcResults" style="display:none; border:1px solid #ccc; padding:1em; border-radius:6px; margin-top:1em;">
    <h2 style="margin-top:0;">Results</h2>

    <p><strong>Area:</strong> <span id="outArea"></span></p>

    <hr />

    <div id="primerSection">
      <h3 style="margin-bottom:0.25em;">Optional Primer: #315Top</h3>
      <p style="margin-top:0.25em;">
        <strong>Primer gallons:</strong> <span id="outPrimerGal"></span><br />
        <strong>Primer units (3-gallon, rounded up):</strong> <span id="outPrimerKits"></span>
      </p>
      <hr />
    </div>

    <h3 style="margin-bottom:0.25em;">1) Base Coat: #315BC</h3>
    <p style="margin-top:0.25em;">
      <strong>Coverage:</strong> 216 SF per gallon<br />
      <strong>Base coat gallons:</strong> <span id="outBCGal"></span><br />
      <strong>Base coat units (3-gallon, rounded up):</strong> <span id="outBCKits"></span>
    </p>

    <h3 style="margin-bottom:0.25em;">2) Decorative Chips</h3>
    <p style="margin-top:0.25em;">
      <strong>Chip usage:</strong> 55 lb per 650 SF<br />
      <strong>Raw chip pounds needed:</strong> <span id="outChipsRaw"></span><br />
      <strong>Order chips as:</strong> <span id="outChipsPackaging"></span><br />
      <strong>Total ordered chip pounds:</strong> <span id="outChipsOrder"></span>
    </p>

    <h3 style="margin-bottom:0.25em;">3) Topcoats: #315Top</h3>
    <p style="margin-top:0.25em;">
      <strong>Two-coat combined coverage:</strong> 144 SF per gallon<br />
      <strong>Topcoat gallons:</strong> <span id="outTopGal"></span><br />
      <strong>Topcoat units (3-gallon, rounded up):</strong> <span id="outTopKits"></span>
    </p>

    <div id="topCombinedSection">
      <hr />
      <h3 style="margin-bottom:0.25em;">Total #315Top Required</h3>
      <p style="margin-top:0.25em;">
        <strong>Total #315Top gallons (primer + topcoats):</strong> <span id="outTopTotalGal"></span><br />
        <strong>Total #315Top units (3-gallon, rounded up):</strong> <span id="outTopTotalKits"></span>
      </p>
    </div>

    <hr />

    <p style="margin-top:0.75em;">
      <em>Note:</em> No waste factor is included. Add your own allowance for porosity, surface profile,
      mixing loss, broadcast loss, and installer preference.
    </p>
  </div>

</div>

<script>
function ceilUnits(gallonsNeeded, unitGallons) {
  let units = Math.ceil(gallonsNeeded / unitGallons);
  if (units < 1) units = 1;
  return units;
}

function formatNumber(value, decimals) {
  return Number(value).toFixed(decimals);
}

function calculateChipPackaging(rawLb) {
  const CHIP_BOX_LB = 40;
  const CHIP_BAG_LB = 10;

  let boxCount = 0;
  let bagCount = 0;

  if (rawLb > 0) {
    boxCount = Math.floor(rawLb / CHIP_BOX_LB);
    let remainingLb = rawLb - (boxCount * CHIP_BOX_LB);

    if (remainingLb > 0) {
      bagCount = Math.ceil(remainingLb / CHIP_BAG_LB);
    }

    if (bagCount === 4) {
      boxCount += 1;
      bagCount = 0;
    }

    if (boxCount === 0 && bagCount === 0) {
      bagCount = 1;
    }
  }

  const totalOrderLb = (boxCount * CHIP_BOX_LB) + (bagCount * CHIP_BAG_LB);

  let packagingText = "";
  if (boxCount > 0 && bagCount > 0) {
    packagingText = boxCount + " box(es) of 40 lb and " + bagCount + " bag(s) of 10 lb";
  } else if (boxCount > 0) {
    packagingText = boxCount + " box(es) of 40 lb";
  } else {
    packagingText = bagCount + " bag(s) of 10 lb";
  }

  return {
    boxCount: boxCount,
    bagCount: bagCount,
    totalOrderLb: totalOrderLb,
    packagingText: packagingText
  };
}

function calculateChipFlooring() {
  const BC_SF_PER_GAL = 216.0;
  const TOP_SF_PER_GAL_TWO_COATS = 144.0;
  const PRIMER_SF_PER_GAL = 200.0;
  const UNIT_GAL = 3.0;
  const CHIPS_LB_PER_SF = 55.0 / 650.0;

  const sqftInput = document.getElementById("sqft");
  const includePrimer = document.getElementById("includePrimer").checked;
  const errorBox = document.getElementById("calcError");
  const resultsBox = document.getElementById("calcResults");

  const sf = parseFloat(sqftInput.value);

  errorBox.style.display = "none";
  errorBox.innerHTML = "";
  resultsBox.style.display = "none";

  if (isNaN(sf) || sf <= 0) {
    errorBox.innerHTML = "<strong>Error:</strong> Please enter a valid positive square footage.";
    errorBox.style.display = "block";
    return;
  }

  const bcGal = sf / BC_SF_PER_GAL;
  const bcKits = ceilUnits(bcGal, UNIT_GAL);

  const chipsRawLb = sf * CHIPS_LB_PER_SF;
  const chipPackaging = calculateChipPackaging(chipsRawLb);

  const topGal = sf / TOP_SF_PER_GAL_TWO_COATS;
  const topKits = ceilUnits(topGal, UNIT_GAL);

  let primerGal = 0;
  let primerKits = 0;

  if (includePrimer) {
    primerGal = sf / PRIMER_SF_PER_GAL;
    primerKits = ceilUnits(primerGal, UNIT_GAL);
  }

  const topTotalGal = topGal + primerGal;
  const topTotalKits = ceilUnits(topTotalGal, UNIT_GAL);

  document.getElementById("outArea").textContent = formatNumber(sf, 2) + " SF";

  document.getElementById("outBCGal").textContent = formatNumber(bcGal, 2) + " gallons";
  document.getElementById("outBCKits").textContent = bcKits + " unit(s)";

  document.getElementById("outChipsRaw").textContent = formatNumber(chipsRawLb, 1) + " lb";
  document.getElementById("outChipsPackaging").textContent = chipPackaging.packagingText;
  document.getElementById("outChipsOrder").textContent = chipPackaging.totalOrderLb + " lb";

  document.getElementById("outTopGal").textContent = formatNumber(topGal, 2) + " gallons";
  document.getElementById("outTopKits").textContent = topKits + " unit(s)";

  const primerSection = document.getElementById("primerSection");
  const topCombinedSection = document.getElementById("topCombinedSection");

  if (includePrimer) {
    document.getElementById("outPrimerGal").textContent = formatNumber(primerGal, 2) + " gallons";
    document.getElementById("outPrimerKits").textContent = primerKits + " unit(s)";
    document.getElementById("outTopTotalGal").textContent = formatNumber(topTotalGal, 2) + " gallons";
    document.getElementById("outTopTotalKits").textContent = topTotalKits + " unit(s)";
    primerSection.style.display = "block";
    topCombinedSection.style.display = "block";
  } else {
    primerSection.style.display = "none";
    topCombinedSection.style.display = "none";
  }

  resultsBox.style.display = "block";
}
</script>

<?php include $_SERVER['DOCUMENT_ROOT'].'/includes/footer.php'; ?>