window.addEventListener('load', function() {
var buttons = document.querySelectorAll('.mindbody-trigger');
buttons.forEach(function(button) {
button.addEventListener('click', function() {
var healcodeWidget = document.createElement('healcode-widget');
healcodeWidget.setAttribute('data-version', '0.2');
healcodeWidget.setAttribute('data-link-class', 'healcode-contract-text-link');
healcodeWidget.setAttribute('data-site-id', button.getAttribute('data-site-id'));
healcodeWidget.setAttribute('data-mb-site-id', button.getAttribute('data-mb-site-id'));
healcodeWidget.setAttribute('data-service-id', button.getAttribute('data-service-id'));
healcodeWidget.setAttribute('data-bw-identity-site', 'true');
healcodeWidget.setAttribute('data-type', 'contract-link');
var rawInnerHTML = button.getAttribute('data-inner-html') || "Buy Now";
healcodeWidget.setAttribute('data-inner-html', rawInnerHTML);
document.body.appendChild(healcodeWidget);
// Manually refresh the widget if HealcodeWidget is defined
if (typeof HealcodeWidget !== 'undefined') {
HealcodeWidget.refreshWidgets();
console.log("MindBody widget manually refreshed.");
}
});
});
});