/*! elastic.js - v1.1.1 - 2013-05-24
 * https://github.com/fullscale/elastic.js
 * Copyright (c) 2013 FullScale Labs, LLC; Licensed MIT */

!function(){"use strict";var a,b=this;a="undefined"!=typeof exports?exports:null==b.ejs?b.ejs={}:b.ejs,a.ExtJSClient=function(a){Ext.Ajax.cors=!0;var b={headers:{"Content-Type":"application/json"}},c=function(b){return"/"!==b.charAt(0)&&(b="/"+b),a+b},d=function(a){return function(b){var c=Ext.JSON.decode(b.responseText);null!=a&&a(c)}};return null==a?a="":"/"===a.charAt(a.length-1)&&(a=a.substring(0,a.length-1)),{server:function(b){return null==b?a:(a="/"===b.charAt(b.length-1)?b.substring(0,b.length-1):b,this)},option:function(a,c){return null==a?b:null==c?b[a]:(b[a]=c,void 0)},get:function(a,e,f,g){var h=Ext.apply({},b);return h.method="GET",h.url=c(a),h.params=e,h.success=d(f),h.failure=g,Ext.Ajax.request(h)},post:function(a,e,f,g){var h=Ext.apply({},b);return h.method="POST",h.url=c(a),h.jsonData=e,h.success=d(f),h.failure=g,Ext.Ajax.request(h)},put:function(a,e,f,g){var h=Ext.apply({},b);return h.method="PUT",h.url=c(a),h.jsonData=e,h.success=d(f),h.failure=g,Ext.Ajax.request(h)},del:function(a,e,f,g){var h=Ext.apply({},b);return h.method="DELETE",h.url=c(a),h.jsonData=e,h.success=d(f),h.failure=g,Ext.Ajax.request(h)},head:function(a,d,e,f){var g=Ext.apply({},b);return g.method="HEAD",g.url=c(a),g.params=d,g.failure=f,g.callback=function(a,b,c){if(b){var d,f,g=c.getAllResponseHeaders().split("\n"),h={};for(f=0;f<g.length;f++)d=g[f].split(":"),2!==d.length&&(h[d[0]]=d[1]);null!=e&&e(h)}},Ext.Ajax.request(g)}}}}.call(this);