(function(){var intervalId;var mouseHold;var heldCount;function _click(e){e.dispatchEvent(new Event("click"));heldCount++}
if(document.querySelector('.calculator .calculation'))document.querySelectorAll('.calculator .calculation').forEach(function(el){el.innerHTML='
* | Coverage may vary due to porosity and texture of substrate. |
'});if(document.querySelector('.project_sqft')){document.querySelectorAll('.project_sqft').forEach(function(el,i){el.setAttribute("id","project_sqft"+i);el.setAttribute("data-id",i);el.parentNode.setAttribute("id","project_sqft_form"+i);el.addEventListener("change",calculator);el.addEventListener("keyup",calculator)});if(document.querySelector('.number-up')){document.querySelectorAll('.number-up').forEach(function(el,i){el.addEventListener("click",function(event){event.preventDefault();let e=this.parentNode.querySelector('input[type=number]');if(e.value&&e.value>0){if(heldCount>10){e.value=parseInt(e.value)+10}else e.stepUp()}else e.value=1;e.dispatchEvent(new Event('change'))});el.addEventListener("mousedown",function(event){event.preventDefault();heldCount=0;mouseHold=setTimeout(function(event){intervalId=setInterval(_click,100,event.target)},500,event)});el.addEventListener("mouseup",function(event){event.preventDefault();heldCount=0;clearTimeout(mouseHold);clearInterval(intervalId)});el.addEventListener("mouseout",function(event){event.preventDefault();heldCount=0;clearTimeout(mouseHold);clearInterval(intervalId)})})}
if(document.querySelector('.number-down')){document.querySelectorAll('.number-down').forEach(function(el,i){el.addEventListener("click",function(event){event.preventDefault();let e=this.parentNode.querySelector('input[type=number]');if(e.value&&e.value>1){if(heldCount>10&&e.value>10){e.value=parseInt(e.value)-10}else e.stepDown();e.dispatchEvent(new Event('change'))}});el.addEventListener("mousedown",function(event){event.preventDefault();heldCount=0;mouseHold=setTimeout(function(event){intervalId=setInterval(_click,100,event.target)},500,event)});el.addEventListener("mouseup",function(event){event.preventDefault();heldCount=0;clearTimeout(mouseHold);clearInterval(intervalId)});el.addEventListener("mouseout",function(event){event.preventDefault();heldCount=0;clearTimeout(mouseHold);clearInterval(intervalId)})})}}
var e_val=0;var responseText="";function calculator(event){var e=event.target;if(!e.value||e.value==e_val)return!0;e_val=e.value;document.querySelectorAll('.project_sqft').forEach(function(el,i){if(i!=e.getAttribute("data-id"))el.value=e_val});document.querySelectorAll('label[for="project_sqft"]').forEach(function(el,i){el.classList.add("active");el.style.textIndent=.5+parseInt(e.value.length)*.6+"em"});var xhttp=new XMLHttpRequest();xhttp.onreadystatechange=function(){if(this.readyState==4&&this.status==200){responseText=this.responseText;document.querySelectorAll('.calculator .calculation').forEach(function(el){el.innerHTML=responseText})}};xhttp.open("POST","/sqftcalculate.php");var data=new FormData();data.append("project_coverage",document.querySelector('input[name="project_coverage"]').value);data.append("project_coats",document.querySelector('input[name="project_coats"]').value);data.append("project_model",document.querySelector('input[name="project_model"]').value);data.append("project_containers",document.querySelector('input[name="project_containers"]').value);data.append("project_shopify_id",document.querySelector('input[name="project_shopify_id"]').value);data.append("project_concentrate",document.querySelector('input[name="project_concentrate"]')?document.querySelector('input[name="project_concentrate"]').value:0);data.append("project_sqft",e.value);xhttp.send(data)}})()