var namesList=[],storedFiles=[],filesCount=0;function a(e){return Date.parse(e)}e=/^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i;if($("#attach-files-button").length){$("#contact_attachments").change(function(event){if(event.target.files){let files=Array.prototype.slice.call(event.target.files);files.forEach(function(file){if(!namesList.includes(file.name)){storedFiles.push(file);namesList.push(file.name)}});let html="";for(let i=0;i`;html+=``;html+=`${fileName}`;html+=``;html+=""}$("#selected-files").html(html);let fileCountText=storedFiles.length===1?" File Selected":" Files Selected";$("#selected-files-count").html(storedFiles.length+fileCountText)}});$(document.body).on("click","#attach-files-button",function(event){event.preventDefault();$("#contact_attachments").trigger("click")});$(document.body).on("click",".remove-appended-file",function(event){event.preventDefault();let fileName=$(this).data("file");namesList=namesList.filter(name=>name!==fileName);storedFiles=storedFiles.filter(file=>file.name!==fileName);$(this).parent().remove();let fileCountText=storedFiles.length===1?" File Selected":" Files Selected";$("#selected-files-count").html(storedFiles.length+fileCountText)})}$(document.body).on("click","#submit-contact-button",function(event){event.preventDefault();let hasError=false;let numberPattern=/^[0-9]+$/;$(".contact-form-input").each(function(index,element){if($(element).data("rule")!==undefined){let value=$(element).val().trim();let fieldName=$(element).data("field-name");console.log($(element));let message=$(element).data("msg");let id=$(element).prop("id");$(element).data("rule").split("|").forEach(function(rule){let ruleParts=rule.split(":");let ruleValue=ruleParts.length==2?ruleParts[1]:"";rule=ruleParts[0];if(rule==="number"&&!value.match(numberPattern)){showError(element,fieldName+" must be numbers");hasError=true}else if(rule==="minlen"&&value.length Submitting Message");$("#submit-contact-button").prop("disabled",true);let behaviour=$("#submit-contact-form").data("behaviour");let files=getFiles(storedFiles);document.getElementById("contact_attachments").files=files;$("#submit-contact-form").submit()}});$(document.body).on("keyup change",".contact-form-input",function(event){let inputType=$(this).prop("type");let inputValue=$(this).val().trim();let isMixedRole=$(this).hasClass("mixed-role");let mixedRuleName=$(this).data("mixedrulename");let feedbackId=$(this).data("feedback");if(inputValue&&isMixedRole&&$("#"+mixedRuleName).val().trim()){$("#"+feedbackId).hide()}if(["text","email","date"].includes(inputType)&&inputValue){$(this).removeClass("is-invalid")}});function showError(element,message){if($(element).hasClass("mixed-role")){$("#"+$(element).data("feedback")).html(message);$(element).addClass("is-invalid");$("#"+$(element).data("feedback")).show()}else{$("#"+$(element).prop("id")+"-feedback").html(message);$(element).addClass("is-invalid")}}function getFiles(storedFiles){let dataTransfer=new ClipboardEvent("").clipboardData||new DataTransfer();for(let i=0;i