obips.AnalysisEventManager=function(a){if(!a){alert("Use obips.AnalysisEventManager.getInstance() instead of constructing obips.AnalysisEventManager directly")}this.eventListeners=new Object()};obips.AnalysisEventManager.getInstance=function(){var b="obips_AnalysisEventManager";var a=document[b];if(!a){document[b]=new obips.AnalysisEventManager(true);a=document[b]}return a};obips.AnalysisEventManager.prototype.addEventListener=function(b){var a=b.getType();if(!this.eventListeners[a]){this.eventListeners[a]=[]}else{this.removeAnalysisEventListener(b)}this.eventListeners[a].push(b)};obips.AnalysisEventManager.prototype.removeAnalysisEventListener=function(c){var b=c.getType();if(this.eventListeners[b]){for(var a=0;a<this.eventListeners[b].length;++a){if(this.eventListeners[b][a]==c){this.eventListeners[b].splice(a,1)}}}};obips.AnalysisEventManager.prototype.removeAllListenersForObject=function(a){var c=this.eventListeners;for(listenerType in c){var b=c[listenerType];for(listenerProp in b){var e=b[listenerProp];var d=e.getThisContext&&e.getThisContext();if(d&&d===a){this.removeAnalysisEventListener(e)}}}};obips.AnalysisEventManager.prototype.removeAllListenersForType=function(b){var a=this.eventListeners[b];if(a){for(i in a){delete a[i]}}};obips.AnalysisEventManager.prototype.removeAllListeners=function(){this.eventListeners=new Object()};obips.AnalysisEventManager.raiseEvent=function(b){var a=obips.AnalysisEventManager.getInstance();a._handleEvents(b,false,false)};obips.AnalysisEventManager.raiseSynchronousEvent=function(b){var a=obips.AnalysisEventManager.getInstance();return a._handleEvents(b,true,true)};obips.AnalysisEventManager.raiseReadOnlyEventWithCallback=function(b){var a=obips.AnalysisEventManager.getInstance();a._handleEvents(b,false,true)};obips.AnalysisEventManager.prototype._getStatePathWithType=function(b,d){var a=new RegExp(".+~"+d+":[^~]*");var c=b.match(a);return c&&c[0]||null};obips.AnalysisEventManager.prototype._getReportStatePath=function(a){return this._getStatePathWithType(a,"r")||this._getStatePathWithType(a,"g")||a};obips.AnalysisEventManager.prototype._handleEvents=function(d,b,m){var a=d.getType();var g=this.eventListeners[a];if(g){for(i in g){var e=g[i];if(e.getCallback&&e.getCallback()){e.getCallback().exec(d)}}}var c=null;var f=d.getViewID();if(f){c=this._getReportStatePath(f)}if(d.isServerSyncRequired()){var h=null;if(c){h=obips.Analysis.getReport(c,false)}else{h=obips.Analysis.getCurrentReport(false)}if(h){var l=((m&&d.oCallback)?d.oCallback:null);var k=h.syncWithServer(d.getEventName(),d.getEventParams(),f,d.shouldRefreshSingleViewOnly(),d.shouldStoreInHistory(),d.isCumulative(),b,l);if(k!=true&&typeof(k)=="string"){alert(k)}else{if(k){return k}}}}else{if(d.isClientStateSyncRequired()){if(c){var n=new obips.Callback(this,this._persistClientStateResponse);var j=obips.views.ViewController.getController(c).getClientStateManager();j.persistClientState(n)}}}};obips.AnalysisEventManager.prototype._persistClientStateResponse=function(a){};