var ldForm = document.getElementById('ld-form');
if (ldForm) {
ldForm.addEventListener('submit', function (e) {
e.preventDefault();
var name = document.getElementById('ld-name').value.trim();
var email = document.getElementById('ld-email').value.trim();
var status = document.getElementById('ld-form-status');
if (!name || !email) {
status.hidden = false;
status.textContent = 'Please enter your name and email address.';
return;
}
var done = window.SLForms.busy(ldForm);
window.SLForms.post('/api/lead', {
name: name,
email: email,
phone: document.getElementById('ld-phone').value.trim(),
interest: 'buying',
message: document.getElementById('ld-msg').value.trim(),
email_consent: document.getElementById('ld-consent').checked,
source_page: window.location.pathname + window.location.search,
scene: 'listing-' + item.id
})
.then(function () {
window.SLForms.show(status, 'Thank you, ' + name + '. Steven Lenz Jr. has received your inquiry regarding ' + item.address + ' and will follow up personally.', false);
ldForm.reset();
})
.catch(function (err) { window.SLForms.show(status, err.message, true); })
.then(done);
});
}
});
})();