jQuery('document').ready(function() {
	jQuery('.send-order-email').on('click', function() {
		var button = jQuery(this);
		var cardId = button.data('id');
		var loader = button.find('.fa-spinner');

		button.attr('disabled', 'disabled').addClass('disabled');
		loader.css('display', 'inline-block');

		jQuery.ajax({
			cache: false,
			url: 'index.php?option=com_cmgiftcard&task=order.sendEmail&format=json&' + token + '=1&id=' + cardId,
			type: 'get',
			success: function(r) {
				if (r.message) {
					alert(r.message);
				}
			},
			complete: function(r) {
				button.attr('disabled', null).removeClass('disabled');
				loader.css('display', 'none');
			},
		});
	});

	jQuery('.send-card-email').on('click', function() {
		var button = jQuery(this);
		var cardId = button.data('id');
		var loader = button.find('.fa-spinner');

		button.attr('disabled', 'disabled').addClass('disabled');
		loader.css('display', 'inline-block');

		jQuery.ajax({
			cache: false,
			url: 'index.php?option=com_cmgiftcard&task=card.sendEmail&format=json&' + token + '=1&id=' + cardId,
			type: 'get',
			success: function(r) {
				if (r.message) {
					alert(r.message);
				}
			},
			complete: function(r) {
				button.attr('disabled', null).removeClass('disabled');
				loader.css('display', 'none');
			},
		});
	});
});