function utf16to8(str){var out,i,len,c;out=[];len=str.length;for(i=0;i<len;i++){c=str.charCodeAt(i);if((c>=0x0001)&&(c<=0x007F)){out[i]=str.charAt(i);}else if(c>0x07FF){out[i]=String.fromCharCode(0xE0|((c>>12)&0x0F),0x80|((c>>6)&0x3F),0x80|((c>>0)&0x3F));}else{out[i]=String.fromCharCode(0xC0|((c>>6)&0x1F),0x80|((c>>0)&0x3F));}}
return out.join('');}
function utf8to16(str){var out,i,len,c;var char2,char3;out=[];len=str.length;i=0;while(i<len){c=str.charCodeAt(i++);switch(c>>4)
{case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:out[out.length]=str.charAt(i-1);break;case 12:case 13:char2=str.charCodeAt(i++);out[out.length]=String.fromCharCode(((c&0x1F)<<6)|(char2&0x3F));break;case 14:char2=str.charCodeAt(i++);char3=str.charCodeAt(i++);out[out.length]=String.fromCharCode(((c&0x0F)<<12)|((char2&0x3F)<<6)|((char3&0x3F)<<0));break;}}
return out.join('');}
var base64EncodeChars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var base64DecodeChars=new Array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1);function base64encode(str){var out,i,len;var c1,c2,c3;len=str.length;i=0;out=[];while(i<len){c1=str.charCodeAt(i++)&0xff;if(i==len)
{out[out.length]=base64EncodeChars.charAt(c1>>2);out[out.length]=base64EncodeChars.charAt((c1&0x3)<<4);out[out.length]="==";break;}
c2=str.charCodeAt(i++);if(i==len)
{out[out.length]=base64EncodeChars.charAt(c1>>2);out[out.length]=base64EncodeChars.charAt(((c1&0x3)<<4)|((c2&0xF0)>>4));out[out.length]=base64EncodeChars.charAt((c2&0xF)<<2);out[out.length]="=";break;}
c3=str.charCodeAt(i++);out[out.length]=base64EncodeChars.charAt(c1>>2);out[out.length]=base64EncodeChars.charAt(((c1&0x3)<<4)|((c2&0xF0)>>4));out[out.length]=base64EncodeChars.charAt(((c2&0xF)<<2)|((c3&0xC0)>>6));out[out.length]=base64EncodeChars.charAt(c3&0x3F);}
return out.join('');}
function base64decode(str){var c1,c2,c3,c4;var i,len,out;len=str.length;i=0;out=[];while(i<len){do{c1=base64DecodeChars[str.charCodeAt(i++)&0xff];}while(i<len&&c1==-1);if(c1==-1)break;do{c2=base64DecodeChars[str.charCodeAt(i++)&0xff];}while(i<len&&c2==-1);if(c2==-1)break;out[out.length]=String.fromCharCode((c1<<2)|((c2&0x30)>>4));do{c3=str.charCodeAt(i++)&0xff;if(c3==61)return out.join('');c3=base64DecodeChars[c3];}while(i<len&&c3==-1);if(c3==-1)break;out[out.length]=String.fromCharCode(((c2&0XF)<<4)|((c3&0x3C)>>2));do{c4=str.charCodeAt(i++)&0xff;if(c4==61)return out.join('');c4=base64DecodeChars[c4];}while(i<len&&c4==-1);if(c4==-1)break;out[out.length]=String.fromCharCode(((c3&0x03)<<6)|c4);}
return out.join('');}
function PHP_Serializer(){this.__cut=(String(Object).indexOf('(')!=16)?9:10;}
function PHP_Serializer__String(__s){__s=utf16to8(__s);return['s:',__s.length,':"',__s,'";'].join('');}
function PHP_UnSerializer__String(){this.__c+=2;var sls=this.__s.substr(this.__c,(this.__s.indexOf(':',this.__c)-this.__c));var sli=parseInt(sls);sls=this.__c+sls.length+2;this.__c=sls+sli+2;return utf8to16(this.__s.substr(sls,sli));}
function PHP_Serializer__Boolean(__s){return(['b:',(__s==false?'0':'1'),';'].join(''));}
function PHP_UnSerializer__Boolean(){var tmp=(this.__s.substr((this.__c+2),1)=='1'?true:false);this.__c+=4;return tmp;}
function PHP_Serializer__Number(__s){__s=String(__s);return[((__s.indexOf('.')==-1)?'i:':'d:'),__s,';'].join('');}
function PHP_UnSerializer__Number(){var sli=this.__s.indexOf(';',(this.__c+1))-2;var tmp=Number(this.__s.substr((this.__c+2),(sli-this.__c)));this.__c=sli+3;return tmp;}
function PHP_Serializer__Function(){return'';}
function PHP_Serializer__Undefined(){return'N;';}
function PHP_UnSerializer__Undefined(){this.__c+=2;return null;}
function PHP_Serializer__Common_ArrayObject(__s){var n;var a=0;var ser=new Array();for(var b in __s){n=(__s[b]==null);if(n||(__s[b].constructor!=Function&&b!='__class')){ser[a++]=((!isNaN(b))?this.__number(b):this.__string(b))+
(n?this.__undefined():this.serialize(__s[b]));}}
return[a,ser.join('')];}
function PHP_UnSerializer__Common_ArrayObject(tmp){this.__c+=2;var a=this.__s.indexOf(':',this.__c);var k=parseInt(this.__s.substr(this.__c,(a-this.__c)))+1;this.__c=a+2;while(--k)
tmp[this[this.__s.substr(this.__c,1)]()]=this[this.__s.substr(this.__c,1)]();return tmp;}
function PHP_Serializer__Date(__s){var ser=this.__common_array_object(__s);return['O:4:"Date":',ser[0],':{',ser[1],'}'].join('');}
function PHP_Serializer__Error(__s){var ser=this.__common_array_object(__s);return['O:5:"Error":'+ser[0]+':{'+ser[1]+'}'].join('');}
function PHP_Serializer__Object(__s){var o=String(__s.constructor);var oname=o.substr(this.__cut,o.indexOf('(')-this.__cut);var ser=this.__common_array_object(__s);return['O:',oname.length,':"',oname,'":',ser[0],':{',ser[1],'}'].join('');}
function PHP_UnSerializer__Object(){var tmp='s'+this.__s.substr(++this.__c,(this.__s.indexOf(':',(this.__c+3))-this.__c))+';';var a=tmp.substr(2,(tmp.indexOf(':',2)-2));var o=tmp.substr((a.length+4),parseInt(a));if(eval("typeof("+o+") == 'undefined'"))
eval('function '+o+'(){}');this.__c+=(tmp.length-3);eval('tmp = this.__common(new '+o+'());');++this.__c;return tmp;}
function PHP_Serializer__Array(__s){var ser=this.__common_array_object(__s);return['a:',ser[0],':{',ser[1],'}'].join('');}
function PHP_UnSerializer__Array(){var tmp=this.__common(new Array());++this.__c;return tmp;}
function PHP_Serializer__serialize(what){if(what==null)
var ser=this.__undefined();else switch(what.constructor){case Array:var ser=this.Array(what);break;case Boolean:var ser=this.Boolean(what);break;case Number:var ser=this.Number(what);break;case String:var ser=this.String(what);break;case Function:var ser=this.Function(what);break;case Date:var ser=this.Date(what);break;case Error:var ser=this.Error(what);break;default:var ser=this.Object(what);}
return ser;}
function PHP_UnSerializer__unserialize(what){this.__c=0;this.__s=what;delete what;return this[this.__s.substr(this.__c,1)]();}
PHP_Serializer.prototype.Array=PHP_Serializer__Array;PHP_Serializer.prototype.Boolean=PHP_Serializer__Boolean;PHP_Serializer.prototype.Number=PHP_Serializer.prototype.__number=PHP_Serializer__Number;PHP_Serializer.prototype.String=PHP_Serializer.prototype.__string=PHP_Serializer__String;PHP_Serializer.prototype.Function=PHP_Serializer__Function;PHP_Serializer.prototype.Date=PHP_Serializer__Date;PHP_Serializer.prototype.Error=PHP_Serializer__Error;PHP_Serializer.prototype.Object=PHP_Serializer__Object;PHP_Serializer.prototype.__common_array_object=PHP_Serializer__Common_ArrayObject;PHP_Serializer.prototype.__undefined=PHP_Serializer__Undefined;PHP_Serializer.prototype.serialize=PHP_Serializer__serialize;PHP_Serializer.prototype.s=PHP_UnSerializer__String;PHP_Serializer.prototype.b=PHP_UnSerializer__Boolean;PHP_Serializer.prototype.i=PHP_Serializer.prototype.d=PHP_UnSerializer__Number;PHP_Serializer.prototype.N=PHP_UnSerializer__Undefined;PHP_Serializer.prototype.__common=PHP_UnSerializer__Common_ArrayObject;PHP_Serializer.prototype.O=PHP_UnSerializer__Object;PHP_Serializer.prototype.a=PHP_UnSerializer__Array;PHP_Serializer.prototype.unserialize=PHP_UnSerializer__unserialize;
function phprpc_error(errno,errstr){this.errno=errno;this.errstr=errstr;}
function phprpc_client(){this.__php=new PHP_Serializer();this.__url='';this.__encrypt=false;this.encrypt=0;this.ready=false;this.use_service=function(url,encrypt){if(encrypt){this.__encrypt=true;}
if(typeof(this.__name)=="undefined"){return false;}
this.__url=url;this.ready=false;var id=this.__create_id();var callback;if(this.__encrypt){callback=base64encode(utf16to8([this.__name,".__switch_key('",id,"');"].join('')));}
else{callback=base64encode(utf16to8([this.__name,".__get_functions('",id,"');"].join('')));}
this.__append_script(id,['phprpc_encrypt=',this.__encrypt,'&phprpc_callback=',callback,'&phprpc_encode=false'].join(''));return true;}
this.__switch_key=function(id){if(typeof(phprpc_encrypt)=="undefined"){this.__encrypt=false;this.__get_functions(id);}
else{this.__encrypt=this.__php.unserialize(phprpc_encrypt);this.__remove_script(id);this.__encrypt['p']=dec2num(this.__encrypt['p']);this.__encrypt['g']=dec2num(this.__encrypt['g']);this.__encrypt['y']=dec2num(this.__encrypt['y']);this.__encrypt['x']=rand(127,1);var key=pow_mod(this.__encrypt['y'],this.__encrypt['x'],this.__encrypt['p']);key=num2str(key);for(var i=0;i<16-key.length;i++){key='\0'+key;}
this.__encrypt['k']=key;var encrypt=pow_mod(this.__encrypt['g'],this.__encrypt['x'],this.__encrypt['p']);var callback=base64encode(utf16to8([this.__name,".__get_functions('",id,"');"].join('')));this.__append_script(id,['phprpc_encrypt=',num2dec(encrypt),'&phprpc_callback=',callback,'&phprpc_encode=false'].join(''));}}
this.__get_functions=function(id){var functions=this.__php.unserialize(phprpc_functions);var func=[];for(var i=0;i<functions.length;i++){func=[this.__name,".",functions[i]," = function () {\r\n    this.__call('",functions[i],"', this.__args_to_array(arguments));\r\n}\r\n",this.__name,".",functions[i],".ref = false;\r\n"].join('');eval(func);}
this.__remove_script(id);this.ready=true;if(typeof(this.onready)=="function"){this.onready();}}
this.__call=function(func,args){var __args=this.__php.serialize(args);if((this.__encrypt!==false)&&(this.encrypt>0)){__args=xxtea_encrypt(__args,this.__encrypt['k']);}
__args=base64encode(__args);var id=this.__create_id();var request=['phprpc_func=',func,'&phprpc_args=',__args,'&phprpc_encode=false','&phprpc_encrypt=',this.encrypt];var callback=[this.__name,".",func,"_callback"].join('');if(typeof(eval(callback))!="function"){callback="null";}
request[request.length]='&phprpc_callback=';request[request.length]=base64encode(utf16to8([this.__name,".__callback('",id,"', ",callback,");"].join('')));var ref=eval([this.__name,".",func,".ref"].join(''));if(!ref){request[request.length]='&phprpc_ref=false';}
this.__append_script(id,request.join(''),args,ref);}
this.__callback=function(id,callback){var script=document.getElementById("script_"+id);if(script.args[script.args.length-1].constructor==Function){callback=script.args[script.args.length-1];}
else if(callback==null){this.__remove_script(id);return;}
phprpc_warning=null;if((phprpc_errno!=1)&&(phprpc_errno!=16)&&(phprpc_errno!=64)&&(phprpc_errno!=256)){if((this.__encrypt!==false)&&(script.encrypt>0)){if(script.encrypt>1){phprpc_result=xxtea_decrypt(phprpc_result,this.__encrypt['k']);}
if(script.ref){phprpc_args=xxtea_decrypt(phprpc_args,this.__encrypt['k']);}}
phprpc_result=this.__php.unserialize(phprpc_result);if(script.ref){phprpc_args=this.__php.unserialize(phprpc_args);}
else{phprpc_args=script.args;}
phprpc_warning=new phprpc_error(phprpc_errno,phprpc_errstr);}
else{phprpc_result=new phprpc_error(phprpc_errno,phprpc_errstr);phprpc_args=null;}
callback(phprpc_result,phprpc_args,phprpc_output,phprpc_warning);this.__remove_script(id);}
this.__create_id=function(){return(new Date()).getTime().toString(36)+Math.floor(Math.random()*100000000).toString(36);}
this.__append_script=function(id,request,args,ref){var script=document.createElement("script");script.id="script_"+id;script.src=[this.__url,"?",request.replace(/\+/g,'%2B')].join('');script.defer=true;script.type="text/javascript";script.args=args;script.ref=ref;script.encrypt=this.encrypt;var head=document.getElementsByTagName("head").item(0);head.appendChild(script);}
this.__remove_script=function(id){var script=document.getElementById("script_"+id);var head=document.getElementsByTagName("head").item(0);head.removeChild(script);}
this.__args_to_array=function(args){argArray=new Array();for(i=0;i<args.length;i++){argArray[i]=args[i];}
return argArray;}}
phprpc_client.create=function(name,encrypt){eval([name,' = new phprpc_client();',name,'.__name = "',name,'";'].join(''));if(encrypt){encrypt=true;eval([name,'.__encrypt = ',encrypt,';'].join(''));}}