var escapeJSONChar=function(){var A=["\b","\t","\n","\f","\r"];return function(C){if(C=='"'||C=="\\"){return"\\"+C}if(C.charCodeAt(0)>=32){return C}for(var B=0;B<A.length;B++){if(C==A[B]){return"\\"+C}}return C}}();function escapeJSONString(B){var C=B.split("");for(var A=0;A<C.length;A++){C[A]=escapeJSONChar(C[A])}return'"'+C.join("")+'"'}function toJSON(F){var A="$_$jabsorbed$813492";var H;var E=[];function C(){var I;while(H){I=H[A].prev;delete H[A];H=I}}var G={};var B;function D(J,I,K){var R=[],M,L,Q,O,N;if(J===null||J===undefined){return"null"}else{if(typeof J==="string"){return escapeJSONString(J)}else{if(typeof J==="number"){return J.toString()}else{if(typeof J==="boolean"){return J.toString()}else{if(J[A]){M=[K];Q=I;while(Q){if(L){L.unshift(Q[A].ref)}if(Q===J){O=Q;L=[O[A].ref]}M.unshift(Q[A].ref);Q=Q[A].parent}if(O){if(JSONRpcClient.fixupCircRefs){M.shift();L.shift();E.push([M,L]);return G}else{C();throw new Error("circular reference detected!")}}else{if(JSONRpcClient.fixupDuplicates){L=[J[A].ref];Q=J[A].parent;while(Q){L.unshift(Q[A].ref);Q=Q[A].parent}M.shift();L.shift();E.push([M,L]);return G}}}else{J[A]={parent:I,prev:H,ref:K};H=J}if(J.constructor===Date){return'{javaClass: "java.util.Date", time: '+J.valueOf()+"}"}else{if(J.constructor===Array){for(N=0;N<J.length;N++){B=D(J[N],J,N);R.push(B===G?null:B)}return"["+R.join(", ")+"]"}else{for(var P in J){if(P===A){}else{if(J[P]===null||J[P]===undefined){R.push('"'+P+'": null')}else{if(typeof J[P]=="function"){}else{B=D(J[P],J,P);if(B!==G){R.push(escapeJSONString(P)+": "+B)}}}}}return"{"+R.join(", ")+"}"}}}}}}}B=D(F,null,"root");C();if(E.length){return{json:B,fixups:E}}else{return{json:B}}}function JSONRpcClient(){var B=0,H,A,D,C,E,G=(typeof arguments[0]),F=true;if(G==="function"){this.readyCB=arguments[0];B++}else{if(arguments[0]&&G==="object"&&arguments[0].length){this._addMethods(arguments[0]);B++;F=false}}this.serverURL=arguments[B];this.user=arguments[B+1];this.pass=arguments[B+2];this.objectID=0;if(F){this._addMethods(["system.listMethods"]);H=JSONRpcClient._makeRequest(this,"system.listMethods",[]);if(this.readyCB){C=this;H.cb=function(I,J){if(!J){C._addMethods(I)}C.readyCB(I,J)}}if(!this.readyCB){D=JSONRpcClient._sendRequest(this,H);this._addMethods(D)}else{JSONRpcClient.async_requests.push(H);JSONRpcClient.kick_async()}}}JSONRpcClient.prototype.createCallableProxy=function(G,F){var E,D,C,A,B;E=new JSONRPCCallableProxy(G,F);for(A in JSONRpcClient.knownClasses[F]){E[A]=JSONRpcClient.bind(JSONRpcClient.knownClasses[F][A],E)}return E};function JSONRPCCallableProxy(){this.objectID=arguments[0];this.javaClass=arguments[1];this.JSONRPCType="CallableReference"}JSONRpcClient.knownClasses={};JSONRpcClient.Exception=function(B){var A;for(var C in B){if(B.hasOwnProperty(C)){this[C]=B[C]}}if(this.trace){A=this.trace.match(/^([^:]*)/);if(A){this.name=A[0]}}if(!this.name){this.name="JSONRpcClientException"}};JSONRpcClient.Exception.CODE_REMOTE_EXCEPTION=490;JSONRpcClient.Exception.CODE_ERR_CLIENT=550;JSONRpcClient.Exception.CODE_ERR_PARSE=590;JSONRpcClient.Exception.CODE_ERR_NOMETHOD=591;JSONRpcClient.Exception.CODE_ERR_UNMARSHALL=592;JSONRpcClient.Exception.CODE_ERR_MARSHALL=593;JSONRpcClient.Exception.prototype=new Error();JSONRpcClient.Exception.prototype.toString=function(A,C){var B="";if(this.name){B+=this.name}if(this.message){B+=": "+this.message}if(B.length==0){B="no exception information given"}return B};JSONRpcClient.default_ex_handler=function(A){var B="";for(a in A){B+=a+"\t"+A[a]+"\n"}alert(B)};JSONRpcClient.toplevel_ex_handler=JSONRpcClient.default_ex_handler;JSONRpcClient.profile_async=false;JSONRpcClient.max_req_active=1;JSONRpcClient.requestId=1;JSONRpcClient.fixupCircRefs=true;JSONRpcClient.fixupDuplicates=true;JSONRpcClient.transformDates=false;JSONRpcClient.bind=function(B,A){return function(){return B.apply(A,arguments)}};JSONRpcClient._createMethod=function(A,C){var B=function(){var D=[],G;for(var E=0;E<arguments.length;E++){D.push(arguments[E])}if(typeof D[0]=="function"){G=D.shift()}var F=JSONRpcClient._makeRequest(this,C,D,this.objectID,G);if(!G){return JSONRpcClient._sendRequest(A,F)}else{JSONRpcClient.async_requests.push(F);JSONRpcClient.kick_async();return F.requestId}};return B};JSONRpcClient.prototype.createObject=function(){var C=[],F=null,B,A,E;for(var D=0;D<arguments.length;D++){C.push(arguments[D])}if(typeof C[0]=="function"){F=C.shift()}B=C[0]+".$constructor";A=C[1];E=JSONRpcClient._makeRequest(this,B,A,0,F);if(F===null){return JSONRpcClient._sendRequest(this,E)}else{JSONRpcClient.async_requests.push(E);JSONRpcClient.kick_async();return E.requestId}};JSONRpcClient.CALLABLE_REFERENCE_METHOD_PREFIX=".ref";JSONRpcClient.prototype._addMethods=function(L,G){var C,I,K,D,A,F=[],E,B,M,J;for(var H=0;H<L.length;H++){I=this;K=L[H].split(".");M=L[H].indexOf("[");J=L[H].indexOf("]");if((L[H].substring(0,JSONRpcClient.CALLABLE_REFERENCE_METHOD_PREFIX.length)==JSONRpcClient.CALLABLE_REFERENCE_METHOD_PREFIX)&&(M!=-1)&&(J!=-1)&&(M<J)){E=L[H].substring(M+1,J)}else{for(D=0;D<K.length-1;D++){C=K[D];if(I[C]){I=I[C]}else{I[C]={};I=I[C]}}}C=K[K.length-1];if(E){A=JSONRpcClient._createMethod(this,C);if(!JSONRpcClient.knownClasses[E]){JSONRpcClient.knownClasses[E]={}}JSONRpcClient.knownClasses[E][C]=A}else{A=JSONRpcClient._createMethod(this,L[H]);if((!I[C])&&(!G)){I[C]=JSONRpcClient.bind(A,this)}F.push(A)}E=null}return F};JSONRpcClient._getCharsetFromHeaders=function(A){var E,D,B;try{E=A.getResponseHeader("Content-type");D=E.split(/\s*;\s*/);for(B=0;B<D.length;B++){if(D[B].substring(0,8)=="charset="){return D[B].substring(8,D[B].length)}}}catch(C){}return"UTF-8"};JSONRpcClient.async_requests=[];JSONRpcClient.async_inflight={};JSONRpcClient.async_responses=[];JSONRpcClient.async_timeout=null;JSONRpcClient.num_req_active=0;JSONRpcClient._async_handler=function(){var A,B;JSONRpcClient.async_timeout=null;while(JSONRpcClient.async_responses.length>0){A=JSONRpcClient.async_responses.shift();if(A.canceled){continue}if(A.profile){A.profile.dispatch=new Date()}try{A.cb(A.result,A.ex,A.profile)}catch(C){JSONRpcClient.toplevel_ex_handler(C)}}while(JSONRpcClient.async_requests.length>0&&JSONRpcClient.num_req_active<JSONRpcClient.max_req_active){B=JSONRpcClient.async_requests.shift();if(B.canceled){continue}JSONRpcClient._sendRequest(B.client,B)}};JSONRpcClient.kick_async=function(){if(!JSONRpcClient.async_timeout){JSONRpcClient.async_timeout=setTimeout(JSONRpcClient._async_handler,0)}};JSONRpcClient.cancelRequest=function(B){if(JSONRpcClient.async_inflight[B]){JSONRpcClient.async_inflight[B].canceled=true;return true}var A;for(A in JSONRpcClient.async_requests){if(JSONRpcClient.async_requests[A].requestId==B){JSONRpcClient.async_requests[A].canceled=true;return true}}for(A in JSONRpcClient.async_responses){if(JSONRpcClient.async_responses[A].requestId==B){JSONRpcClient.async_responses[A].canceled=true;return true}}return false};JSONRpcClient._makeRequest=function(B,C,E,H,A){var F={};F.client=B;F.requestId=JSONRpcClient.requestId++;var G="{id:"+F.requestId+",method:";if((H)&&(H>0)){G+='".obj['+H+"]."+C+'"'}else{G+='"'+C+'"'}if(A){F.cb=A}if(JSONRpcClient.profile_async){F.profile={submit:new Date()}}var D=toJSON(E);G+=",params:"+D.json;if(D.fixups){G+=",fixups:"+toJSON(D.fixups).json}F.data=G+"}";return F};JSONRpcClient._sendRequest=function(A,C){var B;if(C.profile){C.profile.start=new Date()}B=JSONRpcClient.poolGetHTTPRequest();JSONRpcClient.num_req_active++;B.open("POST",A.serverURL,!!C.cb,A.user,A.pass);try{B.setRequestHeader("Content-type","text/plain")}catch(D){}if(C.cb){B.onreadystatechange=function(){var E;if(B.readyState==4){B.onreadystatechange=function(){};E={cb:C.cb,result:null,ex:null};if(C.profile){E.profile=C.profile;E.profile.end=new Date()}else{E.profile=false}try{E.result=A._handleResponse(B)}catch(F){E.ex=F}if(!JSONRpcClient.async_inflight[C.requestId].canceled){JSONRpcClient.async_responses.push(E)}delete JSONRpcClient.async_inflight[C.requestId];JSONRpcClient.kick_async()}}}else{B.onreadystatechange=function(){}}JSONRpcClient.async_inflight[C.requestId]=C;try{B.send(C.data)}catch(D){JSONRpcClient.poolReturnHTTPRequest(B);JSONRpcClient.num_req_active--;throw new JSONRpcClient.Exception({code:JSONRpcClient.Exception.CODE_ERR_CLIENT,message:"Connection failed"})}if(!C.cb){delete JSONRpcClient.async_inflight[C.requestId];return A._handleResponse(B)}return null};JSONRpcClient.prototype._handleResponse=function(B){if(!this.charset){this.charset=JSONRpcClient._getCharsetFromHeaders(B)}var A,E,C;try{A=B.status;E=B.statusText;C=B.responseText}catch(D){JSONRpcClient.poolReturnHTTPRequest(B);JSONRpcClient.num_req_active--;JSONRpcClient.kick_async();throw new JSONRpcClient.Exception({code:JSONRpcClient.Exception.CODE_ERR_CLIENT,message:"Connection failed"})}JSONRpcClient.poolReturnHTTPRequest(B);JSONRpcClient.num_req_active--;if(A!=200){throw new JSONRpcClient.Exception({code:A,message:E})}return this.unmarshallResponse(C)};JSONRpcClient.prototype.unmarshallResponse=function(data){function applyFixups(obj,fixups){function findOriginal(ob,original){for(var i=0,j=original.length;i<j;i++){ob=ob[original[i]]}return ob}function applyFixup(ob,fixups,value){var j=fixups.length-1;for(var i=0;i<j;i++){ob=ob[fixups[i]]}ob[fixups[j]]=value}for(var i=0,j=fixups.length;i<j;i++){applyFixup(obj,fixups[i][0],findOriginal(obj,fixups[i][1]))}}function transform_date(obj){var hint,foo,num,i,jsDate;if(obj&&typeof obj==="object"){hint=obj.hasOwnProperty("javaClass");foo=hint?obj.javaClass==="java.util.Date":obj.hasOwnProperty("time");num=0;if(!hint&&foo){for(i in obj){if(obj.hasOwnProperty(i)){num++}}}if(hint&&foo||foo&&num===1){jsDate=new Date(obj.time);return jsDate}else{for(i in obj){if(obj.hasOwnProperty(i)){obj[i]=transform_date(obj[i])}}return obj}}else{return obj}}var obj;try{eval("obj = "+data)}catch(e){throw new JSONRpcClient.Exception({code:550,message:"error parsing result"})}if(obj.error){throw new JSONRpcClient.Exception(obj.error)}var r=obj.result;var i,tmp;if(r){if(r.objectID&&r.JSONRPCType=="CallableReference"){return this.createCallableProxy(r.objectID,r.javaClass)}else{r=JSONRpcClient.extractCallableReferences(this,JSONRpcClient.transformDates?transform_date(r):r);if(obj.fixups){applyFixups(r,obj.fixups)}}}return r};JSONRpcClient.extractCallableReferences=function(B,A){var D,C,E;for(D in A){if(typeof (A[D])=="object"){C=JSONRpcClient.makeCallableReference(B,A[D]);if(C){A[D]=C}else{C=JSONRpcClient.extractCallableReferences(B,A[D]);A[D]=C}}if(typeof (D)=="object"){C=JSONRpcClient.makeCallableReference(B,D);if(C){E=A[D];delete A[D];A[C]=E}else{C=JSONRpcClient.extractCallableReferences(B,D);E=A[D];delete A[D];A[C]=E}}}return A};JSONRpcClient.makeCallableReference=function(A,B){if(B&&B.objectID&&B.javaClass&&B.JSONRPCType=="CallableReference"){return A.createCallableProxy(B.objectID,B.javaClass)}return null};JSONRpcClient.http_spare=[];JSONRpcClient.http_max_spare=8;JSONRpcClient.poolGetHTTPRequest=function(){var A=JSONRpcClient.http_spare.pop();if(A){return A}return JSONRpcClient.getHTTPRequest()};JSONRpcClient.poolReturnHTTPRequest=function(A){if(JSONRpcClient.http_spare.length>=JSONRpcClient.http_max_spare){delete A}else{JSONRpcClient.http_spare.push(A)}};JSONRpcClient.msxmlNames=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","Microsoft.XMLHTTP"];JSONRpcClient.getHTTPRequest=function(){try{JSONRpcClient.httpObjectName="XMLHttpRequest";return new XMLHttpRequest()}catch(B){}for(var A=0;A<JSONRpcClient.msxmlNames.length;A++){try{JSONRpcClient.httpObjectName=JSONRpcClient.msxmlNames[A];return new ActiveXObject(JSONRpcClient.msxmlNames[A])}catch(B){}}JSONRpcClient.httpObjectName=null;throw new JSONRpcClient.Exception({code:0,message:"Can't create XMLHttpRequest object"})}