var $runtime="dhtml";var $dhtml=true;var $as3=false;var $as2=false;var $swf10=false;var $j2me=false;var $debug=false;var $js1=true;var $backtrace=false;var $swf7=false;var $swf9=false;var $swf8=false;var $svg=false;var $profile=false;pmrpc=self.pmrpc=(function(){
var generateUUID;var convertWildcardToRegex;var checkACL;var invokeProcedure;var encode;var decode;var createJSONRpcBaseObject;var createJSONRpcRequestObject;var createJSONRpcErrorObject;var createJSONRpcResponseObject;var register;var unregister;var fetchRegisteredService;var processPmrpcMessage;var processJSONRpcRequest;var processJSONRpcResponse;var call;var sendPmrpcMessage;var waitAndSendRequest;var addCrossBrowserEventListerner;var createHandler;var $2;var $3;var $4;var findAllWindows;var findAllWorkers;var findAllReachableContexts;var $5;var $6;generateUUID=function(){
var $0=[],$1="89AB",$2="0123456789ABCDEF";for(var $3=0;$3<36;$3++){
$0[$3]=$2[Math.floor(Math.random()*16)]
};$0[14]="4";$0[19]=$1[Math.floor(Math.random()*4)];$0[8]=$0[13]=$0[18]=$0[23]="-";return $0.join("")
};convertWildcardToRegex=function($0){
var $1=$0.replace(__wildcardRegexp,"\\$1");$1="^"+$1.replace(__starRegexp,".*")+"$";return $1
};checkACL=function($0,$1){
var $2=$0.whitelist;var $3=$0.blacklist;var $4=false;var $5=false;for(var $6=0;$6<$2.length;++$6){
var $7=convertWildcardToRegex($2[$6]);if($1.match($7)){
$4=true;break
}};for(var $8=0;$6<$3.length;++$8){
var $7=convertWildcardToRegex($3[$8]);if($1.match($7)){
$5=true;break
}};return $4&&!$5
};invokeProcedure=function($0,$1,$2,$3){
if(!($2 instanceof Array)){
var $4=$0.toString();var $5=$4.substring($4.indexOf("(")+1,$4.indexOf(")"));$5=$5===""?[]:$5.split(", ");var $6={};for(var $7=0;$7<$5.length;$7++){
$6[$5[$7]]=$7
};var $8=[];for(var $9 in $2){
if(typeof $6[$9]!=="undefined"){
$8[$6[$9]]=$2[$9]
}else{
throw "No such param!"
}};$2=$8
};if(typeof $3!=="undefined"){
$2=$2.concat($3)
};return $0.apply($1,$2)
};encode=function($0){
return "pmrpc."+JSON.stringify($0)
};decode=function($0){
return JSON.parse($0.substring("pmrpc.".length))
};createJSONRpcBaseObject=function(){
var $0={};$0.jsonrpc="2.0";return $0
};createJSONRpcRequestObject=function($0,$1,$2){
var $3=createJSONRpcBaseObject();$3.method=$0;$3.params=$1;if(typeof $2!=="undefined"){
$3.id=$2
};return $3
};createJSONRpcErrorObject=function($0,$1,$2){
var $3={};$3.code=$0;$3.message=$1;$3.data=$2;return $3
};createJSONRpcResponseObject=function($0,$1,$2){
var $3=createJSONRpcBaseObject();$3.id=$2;if(typeof $0==="undefined"||$0===null){
$3.result=$1==="undefined"?null:$1
}else{
$3.error=$0
};return $3
};register=function($0){
if($0.publicProcedureName in reservedProcedureNames){
return false
}else{
registeredServices[$0.publicProcedureName]={"publicProcedureName":$0.publicProcedureName,"procedure":$0.procedure,"context":$0.procedure.context,"isAsync":typeof $0.isAsynchronous!=="undefined"?$0.isAsynchronous:false,"acl":typeof $0.acl!=="undefined"?$0.acl:{whitelist:["*"],blacklist:[]}};return true
}};unregister=function($0){
if($0 in reservedProcedureNames){
return false
}else{
delete registeredServices[$0];return true
}};fetchRegisteredService=function($0){
return registeredServices[$0]
};processPmrpcMessage=function($0){
var $1=$0.event;var $2=$0.source;var $3=typeof $2!=="undefined"&&$2!==null;if($1.data.indexOf("pmrpc.")!==0){
return
}else{
var $4=decode($1.data);if(typeof $4.method!=="undefined"){
var $5={data:$1.data,source:$3?$2:$1.source,origin:$3?"*":$1.origin,shouldCheckACL:!$3};response=processJSONRpcRequest($4,$5);if(response!==null){
sendPmrpcMessage($5.source,response,$5.origin)
}}else{
processJSONRpcResponse($4)
}}};processJSONRpcRequest=function($0,serviceCallEvent,$1){
if($0.jsonrpc!=="2.0"){
return createJSONRpcResponseObject(createJSONRpcErrorObject(-32600,"Invalid request.","The recived JSON is not a valid JSON-RPC 2.0 request."),null,null)
};var id=$0.id;var $2=fetchRegisteredService($0.method);if(typeof $2!=="undefined"){
if(!serviceCallEvent.shouldCheckACL||checkACL($2.acl,serviceCallEvent.origin)){
try{
if($2.isAsync){
var $3=function($0){
sendPmrpcMessage(serviceCallEvent.source,createJSONRpcResponseObject(null,$0,id),serviceCallEvent.origin)
};invokeProcedure($2.procedure,$2.context,$0.params,[$3,serviceCallEvent]);return null
}else{
var $4=invokeProcedure($2.procedure,$2.context,$0.params,[serviceCallEvent]);return typeof id==="undefined"?null:createJSONRpcResponseObject(null,$4,id)
}}
catch($5){
if(typeof id==="undefined"){
return null
};if($5==="No such param!"){
return createJSONRpcResponseObject(createJSONRpcErrorObject(-32602,"Invalid params.",$5.description),null,id)
};return createJSONRpcResponseObject(createJSONRpcErrorObject(-1,"Application error.",$5.description),null,id)
}}else{
return typeof id==="undefined"?null:createJSONRpcResponseObject(createJSONRpcErrorObject(-2,"Application error.","Access denied on server."),null,id)
}}else{
return typeof id==="undefined"?null:createJSONRpcResponseObject(createJSONRpcErrorObject(-32601,"Method not found.","The requestd remote procedure does not exist or is not available."),null,id)
}};processJSONRpcResponse=function($0){
var $1=$0.id;var $2=callQueue[$1];if(typeof $2==="undefined"||$2===null){
return
}else{
delete callQueue[$1]
};if(typeof $0.error==="undefined"){
$2.onSuccess({"destination":$2.destination,"publicProcedureName":$2.publicProcedureName,"params":$2.params,"status":"success","returnValue":$0.result})
}else{
$2.onError({"destination":$2.destination,"publicProcedureName":$2.publicProcedureName,"params":$2.params,"status":"error","description":$0.error.message+" "+$0.error.data})
}};call=function($0){
if($0.retries&&$0.retries<0){
throw new Exception("number of retries must be 0 or higher")
};var $1=[];if(typeof $0.destination==="undefined"||$0.destination===null||$0.destination==="workerParent"){
$1=[{context:null,type:"workerParent"}]
}else if($0.destination==="publish"){
$1=findAllReachableContexts()
}else if($0.destination instanceof Array){
for(var $2=0;$2<$0.destination.length;$2++){
if($0.destination[$2]==="workerParent"){
$1.push({context:null,type:"workerParent"})
}else if(typeof $0.destination[$2].frames!=="undefined"){
$1.push({context:$0.destination[$2],type:"window"})
}else{
$1.push({context:$0.destination[$2],type:"worker"})
}}}else{
if(typeof $0.destination.frames!=="undefined"){
$1.push({context:$0.destination,type:"window"})
}else{
$1.push({context:$0.destination,type:"worker"})
}};for(var $2=0;$2<$1.length;$2++){
var $3={destination:$1[$2].context,destinationDomain:typeof $0.destinationDomain==="undefined"?["*"]:(typeof $0.destinationDomain==="string"?[$0.destinationDomain]:$0.destinationDomain),publicProcedureName:$0.publicProcedureName,onSuccess:typeof $0.onSuccess!=="undefined"?$0.onSuccess:(function(){}),onError:typeof $0.onError!=="undefined"?$0.onError:(function(){}),retries:typeof $0.retries!=="undefined"?$0.retries:5,timeout:typeof $0.timeout!=="undefined"?$0.timeout:500,status:"requestNotSent"};isNotification=typeof $0.onError==="undefined"&&typeof $0.onSuccess==="undefined";params=typeof $0.params!=="undefined"?$0.params:[];callId=generateUUID();callQueue[callId]=$3;if(isNotification){
$3.message=createJSONRpcRequestObject($0.publicProcedureName,params)
}else{
$3.message=createJSONRpcRequestObject($0.publicProcedureName,params,callId)
};waitAndSendRequest(callId)
}};sendPmrpcMessage=function($0,$1,$2){
if(typeof $0==="undefined"||$0===null){
self.postMessage(encode($1))
}else if(typeof $0.frames!=="undefined"){
return $0.postMessage(encode($1),$2)
}else if($0&&$0.postMessage){
$0.postMessage(encode($1))
}};waitAndSendRequest=function(callId){
var $0=callQueue[callId];if(typeof $0==="undefined"){
return
}else if($0.retries<=-1){
processJSONRpcResponse(createJSONRpcResponseObject(createJSONRpcErrorObject(-4,"Application error.","Destination unavailable."),null,callId))
}else if($0.status==="requestSent"){
return
}else if($0.retries===0||$0.status==="available"){
$0.status="requestSent";$0.retries=-1;callQueue[callId]=$0;for(var $1=0;$1<$0.destinationDomain.length;$1++){
sendPmrpcMessage($0.destination,$0.message,$0.destinationDomain[$1],$0);self.setTimeout(function(){
waitAndSendRequest(callId)
},$0.timeout)
}}else{
$0.status="pinging";$0.retries=$0.retries-1;call({"destination":$0.destination,"publicProcedureName":"receivePingRequest","onSuccess":function($0){
if($0.returnValue===true&&typeof callQueue[callId]!=="undefined"){
callQueue[callId].status="available";waitAndSendRequest(callId)
}},"params":[$0.publicProcedureName],"retries":0,"destinationDomain":$0.destinationDomain});callQueue[callId]=$0;self.setTimeout(function(){
waitAndSendRequest(callId)
},$0.timeout/$0.retries)
}};addCrossBrowserEventListerner=function($0,$1,$2,$3){
if("addEventListener" in $0){
$0.addEventListener($1,$2,$3)
}else{
$0.attachEvent("on"+$1,$2)
}};createHandler=function(method,source,destinationType){
return( function($0){
var $1={event:$0,source:source,destinationType:destinationType};method($1)
})
};$2=function($0){
return typeof fetchRegisteredService($0)!=="undefined"
};findAllWindows=function(){
var $0=[];if(typeof window!=="undefined"){
$0.push({context:window.top,type:"window"});for(var $1=0;typeof $0[$1]!=="undefined";$1++){
var $2=$0[$1];for(var $3=0;$3<$2.context.frames.length;$3++){
$0.push({context:$2.context.frames[$3],type:"window"})
}}}else{
$0.push({context:this,type:"workerParent"})
};return $0
};findAllWorkers=function(){
return allWorkers
};findAllReachableContexts=function(){
var $0=findAllWindows();var $1=findAllWorkers();var $2=$0.concat($1);return $2
};$5=function(){
var $0=[];var $1=typeof this.frames!=="undefined"?window.location.protocol+"//"+window.location.host+(window.location.port!==""?":"+window.location.port:""):"";for(publicProcedureName in registeredServices){
if(publicProcedureName in reservedProcedureNames){
continue
}else{
$0.push({"publicProcedureName":registeredServices[publicProcedureName].publicProcedureName,"acl":registeredServices[publicProcedureName].acl,"origin":$1})
}};return $0
};$6=function(params){
var addToDiscoveredMethods;addToDiscoveredMethods=function($0,$1){
for(var $2=0;$2<$0.length;$2++){
if($0[$2].origin.match(originRegex)&&$0[$2].publicProcedureName.match(nameRegex)){
discoveredMethods.push({publicProcedureName:$0[$2].publicProcedureName,destination:$1,procedureACL:$0[$2].acl,destinationOrigin:$0[$2].origin})
}}};var $0=null;if(typeof params.destination==="undefined"){
$0=findAllReachableContexts();for(var $1=0;$1<$0.length;$1++){
$0[$1]=$0[$1].context
}}else{
$0=params.destination
};var originRegex=typeof params.origin==="undefined"?".*":params.origin;var nameRegex=typeof params.publicProcedureName==="undefined"?".*":params.publicProcedureName;var counter=$0.length;var discoveredMethods=[];pmrpc.call({destination:$0,destinationDomain:"*",publicProcedureName:"getRegisteredProcedures",onSuccess:function($0){
counter--;addToDiscoveredMethods($0.returnValue,$0.destination);if(counter===0){
params.callback(discoveredMethods)
}},onError:function($0){
counter--;if(counter===0){
params.callback(discoveredMethods)
}}})
};if(typeof JSON==="undefined"||typeof JSON.stringify==="undefined"||typeof JSON.parse==="undefined"){
window.console&&console.error&&console.error("pmrpc requires the JSON library")
};if(typeof this.postMessage==="undefined"&&typeof this.onconnect==="undefined"){
window.console&&console.error&&console.error("pmrpc requires the HTML5 cross-document messaging and worker APIs")
};var __wildcardRegexp=new RegExp("([\\^\\$\\.\\+\\?\\=\\!\\:\\|\\\\/\\(\\)\\[\\]\\{\\}])","g");var __starRegexp=new RegExp("\\*","g");var registeredServices={};var callQueue={};var reservedProcedureNames={};if("window" in this){
var $0=createHandler(processPmrpcMessage,null,"window");addCrossBrowserEventListerner(this,"message",$0,false)
}else if("onmessage" in this){
var $0=createHandler(processPmrpcMessage,this,"worker");addCrossBrowserEventListerner(this,"message",$0,false)
}else if("onconnect" in this){
var $1=function($0){
var $1=createHandler(processPmrpcMessage,$0.ports[0],"sharedWorker");addCrossBrowserEventListerner($0.ports[0],"message",$1,false);$0.ports[0].start()
};addCrossBrowserEventListerner(this,"connect",$1,false)
}else{
throw "Pmrpc must be loaded within a browser window or web worker."
};var createDedicatedWorker=this.Worker;this.nonPmrpcWorker=createDedicatedWorker;var createSharedWorker=this.SharedWorker;this.nonPmrpcSharedWorker=createSharedWorker;var allWorkers=[];this.Worker=function($0){
var $1=new createDedicatedWorker($0);allWorkers.push({context:$1,type:"worker"});var $2=createHandler(processPmrpcMessage,$1,"worker");addCrossBrowserEventListerner($1,"message",$2,false);return $1
};this.SharedWorker=function($0,$1){
var newWorker=new createSharedWorker($0,$1);allWorkers.push({context:newWorker,type:"sharedWorker"});var $2=createHandler(processPmrpcMessage,newWorker.port,"sharedWorker");addCrossBrowserEventListerner(newWorker.port,"message",$2,false);newWorker.postMessage=function($0,$1){
return newWorker.port.postMessage($0,$1)
};newWorker.port.start();return newWorker
};register({"publicProcedureName":"receivePingRequest","procedure":$2});register({"publicProcedureName":"getRegisteredProcedures","procedure":$5});reservedProcedureNames={"getRegisteredProcedures":null,"receivePingRequest":null};return {register:register,unregister:unregister,call:call,discover:$6}})();