scratchpad.modules.define("research", {
	show: function(data) {
		var _ = this;
		$(".infocard-content").html("");
		var infocard = new InfoCard({
			query: data,
			container: document.querySelector(".infocard-content"),
			onEmpty: function(container) {
				container.innerHTML="<div class='secondary-text error-message'>No results found.</div>"
			},
			appReferName: "scratchpad",
			onHeadingClick: function(e) {
				_.show(e.target.innerHTML);
			}
			});
			$(".infocard-shell").show();
	},
	generateImage: function(input) {
		var imagetemplate = "<img class='extend-block image-extend-block small' src='" + input + "'/>"
		scratchpad.caret.pasteHtmlAtCaret(imagetemplate, false);
	},
	imageInsertFlow: function(e) {
		var _ = this;
		var position = $(e.target).offset();
		$(".research-insert-button").css({left: position.left, top: position.top});
		$(".research-insert-button").show();
		$(".research-insert-button").off();
		$(".research-insert-button").on("mousedown", function() {
			_.generateImage(e.target.src);
		});
	},
	init: function() {
		var _ = this;
		this.imageInsertFlow = this.imageInsertFlow.bind(this);
		$(document.body).append('<div noprint hidden class="research-insert-button small fab color-green-500" title="Add image to document"><i class="icon-add"></i></div>');
		$(".infocard-shell").on("mouseover", "img", function(e) {
			_.imageInsertFlow(e);
		});
		$(document.body).on("click", function() {
			$(".research-insert-button").hide();
		});
		scratchpad.keybindings.addBinding(115, function() {
			scratchpad.research.show(window.getSelection());
		});
		window.addEventListener("keypress", function(e) {
			if(e.keyCode == 27) {
				$(".infocard-shell").hide();
			}
		});
	}
});
@@ -347,16 +347,147 @@
 %22%0A%09%09%09%7D,%0A
+%09%09%09onError: function(container) %7B%0A%09%09%09%09container.innerHTML=%22%3Cdiv class='secondary-text error-message'%3EAn error occured%3C/div%3E%22%0A%09%09%09%7D,%0A
 %09%09%09appRe

add error callback