(function(g){var c=function(){Error.apply(this,arguments)};c.prototype=new Error();c.prototype.type="XML-RPC fault";var a=g.xmlrpc=function(i,k){if(arguments.length===2){k.url=i}else{k=i;i=k.url}k.dataType="xml json";k.type="POST";k.contentType="text/xml";k.converters={"xml json":a.parseDocument};var l=a.document(k.methodName,k.params);var j=new XMLSerializer();k.data=j.serializeToString(l);return g.ajax(k)};a.document=function(l,o){var n=document.implementation.createDocument(null,null,null);var m=function(p){return g(n.createElement(p))};var j=m("methodName").text(l);var i=m("params").append(g.map(o,function(q){var p=m("value").append(a.toXmlRpc(q,m));return m("param").append(p)}));var k=m("methodCall").append(j,i);n.appendChild(k.get(0));return n};var b=function(i){return(i===parseInt(i,10))&&!isNaN(i)};a.toXmlRpc=function(l,k){if(l instanceof f){return l.toXmlRpc(k)}var i=g.xmlrpc.types;var j=g.type(l);switch(j){case"undefined":case"null":return i.nil.encode(l,k);case"date":return i["datetime.iso8601"].encode(l,k);case"object":if(l instanceof ArrayBuffer){return i.base64.encode(l,k)}else{return i.struct.encode(l,k)}break;case"number":if(b(l)){return i["int"].encode(l,k)}else{return i["double"].encode(l,k)}break;case"array":case"boolean":case"string":return i[j].encode(l,k);default:throw new Error("Unknown type",l)}};a.parseDocument=function(o){var p=g(o);var i=p.children("methodresponse");var l=i.find("> fault");if(l.length===0){var j=i.find("> params > param > value > *");var k=j.toArray().map(a.parseNode);return k}else{var n=a.parseNode(l.find("> value > *").get(0));var m=new c(n.faultString);m.msg=m.message=n.faultString;m.type=m.code=n.faultCode;throw m}};a.parseNode=function(j){if(j===undefined){return null}var i=j.nodeName.toLowerCase();if(i in a.types){return a.types[i].decode(j)}else{throw new Error("Unknown type "+i)}};a.parseValue=function(i){var j=g(i).children()[0];if(j){return a.parseNode(j)}else{return g(i).text()}};var f=function(){};g.xmlrpc.types={};a.makeType=function(j,o,k,m){var i;i=function(p){this.value=p};i.prototype=new f();i.prototype.tagName=j;if(o){var l=k,n=m;k=function(q,p){var r=l(q);return p(i.tagName).text(r)};m=function(p){return n(g(p).text(),p)}}i.prototype.toXmlRpc=function(p){return i.encode(this.value,p)};i.tagName=j;i.encode=k;i.decode=m;a.types[j.toLowerCase()]=i};var e=function(i){return""+Math.floor(i)};var d=function(j,i){return parseInt(j,10)};a.makeType("int",true,e,d),a.makeType("i4",true,e,d),a.makeType("i8",true,e,d),a.makeType("i16",true,e,d),a.makeType("i32",true,e,d),a.makeType("double",true,String,function(i){return parseFloat(i,10)});a.makeType("string",true,String,String);a.makeType("boolean",true,function(i){return i?"1":"0"},function(i){return i==="1"});var h=function(i){return i<10?"0"+i:i};a.makeType("dateTime.iso8601",true,function(i){return[i.getUTCFullYear(),"-",h(i.getUTCMonth()+1),"-",h(i.getUTCDate()),"T",h(i.getUTCHours()),":",h(i.getUTCMinutes()),":",h(i.getUTCSeconds()),"Z"].join("")},function(i){return new Date(i)});a.binary=(function(){var k="=";var i=("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").split("");var j=i.reduce(function(n,m,l){n[m]=l;return n},{});return{toBase64:function(p){var o=[];var q=new Uint8Array(p);var m=0,n;for(;m>18)%64]);o.push(i[(n>>12)%64]);o.push(i[(n>>6)%64]);o.push(i[(n>>0)%64])}var l=3-((p.byteLength%3)||3);while(l--){o[o.length-l-1]=k}return o.join("")},fromBase64:function(m){var l=m.length;var s=(l/4)*3;if(m.charAt(l-1)===k){s--}if(m.charAt(l-2)===k){s--}var q=new ArrayBuffer(s);var r=new Uint8Array(q);var o=0,n=0,p;for(;o>16)%256;r[n+1]=(p>>8)%256;r[n+2]=(p>>0)%256}return q}}})();a.makeType("base64",true,function(i){return a.binary.toBase64(i)},function(i){return a.binary.fromBase64(i)});a.makeType("nil",false,function(j,i){return i("nil")},function(i){return null});a.makeType("struct",false,function(k,j){var i=j("struct");g.each(k,function(l,n){var o=j("name").text(l);var m=j("value").append(a.toXmlRpc(n,j));i.append(j("member").append(o,m))});return i},function(i){return g(i).find("> member").toArray().reduce(function(n,l){var k=g(l);var j=k.find("> name").text();var m=a.parseValue(k.find("> value"));n[j]=m;return n},{})});a.makeType("array",false,function(l,j){var k=j("array");var i=j("data");g.each(l,function(m,n){i.append(j("value").append(a.toXmlRpc(n,j)))});k.append(i);return k},function(i){return g(i).find("> data > value").toArray().map(a.parseValue)});a.force=function(i,j){return new a.types[i](j)}})(jQuery);