DI.Extensions.add("lisa_extension", function() {

  var userinput = ''; 

  this.onAdded = function() {
    var send_btn = jQuery(".di_send");
    send_btn.click(function() {
      jQuery(".di_form_input").submit();
    });
  },

  this.showAnswer = function(responseData,base) {
    try {
      userinput = responseData.lastinput;
    } catch (err) {
      // first request probably
    }
    base(responseData);
  },
 
  this.drawAnswer = function(text, base) {
    if (userinput != null && userinput != "undefined" &&  userinput != "") {
      text = "<span class='di_question'>U zei: " + jQuery.URLDecode(userinput) + "</span>" + text;
    }
    base(text);
  },

  this.show = function(base) {
    var state = DI.StateManager.getState("lisa", {});
    if(state != null && state.session != null && typeof(state.session.transaction) === "undefined") {
        lisa.sendInput();
    }
    base();
  }

});
