if(!window.Presto){var Presto={}}Presto.OnDemand={queue:[],pending:null,checkCondition:function(){var E=this.pending,C=this;var D=function(){if(!E.requestCompleted){if(E.callback){var F=[E.url];if(E.args){for(var G=0;G<E.args.length;G++){F.push(E.args[G])}}E.callback.onSuccess.apply(E.callback.scope,F)}E.requestCompleted=true}if(C.queue.length>0){var H=C.queue.shift();C.requireScript(H.url,H.callback,H.condition,H.args)}};if(E.condition&&typeof E.condition=="function"){if(!E.condition()){var A=1000;var B=setInterval(function(){if(E.condition()){clearInterval(B);D()}else{A+=1000;if(A>30000){clearInterval(B);if(E.callback){clearInterval(B);E.callback.onFailure.apply(E.callback.scope,["30 second timed out."])}}}},A)}else{D()}}else{D()}},matchUrl:function(B,D){if(B&&D){function A(G,E){var F=G.length-E.length;return F>=0&&G.lastIndexOf(E)===F}if(/(http|https):\/\//.test(B)){var C=B.substring(B.indexOf("//")+2);C=C.substring(C.indexOf("/"));if(A(D,C)){return true}}if(A(D,B)){return true}}return false},requireScript:function(A,J,C){var K=this;var E={url:A,callback:J,condition:C,args:Array.prototype.slice.call(arguments,3)};if(this.pending&&!this.pending.requestCompleted){this.queue.push(E);return }this.pending=E;if(C){C()}var D=document.getElementsByTagName("script");var L=false;if(D){for(var F=0;F<D.length;F++){if(this.matchUrl(A,D[F].src)){L=true;break}}}if(!L){var B=this.pending;var H=document.createElement("script");H.setAttribute("type","text/javascript");if(B.callback||B.condition){H.onreadystatechange=function(M){if(this.readyState=="loaded"||this.readyState=="complete"){this.onreadyStateChange=null;K.checkCondition()}};H.onload=function(M){H.onload=null;K.checkCondition()}}var G=document.getElementsByTagName("head")[0];var I=G.appendChild(H);H.src=B.url}else{K.checkCondition()}},requireCSS:function(B,H){var A=document.getElementsByTagName("link");var G=false;if(A){for(var D=0;D<A.length;D++){if(this.matchUrl(B,A[D].href)){G=true;break}}}if(!G){var E=document.createElement("link");E.setAttribute("type","text/css");E.setAttribute("rel","stylesheet");var C=document.getElementsByTagName("head")[0];var F=C.appendChild(E);E.href=B;if(H){H.onSuccess()}}else{if(H){H.onSuccess()}}}};if(!window.Ema){var Ema={containers:{},prestoConnection:null,isReady:false,debug:function(A){},getMashlet:function(D,C){var B=[];for(var A in Ema.containers){for(var E in Ema.containers[A].mashlets){if(Ema.containers[A].mashlets[E][D]==C){B.push(Ema.containers[A].mashlets[E])}}}return B},namespace:function(){var a=arguments,o=null,i,j,d,rt;for(i=0;i<a.length;++i){d=a[i].split(".");rt=d[0];eval("if (typeof "+rt+' == "undefined"){'+rt+" = {};} o = "+rt+";");for(j=1;j<d.length;++j){o[d[j]]=o[d[j]]||{};o=o[d[j]]}}},getContainer:function(A,E,D){if(!A){A=""}if(!E){E=A+"/static"}var B=A||"local";Presto.OnDemand.requireCSS(E+"/mashlet/css/mashlet.css");var C=function(){return(window.Presto&&Ema&&Ema.Container)};Presto.OnDemand.requireScript(E+"/mashlet/js/mashlet-core.js",{onSuccess:function(){var F=this.containers[B];var G=null;if(!F){F=new Ema.Container(A,E,G);this.containers[B]=F}Presto.OnDemand.requireScript(A+"/mashlets/loadconfig.jsp?server="+B,{onSuccess:function(){D.onSuccess.apply(D.scope||window,[this.containers[B]])},onFailure:function(H){D.onFailure.apply(D.scope||this,[H])},scope:this},function(){return(Ema.containers[B].mashletsConfig)})},onFailure:function(F){D.onFailure.apply(D.scope||this,[F])},scope:this},C)},load:function(A){if(!(A.name||A.preferences)){throw new Error('Ema.load() requires either "name" or "preferences" to load the Mashlet')}if(!A.serverUrl){A.serverUrl=""}Ema.getContainer(A.serverUrl,A.resourcesBase,{onSuccess:function(B){B.load(A)},onFailure:function(B){throw new Error(B)},scope:this})},publishEvent:function(C){var A=[];for(var B=1;B<arguments.length;B++){A.push(arguments[B])}for(B=0;B<this.containers.length;B++){}this.fireEvent(C,A)}}};