Added new notification engine
diff --git a/Changes b/Changes
index d89f27e..b0efd68 100755
--- a/Changes
+++ b/Changes
@@ -1,3 +1,7 @@
+0.16 2015-06-18
+        - Update to new KoralQuery API.
+	- Introduced new notifications engine.
+
 0.15 2015-05-21
         - Cleanup for GitHub release
 	- First realease on GitHub.
diff --git a/dev/demo/all.html b/dev/demo/all.html
index d2fd6ce..70457e7 100644
--- a/dev/demo/all.html
+++ b/dev/demo/all.html
@@ -148,5 +148,11 @@
       var KorAP = KorAP || {};
       KorAP.URL = 'http://localhost:3000';
     </script>
+    <script>//<![CDATA[
+KorAP.Notifications = [];
+KorAP.Notifications.push(["warn","767: Case insensitivity is currently not supported for this layer"]);
+KorAP.Notifications.push(["error","404: Not Found (remote)"]);
+//]]>
+    </script>
   </body>
 </html>
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 7c403aa..a414020 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -23,14 +23,14 @@
 
   // Override KorAP.log
   window.alertify = alertifyClass;
-  KorAP.log = function (type, msg) {
+  KorAP.log = function (code, msg) {
 
     // Use alertify to log errors
     alertifyClass.log(
-      (type === 0 ? '' : type + ': ') +
+      (code === 0 ? '' : code + ': ') +
 	msg,
       'error',
-      5000
+      10000
     );
   };
 
@@ -38,6 +38,16 @@
     var obj = {};
 
     /**
+     * Release notifications
+     */
+    if (KorAP.Notifications !== undefined) {
+      var n = KorAP.Notifications;
+      for (var i = 0; i < n.length; i++) {
+	alertifyClass.log(n[i][1], n[i][0], 10000);
+      };
+    };
+
+    /**
      * Replace Virtual Collection field
      */
     var vcname;
diff --git a/kalamar.conf b/kalamar.conf
index 085fdf4..dc3c5f0 100644
--- a/kalamar.conf
+++ b/kalamar.conf
@@ -3,14 +3,13 @@
     'api-0.1' => 'http://10.0.10.13:7070/api/v0.1/'
   },
   Notifications => {
-    Alertify => {
-      base_timeout => 10_000
-    },
+    'Kalamar::Plugin::Notifications' => 1,
     JSON => 1
   },
   Search => {
     engine => 'Kalamar::API',
-    api => 'http://10.0.10.13:7070/api/v0.1/'
+#    api => 'http://10.0.10.13:7070/api/v0.1/'
+    api => 'http://localhost:9999/api/v0.1/'
   },
   CHI => {
     default => {
diff --git a/lib/Kalamar/API.pm b/lib/Kalamar/API.pm
index fc49af8..9b480f6 100644
--- a/lib/Kalamar/API.pm
+++ b/lib/Kalamar/API.pm
@@ -279,7 +279,7 @@
     $c->notify(
       error =>
 	($e->{code} ? $e->{code} . ': ' : '') .
-	  $e->{message} . ' (remote)'
+	  $e->{message} . ' for ' . $type . ' (remote)'
 	);
     return;
   };
@@ -288,7 +288,7 @@
   if (my $res = $tx->success) {
 
     # Set api response for debugging
-    $index->api_response($res->body) if $c->kalamar_test_port;
+    $index->api_response($res->body); # if $c->kalamar_test_port;
 
     # Json failure
     my $json;
@@ -313,12 +313,7 @@
 
     return 1 if ref $json ne 'HASH';
 
-    # Add warnings (Legacy)
-    if ($json->{warning}) {
-      $json->{warning} =~ s/;\s+null$//;
-      $c->notify(warn => $json->{warning});
-    };
-
+    $self->_notify_on_warnings($c, $json);
     $self->_notify_on_error($c, 0, $json);
   }
 
@@ -405,7 +400,7 @@
     $json = $res->json if blessed $res ne 'Mojo::JSON';
   };
 
