var el; el = document.getElementById("cookieCoopContainer"); var seen = getCookie('hidecookie'); if (seen === null) { el.style.display = "block"; } function closeCookieCoop() { setCookie('hidecookie', '1', 300); console.log('close cookie'); el = document.getElementById("cookieCoopContainer"); el.style.display = "none"; } function AJAXform( formID, buttonID, formMethod = 'post', activity = 'lead', from, policy_id) { var selectForm = document.getElementById(formID); var selectButton = document.getElementById(buttonID); var formAction = document.getElementById(formID).getAttribute('action'); var formInputs = document.getElementById(formID).querySelectorAll("input"); function XMLhttp(){ var httpRequest = new XMLHttpRequest(); var formData = new FormData(); formData.append("activity", activity); formData.append("sent_from", from); formData.append("policy_id", policy_id); for( var i=0; i < formInputs.length; i++ ){ formData.append(formInputs[i].name, formInputs[i].value); } httpRequest.onreadystatechange = function(){ if ( this.readyState == 4 && this.status == 200 ) { setTimeout(function(){ selectForm.submit(); }, 200); } }; httpRequest.open(formMethod, "https://cooplists.com/activity"); httpRequest.send(formData); } selectButton.onclick = function(){ XMLhttp(); } selectForm.onsubmit = function(event){ return false; } } function setCookie(name,value,days) { var expires = ""; if (days) { var date = new Date(); date.setTime(date.getTime() + (days*24*60*60*1000)); expires = "; expires=" + date.toUTCString(); } document.cookie = name + "=" + (value || "") + expires + "; path=/"; } function getCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; }