var BASE_URL=null,ID_AREA_ACTIVE=null,inputSlider=null,ID_TEST=null,$buttonSave=$("#btn-save");function saveTest(){$buttonSave.prop("disabled",!0),$.post(BASE_URL+"home/saveTest",prepareObjSave(),onSuccess).fail(onError).always((function(){$buttonSave.prop("disabled",!1)}))}function saveFinalTest(){$buttonSave.prop("disabled",!0),$.post(BASE_URL+"home/saveTest",prepareObjSave(),(function(e){e=JSON.parse(e),setTimeout((function(){CLIENT_SESSION?saveLeadClientSession(e.answer.id_test):location.href=BASE_URL+"home/register/"+e.answer.id_test}),0)})).fail(onError).always((function(){$buttonSave.prop("disabled",!1)}))}function saveLead(){var e={name:$("#name").val(),email:$("#email").val(),phone:$("#phone").val(),id_test:ID_TEST};$buttonSave.prop("disabled",!0),$.post(BASE_URL+"home/saveLead",e,(function(e){e=JSON.parse(e),setTimeout((function(){location.href=BASE_URL+"home/result/"+e.id_test}),0)})).fail(onError).always((function(){$buttonSave.prop("disabled",!1)}))}function saveLeadClientSession(e){var t={id_test:e};$buttonSave.prop("disabled",!0),$.post(BASE_URL+"home/saveLead/1",t,(function(e){e=JSON.parse(e),setTimeout((function(){location.href=BASE_URL+"home/result/"+e.id_test}),0)})).fail(onError).always((function(){$buttonSave.prop("disabled",!1)}))}function onSuccess(e){e=JSON.parse(e),setTimeout((function(){var t=BASE_URL+"home/area/"+(parseInt(ID_AREA_ACTIVE)+1)+"/"+e.answer.id_test;CLIENT_SESSION&&(t+="/1"),location.href=t}),0)}function onError(e){$buttonSave.prop("disabled",!1),e=JSON.parse(e),console.log(e),console.log("Erro ao inserir a resposta")}function prepareObjSave(){return{value:parseInt(inputSlider.noUiSlider.get()),text:$("#text_area").val(),id_area:ID_AREA_ACTIVE,id_test:ID_TEST}}$(document).ready((function(){$(".input-slider-container-area")[0]&&$(".input-slider-container-area").each((function(){var e=$(this).find(".input-slider"),t=e.attr("id"),a=e.data("range-value-min"),n=e.data("range-value-max");inputSlider=document.getElementById(t),noUiSlider.create(inputSlider,{start:[1],step:1,pips:{mode:"steps",filter:function(){return 1},density:10},range:{min:[parseInt(a)],max:[parseInt(n)]}})}))}));