var legacies=legacies||{};!function(e){legacies={form:null,formWrapper:null,stage:1,firstName:null,year:null,questionCount:null,activeQuestion:null,videoPlayed:!1,formData:null,answers:{},init:function(){e(".c-legacies").length<1||(this.storeFormReferences(),this.handleFormSubmission(),this.questionsHandler(),this.skipHandler(),this.handleSharedView())},storeFormReferences:function(t){var s=e(".c-legacies__form");this.formWrapper=s,this.form=e("form",s),this.postID=e(".c-legacies__form").attr("data-post-id"),this.dataCapturePosition=e(".c-legacies").attr("data-form-position")||"start"},handleFormSubmission:function(){var t=this;e(this.form).on("submit",function(){if(e(this).valid()){var s=e(this).serialize();t.formData=s,t.firstName=t.getFirstName(),t.year=t.getYear(),t.moveToNextStage()}})},questionsHandler:function(){this.questionCount=e(".js-questions").attr("question-count");var t=this;e(".c-questions__option").on("click",function(){var s=e(this).attr("question-number"),i=e(this).attr("option-letter");t.questionAnswered(s,i)})},skipHandler:function(){var t=this;e(".js-questions-skip").on("click",function(){t.answers=t.simulateAnswers(),t.analyticsEvent("questionsSkipped"),t.moveToNextStage()})},handleSharedView:function(){e(".js-legacies-shared").length<1||this.attemptToLoadSharedVideo()},getFirstName:function(){return e(".js-first-name")?e(".js-first-name input").val():null},getYear:function(){return e(".js-year-of-birth")?e(".js-year-of-birth input").val():null},checkQuestionsInView:function(){if(e(window).width()<580){var t=e(".c-legacies").offset().top-e(".c-site-header").height()-20;e("html, body").animate({scrollTop:t},500)}},showForm:function(){e(this.formWrapper).slideDown(),e(".c-questions__skip").hide()},hideForm:function(){e(this.formWrapper).slideUp()},showFirstQuestion:function(){this.activeQuestion=1,e(".c-questions").show(),e(".c-questions__skip").show(),e('.c-questions__single[question-number="1"]').slideDown()},hideQuestions:function(t){e(".js-questions").slideUp(function(){t&&e(".js-questions").remove()})},moveToNextStage:function(){var t=this.stage+1;this.stage=t;var s=e(".c-legacies-steps__single").length;return e(".c-legacies-steps__single").removeClass("active"),e('.c-legacies-steps__single[legacies-step="'+t+'"]').addClass("active"),t===s?(this.hideForm(),this.hideQuestions(!0),this.sendToApis()):void("end"!==this.dataCapturePosition?(this.checkQuestionsInView(),this.hideForm(),this.showFirstQuestion()):(this.hideQuestions(),this.showForm()))},updateStage:function(t){this.stage=t,e(".c-legacies-steps__single").removeClass("active"),e('.c-legacies-steps__single[legacies-step="'+t+'"]').addClass("active")},simulateAnswers:function(){function e(e){for(var t={},s=0;s=1954&&s<=1960?"b":"c")},questionAnswered:function(e,t){return this.answers[e]=t,this.nextQuestionExists(e)?void this.showNextQuestion(e):(this.moveToNextStage(),this.year=null,void this.analyticsEvent("questionsCompleted"))},nextQuestionExists:function(e){return e+10&&e(".c-formstack-api").attr("data-entry"),u=this.updateSubmissionDetails(r);e.ajax({url:legacies_js.ajaxurl,type:"POST",data:{security:legacies_js.ajax_nonce,action:"legacies_answers_given",params:a,postId:t.postID,entry:u,form_data:o},success:function(s){var i;try{i=JSON.parse(s)}catch(n){return void t.videoError("")}if(i.error)return void t.videoError(i.error.msg);var a=i.unique_id,o="";o="sftp"==e(".c-formstack-api").attr("data-upload")?e(".c-formstack-api").attr("data-upload-url")+a+".mp4":i.url,t.insertVideo(o),t.updateShareUrls(a)},error:function(e){e.hasOwnProperty("statusText")?t.videoError(e.statusText):t.videoError("")}})},insertVideo:function(t){if(e(".js-legacies-video video").length>0)return void this.showLoadedVideo();var s=e(".js-legacies-video").attr("data-poster"),i=this,n=e("