var NADAjs=NADAjs||{};NADAjs.home=function(){function t(t){var i,r,u;if(n=$.extend(n,t),$("body").bind("zipSuccess",function(n,t){$(".user-zip").val(t)}),n.heroDestUrl!==""){$(".js-nhp-hero").on("click",function(){$(this).hasClass("js-nhp-hero")&&(document.location.href=n.heroDestUrl)});i=$("#dqMake").text(),i!==""&&($("#make option").each(function(){$(this).text()===i&&$(this).attr("selected","selected")}),r=$("#make").val(),u=(new Date).getFullYear(),$("#model").html(""),$.getJSON("/Cars/Ajax/GetIncentiveModel",{year:u,makeID:r},function(n){n=$.map(n,function(n){return n.Attributes.Keys.length>0?"<option value="+n.Value+'" data-dtc-make="'+n.Attributes.Keys[0]+'" data-dtc-model="'+n.Attributes.Keys[1]+'">'+n.Text+"</option>":"<option value="+n.Value+'" data-dtc-make="" data-dtc-model="">'+n.Text+"</option>"}),$("#model").html(n.join(""));var t=$("#dqModel").text();t!==""&&$("#model option").each(function(){$(this).text()===t&&$(this).attr("selected","selected")})}))}$("#make").change(function(){var n=$("#make").val(),t=(new Date).getFullYear();$("#model").html(""),$.getJSON("/Cars/Ajax/GetIncentiveModel",{year:t,makeID:n},function(n){n=$.map(n,function(n){return n.Attributes.Keys.length>0?"<option value="+n.Value+'" data-dtc-make="'+n.Attributes.Keys[0]+'" data-dtc-model="'+n.Attributes.Keys[1]+'">'+n.Text+"</option>":"<option value="+n.Value+'" data-dtc-make="" data-dtc-model="">'+n.Text+"</option>"}),$("#model").html(n.join(""))})});$(".js-dq-form").on("submit",function(n){n.preventDefault()});$(".js-dq-zip").on("keyup",function(n){n.keyCode==13&&NADAjs.home.gotoDealer()});$(".js-at-click-time").click(function(){var t,n;try{t=NADAjs.CookieHelper.getCookie("at_clicked_time"),Math.round(+new Date/1e3)-t>1800&&(n=new Date,n.setMinutes(n.getMinutes()+30),NADAjs.CookieHelper.setCookie("at_clicked_time",Math.round(+new Date/1e3),n))}catch(i){}})}var n={heroDestUrl:""},i=function(){var n="",i="",t;$("#make option:selected").text()!=" "&&$("#make option:selected").text()!="Select a Make"&&(n=$("#make option:selected").text()),$("#model option:selected").text()!=" "&&$("#model option:selected").text()!="Select Model"&&(i=$("#model option:selected").text()),t=$("#txtATCZipHP1").val(),n!=""?window.open("https://quotes.nadaguides.com?contactDrillIn=true&make="+n+"&model="+i+"&zip="+t):window.open("https://quotes.nadaguides.com?zip="+t)};return{init:t,gotoDealer:i}}(),NADAjs.QuickPoll=function(){function t(){$(".js-poll-show-results").click(function(){i()}),$(".js-poll-back").click(function(){return u(),!1}),$(".js-poll-submit").click(function(){r()})}var i=function(){n("SurveyID="+$(".js-poll-survey-id").val()+"&IsMultipleSelect="+$(".js-poll-is-multisel").val())},r=function(){var i,t;if($(".js-poll-is-grid").val()=="False"){if(!$("input[name='AnswerIDList']").is(":checked")){alert("Please complete the quick poll before voting");return}}else for(i=$("input:radio.answer"),t=0;t<i.length;t++)if($("input[name='"+i[t].name+"']:checked").val()==undefined){alert("Please complete the quick poll before voting");return}n($(".js-poll-form").serialize())},u=function(){$("input[name='AnswerIDList']").attr("checked",!1),$("input:radio.answer").attr("checked",!1),$(".js-open-field-text").val(""),$(".js-poll-form").show(),$(".js-poll-results").hide()},n=function(n){$(".js-poll-form").hide(),$(".js-poll-wait").show(),$.ajax({type:"POST",data:n,dataType:"json",url:"Cars/Survey/Ajax/VoteGetResults",timeout:21e4,error:function(){$(".js-poll-form").show(),$(".js-poll-wait").hide(),alert("Sorry, an error occurred while processing your request.")},success:function(n){$.each(n,function(n,t){t.Percent==0?$("#AnswerID_"+t.SurveyAnswerID).html("0%").css({"background-color":"#edf0f5"}):$("#AnswerID_"+t.SurveyAnswerID).html(t.DisplayPercent).width(t.Percent*2.9).css({"background-color":"rgba(49,196,243,0.4)"})}),$(".js-poll-wait").hide(),$(".js-poll-results").show()}})};return{init:t}}(),NADAjs.VehicleHistory=function(){var n,t,u=function(){n=$("#txtVIN").val(),t=$("#txtPlate").val(),$("#formVIN").submit(function(){i(),_gaq.push(["_trackEvent","ExtLinks","Autocheck","100472-home",1,!0])}),$("#txtVIN").focus(function(){i()}),$("#txtVIN").blur(function(){$(this).val()==""&&$("*:focus").attr("id")!="freevincheckGO"&&$(this).val(n)}),$("#formPlate").submit(function(){r(),_gaq.push(["_trackEvent","ExtLinks","Autocheck","100472-home",1,!0])}),$("#txtPlate").focus(function(){r()}),$("#txtPlate").blur(function(){$(this).val()==""&&$(this).val(t)}),$("#txtVIN").keyup(function(n){$("#freevincheckGO").removeClass("track-hp-1463"),$("#freevincheckGO").addClass("track-hp-1462"),n.which==13&&$("#formVIN").submit()})},i=function(){$("#txtVIN").val()==n&&$("#txtVIN").val("")},r=function(){$("#txtPlate").val()==t&&$("#txtPlate").val("")};return{init:u}}()