jQuery(document).ready(function($){function isIE(){var e=window.navigator.userAgent;if(e.indexOf("MSIE ")>0)return!0;return e.indexOf("Trident/")>0}function isOldAndroidVersion(){var e=navigator.userAgent.toLowerCase().match(/android\s([0-9\.]*)/);return!!e&&parseFloat(e[1])<5}function oldBrowserFix(e){$(e).find("#fca_qc_back_container").css("backface-visibility","visible"),$(e).find("#fca_qc_back_container").css("transform","none"),$(e).find("#fca_qc_back_container").hide(),isIE()&&(svg_square='<svg xmlns="http://www.w3.org/2000/svg" class="fca_qc_rectancle" width="26" height="26"><rect class="fca_qc_checkbox" width="26" height="26"></rect></svg>')}function loadQuizzes(){$(".fca_qc_quiz").each(function(index){var thisId=get_quiz_id(this);thisId&&(quizzes[thisId]=eval("quizData_"+thisId),quizzes[thisId].selector=this,default_img=quizzes[thisId].default_img)}),$.each(quizzes,function(e,t){quizzes[e].questions=quizzes[e].questions.filter(function(e){return 0!==e.answers.filter(function(e){return e.answer||e.img}).length})}),$.each(quizzes,function(e){"on"===quizzes[e].quiz_settings.shuffle_questions&&(quizzes[e].questions=shuffleArray(quizzes[e].questions))}),$.each(quizzes,function(e){"on"===quizzes[e].quiz_settings.autostart_quiz&&startQuiz(quizzes[e])})}function preloadImages(){$.each(quizzes,function(e,t){quizzes[e].questions[0]&&lazyLoadQuestion(quizzes[e].questions[0])})}function lazyLoadResults(e){e.hasOwnProperty("quiz_results")&&$.each(e.quiz_results,function(t){e.quiz_results[t].hasOwnProperty("img")&&lazyLoadImage(e.quiz_results[t].img)})}function lazyLoadImage(e){if(""!==e&&void 0!==e&&"string"==typeof e){(new Image).src=e}}function lazyLoadQuestion(e){e.hasOwnProperty("img")&&lazyLoadImage(e.img),e.hasOwnProperty("answers")&&$.each(e.answers,function(t){e.answers[t].hasOwnProperty("img")&&lazyLoadImage(e.answers[t].img)})}function startQuiz(e){usingOldBrowser&&oldBrowserFix(e.selector),fix_hover(e),e.currentQuestion=0,e.score=0,e.responses=[],e.questionCount=e.questions.length,""===e.quiz_settings.hide_answers?e.hideAnswers="after":"on"===e.quiz_settings.hide_answers?e.hideAnswers="end":e.hideAnswers=e.quiz_settings.hide_answers,$(e.selector).find(".fca_qc_quiz_title").hide(),$(e.selector).find(".fca_qc_quiz_description").hide(),$(e.selector).find(".fca_qc_quiz_description_img").hide(),$(e.selector).find(".fca_qc_start_button").hide(),$(e.selector).find(".fca_qc_quiz_div").show(),$(e.selector).find(".fca_qc_quiz_footer").show(),$(e.selector).find(".flip-container").show(),$(e.selector).find(".fca_qc_question_count").html("1/"+e.questionCount),showQuestion(e)}function fca_qc_process_answer(e,t){"question"===e.quiz_settings.timer_mode&&$("#fca_qc_quiz_"+e.quiz_id).data("endDate",""),$(".fakehover").removeClass("fakehover");var i=t.closest("#fca_qc_answer_container").data("id"),n=t.data("id"),s=!1;if(1===e.currentQuestion&&add_activity(e.ajaxurl,e.nonce,e.quiz_id,"starts"),"wq"===e.quiz_settings.quiz_type){var r=parseInt(e.questions[e.currentQuestion-1].answers.filter(function(e){return e.id===n})[0].points);isNaN(r)||(e.score=parseInt(e.score)+r)}else t.attr("data-question")===e.currentAnswer&&(e.score=e.score+1,s=!0);var c={answer:addQuizImg(t.children(".fca_qc_quiz_answer_img").attr("src"))+t.children(".fca_qc_answer_span").html().replace(svg_square,""),answer:addQuizImg(t.children(".fca_qc_quiz_answer_img").attr("src"))+t.children(".fca_qc_answer_span").html().replace(svg_square,""),isCorrect:s,correctAnswer:get_correct_answer_html(e),question:t.siblings("#fca_qc_question").html(),id:i,response:n};if("on"===e.quiz_settings.explanations){var a=e.questions[e.currentQuestion-1].answers.filter(function(e){return e.hasOwnProperty("hint")});a.length&&(c.hint=a[0].hint)}e.responses.push(c),add_response(e.ajaxurl,e.nonce,e.quiz_id,i,n),"pt"===e.quiz_settings.quiz_type?($.each(t.data("results"),function(t,i){$.each(e.quiz_results,function(e,t){i===t.id&&(t.hasOwnProperty("score")?t.score=t.score+1:t.score=1)})}),showQuestion(e,!0)):"wq"===e.quiz_settings.quiz_type?($.each(t.data("results"),function(t,i){$.each(e.quiz_results,function(e,t){i===t.id&&(t.hasOwnProperty("score")?t.score=t.score+1:t.score=1)})}),showQuestion(e,!0)):"after"===e.hideAnswers?($(e.selector).find("#fca_qc_your_answer").html(addQuizImg(t.children(".fca_qc_quiz_answer_img").attr("src"))+t.children(".fca_qc_answer_span").html().replace(svg_square,"")),fca_qc_hide_answers_after(e,s)):showQuestion(e,!0),e.quiz_settings.disable_scroll||scrollQuizInToView(e.selector)}function fca_qc_push_timeout_question(e,t){e.quiz_settings.timer_limit;var i=e.timeout_string,n=$(this).closest("#fca_qc_answer_container").data("id");if(e.responses.length!==e.questionCount){var n=t||$(this).closest("#fca_qc_answer_container").data("id"),s={answer:i,isCorrect:!1,correctAnswer:get_correct_answer_html(e),question:$(this).siblings("#fca_qc_question").html(),id:n,response:0};if("on"===e.quiz_settings.explanations){var r=e.questions[e.currentQuestion-1].answers.filter(function(e){return e.hasOwnProperty("hint")});r.length&&(s.hint=r[0].hint)}e.responses.push(s),add_response(e.ajaxurl,e.nonce,e.quiz_id,n,null)}}function fca_qc_push_timeout_quiz(e){for(var t=e.currentQuestion-1;t<e.questionCount;t++)fca_qc_push_timeout_question(e,t)}function fca_qc_update_timer(e,t){var i=quizzes[get_quiz_id($("#fca_qc_quiz_"+e))];if(Date.now()<t){var n=t-Date.now(),s=Math.floor(n/36e5);n-=36e5*s,i.time_remaining=n;var r=Math.floor(n/6e4),c=((n-=6e4*r)/1e3).toFixed(2);s&&$(i.selector).find(".fca_qc_timer_hours").html(s+" :"),$(i.selector).find(".fca_qc_timer_minutes").html(r+" :"),$(i.selector).find(".fca_qc_timer_seconds").html(c)}else $("#fca_qc_quiz_"+e).data("endDate",""),i.time_remaining=0,$(i.selector).find(".fca_qc_timer_minutes").html("0 :"),$(i.selector).find(".fca_qc_timer_seconds").html("0.00"),"after"===i.hideAnswers&&"mc"===i.quiz_settings.quiz_type?"question"===i.quiz_settings.timer_mode?(fca_qc_push_timeout_question(i),$(i.selector).find("#fca_qc_your_answer").html(addQuizImg($(this).children(".fca_qc_quiz_answer_img").attr("src"))+i.timeout_string),fca_qc_hide_answers_after(i)):(fca_qc_push_timeout_quiz(i),fca_qc_show_timeout_screen(i)):($(i.selector).find("#fca_qc_your_answer").html(addQuizImg($(this).children(".fca_qc_quiz_answer_img").attr("src"))+i.timeout_string),fca_qc_show_timeout_screen(i),i.currentQuestion<i.questionCount&&"question"===i.quiz_settings.timer_mode?fca_qc_push_timeout_question(i):fca_qc_push_timeout_quiz(i))}function fca_qc_start_timer(e){timer_limit=e.quiz_settings.timer_limit;var t=Date.now()+1e3*timer_limit;$(e.selector).data("endDate",t),void 0===fcaQcInterval&&(fcaQcInterval=setInterval(function(){var e=0;for(var t in quizzes){var i=$("#fca_qc_quiz_"+t).data("endDate");i&&(fca_qc_update_timer(t,i),e++)}e||(clearInterval(fcaQcInterval),fcaQcInterval=void 0)},10))}function get_quiz_id(e){var t=$(e).attr("id");return!!t&&t.replace(/\D+/g,"")}function fca_qc_show_timeout_screen(e){var t=e.timeout_string;usingOldBrowser?($(e.selector).find("#fca_qc_answer_container").hide(),$(e.selector).find("#fca_qc_back_container").show()):$(e.selector).find(".fca_qc_quiz_div").addClass("flip"),$(e.selector).find("#fca_qc_question_back").hide(),$(e.selector).find("#fca_qc_back_response_p").hide(),$(e.selector).find("#fca_qc_correct_answer_p").hide(),$(e.selector).find("#fca_qc_back_container").addClass("wrong-answer"),$(e.selector).find("#fca_qc_question_right_or_wrong").html(t),scale_flip_box_back(e.selector)}function fca_qc_hide_answers_after(e,t){var i=get_correct_answer_html(e);if($(e.selector).find("#fca_qc_correct_answer").html(i),"on"===e.quiz_settings.explanations){var n=e.questions[e.currentQuestion-1].answers.filter(function(e){return e.hasOwnProperty("hint")});n.length?($(e.selector).find("#fca_qc_hint_p").show(),$(e.selector).find("#fca_qc_hint_p").html(n[0].hint.replace(/\n/g,"<br />"))):$(e.selector).find("#fca_qc_hint_p").html("")}usingOldBrowser?($(e.selector).find("#fca_qc_answer_container").hide(),$(e.selector).find("#fca_qc_back_container").show()):$(e.selector).find(".fca_qc_quiz_div").addClass("flip"),$(e.selector).find("#fca_qc_back_container").removeClass("correct-answer"),$(e.selector).find("#fca_qc_back_container").removeClass("wrong-answer"),t?($(e.selector).find("#fca_qc_back_container").addClass("correct-answer"),$(e.selector).find("#fca_qc_question_right_or_wrong").html(e.correct_string),$(e.selector).find("#fca_qc_correct_answer_p").hide()):($(e.selector).find("#fca_qc_back_container").addClass("wrong-answer"),$(e.selector).find("#fca_qc_question_right_or_wrong").html(e.wrong_string),$(e.selector).find("#fca_qc_correct_answer_p").show()),scale_flip_box_back(e.selector)}function showQuestion(e,t){handleQuizScrolling(e),e.currentQuestion<e.questionCount?("question"===e.quiz_settings.timer_mode&&0!==e.currentQuestion&&fca_qc_start_timer(e),$(e.selector).find(".fca_qc_question_count").html(e.currentQuestion+1+"/"+e.questionCount),setQuestionContent(e),handleLazyLoading(e),$(e.selector).find(".fca_qc_answer_div").hide(),populateAnswerDivs(e,t),$(e.selector).find("#fca_qc_answer_container").waitForImages(function(){maybe_add_quarter_class(e.selector),scale_flip_box_question(e.selector)}),e.currentQuestion=e.currentQuestion+1):(e.time_remaining=($("#fca_qc_quiz_"+e.quiz_id).data("endDate")-Date.now())/1e3,endTest(e))}function handleQuizScrolling(e){e.quiz_settings.disable_scroll||"on"===e.quiz_settings.autostart_quiz&&0===e.currentQuestion||scrollQuizInToView(e.selector)}function setQuestionContent(e){$(e.selector).find("#fca_qc_answer_container").data("id",e.questions[e.currentQuestion].id);var t=e.questions[e.currentQuestion].question.replace(/\n/g,"<br />");$(e.selector).find("#fca_qc_question").html(t),$(e.selector).find("#fca_qc_question_back").html(t);var i=e.questions[e.currentQuestion].img;$(e.selector).find("#fca_qc_answer_container").find(".fca_qc_quiz_question_img").attr("src",i),$(e.selector).find("#fca_qc_back_container").find(".fca_qc_quiz_question_img").attr("src",i)}function getCorrectAnswer(e){if("mc"===e.quiz_settings.quiz_type||""===e.quiz_settings.quiz_type){var t=e.questions[e.currentQuestion].answers.filter(function(e){return 1==e.points})[0];return void 0===t&&(t=e.questions[e.currentQuestion].answers[0]),t}return null}function getQuizAnswers(e){return"off"!==quizzes[e.quiz_id].quiz_settings.fixed_answers&&quizzes[e.quiz_id].quiz_settings.fixed_answers?e.questions[e.currentQuestion].answers:shuffleArray(e.questions[e.currentQuestion].answers)}function handleLazyLoading(e){e.currentQuestion+1<e.questionCount?lazyLoadQuestion(e.questions[e.currentQuestion+1]):lazyLoadResults(e)}function populateAnswerDivs(e,t){for(var i=getCorrectAnswer(e),n=getQuizAnswers(e),s=0;s<n.length;s++){var r=void 0!==n[s].img&&""!==n[s].img,c=void 0!==n[s].answer&&""!==n[s].answer;if(r||c){var a=$(e.selector).find(".fca_qc_answer_div").eq(s);"mc"!==e.quiz_settings.quiz_type&&""!==e.quiz_settings.quiz_type||!i||n[s].answer===i.answer&&n[s].img===i.img&&(e.currentAnswer=a.attr("data-question")),"pt"!==e.quiz_settings.quiz_type&&"wq"!==e.quiz_settings.quiz_type||a.data("results",n[s].results),a.find(".fca_qc_quiz_answer_img").attr("src",n[s].img),a.find(".fca_qc_answer_span").html(svg_square+n[s].answer.replace(/\n/g,"<br />")),a.data("id",n[s].id),t?a.fadeIn():a.show()}}}function maxHeightOfElementSet(e){var t=0;return $.each(e,function(i){e.eq(i).outerHeight()>t&&(t=e.eq(i).outerHeight())}),t}function scale_flip_box_question(e){var t=$(e).find("#fca_qc_question").outerHeight(!0);t+=$(e).find(".fca_qc_quiz_question_img").outerHeight(!0),$(e).find(".fca_qc_confirm_button").length>0&&(t+=20+$(e).find(".fca_qc_confirm_button").outerHeight(!0));var i=0,n=0;$(e).find(".fca_qc_answer_div:visible").eq(0).hasClass("fca-qc-twoup")?(n=maxHeightOfElementSet($(e).find(".fca_qc_answer_div:visible")),i=$(e).find(".fca_qc_answer_div:visible").length,i=Math.floor(i/2)+i%2,t+=n*i):$(e).find(".fca_qc_answer_div:visible").eq(0).hasClass("fca-qc-threeup")?(n=maxHeightOfElementSet($(e).find(".fca_qc_answer_div:visible")),i=$(e).find(".fca_qc_answer_div:visible").length,t+=n*(i/=3)):$(e).find(".fca_qc_answer_div:visible").each(function(){t+=$(this).outerHeight(!0)}),t<200&&(t=200),$(e).find(".fca_qc_quiz_footer").show(),$(e).find(".fca_qc_quiz_div, #fca_qc_answer_container, #fca_qc_back_container").outerHeight(t)}function scale_flip_box_back(e){var t=0;$(e).find("#fca_qc_back_container").children().each(function(){$(this).is(":visible")&&(t+=$(this).outerHeight(!0))}),(t+=35)<200&&(t=200),$(e).find(".fca_qc_quiz_footer").hide(),$(e).find(".fca_qc_quiz_div, #fca_qc_answer_container, #fca_qc_back_container").height(t)}function maybe_add_quarter_class(e){$(e).find(".fca_qc_answer_div").height("auto"),$(e).find(".fca_qc_answer_div").removeClass("fca-qc-twoup fca-qc-threeup"),$(e).find(".fca_qc_quiz_answer_img").css("marginBottom",0);var t=!0,i=0;if($(e).find(".fca_qc_answer_div:visible").each(function(){if(i++,""===$(this).find(".fca_qc_quiz_answer_img").attr("src")||!t)return t=!1,!1}),t){var n="fca-qc-twoup";i%3==0&&0===$(e).find(".fca_qc_mobile_check:visible").length&&(n="fca-qc-threeup"),$(e).find(".fca_qc_answer_div").addClass(n);var s=maxHeightOfElementSet($(e).find(".fca_qc_quiz_answer_img:visible"));s>200&&(s=200),$(e).find(".fca_qc_quiz_answer_img:visible").each(function(){$(this).css("marginBottom",s-$(this).height()+10+"px")});var r=maxHeightOfElementSet($(e).find(".fca_qc_answer_div:visible"));return $(e).find(".fca_qc_answer_div:visible").outerHeight(r),!0}return!1}function get_time_taken(e){var t=e.quiz_settings.timer_limit,i=e.time_taken_string;return e.time_remaining?i+" "+(t-e.time_remaining).toFixed(2)+"s":i+" "+timer_limit+"s ("+e.timeout_string+")"}function get_result(e){if(!e.quiz_results)return!1;if("pt"===e.quiz_settings.quiz_type){var t=[],i=-1;return $.each(e.quiz_results,function(e,t){t.hasOwnProperty("score")&&t.score>i&&(i=t.score)}),$.each(e.quiz_results,function(e,n){n.hasOwnProperty("score")&&n.score===i&&t.push(n)}),0===t.length&&(t=e.quiz_results),t[Math.floor(Math.random()*t.length)]}if("wq"===e.quiz_settings.quiz_type)for(n=0;n<e.quiz_results.length;n++)if(e.quiz_results[n].min<=e.score&&e.quiz_results[n].max>=e.score)return e.quiz_results[n];if("mc"===e.quiz_settings.quiz_type||""===e.quiz_settings.quiz_type)for(var n=0;n<e.quiz_results.length;n++)if(e.quiz_results[n].min<=e.score&&e.quiz_results[n].max>=e.score)return e.quiz_results[n];return!1}function show_responses(e){for(var t,i=0;i<e.questions.length;i++)t="",e.responses[i].isCorrect?t+="<div class='fca_qc_question_response_item correct-answer'>":t+="<div class='fca_qc_question_response_item wrong-answer'>",t+="<p class='fca_qc_question_response_question'>"+(i+1)+". "+e.questions[i].question+"</p>",e.questions[i].img&&(t+="<img class='fca_qc_quiz_question_img' src='"+e.questions[i].img+"'>"),t+="<p class='fca_qc_question_response_response'><span class='fca_qc_bold'>"+e.your_answer_string+" </span>"+e.responses[i].answer+"</p>",t+="<p class='fca_qc_question_response_correct_answer'><span class='fca_qc_bold'>"+e.correct_answer_string+" </span>"+e.responses[i].correctAnswer+"</p>",e.responses[i].hasOwnProperty("hint")&&(t+="<p class='fca_qc_question_response_hint'>"+e.responses[i].hint+"</p>"),t+="</div>",$(e.selector).find(".fca_qc_insert_response_above").before(t);$(e.selector).find(".fca_qc_your_answer_container").show()}function endTest(e){if($(e.selector).find(".fca_qc_quiz_footer").hide(),$(e.selector).find(".fca_qc_quiz_div").hide(),"mc"===e.quiz_settings.quiz_type||""===e.quiz_settings.quiz_type){var t=scoreString.replace("{{SCORE_CORRECT}}",e.score);t=t.replace("{{SCORE_TOTAL}}",e.questionCount),$(e.selector).find(".fca_qc_score_text").html(t)}"pt"!==e.quiz_settings.quiz_type&&"wq"!==e.quiz_settings.quiz_type||$(e.selector).find(".fca_qc_score_text").hide();var i=get_result(e);i&&($(e.selector).find(".fca_qc_score_title").html(i.title),"quiz"===e.quiz_settings.timer_mode&&$(e.selector).find(".fca_qc_score_time").html(get_time_taken(e)),$(e.selector).find(".fca_qc_score_img").attr("src",i.img),$(e.selector).find(".fca_qc_score_desc").html(i.desc.replace(/\n/g,"<br />"))),"on"===e.optin_settings.capture_emails?show_optins(e,i):show_sharing_and_result_screen(e,i)}function show_optins(e,t){$(e.selector).find(".fca_qc_optin_input, .fca-qc-gdpr-consent").not(".tooltipstered").tooltipster({trigger:"custom",maxWidth:240,theme:["tooltipster-borderless","tooltipster-quiz-cat"]}),$(e.selector).find(".tooltipstered").tooltipster("close"),$(e.selector).find(".fca_qc_optin_container").show(),$(e.selector).find(".fca_qc_optin_input").first().focus(),$(e.selector).find(".fca_qc_skip_email_button").on("click",function(){$(e.selector).find(".fca_qc_optin_container").hide(),$(e.selector).find(".tooltipstered").tooltipster("close"),show_sharing_and_result_screen(e,t)}),$(e.selector).find(".fca_qc_submit_email_button").on("click",function(){var i=$(e.selector).find("#fca_qc_email_input").val(),n=$(e.selector).find("#fca_qc_name_input").val(),s=/^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(i),r=""!==n||0===$(e.selector).find("#fca_qc_name_input").length;if($(e.selector).find(".fca_qc_optin_input").removeClass("fca_qc_invalid"),e.selector.offsetWidth=e.selector.offsetWidth,s&&r){$(e.selector).find(".tooltipstered").tooltipster("close");if(e.gdpr_checkbox){var c=$(e.selector).find(".fca-qc-gdpr-consent:visible");if(0==c.length)return $(e.selector).find(".fca-qc-gdpr").show(),$(e.selector).find(".fca_qc_optin_input").hide(),!1;if(0==c.prop("checked"))return c.tooltipster("open"),!1;!0}$(document).off("keypress"),$(e.selector).find(".tooltipstered").tooltipster("close"),e.user={name:n,email:i},add_to_mailing_list(e,i,n,t),$(e.selector).find(".fca_qc_optin_container").hide(),show_sharing_and_result_screen(e,t)}else s?($(e.selector).find("#fca_qc_email_input").tooltipster("close"),$(e.selector).find("#fca_qc_email_input").removeClass("fca_qc_invalid")):($(e.selector).find("#fca_qc_email_input").tooltipster("open"),$(e.selector).find("#fca_qc_email_input").addClass("fca_qc_invalid")),r?($(e.selector).find("#fca_qc_name_input").tooltipster("close"),$(e.selector).find("#fca_qc_name_input").removeClass("fca_qc_invalid")):($(e.selector).find("#fca_qc_name_input").tooltipster("open"),$(e.selector).find("#fca_qc_name_input").addClass("fca_qc_invalid"))}),0===$(e.selector).find(".fca_qc_skip_email_button").length&&0===$(e.selector).find(".fca_qc_submit_email_button").length?show_sharing_and_result_screen(e,t):$(document).on("keypress",function(t){if(13===t.which)return $(e.selector).find(".fca_qc_submit_email_button").trigger("click"),!1})}function add_to_mailing_list(e,t,i,n){if(fcaQcData.debug&&console.log(n),-1!==optins.indexOf(e.quiz_id))return fcaQcData.debug&&console.log("already opted in for this quiz! woop"),!1;optins.push(e.quiz_id);var s=jstz.determine();e.doing_ajax=!0,$.ajax({url:e.ajaxurl,type:"POST",data:{nonce:e.nonce,post_id:e.quiz_id,action:"fca_qc_add_to_mailing_list",email:t,name:i,result:get_result_text(e,n),tags:n.tags,groups:n.groups,timezone:s.name()}}).done(function(t){fcaQcData.debug&&console.log(t),e.doing_ajax=!1})}function add_activity(e,t,i,n){if(0==fcaQcData.analytics)return!1;if("shares"===n){if(-1!==shared.indexOf(i))return fcaQcData.debug&&console.log("already shared this quiz! woop"),!1;shared.push(i)}else if("completions"===n){if(-1!==completed.indexOf(i))return fcaQcData.debug&&console.log("already completed this quiz! woop"),!1;completed.push(i)}$.ajax({url:e,type:"POST",data:{nonce:t,quiz_id:i,action:"fca_qc_activity",type:n}}).done(function(e){fcaQcData.debug&&console.log(e)})}function add_response(e,t,i,n,s){if(0==fcaQcData.analytics)return!1;$.ajax({url:e,type:"POST",data:{nonce:t,quiz_id:i,question:n,response:s,action:"fca_qc_add_response_ajax"}}).done(function(e){fcaQcData.debug&&console.log(e)})}function send_responses(e,t){var i="",n="",s="",r="unknown";if(0==fcaQcData.analytics)return!1;if(e.gdpr_checkbox){r=!!$(e.selector).find(".fca-qc-gdpr-consent").prop("checked")}e.hasOwnProperty("user")&&(i=e.user.name,n=e.user.email),s=t.hasOwnProperty("id")?t.id:e.score,e.doing_ajax2=!0,$.ajax({url:e.ajaxurl,type:"POST",data:{nonce:e.nonce,quiz_id:e.quiz_id,name:i,email:n,gdpr_consent:r,result:s,result_text:get_result_text(e,t),responses:e.responses,action:"fca_qc_send_responses_ajax"}}).done(function(t){fcaQcData.debug&&console.log(t),e.doing_ajax2=!1})}function restart_quiz(e){location.href=location.origin+location.pathname+location.search+"#"+e.selector.id,location.reload(),location.href=location.origin+location.pathname+location.search+"#"+e.selector.id}function get_result_text(e,t){var i="";return t.hasOwnProperty("title")&&(i=t.title),"mc"!==e.quiz_settings.quiz_type&&""!==e.quiz_settings.quiz_type||(i=i?e.score+"/"+e.questionCount+": "+t.title:e.score+"/"+e.questionCount),i}function show_sharing_and_result_screen(e,t){send_responses(e,t),"redirect"===e.quiz_settings.result_mode?($(e.selector).find(".fca_qc_wait_container").show(),e.hasOwnProperty("doing_ajax")||e.hasOwnProperty("doing_ajax2")?fcaQcAjaxInterval=setInterval(function(){var i=e.hasOwnProperty("doing_ajax"),n=e.hasOwnProperty("doing_ajax2"),s=i&&e.doing_ajax,r=n&&e.doing_ajax2;s||r||(window.location.href=t.url,clearInterval(fcaQcAjaxInterval))},100):window.location.href=t.url):("on"===e.quiz_settings.restart_button&&$(e.selector).find("#fca_qc_restart_button").on("click",function(){restart_quiz(e),$(this).hide()}).show("fast"),"end"===e.hideAnswers&&show_responses(e),"on"===e.quiz_settings.show_sharing&&show_sharing(e,t),$(e.selector).find(".fca_qc_score_container").show())}function get_correct_answer_html(e){var t="",i="";return $(e.selector).find(".fca_qc_answer_div").each(function(){$(this).attr("data-question")===e.currentAnswer&&(t=addQuizImg($(this).find(".fca_qc_quiz_answer_img").attr("src")),i=$(this).find(".fca_qc_answer_span").html().replace(svg_square,""))}),t+i}function fix_hover(e){e.quiz_settings.hasOwnProperty("confirm_button")&&"on"===e.quiz_settings.confirm_button||$(e.selector).find(".fca_qc_answer_div").hover(function(e){$(this).addClass("fakehover"),$(this).children("span").addClass("fakehover")},function(e){$(this).removeClass("fakehover"),$(this).children("span").removeClass("fakehover")})}function show_sharing(e,t){$(e.selector).find(".fca_qc_social_share").show("fast");var i=$(e.selector).find(".fca_qc_score_img").attr("src");""===i&&(i=$(e.selector).find(".fca_qc_quiz_description_img").attr("src")),""===i&&(i=default_img);var n=$(e.selector).find("#fca_qc_share_link_facebook");1===n.length&&(0==t?n.prop("href",n.prop("href")+"0"+encodeURIComponent("&fca_qc_title="+get_result_text(e,t))):n.prop("href",n.prop("href")+e.quiz_results.indexOf(t)+encodeURIComponent("&fca_qc_title="+get_result_text(e,t))));var s=$(e.selector).find("#fca_qc_share_link_twitter");1===s.length&&(s.data("sharestring",encodeURIComponent(s.data("sharestring").replace("{{MY_QUIZ_RESULT}}",get_result_text(e,t)))),s.prop("href",s.prop("href")+encodeURIComponent("&fca_qc_title="+get_result_text(e,t).replace(/ /g,"+"))+"&text="+s.data("sharestring")));var r=$(e.selector).find("#fca_qc_share_link_email");1===r.length&&encode_share_link(r,get_result_text(e,t)),iOS&&r.hide();var c=$(e.selector).find("#fca_qc_share_link_pinterest");1===c.length&&(encode_share_link(c,get_result_text(e,t)),c.prop("href",c.prop("href")+"&media="+i)),$(e.selector).find(".fca_qc_share_link").on("click",function(t){t.preventDefault();var i=$(this).prop("href");window.open(i,"_blank","resizable=yes,scrollbars=yes,titlebar=yes, width=560, height=443, top=100, left=50"),add_activity(e.ajaxurl,e.nonce,e.quiz_id,"shares")})}function encode_share_link(e,t){var i=encodeURIComponent(e.data("sharestring").replace("{{MY_QUIZ_RESULT}}",t)),n=e.prop("href");e.prop("href",n+i)}function shuffleArray(e){for(var t=e.length-1;t>0;t--){var i=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[i],e[i]=n}return e}function addQuizImg(e){return e&&""!==e&&"string"==typeof e?"<img class='fca_qc_quiz_answer_img' src='"+e+"'>":""}function scrollQuizInToView(e){var t=$(e).offset().top+-100;t<0&&(t=0),$("html, body").animate({scrollTop:t},300)}function debounce(e,t,i){var n;return function(){var s=this,r=arguments,c=i&&!n;clearTimeout(n),n=setTimeout(function(){n=null,i||e.apply(s,r)},t),c&&e.apply(s,r)}}var usingOldBrowser=isIE()||isOldAndroidVersion(),iOS=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,scoreString=$(".fca_qc_score_text").first().html(),svg_square='<svg xmlns="http://www.w3.org/2000/svg" class="fca_qc_rectancle" width="26" height="26"><rect class="fca_qc_checkbox" width="26" height="26"></rect></svg>',quizzes={},fcaQcInterval,default_img="";loadQuizzes(),fcaQcData.debug&&console.log(quizzes),preloadImages(),$(".fca_qc_start_button").on("click",function(){var e=quizzes[get_quiz_id($(this).closest(".fca_qc_quiz"))];startQuiz(e),"off"!==e.quiz_settings.timer_mode&&fca_qc_start_timer(e)}),$(".fca_qc_next_question").on("click",function(){var e=quizzes[get_quiz_id($(this).closest(".fca_qc_quiz"))];if($(e.selector).find("#fca_qc_your_answer").html(""),usingOldBrowser?($(e.selector).find("#fca_qc_answer_container").show(),$(e.selector).find("#fca_qc_back_container").hide()):($(e.selector).find("#fca_qc_hint_p").hide(),$(e.selector).find(".fca_qc_quiz_div").removeClass("flip")),"quiz"===e.quiz_settings.timer_mode&&!e.time_remaining)return e.time_remaining=0,void endTest(e);showQuestion(e)}),$(".fca_qc_answer_div").on("click",function(){var e=quizzes[get_quiz_id($(this).closest(".fca_qc_quiz"))];e.quiz_settings.hasOwnProperty("confirm_button")&&"on"===e.quiz_settings.confirm_button?($(".fakehover").removeClass("fakehover"),$(this).addClass("fakehover"),$(this).children("span").addClass("fakehover")):fca_qc_process_answer(e,$(this))}),$(".fca_qc_confirm_button").on("click",function(){var e=quizzes[get_quiz_id($(this).closest(".fca_qc_quiz"))],t=$(e.selector).find(".fca_qc_answer_div.fakehover");t.length>0&&fca_qc_process_answer(e,t),this.blur()});var optins=[],shared=[],completed=[],fcaQcAjaxInterval,resizeWindow=debounce(function(){jQuery.each(quizzes,function(e){$(quizzes[e].selector).find("#fca_qc_answer_container").waitForImages(function(){maybe_add_quarter_class(quizzes[e].selector),$("#fca_qc_back_container").is(":visible")?scale_flip_box_back(quizzes[e].selector):scale_flip_box_question(quizzes[e].selector)})})},50)});