/*
 * jquery.zend.jsonrpc.js 1.1
 * 
 * CHANGELOG: 12/11/2010 added namespace support
 *
 * Copyright (c) 2010 Tanabicom, LLC
 * http://www.tanabi.com
 *
 * Released under the MIT license:
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
if(!jQuery.Zend)jQuery.Zend={};
jQuery.Zend.jsonrpc=function(l){return new (function(m){var a=this;this.options=jQuery.extend({url:"",version:"",async:false},m);this.sequence=1;this.methodError=this.error=false;this.lastRequest={};jQuery.ajax({async:a.options.async,contentType:"application/json",type:"get",processData:false,dataType:"json",url:a.options.url,cache:false,error:function(e,g){a.error=true;a.errorMessage=g;a.errorRequest=e},success:function(e){if(!a.options.version)a.options.version=e.envelope=="JSON-RPC-1.0"?1:2;var g=
/([^.]+)\.([^.]+)/;jQuery.each(e.methods,function(f){var i=function(){a.methodError=false;a.methodErrorMessage="";a.methodErrorRequest="";for(var h=[],c=0;c<arguments.length;c++)h.push(arguments[c]);c=a.sequence++;var j=[];jQuery.ajax({async:a.options.async,contentType:"application/json",type:e.transport,processData:false,dataType:"json",url:a.options.url,cache:false,data:JSON.stringify(a.options.version==1?{method:f,params:h,id:c}:{jsonrpc:"2.0",method:f,params:h,id:c}),error:function(b,k){a.lastRequest=
b;a.error=true;a.errorMessage=k;a.errorRequest=b},success:function(b,k,n){a.lastRequest=b;j=b.result;if(b.error){a.methodError=true;a.methodErrorMessage=b.error.message;a.methodErrorRequest=n}}});return j},d=g.exec(f);if(!d||!d.length){a[f]=i;i.name=f}else{a[d[1]]||(a[d[1]]={});a[d[1]][d[2]]=i}})}});return this})(l)};

