swell.svc.agDataSvc=function(a){swell.svc.baseSvc.apply(this,[a]);this.endPoints={getCatSpendData:"/services/cache/data/getdata",getCatSpendCompData:"/services/cache/data/getdata",getFilters:"/services/cache/data/initializefilters",getMap:"/services/cache/data/getmapforlocations",getMerchants:"/services/cache/data/getmerchantsbycategoryandlocation",getSavingsData:"/services/cache/data/GetSavingData",getSavingsCompData:"/services/cache/data/GetSavingData"};};swell.svc.agDataSvc.prototype=new swell.svc.baseSvc();swell.svc.agDataSvc.constructor=swell.svc.agDataSvc;swell.svc.agDataSvc.prototype.sendResponseToCallback=function(c,a,b){if(c(a)){swell.data.reqPipeLine.removeExecReq(b.event);}else{swell.data.reqPipeLine.flagAsComplete(b.event);}};swell.svc.agDataSvc.prototype.getDao=function(b,c){var a="get"+b+"Dao";var d=this.daoFactory[a]();d.event=c.event;d.targetId=c.targetId;logger.log("request:",c.event,c.targetId);logger.log(b,d);return d;};swell.svc.agDataSvc.prototype.getCatSpendData=function(c){var b=this.getDao("JSON",c),a=this;b.get(this.endPoints[c.event],c.args,function(d){d.state=c.state;var e=d.getResponseContext();e.state=c.state;a.sendResponseToCallback(c.onSuccess,e,d);});swell.data.reqPipeLine.addExecReq(b);};swell.svc.agDataSvc.prototype.getSavingsData=function(b){var c=this.getDao("JSON",b),a=this;c.get(this.endPoints[b.event],b.args,function(d){d.state=b.state;var e=d.getResponseContext();e.state=b.state;a.sendResponseToCallback(b.onSuccess,e,d);});swell.data.reqPipeLine.addExecReq(c);};swell.svc.agDataSvc.prototype.getDefaultFiltersFrom=function(b){delete b.Status;delete b.ErrorCode;delete b.Errors;delete b.HouseholdComposition;delete b.IncomeGroup;delete b.AgeGroup;b.AgeId=0;b.HouseholdCompositionId=0;b.IncomeId=0;b.SegmentId=0;b.YearMonth=(b.Months[0].Id!=null)?b.Months[0].Id:new Date().getFullYear+new Date().getMonth();var a=$.cookies.get("spendType");if(a!==null){b.SegmentId=a;}return b;};swell.svc.agDataSvc.prototype.getFilters=function(a){var b=this.getDao("JSON",a);svc=this;b.get(this.endPoints[a.event],a.data,function(f){var d=f.getResponseContext();var e=f.xhr.getResponseHeader("User-State");var c=f.xhr.getResponseHeader("User-City");if(c===""){c=null;}if(e===""){e=null;}if(c==null){c="U.S.";}else{c+=", ";}if(e==null){e="";}d.data.Location=c+e;svc.sendResponseToCallback(a.onSuccess,d,f);});swell.data.reqPipeLine.addExecReq(b);};swell.svc.agDataSvc.prototype.getMap=function(b){delete b.args.authToken;var a=this.getDao("JSON",b);a.get(this.endPoints[b.event],b.args,function(c){b.onSuccess(c.getResponseContext());});};swell.svc.agDataSvc.prototype.getMerchants=function(b){var a=this.getDao("JSON",b);a.get(this.endPoints[b.event],b.args,function(c){b.onSuccess(c.getResponseContext());});};swell.svc.insightSvc=function(a){this.factory=(a!==undefined)?a:swell.data.ajaxDaoFactory,this.dataEndPoint="/services/nocache/insights/saveuserinsight";swell.svc.baseSvc.call(this,a);};swell.svc.insightSvc.prototype=new swell.svc.baseSvc();swell.svc.insightSvc.constructor=swell.svc.insightSvc;swell.svc.insightSvc.prototype.saveUserInsight=function(a){var c=this.factory.getJSONDao();var b={title:a.title,body:a.body,snapshotUrl:a.url,facebookUserId:a.userId};c.post(this.dataEndPoint,b,function(d){logger.log("dao callback");var e=d.data;logger.log("returned data:",e);if(e.Status){a.onSuccess(e);}else{a.onError(e);}});};swell.views.msgModalView=function(a,b){swell.views.baseView.apply(this,[a,b]);this.type="";this.title="";this.body="";this.contentStore={awaitingapproval:{title:"Wow. That was fast.",body:"<p>You got to this insight before we've cleared it for posting.  In the meantime, have a look at the numbers that inspired it.<p>"},rejected:{title:"Rejected",body:"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas vehicula massa id urna vulputate pellentesque tincidunt nulla fringilla. In molestie pellentesque diam at porta. Proin aliquam tristique elit, a cursus nisl rutrum eu. Fusce sollicitudin, mauris quis imperdiet vulputate, felis ipsum lacinia nulla, non volutpat massa quam at massa."}};};swell.views.msgModalView.prototype=new swell.views.baseView();swell.views.msgModalView.constructor=swell.views.shareInsight;swell.views.msgModalView.prototype.modalInit=function(){$("#msgModalTitle").html(this.contentStore[this.type].title);$("#msgModalContent").append(this.contentStore[this.type].body);};swell.views.msgModalView.prototype.closeModal=function(){$("#cboxOverlay").trigger("click");};swell.views.msgModalView.prototype.launchModal=function(a){this.type=a;if(this.contentStore[a]){$.fn.colorbox({href:"/UIComponent/msgmodal",open:true,opacity:0.5});$("#cboxClose").remove();$("#cboxTitle").remove();$("#colorbox").css("cursor","pointer");var b=this;$().bind("cbox_complete",function(){b.modalInit();});$("#colorbox").click(function(c){c.preventDefault();b.closeModal();});}};swell.views.spendTypeModalView=function(b,c){swell.views.baseView.apply(this,[b,c]);var a={width:650,opacity:0.75,initialWidth:32,initialHeight:32,customSetup:function(){}};c=c||{};this.properties=$.extend({},a,c.properties);};swell.views.spendTypeModalView.prototype=new swell.views.baseView();swell.views.spendTypeModalView.constructor=swell.views.shareInsight;swell.views.spendTypeModalView.prototype.modalInit=function(){$("#spendTypeList").wrap('<div class="stl-modal"></div>');$.fn.colorbox.resize();$(".left-sel").removeClass("left-sel");$("#closeModal").click(function(a){a.preventDefault();$("#cboxOverlay").trigger("click");});$(".select-btn").click(function(b){b.preventDefault();var a=$(this).attr("id");a=a.split("-");a=a[1];swell.events.raiseEvent("setSegment",{segmentId:a});$("#cboxOverlay").trigger("click");});};swell.views.spendTypeModalView.prototype.closeModal=function(){$("#cboxOverlay").trigger("click");};swell.views.spendTypeModalView.prototype.launchModal=function(){$.fn.colorbox($.extend({},this.properties,{href:"/uicomponent/segments",open:true,opacity:0.5}));$("#cboxClose").remove();$("#cboxTitle").remove();$("#colorbox").css("cursor","pointer");var a=this;$().bind("cbox_complete",function(){a.modalInit();});};swell.views.shareInsight=function(d,e){swell.views.baseView.apply(this,[d,e]);var a={width:490,opacity:0.75,initialWidth:32,initialHeight:32,customSetup:function(){}};e=e||{};this.properties=$.extend({},a,e.properties);this.shareInsightValidator=new validator();var c=new txtValidation({instance:"#modalTitleField",constraints:[new txtConstraint({expression:txtConstraint.availConstraints.NotBlank})]});var b=new txtValidation({instance:"#modalCommentField",constraints:[new txtConstraint({expression:txtConstraint.availConstraints.NotBlank})]});this.shareInsightValidator.registerItem(c);this.shareInsightValidator.registerItem(b);};swell.views.shareInsight.prototype=new swell.views.baseView();swell.views.shareInsight.constructor=swell.views.shareInsight;swell.views.shareInsight.prototype.successConfirmation=function(){$("#postInsightLoader").remove();$("#capShareInsight").addClass("hide");$("#shareInsightConfirm").removeClass("hide");};swell.views.shareInsight.prototype.loading=function(){$("#capShareInsight").css("opacity",".5");$('<img id="postInsightLoader" src="/assets/img/loading_static.png" />').css("position","absolute").css("top","140px").css("left","160px").appendTo($("#shareInsightDialog"));};swell.views.shareInsight.prototype.launchModal=function(c){var d=this;var b=function(){swell.behaviors.opensNewWindow($("#shareInsightFBLink"),{preProcess:a});$("#shareInsightFBLink").click(function(f){f.preventDefault();swell.events.raiseEvent("metricsLinkClick",{key:"InsightShare",props:{events:"event4",prop3:"Facebook",prop4:swell.metrics.config.pageName+document.location.hash},domEl:this});});$("#shareInsightTWLink").click(function(h){h.preventDefault();swell.events.raiseEvent("metricsLinkClick",{key:"InsightShare",props:{events:"event4",prop3:"Twitter",prop4:swell.metrics.config.pageName+document.location.hash},domEl:this});var f=$("#shareInsightTWLink");var g=document.location;var i=window.open("/share/twitter?u="+g+"&t="+document.title,"","toolbar=0,status=0,scrollbars=1,location=1,resizable=1,width=763,height=436");});swell.behaviors.opensNewWindow($("#shareInsightEMLink"));$("#shareInsightFBLogout").click(function(f){f.preventDefault();swell.events.raiseEvent("requestLogout");});$("#colorbox").draggable();$("#closeModal").click(function(f){f.preventDefault();$("#cboxOverlay").trigger("click");});$("#modalTitleField").focus(function(){$(this).bind("keyup",function(){var f=160;var g=$(this).val();if(g.length>f){g=g.substring(0,f);$(this).val(g);}$("#titleCount span").html(f-g.length);});});$("#modalTitleField").blur(function(){$(this).unbind("keyup");});$("#modalTitleField").blur(function(){$(this).unbind("keyup");});$("#capShareInsight").submit(function(g){g.preventDefault();var f=d.shareInsightValidator.validate();if(f){swell.events.raiseEvent("submitUserInsight",{title:$("#modalTitleField").val(),body:$("#modalCommentField").val(),userId:swell.svc.loginSvc.userProfile.uid,url:window.location.href});}});var e=function(){FB.XFBML.Host.parseDomTree();swell.events.raiseEvent("checkAuthentication");};if(FB.XFBML.Host.parseDomTree){setTimeout(e,0);}};var a=function(){var f=location.href;var e=$("#modalTitleField").val();if(e===""){e=document.title;}$("#shareInsightFBLink").attr("href","http://www.facebook.com/sharer.php?u="+encodeURIComponent(f)+"&t="+encodeURIComponent(e));};$.fn.colorbox($.extend({},this.properties,{href:"/uicomponent/shareinsight",open:true}),b);$("#cboxClose").remove();$("#cboxTitle").remove();};swell.views.shareInsight.prototype.postToFacebook=function(){return $("#insightPostToFB:checked").length>0;};swell.views.shareInsight.prototype.showError=function(){$("#postInsightLoader").remove();$("#capShareInsight").removeClass("hide");$("#shareInsightConfirm").addClass("hide");$("#capShareInsight").css("opacity","1");$("#capShareInsight textarea").addClass("err");$("#modalErrs").html("There was a problem with your submission.");};swell.views.shareInsight.prototype.loggedIn=function(d){var a=$("#modalActionArea .fb-log-in");var c=$("#modalActionArea .fb-logged-in");$("#shareInsightFBPic").attr("src",d.pic);$("#shareInsightFBName").html(d.firstName+" "+d.lastName+" / ");a.addClass("hide");c.removeClass("hide");var b=$("#modalActionArea .legal").each(function(f,e){$(e).toggleClass("hide");});};swell.views.shareInsight.prototype.loggedOut=function(d){var a=$("#modalActionArea .fb-log-in");var c=$("#modalActionArea .fb-logged-in");a.removeClass("hide");c.addClass("hide");var b=$("#modalActionArea .legal").each(function(f,e){$(e).toggleClass("hide");});};swell.controllers.agDataController=function(b){var c=(b!==undefined)?b:swell.data.ajaxDaoFactory;swell.controllers.baseController.apply(this,[{daoFactory:c}]);this.isInitialized=false;this.initialStateChange=true;this.articleSvc=new swell.svc.articleSvc(this.daoFactory);this.socNetSvc=new swell.svc.socNetSvc(this.daoFactory);this.agDataSvc=new swell.svc.agDataSvc(this.daoFactory);this.catSpendDataModel=new swell.models.baseDataModel("getCatSpendData");this.articleModel=new swell.models.htmlDataModel("getArticles");this.mapModel=new swell.models.baseDataModel("getMap");this.merchantsModel=new swell.models.baseDataModel("getMerchants");this.savingsDataModel=new swell.models.baseDataModel("getSavingsData");this.spendCatHierarchy=null;var a=this;this.actionDispatcher=function(h){if(!this.isInitialized){this.isInitialized=true;return;}var g=SWFAddress.getPathNames();if(g.length>0){logger.log("actionDispatcher():reconstruct event from stored application state");var m={},n=g[0].split("_"),s=n[0],k=n[1],e=n[2],q=a.getView(s),j=q.stateStencil[k],i=0,p={targetId:s,event:e,state:{viewState:k},callback:a.sendRespToView};var f={},o=null;logger.log(j);logger.log(g);$.each(j.args,function(v,t){var u=g[v+1].split("_",2);f[t]=u[0];if(u.length>1){o=o||{};o[t]=u[1];}m[t]=g[v+1];i=v+1;});p.state.categories=g[++i].split("_");p.args=[];p.args.push(f);p.isStateful=true;if(o){p.args.push(o);if(a.initialStateChange){swell.events.raiseEvent(j.defaultCompareAction,$.extend({},p,{event:j.defaultCompareAction}));}}var r=a.filterSuperCategories.apply(a,[p.state.viewState,p.state.categories]);logger.log("dispatcher: argument object constructed: ",p);var d={targetId:"discoveries",event:"searchDiscoveries",args:{superCategoryIds:r},state:p.state};swell.events.raiseEvent("searchDiscoveries",d);swell.events.raiseEvent(p.event,p);a.initialStateChange=false;var l=(k.toLowerCase().indexOf("map")!=-1)?"CategoryDetailPageView":"InsightPageView";swell.events.raiseEvent("metricsPageView",{key:l,props:{pathInfo:SWFAddress.getPathNames()},viewState:k});}};};swell.controllers.agDataController.prototype=new swell.controllers.baseController();swell.controllers.agDataController.constructor=swell.controllers.agDataController;swell.controllers.agDataController.prototype.initVisualizerWithFilters=function(f,a){var e=(a)?a.split("/"):SWFAddress.getPathNames();var b=[];var g="bbViz";var c="getCatSpendData";var k=[];var h="agdata";if(e.length>0){var j=e[0].split("_"),i=(j[1]==="segment")?"statefulSegmentCompare":"statefulBootstrap";swell.events.raiseEvent(i,{state:e,viewCompositeKey:j,filters:f});return;}if(k.length==0){for(var d in this.catHierarchy.bbViz){if(this.catHierarchy.bbViz[d].parent==d){k.push(d);}}}swell.events.raiseEvent("visualizerStatefulAction",{targetId:h,args:[f],state:{viewState:g,categories:k},action:c});};swell.controllers.agDataController.prototype.setCategoryHierarchy=function(c){this.catHierarchy={bbViz:{},savings:{},spendingMap:{},spendingStats:{},savingMap:{},savingComingSoon:{}};var a=function(h,i){var g=h.SuperCategory;i[g.Id]={};i[g.Id].parent=g.Id;for(var f=0;f<h.Categories.length;f++){i[h.Categories[f].Id]={};i[h.Categories[f].Id].parent=g.Id;}};for(var d=0,e=c.length;d<e;d++){var b=c[d];if(b.SuperCategory.CategoryType==1){a(b,this.catHierarchy.bbViz);a(b,this.catHierarchy.spendingMap);a(b,this.catHierarchy.spendingStats);}else{a(b,this.catHierarchy.savings);a(b,this.catHierarchy.savingMap);a(b,this.catHierarchy.savingComingSoon);}}};swell.controllers.agDataController.prototype.filterSuperCategories=function(a,b){var d=[];logger.log("filtering categories:",b);var g=this.catHierarchy[a];logger.log("heir object:",g);for(var e=0,f=b.length;e<b.length;e++){var c=b[e];if(g[c].parent==c){d.push(c);}else{if($.inArray(g[c].parent,d)==-1){d.push(g[c].parent);}}}return d;};swell.controllers.agDataController.prototype.getModelDataAndSetOnView=function(f,c,a){logger.log(f,c,a);if(!f.hasDataFor(a)){return false;}var e=f.getData(a);var d=this.agDataSvc.cachedResultFrom($.extend(c,{data:e}));d.state.args=c.args;var b=this.getView(c.targetId).instance;b.setViewData(d);return true;};swell.controllers.agDataController.prototype.processStatefulEvent=function(b){var f={},e=b.targetId,a=b.state;var d=String.format("/{0}_{1}_{2}/",e,a.viewState,b.action),g=this.getView(e).stateStencil,c=g[a.viewState];logger.log("stencil:",g);d+=swell.util.buildArgStatePath(b.args,c);d+=swell.util.buildCategoriesStatePath(a.categories);logger.log("new state path constructed: "+d);if(d!==SWFAddress.getValue()){SWFAddress.setValue(d);}else{this.isInitialized=true;this.actionDispatcher({pathNames:SWFAddress.getPathNames()});}};swell.controllers.agDataController.prototype.onGetFilters=function(b){var c=this;var a=this.agDataSvc;this.agDataSvc.getFilters($.extend({},b,{onSuccess:function(e){var f=$.cookies.get("spendType");if(f!==null){e.data.UserSegment=f;}var d=c.sendRespToView(e),h=e.data;c.setCategoryHierarchy(h.CategoriesHierarchy);var g=a.getDefaultFiltersFrom($.extend({},h));c.initVisualizerWithFilters(g,b.statePathOverride);return d;}}));};swell.controllers.agDataController.prototype.getDataHelper=function(g,c,e,b){var d=this.getModelDataAndSetOnView(g,c,e);if(!d){var a=this;var f=$.extend({},c,{args:e,onSuccess:function(h){h.state.args=c.args;h.isStateful=c.isStateful;var i=a.sendRespToView(h);g.setData(e,h.data);return i;}});b.apply(this.agDataSvc,[f]);}};swell.controllers.agDataController.prototype.onGetCatSpendData=function(a){this.getDataHelper(this.catSpendDataModel,a,a.args[0],this.agDataSvc.getCatSpendData);};swell.controllers.agDataController.prototype.onGetCatSpendCompData=function(a){this.getDataHelper(this.catSpendDataModel,a,a.args[1],this.agDataSvc.getCatSpendData);};swell.controllers.agDataController.prototype.onGetSavingsData=function(a){this.getDataHelper(this.savingsDataModel,a,a.args[0],this.agDataSvc.getSavingsData);};swell.controllers.agDataController.prototype.onGetSavingsCompData=function(a){this.getDataHelper(this.savingsDataModel,a,a.args[1],this.agDataSvc.getSavingsData);};swell.controllers.agDataController.prototype.onGetMap=function(a){var b=this;this.agDataSvc.getMap($.extend(a,{event:"getMap",onSuccess:function(c){return b.sendRespToView(c);}}));};swell.controllers.agDataController.prototype.onChangeViewState=function(b){logger.log("onChangeCategories():request:",b);var d=this.daoFactory.getCachedDao(),a=$.extend({},b.state,{args:b.args}),c=$.extend(d.getResponseContext(),{event:b.event,targetId:b.targetId,state:a,isStateful:b.isStateful});this.sendRespToView(c);};swell.controllers.agDataController.prototype.onGetMerchants=function(a){var b=this;logger.log("merchant call request:",a);this.agDataSvc.getMerchants($.extend({},a,{event:"getMerchants",onSuccess:function(c){logger.log("merchant call response:",c);return b.sendRespToView(c);}}));};swell.controllers.agDataController.prototype.onSetSegment=function(a){var b=this.getView("agdata").instance;b.setSegmentId(a.segmentId);};swell.controllers.agDataController.prototype.onStatefulBootstrap=function(h){var e=h.filters,g=h.viewCompositeKey,d=g[0],i=h.state,c=0,f=g[1],b=g[2],a=this.getView(d).stateStencil[f];if(a.defaultAction){b=(b!=a.defaultAction)?a.defaultAction:b;}$.each(a.args,function(k,j){e[j]=i[k+1];c=k+1;});categories=i[++c].split("_");swell.events.raiseEvent("visualizerStatefulAction",{targetId:d,args:[e],state:{viewState:f,categories:categories},action:b});};swell.controllers.agDataController.prototype.onStatefulSegmentCompare=function(i){var f=i.filters,h=i.viewCompositeKey,e=h[0],j=i.state,d=0,g=h[1],c=h[2],b=this.getView(e).stateStencil["bbViz"],k=[];$.each(b.args,function(o,m){var l=(m==="SegmentId")?j[1]:f[m];var n=f[m]+"_"+l;f[m]=n;});for(var a in this.catHierarchy.bbViz){if(this.catHierarchy.bbViz[a].parent==a){k.push(a);}}swell.events.raiseEvent("visualizerStatefulAction",{targetId:e,args:[f],state:{viewState:"bbViz",categories:k},action:c});};swell.controllers.agDataController.prototype.onRedirectToEverybodysMoney=function(a){window.location="/everybodysmoney"+document.location.hash;};swell.controllers.agDataController.prototype.init=function(){var a=this;swell.events.registerListener("agdataInit",function(b){var c=this.getView("agdata").instance;c.isInitialized=true;swell.data.reqPipeLine.flushCompleteReq({targetId:b.targetId,event:"getFilters",onSuccess:function(d){a.sendRespToView(d);}});},this);swell.events.registerListener("agdataReadyForData",function(b){swell.data.reqPipeLine.updateAllComplete({callback:function(c){a.sendRespToView(c);}});},this);swell.events.registerListener("visualizerStatefulAction",function(b){this.processStatefulEvent($.extend(b,{event:"visualizerStatefulAction"}));},this);swell.events.registerListener("getFilters",this.onGetFilters,this);swell.events.registerListener("getCatSpendData",this.onGetCatSpendData,this);swell.events.registerListener("getCatSpendCompData",this.onGetCatSpendCompData,this);swell.events.registerListener("getMap",this.onGetMap,this);swell.events.registerListener("getMerchants",this.onGetMerchants,this);swell.events.registerListener("changeViewState",this.onChangeViewState,this);swell.events.registerListener("setSegment",this.onSetSegment,this);swell.events.registerListener("getSavingsData",this.onGetSavingsData,this);swell.events.registerListener("getSavingsCompData",this.onGetSavingsCompData,this);swell.events.registerListener("statefulSegmentCompare",this.onStatefulSegmentCompare,this);swell.events.registerListener("statefulBootstrap",this.onStatefulBootstrap,this);swell.events.registerListener("redirectToEverybodysMoney",this.onRedirectToEverybodysMoney,this);if(SWFAddress){SWFAddress.onChange=this.actionDispatcher;}};swell.controllers.spendTypeModalController=function(){};swell.controllers.spendTypeModalController.prototype=new swell.controllers.baseController();swell.controllers.spendTypeModalController.constructor=swell.controllers.spendTypeModalController;swell.controllers.spendTypeModalController.prototype.onLaunchSpendTypeModal=function(a){var b=this.getView("spendTypeModal");b.instance.launchModal(a.type);};swell.controllers.spendTypeModalController.prototype.init=function(){swell.events.registerListener("launchSpendTypeModal",this.onLaunchSpendTypeModal,this);};swell.controllers.msgModalController=function(){};swell.controllers.msgModalController.prototype=new swell.controllers.baseController();swell.controllers.msgModalController.constructor=swell.controllers.msgModalController;swell.controllers.msgModalController.prototype.onLaunchMsgModal=function(a){var b=this.getView("msgModal");b.instance.launchModal(a.type);};swell.controllers.msgModalController.prototype.init=function(){swell.events.registerListener("launchMsgModal",this.onLaunchMsgModal,this);};swell.controllers.insightController=function(a){var a=(a!==undefined)?a:swell.data.ajaxDaoFactory;swell.controllers.baseController.apply(this,[{daoFactory:a}]);this.insightSvc=new swell.svc.insightSvc(this.daoFactory);this.savingInsight=false;};swell.controllers.insightController.prototype=new swell.controllers.baseController();swell.controllers.insightController.constructor=swell.controllers.insightController;swell.controllers.insightController.prototype.onShareInsight=function(a){var b=this.getView("shareInsight").instance;logger.log("calling initialize for view:",b);b.launchModal();};swell.controllers.insightController.prototype.onShareInsightLoggedIn=function(a){var b=this.getView("shareInsight").instance;b.loggedIn(a);};swell.controllers.insightController.prototype.onShareInsightLoggedOut=function(a){var b=this.getView("shareInsight").instance;b.loggedOut(a);};swell.controllers.insightController.prototype.onSubmitUserInsight=function(a){logger.log("event handled: submit user insight. request:",a);var b=this;if(!this.savingInsight){var c=b.getView("shareInsight").instance;c.loading();this.insightSvc.saveUserInsight($.extend({},a,{onSuccess:function(f){b.savingInsight=false;logger.log("success");c.successConfirmation();var d=$.extend(a,{insightUrl:"http://"+window.location.href.split("/")[2]+"/everybodysmoney/"+f.RelativeUrl});var e=$.extend(d,f);if(c.postToFacebook()){swell.events.raiseEvent("postInsightToFacebook",e);}swell.events.raiseEvent("metricsLinkClick",{key:"SubmitInsight",props:{events:"event3"},domEl:this});},onError:function(d){b.savingInsight=false;logger.log("onError");c.showError(d);}}));this.savingInsight=true;}};swell.controllers.insightController.prototype.onPostInsightToFacebook=function(a){logger.log("onPostInsightToFacebook. req = ",a);FB.Connect.streamPublish("",{name:a.title,caption:"{*actor*} posted an insight.",description:a.body,href:a.insightUrl});};swell.controllers.insightController.prototype.init=function(){swell.events.registerListener("loggedIn",this.onShareInsightLoggedIn,this);swell.events.registerListener("loggedOut",this.onShareInsightLoggedOut,this);swell.events.registerListener("shareInsight",this.onShareInsight,this);swell.events.registerListener("submitUserInsight",this.onSubmitUserInsight,this);swell.events.registerListener("postInsightToFacebook",this.onPostInsightToFacebook,this);};swell.config.VisualizerConfig={riaStateStencil:{bbViz:{args:["Location","HouseholdCompositionId","IncomeId","AgeId","SegmentId","YearMonth"],decorators:["categories"],defaultAction:"getCatSpendData",defaultCompareAction:"getCatSpendCompData"},spendingMap:{args:["Location","HouseholdCompositionId","IncomeId","AgeId","SegmentId","YearMonth"],decorators:["categories"],defaultAction:"getCatSpendData",defaultCompareAction:"getCatSpendCompData"},segment:{args:["SegmentId"],defaultAction:"getCatSpendData",viewStateTransformer:"bbViz"},savings:{args:["Location","HouseholdCompositionId","IncomeId","AgeId","YearMonth"],decorators:["categories"],defaultAction:"getSavingsData",defaultCompareAction:"getSavingsCompData"},spendingStats:{args:["Location","HouseholdCompositionId","IncomeId","AgeId","SegmentId","YearMonth"],decorators:["categories"],defaultAction:"getCatSpendData",defaultCompareAction:"getCatSpendCompData"},savingMap:{args:["Location","HouseholdCompositionId","IncomeId","AgeId","YearMonth"],decorators:["categories"],defaultAction:"getSavingsData",defaultCompareAction:"getSavingsCompData"},savingComingSoon:{args:["Location","HouseholdCompositionId","IncomeId","AgeId","YearMonth"],decorators:["categories"],defaultAction:"getSavingsData",defaultCompareAction:"getSavingsCompData"}}};swell.visualizer={config:swell.config.VisualizerConfig,selectedCategory:"",init:function(){swell.controllers.loginController.init();swell.support.discoveriesListConfigurator.visit(this,{hideOnStartUp:true});swell.support.updatesConfigurator.visit(this);this.agDataController=new swell.controllers.agDataController();this.insightController=new swell.controllers.insightController();this.msgModalController=new swell.controllers.msgModalController();this.spendtypeModalController=new swell.controllers.spendTypeModalController();this.agDataController.init();this.insightController.init();this.msgModalController.init();this.spendtypeModalController.init();this.insightController.registerView("shareInsight",new swell.views.shareInsight());this.msgModalController.registerView("msgModal",new swell.views.msgModalView());this.spendtypeModalController.registerView("spendTypeModal",new swell.views.spendTypeModalView());this.agDataController.registerView("agdata",new swell.views.riaView({}),this.config.riaStateStencil);swell.events.registerListener("agDataFailed",function(c){logger.log("ria view failed event handler",c);this.registerView("agdata",new swell.views.riaView(c.ref),c.stateStencil);},this.agDataController);if(!swell.util.hasFlashPlayerVersion(10)){swell.events.raiseEvent("agDataFailed",{id:"agdata",stateStencil:swell.visualizer.config.riaStateStencil,ref:null});}swell.events.registerListener("agDataLoaded",function(c){logger.log("ria view loaded event handler",c);this.getView("agdata").instance.view=c.ref;},this.agDataController);swell.events.raiseEvent("getFilters",{targetId:"agdata",event:"getFilters"});var a=new String(document.location);if(a.indexOf("awaitingapproval")>-1){swell.events.raiseEvent("launchMsgModal",{type:"awaitingapproval"});}if(a.indexOf("rejected")>-1){swell.events.raiseEvent("launchMsgModal",{type:"rejected"});}this.insightController.registerView("openXAds",new swell.views.openXAds());var b=this.insightController;$(document).ready(function(){b.getView("openXAds").instance.init();$("#scSpend a").click(function(c){b.getView("openXAds").instance.reload();});});}};swell.insightDetail={config:swell.config.VisualizerConfig,detailController:null,agDataController:null,initReporting:function(a){$("#detailMetadata .report-this").click(function(b){b.preventDefault();swell.events.raiseEvent("reportInsightAbuse",{id:a});});},init:function(g){this.detailController=new swell.controllers.discoveryDetailController();this.agDataController=new swell.controllers.agDataController();this.agDataController.registerView("agdata",new swell.views.riaView({}),this.config.riaStateStencil);swell.support.discoveryDetailConfigurator.visit(this,{type:"insight"});swell.support.updatesConfigurator.visit(this);swell.events.registerListener("riaViewLoaded",function(h){if(h.success==false){$(".site-logo").css("top",21);}this.getView("agdata").instance.view=h.ref;},this.agDataController);var a=this;var c=this.agDataController;var b=this.detailController;var f="";this.detailController.registerView("comments",new swell.views.commentsView($("#comWrap")));var d=swell.util.extractId(window.location.pathname);this.detailController.init({contentId:d,title:swell.locals.discoveryTitle});this.agDataController.init();swell.controllers.loginController.init();swell.uihelpers.initShare();this.initReporting(d);swell.events.raiseEvent("getFilters",{targetId:"agdata",event:"getFilters",statePathOverride:g});swell.events.raiseEvent("getComments",{id:"comments",args:{id:d}});this.detailController.registerView("openXAds",new swell.views.openXAds());var e=this.detailController;$(document).ready(function(){e.getView("openXAds").instance.init();});}};