$(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 = [];
  $('input.text:not(input#registrationAddress2)', 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#registrationSex', 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)
    }
  );
  
  var avatar = $('img#registrationAvatarImage', registrationForm);
  /* Bind validation function to submit event
   */
  registrationForm.submit (function () {
    var formValid = validateForm (registrationForm, notEmpty, selected, emails, passwords);
    
    if (formValid) {  
      return true;
    }
    else {
      return false;
    }
  });
  
});
