$(function () {
    var registrationForm = $('form#registrationForm');
    // Override default input values - optional
    $('input.text', registrationForm).each (function () {
      $(this).data ('default', {value: ''});
    });
    
  // List of jQuery elements that must be inputed
  var notEmpty = [];
  if (registrationForm.hasClass('profile')) {
    $('input.text:not(input#registrationAddress, input#registrationPhone, input#registrationPassword, input#registrationPasswordConfirm)', registrationForm).each (function () {
      notEmpty[$('input.text', registrationForm).index ($(this))] = $(this);
    });
  }
  else {
    $('input.text:not(input#registrationAddress, input#registrationPhone)', registrationForm).each (function () {
      notEmpty[$('input.text', registrationForm).index ($(this))] = $(this);
    });
  }
  
  // List of jQuery elements that must be selected
  var selected = new Array (
    new Array (
      $('select#registrationBirthDay', registrationForm),
      $('select#registrationBirthMonth', registrationForm),
      $('select#registrationBirthYear', registrationForm)
    ),
    $('select#registrationState', registrationForm)
  );
  
  // List of jQuery elements that must be correctly inputed emails
  var emails = new Array (
    //$('input#registrationEmail', registrationForm)
  );
  
  // List of 'password and password confirmation' couples
  var passwords = new Array (
    {
      'password': $('input#registrationPassword', registrationForm),
      'confirmation': $('input#registrationPasswordConfirm', registrationForm)
    }
  );
  
  // List of checkboxes that must be checked
  if ($('input#registrationConfirm', registrationForm).length == 1) {
    var checkBoxes = new Array (
      $('input#registrationConfirm', registrationForm)
    );
  }
  
  /* Bind validation function to submit event
   */
  registrationForm.submit (function () {
    var formValid = validateForm (registrationForm, notEmpty, selected, emails, passwords, checkBoxes);
    
    if (formValid) {  
      return true;
    }
    else {
      return false;
    }
  });
  
});