function getFlowNameForFlowCode(n){var t="";return n==1?t="everyday":n==6?t="savings":n==100?t="student":n==101?t="over65":n==102&&(t="graduate"),t}function getFlowOrPackageForFlowCode(n){var t="";return n==1?t="everyday":n==6?t="savings":n==100?t="package":n==101?t="package":n==102&&(t="package"),t}function trackFlow(n,t){var r=getFlowNameForFlowCode(n),i;r===""||isSupertagFunctionUnavailable()||(i=s_gi(s_account),i.pageName="tools:personal-accounts:which-account:"+r+"-Q"+t,i.prop1=i.eVar1="tools",i.prop2=i.eVar2="tools:personal-accounts",i.channel=i.eVar3="tools:personal-accounts:which-account",i.eVar4=i.prop3=i.eVar26=i.pageName,i.hier1="tools|personal-accounts|which-account|"+r+"-Q"+t,i.t())}function OmnitureTrackResults(n,t){var u=n.find(".result1").find("#OmnitureResultCode").val(),i=null,r=n.find(".result2");r.length>0&&(i=r.find("#OmnitureResultCode").val());trackResults(t,u,i)}function trackResults(n,t){var r=getFlowOrPackageForFlowCode(n),i;r===""||isSupertagFunctionUnavailable()||(i=s_gi(s_account),i.pageName="tools:personal-accounts:which-account:results:"+r,i.prop1=i.eVar1="tools",i.prop2=i.eVar2="tools:personal-accounts",i.channel=i.eVar3="tools:personal-accounts:which-account",i.eVar4=i.prop3="tools:personal-accounts:which-account:results",i.eVar26=i.pageName,i.hier1="tools|personal-accounts|which-account|results|"+r,i.products=";"+t,i.events="event21",i.t())}function trackApplyNowPrimary(n){var i=getFlowOrPackageForFlowCode(n),t;if(i!==""&&!isSupertagFunctionUnavailable())return t=s_gi(s_account),t.linkTrackVars="prop1,prop2,eVar1,eVar2,eVar26,eVar24,events",t.linkTrackEvents="event11",t.eVar24="tools|personal-accounts|which-account|results|"+i+"|apply-recommended",t.events="event11",t.tl(this,"o","tools|personal-accounts|which-account|results|"+i+"|apply-recommended"),!1}function trackLearnMorePrimary(n){var i=getFlowOrPackageForFlowCode(n),t;if(i!=="")return t=s_gi(s_account),t.linkTrackVars="prop1,prop2,eVar1,eVar2,eVar26,eVar24,events",t.linkTrackEvents="event11",t.eVar24="tools|personal-accounts|which-account|results|"+i+"|learnmore-recommended",t.events="event11",t.tl(this,"o","tools|personal-accounts|which-account|results|"+i+"|learnmore-recommended"),!1}function trackApplyNowSecondary(n){var i=getFlowOrPackageForFlowCode(n),t;if(i!==""&&!isSupertagFunctionUnavailable())return t=s_gi(s_account),t.linkTrackVars="prop1,prop2,eVar1,eVar2,eVar26,eVar24,events",t.linkTrackEvents="event11",t.eVar24="tools|personal-accounts|which-account|results|"+i+"|apply-secondary",t.events="event11",t.tl(this,"o","tools|personal-accounts|which-account|results|"+i+"|apply-secondary"),!1}function trackLearnMoreSecondary(n){var i=getFlowOrPackageForFlowCode(n),t;if(i!=="")return t=s_gi(s_account),t.linkTrackVars="prop1,prop2,eVar1,eVar2,eVar26,eVar24,events",t.linkTrackEvents="event11",t.eVar24="tools|personal-accounts|which-account|results|"+i+"|learnmore-secondary",t.events="event11",t.tl(this,"o","tools|personal-accounts|which-account|results|"+i+"|learnmore-secondary"),!1}function trackApplyNowPackage(n){var i=getFlowOrPackageForFlowCode(n),t;if(i!==""&&!isSupertagFunctionUnavailable())return t=s_gi(s_account),t.linkTrackVars="prop1,prop2,eVar1,eVar2,eVar26,eVar24,events",t.linkTrackEvents="event11",t.eVar24="tools|personal-accounts|which-account|results|package|apply",t.events="event11",t.tl(this,"o","tools|personal-accounts|which-account|results|package|apply"),!1}function trackLearnMorePackage(n){var i=getFlowOrPackageForFlowCode(n),t;if(i!==""&&!isSupertagFunctionUnavailable())return t=s_gi(s_account),t.linkTrackVars="prop1,prop2,eVar1,eVar2,eVar26,eVar24,events",t.linkTrackEvents="event11",t.eVar24="tools|personal-accounts|which-account|results|package|learnmore",t.events="event11",t.tl(this,"o","tools|personal-accounts|which-account|results|package|learnmore"),!1}function initialiseQuestionSlider(){questionSlider=$("#questionCarousel").bxSlider({minSlides:1,maxSlides:1,slideMargin:10,pager:!1,nextSelector:"#slider-next",prevSelector:"#slider-prev",nextText:'Next <i class="icon-forward-arrow"><\/i>',prevText:'<i class="icon-back-arrow"><\/i> Previous',hideControlOnEnd:!0,infiniteLoop:!1,touchEnabled:!1,onSliderLoad:function(){setTimeout(function(){checkDisableNextButton();checkDisablePrevButton();checkIfFirstSlide()},10)},onSlideBefore:function(n){scrollToProgressBar(150);updateProgressBar(progBarElement,questionSlider);setQuestionImage(n);var t=$(".js-hiddenFlowCodeID").val(),i=n.find("#CurrentSelection").attr("data-hiddenanswerorder");trackFlow(t,i)},onSlideAfter:function(n){n.hasClass("js-questionPanelLoad")&&getQuestionPanels($(".js-landingPanelFlow.selected"));checkDisableNextButton();checkDisablePrevButton();checkIfFirstSlide();checkIfLastSlide()}});var n=$(".js-hiddenFlowCodeID").val();return trackFlow(n,1),$(".js-sliderControls").show(),questionSlider}function setQuestionImage(n){var t=n.find(".questionImage");t.removeAttr("src");t.attr("src",t.data("imagesrc"))}function getQuestionPanels(n){var i=n.data("flow"),r=n.data("flowname"),t;resultContainer=$(".js-questionPanels-area");t=$(".js-accountFinderContext");$.ajax({type:"GET",url:$accountFinderGetQuestionPanelsURL,cache:!1,beforeSend:function(){whileGettingResults($(".js-questionPanelLoad"))},dataType:"html",data:{flow:i,responsive:$isMobile},success:function(n){t.find("span:nth-child(2)").text(r);t.show();showQuestionPanels(n,resultContainer);progBarElement=initialiseProgressBar();setQuestionImage(resultContainer.children(".slide").first());$(".js-landingPanel").hide();questionSlider=initialiseQuestionSlider();updateProgressBar(progBarElement,questionSlider)},error:function(){showAjaxError()},complete:function(){scrollToProgressBar(300)}})}function initialiseProgressBar(){var n=$("#js-progressbar");return $(n).progressbar({value:0}),n.show(),n}function updateProgressBar(n,t){var i=(1+t.getCurrentSlide())/(t.getSlideCount()+1)*100;$(n).progressbar("value",i)}function updateProgressBarResultPane(n){$(n).progressbar("value",100)}function setAnswer(n){var t=$(n).data("answerid"),i=$(n).data("questionid"),r=$(n).data("questionorder");$("[data-hiddenanswerorder='"+r+"']").val(t);$(n).setSelected(i)}function getResults(n){var i=$(".js-hiddenFlowID").val(),r=$(".js-hiddenFlowCodeID").val(),u=$("[data-hiddenanswerorder='1']").val(),f=$("[data-hiddenanswerorder='2']").val(),e=$("[data-hiddenanswerorder='3']").val(),t=$(".js-results-area");n.attr("data-flowint")&&(i=n.data("flowint"),r=101);$.ajax({type:"GET",url:$accountFinderResultsURL,beforeSend:function(){whileGettingResults(t)},dataType:"html",data:{flowID:i,a1:u,a2:f,a3:e},success:function(n){showResults(n,t);progBarElement.length||(progBarElement=initialiseProgressBar());updateProgressBarResultPane(progBarElement,questionSlider);bxSliderShowResult(t);$(".js-landingPanel").hide();OmnitureTrackResults(t,r)},error:function(){showAjaxError()},complete:function(){}})}function whileGettingResults(n){n.html('<img src="/Tools/Content/themes/img/loading.gif" class="loadingGif" />')}function showResults(n,t){t.html(n)}function showQuestionPanels(n,t){t.html(n).fadeIn(700)}function checkIfAnswerSelected(){return $("[data-hiddenanswerorder='"+(questionSlider.getCurrentSlide()+1)+"']").val()==0?!1:!0}function checkDisableNextButton(){checkIfAnswerSelected()?$("#slider-next a").removeClass("disabled"):$("#slider-next a").addClass("disabled")}function checkDisablePrevButton(){$("#slider-prev a").removeClass("disabled")}function displayLandingPanel(){questionSlider.getCurrentSlide()+1==1&&($(".slide .questionImage").removeAttr("src"),window.location.href=$accountFinderHome)}function showAjaxError(){$(".js-carouselContainer").hide();$(".js-landingPanel").hide();$("#js-ajax-error").show()}function bxSliderShowResult(n){n.fadeIn(700,function(){scrollToProgressBar(150)});$(".outside").hide();questionSlider.length&&questionSlider.destroySlider();$("#questionCarousel").hide()}function bxSliderHideResult(){$(".js-results-area").hide();$(".outside").show();$("#lastSlider").hide();$("#questionCarousel").show().css("opacity",100);resultInfoSlider.length&&resultInfoSlider.destroySlider();questionSlider.reloadSlider();checkDisableNextButton();checkDisablePrevButton();checkIfFirstSlide();checkIfLastSlide()}function stickyRelocate(){var n=$(window).scrollTop(),t=$(".js-sticky-anchor").offset().top;n>t?$(".js-sticky").addClass("js-stick sticky-stick"):$(".js-sticky").removeClass("js-stick sticky-stick")}function toggleShowMore(n){n.next(".js-showMoreContent").slideToggle(200);var t=n.children("span:first-of-type");return t.text()=="Show other benefits"?(t.text("Show less"),n.children("i").addClass("icon-arrow-up").removeClass("icon-arrow-down")):(t.text("Show other benefits"),n.children("i").addClass("icon-arrow-down").removeClass("icon-arrow-up")),!1}function checkIfLastSlide(){questionSlider.getCurrentSlide()+1==questionSlider.getSlideCount()?$(".bx-next").addClass("js-isLastQuestion"):$(".bx-next").removeClass("js-isLastQuestion")}function checkIfFirstSlide(){questionSlider.getCurrentSlide()==0?$(".bx-prev").addClass("js-isFirstQuestion"):$(".bx-prev").removeClass("js-isFirstQuestion")}function scrollToProgressBar(n){$("html,body").animate({scrollTop:$(".js-sticky-anchor").offset().top},n)}function goBackToSlide(n){n==0?(updateProgressBar(progBarElement,questionSlider),questionSlider.goToPrevSlide()):questionSlider.goToSlide(n)}var isSupertagFunctionUnavailable=function(){return typeof s_gi!="function"};$(document).ready(function(){$(".js-results-area").hide();$("body").on("click",".bx-next",function(n){n.preventDefault();checkIfLastSlide();checkDisableNextButton()});$("body").on("click",".bx-prev",function(n){n.preventDefault();checkIfFirstSlide()});$("body").on("click",".slider .js-isLastQuestion",function(n){return n.preventDefault(),checkIfAnswerSelected()&&getResults($(this)),!1});$("body").on("click",".slider .js-isFirstQuestion",function(n){return n.preventDefault(),displayLandingPanel(),!1});$("body").on("click",".js-showMoreLink",function(){return $(".js-showMoreLink").each(function(){toggleShowMore($(this))}),!1});var n=!1;$(".js-landingPanelFlow").click(function(){n||$(this).hasClass("js-results-button")||(n=!0,$(this).addClass("selected"),getQuestionPanels($(".js-landingPanelFlow.selected")))});$("body").on("click",".js-results-button",function(){setAnswer($(this));getResults($(this))});$("body").on("click",".js-questionAnswer",function(){setAnswer($(this));questionSlider.goToNextSlide()});$("body").on("click",".js-go-back-to-slide",function(){var n=$(this).data("questionid");if($(this).data("issinglequestion")=="True"){window.location.href=$accountFinderHome;return}bxSliderHideResult();setQuestionImage(resultContainer.find(".slide").eq(n));goBackToSlide(n)});$(window).scroll(stickyRelocate);stickyRelocate();$("body").on("click",".js-applyNow",function(){var n=$(".js-results-flowcodeid").val();$(this).hasClass("js-isSecondaryResult")?trackApplyNowSecondary(n):$(this).hasClass("js-isPackageResult")?trackApplyNowPackage(n):trackApplyNowPrimary(n)});$("body").on("click",".js-learnMore",function(){var n=$(".js-results-flowcodeid").val();$(this).hasClass("js-isSecondaryResult")?trackLearnMoreSecondary(n):$(this).hasClass("js-isPackageResult")?trackLearnMorePackage(n):trackLearnMorePrimary(n)})});var resultInfoSlider="",questionSlider="",progBarElement="",resultContainer;$.fn.setSelected=function(n){$("[data-questionid='"+n+"']").removeClass("selected");$(this).addClass("selected")}