<script>
	(function(){
		var waitIntgrtn = setInterval(function () {
			if (!window.intgrtn) {
				return false;
			}
			clearInterval(waitIntgrtn);
			var optinFormSelector = $('.intgrtn-sp-form-step-1');
			var signupFormSelector = $('.intgrtn-sp-form-step-2').hide();

			window.intgrtn.setOptions({
				forms: {
					signup: {
						placeholders: {
							firstName: "<?= $firstName ?>",
							lastName: "<?= $lastName ?>",
							email: "<?= $email ?>",
						},
						buttons: {
							submit: {
								text: "<?= $submitButton ?>",
							},
							generatePassword: {
								show: true,
							},
						},

					},
					optin: {
						placeholders: {
							name: "<?= $name ?>",
							firstName: "<?= $firstName ?>",
							lastName: "<?= $lastName ?>",
							email: "<?= $email ?>",
						},
						buttons: {
							submit: {
								text: "<?= $submitButton ?>",
							},
						},
					}
				}
			});

			window.intgrtn.events.on('send.optin.request.success', function () {
				optinFormSelector.hide();
				signupFormSelector.show();
				signupFormSelector.toArray().forEach(function (element) {
					window.intgrtn.generateSignupForm({}, element);
				});
			});
		}, 10);
	}());
</script>

<div class="form-optin-holder">
	<div class="intgrtn-sp-form-step-1">
		<div data-intgrtn-form-optin=""
             data-intgrtn-fields-name-show="1"
             data-intgrtn-fields-first-name-show="0"
             data-intgrtn-fields-last-name-show="0">
        </div>
	</div>
	<div class="intgrtn-sp-form-step-2"></div>
</div>
