function SetFilterOption(n,t,i,r){i!=null&&i!="null"&&i.toString().length>0?$(n).html(i):$(n).html(r)}function SetTextForModel(n,t,i,r){i!=null&&i!="null"&&i.toString().length>0?$(n).val(i):$(n).val(r)}function _toConsumableArray(n){if(Array.isArray(n)){for(var t=0,i=Array(n.length);t<n.length;t++)i[t]=n[t];return i}return Array.from(n)}function _classCallCheck(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function");}var SSautocomplete=SSautocomplete||function(){var w=120,c,n=" .js-car-selection-container",l=" .js-redirect-to-input-brand",a=" .js-redirect-to-input-model",v=" .js-redirect-to-input-cartype",ct=n.concat(v),f=n.concat(l),e=n.concat(a),y=n.concat(" select#SelectedCarTypeId"),u=n.concat(" select#SelectedCarBrandId"),o=n.concat(" select#SelectedCarModelId"),s=" input.brand-autocomplete",h=" input.model-autocomplete",b=" input.cartype-autocomplete",i=n.concat(s),t=n.concat(h),r=n.concat(b),k=" ul li:first div",d=f.concat(k),g=e.concat(k),it=function(){return window.simpleSearchModels=[{name:"",code:""}],$(o.concat(" > option")).each(function(){this.value.length>0&&window.simpleSearchModels.push({name:this.text,code:this.value,isgroup:$(this).data("isgroup"),isSeriesModel:$(this).data("isSeriesModel")})}),window.simpleSearchModels},rt=function(){return window.simpleSearchCarTypes=[],$(y.concat(" > option")).each(function(){window.simpleSearchCarTypes.push({name:this.text,code:this.value})}),window.simpleSearchCarTypes},p=function(n,t,i){var u=$(n).getSelectedItemData().code,r;$(t).val(u).trigger("change");r=$(i).val();$(i).val("");$(n).attr("data-hide","true");GSautocomplete.triggerFocus(i);$(i).trigger("blur");$(i).val(r);GSautocomplete.unFocus()},nt=function(){var n=$(i),r={data:window.simpleSearchBrands,getValue:"name",highlightPhrase:!1,adjustWidth:!1,list:{maxNumberOfElements:w,bypassCode0ValuesForArrowNavigation:!0,bypassEmptyCodeValuesForArrowNavigation:!0,match:{enabled:!0,method:function(n,t){return t.length>0?n.indexOf(t)===0?!0:!1:!0}},onShowListEvent:function(){GSautocomplete.highlightItem($(u).val(),f,window.simpleSearchBrands)},onLoadEvent:function(){$(".js-car-selection-container .js-redirect-to-input-brand ul li:contains('separatorLine')").replaceWith("<li style='border-bottom: 1px solid #9e9e9e;'><\/li>");$(d).is(":empty")&&$(d).css("display","none")},onChooseEvent:function(){$(t).val("").prop("disabled",!0);$(".js-car-selection + .js-redirect-to-input-model i").removeClass("is-disabled");p(i,u,i)},sort:{enabled:!1}},theme:null};n.easyAutocomplete(r)},ut=function(){var n=$(t),i;$(t).prop("disabled",!1);i={data:it(),template:{type:"custom",method:function(n,t){var i;return n===""?"":(i=t.isgroup?"series-item":t.isSeriesModel?"series-model-item":"","<span class="+i+">"+n+"<\/span>")}},getValue:"name",highlightPhrase:!1,adjustWidth:!1,list:{maxNumberOfElements:w,match:{enabled:!0,method:function(n,t){return t.length>0?n.indexOf(t)===0?!0:!1:!0}},onLoadEvent:function(){$(g).is(":empty")&&$(g).css("display","none")},onShowListEvent:function(){GSautocomplete.highlightItem($(o).val(),e,window.simpleSearchModels)},onChooseEvent:function(){var i=n.getSelectedItemData().code,r=n.getSelectedItemData().name;c(i,r);p(t,o,t)},sort:{enabled:!1}},theme:null};n.easyAutocomplete(i)},tt=function(){var f=$(r),n,u;$(r).prop("disabled",!1);n={data:rt(),getValue:"name",highlightPhrase:!1,adjustWidth:!1,list:{onChooseEvent:function(){var u=$(r).getSelectedItemData().code,n;if(u==="4")return n=$(v).data("leasing-url"),window.location.href=n,$(i).prop("disabled",!0),$(t).prop("disabled",!0),!1;p(r,y,r)}},theme:null};u=$(y.concat(" > option:first")).text();$(r).val(u);f.easyAutocomplete(n)},ft=function(){var n=$(u).val(),t;n.length>0&&(t=$(u.concat(" option[value="+n+"]:first")).text(),$(i).val(t))},et=function(){$(n).on("click",".js-car-type-select input.select-dropdown",function(){$(e.concat(" ul")).css("display","none");$(f.concat(" ul")).css("display","none");$(i).trigger("blur");$(t).trigger("blur")})},ot=function(){$(n).on("keyup",s,function(n){var r=this.value;GSautocomplete.handleEnterKey(n,f,r);this.value.length===0&&($(t).val("").prop("disabled",!0),$(".js-car-selection + .js-redirect-to-input-model i").addClass("is-disabled"),$(u).val("").trigger("change"),GSautocomplete.triggerFocus(i))})},st=function(){$(n).on("keyup",h,function(n){var i=this.value;GSautocomplete.handleEnterKey(n,e,i);this.value.length===0&&(c("",""),$(t).val(""),$(o).val("").trigger("change"),GSautocomplete.triggerFocus(t))})},ht=function(t){c=t;GSautocomplete.handleRedirectToInput(n,v,b);GSautocomplete.handleRedirectToInput(n,l,s);GSautocomplete.handleRedirectToInput(n,a,h);ot();st();tt();nt();GSautocomplete.initTabSelection(s,n,l);GSautocomplete.initTabSelection(h,n,a);et()};return{init:ht,initBrandsAutocomplete:nt,initModelsAutocomplete:ut,initCarTypesAutocomplete:tt,populateBrandInputOnBackInHistory:ft}}(),Search=Search||function(){var n,t,i,u=function(){return n},f=function(){return t},e=function(){return i},o=function(){try{var r=$(".js-car-selection-container #SelectedCarTypeId").val(),i=$(".js-car-selection-container #SelectedCarBrandId").val(),u=document.getElementById("hiddenCarModelId").value;SSautocomplete.populateBrandInputOnBackInHistory();SSautocomplete.init(Search.setCarModel);typeof AdvancedFilters!="undefined"&&AdvancedFilters.filter!==undefined&&Search.SetAdvancedCarType(r);i!=""?Search.SetSelectedValues(i,u):GetCountOnFilterChange(!0);$(".js-car-selection-container").on("change",".js-car-selection",function(){Search.getCount()});$(".js-car-selection-container").on("change","#SelectedCarTypeId",function(){n=this.value;typeof AdvancedFilters!="undefined"&&AdvancedFilters.filter!==undefined&&(AdvancedFilters.filter.CarType=this.value,Search.SetAdvancedCarType(AdvancedFilters.filter.CarType));$(".js-car-selection-container #carModelIdInput").val("").prop("disabled",!0);$(".js-car-selection-container select#SelectedCarBrandId").trigger("change")});$(".js-car-selection-container").on("change","#SelectedCarBrandId",function(){t=this.value;typeof AdvancedFilters!="undefined"&&AdvancedFilters.filter!==undefined&&(AdvancedFilters.filter.BrandId=this.value);this.value==""?(Search.ClearModelDropdown(),$("#SelectedCarModelId").prop("disabled",!0),$(".js-car-selection-container #carModelIdInput").prop("disabled",!0),typeof AdvancedFilters!="undefined"&&AdvancedFilters.filter!==undefined&&(Search.SetAdvBrandSelected(AdvancedFilters.filter.BrandId,""),Search.SetAdvancedData())):(Search.getModels(),typeof AdvancedFilters!="undefined"&&AdvancedFilters.filter!==undefined&&(Search.SetAdvBrandSelected(AdvancedFilters.filter.BrandId,""),Search.SetAdvancedData()));$("#divDropdowBrand ul li:contains('separatorLine'):last").each(function(){$(this).addClass("seperator");$(this).text("")})});$("#buttonSearch").on("click",function(){$("#selModelId").val($("#SelectedCarModelId").val())});$("#divDropdowBrand ul li:contains('separatorLine'):last").each(function(){$(this).addClass("seperator");$(this).text("")})}catch(f){console.log(f.message)}},s=function(){try{$("#SelectedCarModelId").val($("#selModelId").val());Search.getCount();SSautocomplete.initModelsAutocomplete()}catch(n){console.log(n.message)}},h=function(i){try{$("#SelectedCarModelId").val(i);var f=$("#SelectedCarModelId option:selected").html(),r=$("#SelectedCarBrandId").val(),u=$(".js-car-selection-container #SelectedCarTypeId").val();SSautocomplete.initModelsAutocomplete();n=u;t=r;typeof AdvancedFilters!="undefined"&&AdvancedFilters.filter!==undefined&&(AdvancedFilters.filter.CarType=u,AdvancedFilters.filter.BrandId=r,Search.SetAdvancedCarType(AdvancedFilters.filter.CarType));Search.setCarModel(i,f)}catch(e){console.log(e.message)}},r=function(n,t,i){n.val(t);n.find("option[value='"+t+"']").attr("selected","selected");i.val(n.find("option[value='"+t+"']").text())},c=function(n,t){try{t="#js-CarType";$(t+" .option").prop("checked",!1);n!==""&&n!=="0"&&n!==null?$(t+" .checkAll").prop("checked",!1):$(t+" .checkAll").prop("checked",!0);String(n).split(",").forEach(function(n){n.length>0&&$(t).find("[name="+n+"]").prop("checked",!0)})}catch(i){console.log(i.message)}},l=function(){try{typeof AdvancedFilters!="undefined"&&AdvancedFilters.filter!==undefined&&AdvancedFilters.SetLinkToSearchBtn()}catch(n){console.log(n.message)}},a=function(){var n=$("#divDropdownModel").attr("data-allText");SetTextForModel("#divDropdownModel input","","",n);document.getElementById("hiddenCarModelId").value=""},v=function(n){try{Search.ClearModelDropdown();FillModels(n!=undefined?function(){h(n)}:s)}catch(t){console.log(t.message)}},y=function(){try{GetCountOnFilterChange()}catch(n){console.log(n.message)}},p=function(n,t){$("#SelectedCarModelId").prop("disabled",!1);$(".js-car-selection-container #carModelIdInput").prop("disabled",!1);SSautocomplete.initBrandsAutocomplete();SSautocomplete.initModelsAutocomplete();Search.getModels(t)},w=function(n,t){try{var i=$("#divSelectedTypeFilter").attr("data-allText");document.getElementById("hiddenCarTypeId").value=n;SetFilterOption("#spanSelectedCarTypeId",n,t,i)}catch(r){console.log(r.message)}},b=function(n,t){var r=$("#divDropdownModel").attr("data-allText");document.getElementById("hiddenCarModelId").value=n;$("#SelectedCarModelId").val(n);SetTextForModel("#divDropdownModel input",n,t,r);GetCountOnFilterChange();i=n;typeof AdvancedFilters!="undefined"&&AdvancedFilters.filter!==undefined&&(AdvancedFilters.filter.ModelId=n,Search.SetAdvBrandSelected(AdvancedFilters.filter.BrandId,n),Search.SetAdvancedData())},k=function(n,t){try{r($(".js-adv-container #SelectedCarBrandId"),n,$(".js-adv-container .brand-autocomplete"));CarDetails.FillModels(".js-adv-container #SelectedCarModelId",".js-adv-container #SelectedCarBrandId","",".js-adv-container #divAdvDropdowBrand","#divDropdowModel","",function(){r($(".js-adv-container #SelectedCarModelId"),t,$(".js-adv-container .model-autocomplete"));typeof AdvancedFilters!="undefined"&&AdvancedFilters.ApplyDropDownStyleOnLoad()})}catch(i){console.log(i.message)}};return{init:o,getModels:v,getCount:y,SetSelectedValues:p,ClearModelDropdown:a,setCarType:w,setCarModel:b,SetAdvBrandSelected:k,SetAdvancedCarType:c,SetAdvancedData:l,CarType:u,BrandId:f,ModelId:e}}(),SearchDDL,_createClass,MH,Home;$(document).ready(function(){$("html").attr("data-platform")==="ipad"&&$(window).bind("pageshow",function(n){n.originalEvent.persisted&&SSautocomplete.populateBrandInputOnBackInHistory()});Search.init()});SearchDDL=SearchDDL||function(){var n=function(){try{$.ajax({url:'@Url.Action("GetCarModelList","Home")',data:{BrandId:$("#CarBrandDropDownList").val()},datatype:"JSON",type:"POST",success:function(n){alert("succes");var t="";t+="<option value><\/option>";$.each(n,function(n,i){t+='<option value="'+i.Id+'">'+i.Name+"<\/option>"});$("#CarModelDropDownList").html(t)},error:function(n,t,i){console.log(t,i)}})}catch(n){console.log(n.message)}};return{getCarModel:n}}();_createClass=function(){function n(n,t){for(var i,r=0;r<t.length;r++)i=t[r],i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,i.key,i)}return function(t,i,r){return i&&n(t.prototype,i),r&&n(t,r),t}}();MH=MH||{};MH.Sticky=function(){function n(t){var i=this;if(_classCallCheck(this,n),this.targetElement=t.targetElement,this.targetNode=document.querySelector(this.targetElement)||!1,!this.targetNode)return!1;this.referenceElement=t.referenceElement||"body";this.referenceNode=document.querySelector(this.referenceElement);this.referencePoint=t.referencePoint||"bottom";this.breakpoints=t.breakpoints||null;this.desiredTriggerPoint=t.desiredTriggerPoint||0;this.cssSetSticky=t.cssSetSticky||["is-sticky"];this.cssSetUnsticky=t.cssSetUnsticky||["is-unsticky"];this.scrollPosition=null;this.targetElementHeight=null;window.addEventListener("load",function(){return i._initialiseSticky()},!1);window.addEventListener("orientationChange",function(){return i._reInitialiseSticky()},!1);window.addEventListener("resize",function(){return i._reInitialiseSticky()},!1);window.addEventListener("scroll",function(){return i._reInitialiseSticky()},!1)}return _createClass(n,[{key:"calcHeight",value:function(n){return document.querySelector(n).offsetHeight}},{key:"haystack",value:function(n){var t=n!==n,i;return i=t||typeof Array.prototype.indexOf!="function"?function(n){for(var i=-1,u=-1,r,i=0;i<this.length;i++)if(r=this[i],t&&r!==r||r===n){u=i;break}return u}:Array.prototype.indexOf,i.call(this,n)>-1}},{key:"pageHeight",value:function(){var t=document.body,n=document.documentElement;return Math.max(t.scrollHeight,t.offsetHeight,n.clientHeight,n.scrollHeight,n.offsetHeight)}},{key:"_scrollYPosition",value:function(){return document.documentElement.scrollTop||document.body.scrollTop}},{key:"update",value:function(){this.scrollPosition=this._scrollYPosition();this.targetElementHeight=this.calcHeight(this.targetElement)}},{key:"_getTriggerPoint",value:function(){this._referenceElementHeight=parseInt(window.getComputedStyle(this.referenceNode,null).getPropertyValue("height"))}},{key:"_initialiseSticky",value:function(){var n,t,i,r,u,f,e;this.haystack.call(this.breakpoints,MH.param.currentBreakpoint)||this.breakpoints==null?(this.update(),n=!!navigator.userAgent.match(/Trident/g)||!!navigator.userAgent.match(/MSIE/g),this.scrollPosition>this.desiredTriggerPoint&&((t=this.targetNode.classList).remove.apply(t,_toConsumableArray(this.cssSetUnsticky)),(i=this.targetNode.classList).add.apply(i,_toConsumableArray(this.cssSetSticky)),n&&(args1=this.cssSetUnsticky,el=this.targetNode,args1.map(function(n){return el.classList.remove(n)}),args2=this.cssSetSticky,el=this.targetNode,args2.map(function(n){return el.classList.add(n)})),this.targetNode.style.bottom=null,document.documentElement.style.marginBottom=this.targetNode.clientHeight+"px"),this.scrollPosition<this.desiredTriggerPoint&&((r=this.targetNode.classList).remove.apply(r,_toConsumableArray(this.cssSetSticky)),(u=this.targetNode.classList).add.apply(u,_toConsumableArray(this.cssSetUnsticky)),n&&(args1=this.cssSetSticky,el=this.targetNode,args1.map(function(n){return el.classList.remove(n)}),args2=this.cssSetUnsticky,el=this.targetNode,args2.map(function(n){return el.classList.add(n)})),this.targetNode.style.bottom="-"+this.targetElementHeight+"px",document.documentElement.style.marginBottom="0")):((f=this.targetNode.classList).remove.apply(f,_toConsumableArray(this.cssSetSticky)),(e=this.targetNode.classList).add.apply(e,_toConsumableArray(this.cssSetUnsticky)),this.targetNode.style.bottom="-"+this.targetElementHeight+"px")}},{key:"_reInitialiseSticky",value:function(){this._initialiseSticky()}},{key:"stickiness",get:function(){return this.targetElement.style.position}}],[{key:"_offset",value:function(n){var t=n.getBoundingClientRect(),i=windows.pageXOffset||document.documentElement.scrollLeft,r=windows.pageYOffset||document.documentElement.scrollTop;return{top:t.top+r,left:t.left+i,bottom:null,right:null}}},{key:"layoutPosition",value:function(n){var r=n.getBoundingClientRect(),t=windows.pageXOffset,i=windows.pageYOffset;return{top:t,left:i,bottom:null,right:null}}}]),n}();Home=Home||function(){var n=[],t=function(){var n,t,i;f();n=$(".js-display-previous-search-block");n.length>0&&(t=JSON.parse(n.val().toLowerCase()),i=n.data("action-url"),t&&$.ajax({url:i,datatype:"JSON",type:"GET",error:function(n,t,i){console.log(t,i)}}).done(function(t){n.after($(t));Fav.init()}));$("#js-companyName").hide();$("#SelectedPersonType").on("change",function(){var n=$("#SelectedPersonType").val();n=="1"?($("#js-contactName").show(),$("#js-companyName").hide()):($("#js-companyName").show(),$("#js-contactName").hide())});message=$("#hidSendingMessage").val();message!=""&&typeof message!="undefined"&&showNotification(message)},i=function(){var t=document.querySelectorAll("#resultId-");t.forEach(function(t){var o=$(t).find('[src*="No-Classified"]'),i;if(o.length>0){var r=$(t).attr("href").toString(),u=r.indexOf("?entity_type"),f=r.substr(0,u).lastIndexOf("/"),e=r.substr(f+1,parseInt(u)-parseInt(f)-1);n.push(e);i=$(t).attr("id");i=i+e;$(t).attr("id",i)}})},r=function(n){$("body").append(n);$("#trackuity-missing-pictures picture").each(function(){var n=$(this).data("car-id"),t="#resultId-"+n;$(t+" figure picture").html($(this).html())})},u=function(){if(Home.getIdFrommissingPictureCar(),n.length>0){var t=n.join(",");$.ajax({url:"/nl/tweedehands/getpictureelement",datatype:"JSON",data:{id:"1",ids:t},type:"GET",error:function(n,t,i){console.log(t,i)}}).done(function(n){Home.replacedata(n)})}},f=function(){if("MutationObserver"in window){var n=new MutationObserver(function(t){var i=!1;t.forEach(function(n){var t=n.addedNodes,r;t!==null&&(r=$(t),r.each(function(){var t=$(this),n=t.attr("id");n!=undefined&&n.contains("tty-recommender-container-")&&(i=!0)}))});i&&(n.disconnect(),setTimeout(Home.findMissingPictures,3e3))}),t=document.querySelector("[data-takeover-2]");t&&n.observe(t,{attributes:!0,attributeoldValue:!0,characterData:!0,childList:!0,subtree:!0})}};return{init:t,findMissingPictures:u,getIdFrommissingPictureCar:i,replacedata:r}}();$(document).ready(function(){Home.init();var n=!!navigator.userAgent.match(/Trident/g)||!!navigator.userAgent.match(/MSIE/g);n||(stickyActionBarFooter=new MH.Sticky({breakpoints:["bp-xs"],targetElement:"#sellYourCar",desiredTriggerPoint:240,cssSetSticky:["js-is-sticky","js-is-sticky--onscreen"],cssSetUnsticky:["js-is-sticky","js-is-sticky--offscreen"]}));Newsletter.setStickyNewsletterPopup();Newsletter.handlePopupOnClose(".newsletter__close-button",".popup.newsletter")})