$(function() {
  init_validation();
  // when the country selector changes, update the state selector:
  init_country_state('edit-country', 'edit-state');
});

/**
 * Set up some validation stuff on page load.
 */
function init_validation() {
  // add jquery validation:
  validator = $("#brochure-order-form").validate({
    errorPlacement: showValidationError,
    submitHandler: function(form) {
      // submit form:
      form.submit();
    }
  });

  // custom validation for T&C checkbox:
  $.validator.addMethod('checked', function(value, element) {
    return element.checked;
  }, "This must be checked.");
  $('#edit-t-and-c').rules('add', {checked: true});
  
  // make preferred contact method required:
  radioButtonsRequired('contact_method');
}

