{% if not hide_footer_signup %}
<div class="container">
	<div class="row">
		<div class="col-sm-6 col-sm-offset-3 text-center" style="margin-top: 15px;">
				<input class="form-control" type="text" id="footer-subscribe-email"
                    style="display: inline-block; max-width: 50%; margin-right: 10px;"
					placeholder="{{ _('Your email address') }}...">
				<button class="btn btn-default btn-sm" type="button"
					id="footer-subscribe-button">{{ _("Get Updates") }}</button>
		</div>
	</div>
    <div class="text-center text-muted small" style="padding: 30px;">
        <a href="https://erpnext.com?source=website_footer" target="_blank" class="text-extra-muted">
            Powered by ERPNext</a>
    </div>
</div>
<script>
	$("#footer-subscribe-button").click(function() {

		if($("#footer-subscribe-email").val()) {
			$("#footer-subscribe-email").attr('disabled', true);
			$("#footer-subscribe-button").html("Sending...")
				.attr("disabled", true);
			erpnext.subscribe_to_newsletter({
				email: $("#footer-subscribe-email").val(),
				callback: function(r) {
					if(!r.exc) {
						$("#footer-subscribe-button").html(__("Added"))
							.attr("disabled", true);
					} else {
						$("#footer-subscribe-button").html(__("Error: Not a valid id?"))
							.addClass("btn-danger").attr("disabled", false);
						$("#footer-subscribe-email").val("").attr('disabled', false);
					}
				}
			});
		}
		else
			frappe.msgprint(frappe._("Please enter email address"))
	});
</script>
{% endif %}
