jQuery(function($) {
  $(".registration_button").live("click", function(){
	  $('html, body').animate({ scrollTop: 0 }, 200);
    $(".logform").hide();
    $(".regform").fadeIn(500);
    return false;
  });
  $("#registration_close_button").click(function(){
    $(".regform").fadeOut(500);
    return false;
  });
  $("#form-registration").submit(function(){
    return registrationForm.submit();
  });
  $("#form-registration .agreement input").click(function(){
    registrationForm.check();
  });
  var registrationForm = {
    is_ok: false,
    $form: $("#form-registration"),
    check: function(){
      if ($(".agreement input", this.$form).is(":checked"))
      {
        this.is_ok = true;
        $(".regbut", this.$form).removeAttr("disabled").css("opacity", 1);
      }
      else
      {
        this.is_ok = false;
        $(".regbut", this.$form).attr("disabled", true).css("opacity", 0.3);
      }
    },
    submit: function(){
      if (!this.is_ok)
        return false;
    }
  }
  registrationForm.check();

  // валидация формы
  /*
  $("#form-registration").validate({
    rules: {
      "user[username]": "required",
      "user[password]": "required",
      "user[password_again]": {
        required: true,
        equalTo: "#user_password"
      },
      "user[email_address]": {
        required: true,
        email: true
      }
    },
  });
  */

});

