jQuery(document).ready(function(){
	jQuery('#adminForm input[name="jform[defined_amount]"]').on('change', function() {
		var amount = jQuery('input[name="jform[defined_amount]"]:checked', '#adminForm').val();
		jQuery('#jform_amount').val(amount);
	});

	document.formvalidator.setHandler('amount', function (value) {
		return (value >= minAmount && value <= maxAmount);
	});

	document.formvalidator.setHandler('date', function (value) {
		var deliverDate = new Date(value).setHours(0, 0, 0, 0);
		var now = new Date().setHours(0, 0, 0, 0);
		return (deliverDate >= now);
	});
});

function checkAmount() {
	var amount = jQuery('#jform_amount').val();
	amount = parseFloat(amount).toFixed(2);

	jQuery.each(jQuery('#adminForm input[name="jform[defined_amount]"]'), function(i, e) {
		var eAmount = parseFloat(jQuery(this).val()).toFixed(2);

		if (eAmount == amount) {
			jQuery(this).prop('checked', true);
		} else {
			jQuery(this).prop('checked', false);
		}
	});
}