-  # Chec json response error message
+  # Check json response error message
   if ($json) {
     if ($json->{error}) {
       # Temp
@@ -422,6 +417,18 @@
       return;
     }
 
+    elsif ($json->{errors}) {
+      my $errors = $json->{errors};
+      # TODO: Check for ref!
+      foreach (@$errors) {
+	$c->notify(
+	  error =>
+	    ($_->[0] ? $_->[0] . ': ' : '') .
+	      $_->[1]
+	  );
+      };
+    }
+
     # policy service error messages
     elsif ($json->{status}) {
       $c->notify(error => 'Middleware error ' . $json->{status});
@@ -440,6 +447,31 @@
 };
 
 
+sub _notify_on_warnings {
+  my ($self, $c, $json) = @_;
+
+  # Add warnings (Legacy)
+  if ($json->{warning}) {
+    $json->{warning} =~ s/;\s+null$//;
+    $c->notify(warn => $json->{warning});
+  }
+
+  # Add warnings
+  elsif ($json->{warnings}) {
+
+    my $warnings = $json->{warnings};
+    # TODO: Check for ref!
+    foreach (@$warnings) {
+      $c->notify(
+	warn =>
+	  ($_->[0] ? $_->[0] . ': ' : '') .
+	    $_->[1]
+	  );
+    };
+  };
+};
+
+
 # Cleanup array of matches
 sub _map_matches {
   return () unless $_[0];
diff --git a/lib/Kalamar/Controller/Search.pm b/lib/Kalamar/Controller/Search.pm
index 66b602e..c0c3e6e 100644
--- a/lib/Kalamar/Controller/Search.pm
+++ b/lib/Kalamar/Controller/Search.pm
@@ -50,10 +50,10 @@
       ) if $query;
 
       # Search resource (async)
-      $c->search->resource(
-	type => 'collection',
-	$delay->begin
-      );
+      # $c->search->resource(
+      #   type => 'collection',
+      #   $delay->begin
+      # );
     },
 
     # Collected search
diff --git a/lib/Kalamar/Plugin/Notifications.pm b/lib/Kalamar/Plugin/Notifications.pm
new file mode 100644
index 0000000..9fea51b
--- /dev/null
+++ b/lib/Kalamar/Plugin/Notifications.pm
@@ -0,0 +1,35 @@
+package Kalamar::Plugin::Notifications;
+use Mojo::Base 'Mojolicious::Plugin::Notifications::Engine';
+use Mojo::ByteStream 'b';
+use Mojo::Util qw/xml_escape quote/;
+use Mojo::JSON qw/decode_json encode_json/;
+use File::Spec;
+use File::Basename;
+
+# Notification method
+sub notifications {
+  my ($self, $c, $notify_array) = @_;
+
+  return '' unless @$notify_array;
+
+  # Start JavaScript snippet
+  my $js .= qq{<script>//<![CDATA[\n};
+  $js .= "KorAP.Notifications = [];\n";
+  my $noscript = "<noscript>";
+
+  # Add notifications
+  foreach (@$notify_array) {
+    $js .= 'KorAP.Notifications.push([';
+    $js .= quote($_->[0]) . ',' . quote($_->[-1]);
+    $js .= "]);\n";
+
+    $noscript .= qq{<div class="notify notify-} . $_->[0] . '">' .
+      xml_escape($_->[-1]) .
+	"</div>\n";
+  };
+
+  return b($js . "//]]>\n</script>\n" . $noscript . '</noscript>');
+};
+
+
+1;
diff --git a/package.json b/package.json
index e617117..61e2062 100755
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "Kalamar",
   "description": "Mojolicious-based Frontend for KorAP",
-  "version": "0.15.0",
+  "version": "0.16.0",
   "repository" : {
     "type": "git",
     "url": "https://github.com/KorAP/Kalamar.git"
diff --git a/templates/layouts/main.html.ep b/templates/layouts/main.html.ep
index d05aac0..9050f77 100644
--- a/templates/layouts/main.html.ep
+++ b/templates/layouts/main.html.ep
@@ -40,6 +40,6 @@
       <%= doc_link_to 'V '. $Kalamar::VERSION, 'korap', 'kalamar' %>
     </footer>
     % };
-%= notifications 'Alertify', -no_include
+%= notifications 'Kalamar::Plugin::Notifications'
   </body>
 </html>
diff --git a/templates/query.html.ep b/templates/query.html.ep
index 954488c..9b796f3 100644
--- a/templates/query.html.ep
+++ b/templates/query.html.ep
@@ -3,3 +3,7 @@
 %= javascript begin
  KorAP.currentQuery = <%== Mojo::JSON::encode_json(search->query_jsonld) %>;
 % end
+
+<pre>
+%== Mojo::JSON::encode_json(search->api_response)
+</pre>