// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function confirmRecalculateScores() {
  return confirm("If you change tournament details, all players' scores will be recalculated.\n\n"
               + "Are you sure you want to change the details?");
}

function ensureEmailChosen(form) {
  var email = $(form).serialize(true)['email'];
  var emailNotChosen = /^(\(.*\))?$/.test(email);
  if (emailNotChosen) { alert("Please Enter an E-mail"); }
  return !emailNotChosen;
}

function ensureIdChosen(form, optionType) {
  var id = $(form).serialize(true)['id'];
  var validId = /^\d+$/.test(id);
  if (!validId) { alert("You must choose a " + optionType) }
  return validId;
}
