function onPromotionLinkMouseOver(event) {
    glow.dom.get("#promotion_link").addClass("highlight");
}

function onPromotionLinkMouseOut(event) {
    glow.dom.get("#promotion_link").removeClass("highlight");
}

glow.ready(function() {
    glow.events.addListener("#promotion_link", "mouseover", onPromotionLinkMouseOver);
    glow.events.addListener("#promotion_link", "mouseout", onPromotionLinkMouseOut);

    var myForm = new glow.forms.Form("#formularz")
      .addTests(
        "user_name",
        ["required", {
          on: "change submit",
          message: "Proszę wprowadzić nazwę użytkownika"
        }],
        ["minLen", {
          on: "idle change submit",
          arg: 4,
          message: "Nazwa musi zawierać minimum 4 znaki"
        }]
      )
      .addTests(
        "user_password",
        ["required", {
          on: "idle change submit",
          message: "Proszę wprowadzić hasło użytkownika"
        }],
        ["minLen", {
          on: "idle change submit",
          arg: 8,
          message: "Hasło musi zawierać minimum 8 znaków"
        }]
      )
      .addTests(
        "user_password_copy",
        ["sameAs", {
          on: "change submit",
          arg: "user_password",
          message: "Hasła nie są takie same!"
        }]
      )
      .addTests(
        "bride_name",
        ["required", {
          on: "change submit",
          message: "Proszę wprowadzić imię panny młodej"
        }]
      )
      .addTests(
        "bride_surname",
        ["required", {
          on: "change submit",
          message: "Proszę wprowadzić nazwisko panny młodej"
        }]
      )
      .addTests(
        "groom_name",
        ["required", {
          on: "change submit",
          message: "Proszę wprowadzić imię pana młodego"
        }]
      )
      .addTests(
        "groom_surname",
        ["required", {
          on: "change submit",
          message: "Proszę wprowadzić nazwisko pana młodego"
        }]
      )
      .addTests(
        "phone",
        ["required", {
          on: "change submit",
          message: "Proszę wprowadzić numer telefonu"
        }],
        ["regex", {
          on: "idle change submit",
          arg: /^[0-9()-]+$/,
          message: "Wprowadź tylko cyfry i znaki '()-'"
        }]
      )
      .addTests(
          "email",
        ["required", {
          on: "change submit",
          message: "Proszę wprowadzić adres email"
        }],
        ["isEmail", {
          on: "change submit",
          message: "Proszę wprowadzić poprawny adres email"
        }]
      )
      .addTests(
        "wedding_date",
        ["required", {
          on: "change submit",
          message: "Proszę wprowadzić datę ślubu"
        }],
        ["regex", {
          on: "idle change submit",
          arg: /^[0-9-]+$/,
          message: "Wprowadź tylko cyfry i znak '-'"
        }],
        ["regex", {
          on: "idle change submit",
          arg: /^[0-9]+-[0-9]+-[0-9]{4}$/,
          message: "Wprowadź datę w poprawnym formacie"
        }]
      )
      .addTests(
        "destination_address",
        ["required", {
          on: "change submit",
          message: "Proszę wprowadzić adres"
        }]
      )
      .addTests(
        "destination_city_post_code",
        ["required", {
          on: "change submit",
          message: "Proszę wprowadzić kod i miejscowość"
        }]
      )
      .addTests(
        "confirm_terms",
        ["required", {
          on: "change submit",
          message: "Proszę zaakceptować regulamin"
        }]
      );
});

