var articleDetail={isNewSwiper:!1,isNewSwiperLoad:!1,init:function(){"undefined"!=typeof genBoxLead&&genBoxLead.init(),-90==window.orientation||90==window.orientation?$(".MobileBottomOfArticle img").attr("src","https://img1.oto.com.vn/Static/mobile/PNL1-Oto-191108-Banner-1280x640-min.gif"):$(".MobileBottomOfArticle img").attr("src","https://img1.oto.com.vn/Static/mobile/PNL1-Oto-191108-Banner-640x1280-min.gif"),changeTableImageToSlider(),$("div[data-type='slider-compare']").sliderCompare(),$("div[id*='player'][data-type='jwplayer']").playVideo(!1),$("div[data-type='embed']").playVideo(!1),$(".detail-review-car img").not(".link-source-detail img, .dmca, .twentytwenty-before, .twentytwenty-after").lightGalleryNews(),$("table").each((function(){!$($(this).parentElement).hasClass("divresponsive")&&$(this).is(":visible")&&$(this).wrap('<div class="divresponsive"></div>')})),VideoLibrary.Register(),$(".box-vote").length>0&&vote.Init(),window.addEventListener("orientationchange",(function(){$("div[data-type='slider-compare']").sliderCompare();$(".MobileBottomOfArticle img").attr("src");-90==window.orientation||90==window.orientation?$(".MobileBottomOfArticle img").attr("src","https://img1.oto.com.vn/Static/mobile/PNL1-Oto-191108-Banner-1280x640-min.gif"):$(".MobileBottomOfArticle img").attr("src","https://img1.oto.com.vn/Static/mobile/PNL1-Oto-191108-Banner-640x1280-min.gif")}),!1),lazyLoading.init(),this.slideImage(),this.slideInContent(),this.newsSource(),this.boxAutoRelation(),$(document).ready((function(e){articleDetail.swapLocationAutoMenu($(".box-detail-new"),(()=>{articleDetail.autoMenuHeading($(".box-detail-new"))}))})),$(".box-panorama-image").length>0&&panoramaImage.init(),$(".box-reel-image").length>0&&reelImage.init(),$(document).on("click","#box_get_lead_sticky",(function(e){var t=$(this).parent().parent(".cpn-carprice").data("make-id"),a=$(this).parent().parent(".cpn-carprice").data("model-id"),i=$(this).parent().parent(".cpn-carprice").data("price"),o=$(".currentArticleIdRelateSapo").val(),n=$("#box-consultation-second"),l={makeId:t,modelId:a,price:i,articleId:o};$.ajax({type:"POST",cache:!1,url:"/nhan-uu-dai-va-ho-tro-tra-gop",data:l,success:function(e){if(""==e||null==e)return OpenPopupOnPage(n),void dataLayer.push({event:"submitPreferentialSuccess"});$("#popup").empty().html(e),$("#popup .modal").css("position","fixed"),NoScroll(),articleDetail.randomItemPopup(null)}})})),$(".video-container").length>0&&($(".video-container").videoYoutubeLoadImage(),$(".video-container").videoYoutubeActive()),lazyLoading.init(),articleInfinityScroll.init(),articleDetail.lazyLoadImage($(".box-detail-new"))},lazyLoadImage:function(e){var t=e.find("img");null!=t&&null!=t&&t.length>0&&t.each((function(){$(this).attr("src",$(this).attr("data-src"))}))},randomItemPopup:function(e){articleDetail.make_request_get_location(e,articleDetail.hight_light_salon_near_you)},make_request_get_location:function(e,t){if(null==localStorage.getItem("ipLocationAdress"))$.ajax({type:"GET",cache:!1,async:!0,data:{},url:"https://log.oto.com.vn/IpLocationApi/location",success:function(a){t(e,a)},complete:function(){},error:function(a,i,o){t(e,null)}});else{var a=JSON.parse(localStorage.getItem("ipLocationAdress"));t(e,a)}},hight_light_salon_near_you:function(e,t){var a=$("#popup .content-popup .cpn-sale-support .item-info-salon");if(null!=a&&null!=a&&a.length>=1){for(var i=a.length-1,o=$("#popup .content-popup .cpn-sale-support .item-info-salon"),n=[],l=[],r=0;r<=i;r++){var s=o.eq(r).data("cityId");null!=t&&s==t.city_id?n.push(r):l.push(r)}var d=[];if(l.length>=2)for(;l.length>0;){var c=Math.floor(Math.random()*l.length);d.push(l[c]),l.splice(c,1)}else 1==l.length&&d.push(l[0]);$("#popup .content-popup .cpn-sale-support").empty();var p=0;for(r=0;r<n.length;r++){(u=o.eq(n[r])).find("a").attr("data-position",p),p++,$(".map-link",u).append("Showroom gần bạn"),$("#popup .content-popup .cpn-sale-support").append(u)}for(r=0;r<d.length;r++){var u;(u=o.eq(d[r])).find("a").attr("data-position",p),p++,$("#popup .content-popup .cpn-sale-support").append(u)}}},slideImage:function(e){$("#articleslideposition",e).html($("#slideimage",e).show());var t=$("#slideimage .swiper-container",e),a=$("#slideimage .swiper-pagination",e);new Swiper(t[0],{pagination:a[0],paginationClickable:!0,nextButton:!1,prevButton:!1,spaceBetween:35})},slideInContent:function(e){$(".slideincontent",e).length>0&&$(".slideincontent",e).each((function(){var e=$(".swiper-container",$(this));$(".swiper-button-next",$(this)),$(".swiper-button-prev",$(this)),new Swiper(e,{slidesPerView:"auto",paginationClickable:!1,paginationType:"bullets",pagination:".swiper-pagination"})}))},newsSource:function(e){$(".link-source-detail .btn-copy-link-source",e).click((function(){var e=$(this).find("#link-source");copyToClipboard(e),$(this).find("span").html("Link đã copy!")}))},boxAutoRelation:function(e){var t=this;$("#toggletab .tabcaption",e).click((function(a){if(!$(this).hasClass("ui-tabs-active")){var i=$(this).attr("id");$("#toggletab .ui-tabs-active",e).removeClass("ui-tabs-active"),$(this).addClass("ui-tabs-active"),$("#toggletab .box-list-car",e).hide(),$("#toggletab ."+i,e).show(),"1"!=$(this).attr("init-swipper")&&($(this).attr("init-swipper","1"),t.initSwiperRelation($("#toggletab ."+i,e)))}})),$("#toggletab .tabcaption:eq(0)",e).trigger("click")},initSwiperRelation:function(e){setTimeout((function(){new Swiper(e.find(".swiper-container"),{slidesPerView:"auto",paginationClickable:!0,paginationType:"bullets",pagination:e.find(".swiper-pagination")})}),100)},autoMenuHeading:function(e){if($(".blog-detail",e).length>0){var t=20,a=0,i=!0;$(window).scroll((function(){!function(){if($(".menu-fixed-detail",e).length>0&&1==i){var o=$(window).scrollTop()+t,n=$(".blog-detail",e).offset().top+$(".blog-detail",e).height();e.hasClass("hidden-news")||!e.hasClass("active")?$(".auto-head-2",e).hide():$(".box-index",e).offset().top+$(".box-index",e).height()<o&&o<=n?$(".auto-head-2",e).show():$(".auto-head-2",e).hide(),o>a||(o+=$("#header").outerHeight()),a=o;for(var l=$("[data-auto-menu]",e),r=0;r<l.length;r++){var s,d=$(l[r]),c=d.offset().top-t;if(r==l.length-1)s=$(".blog-detail",e).offset().top+$(".blog-detail",e).height();else s=$(l[r+1]).offset().top-t;if(c<=o&&o<s){var p=d.attr("data-auto-menu"),u=$('.menu-fixed-detail li a[data-id="'+p+'"]',e);return u.parent().hasClass("active")||($(".menu-fixed-detail li.active",e).removeClass("active"),$(u).parent().addClass("active")),!1}}}}()}));var o=0;$(".menu-auto-detail li a",e).click((function(){var a=$(this).attr("data-id"),i=0;$(".blog-detail [data-auto-menu]",e).length>0&&(i=$('.blog-detail [data-auto-menu="'+a+'"]',e).offset().top-t),$("html, body").stop().animate({scrollTop:i},300),o=i})),$(".menu-fixed-detail li a",e).length>0&&(e.off("click",".menu-fixed-detail li a"),e.on("click",".menu-fixed-detail li a",(function(){i=!1,$(".menu-fixed-detail li",e).removeClass("active"),$(this).parent().addClass("active");var a=$(this).attr("data-id"),n=$('.blog-detail [data-auto-menu="'+a+'"]',e).offset().top-t;n>o||(n-=$("#header").outerHeight()),o=n,$("html, body").stop().animate({scrollTop:n},300,(function(){i=!0}))}))),$("#auto-head-2",e).on("click",(function(){$("#auto-head-box",e).is("visible")?$(".popup-onpage",e).hide():($(".popup-onpage",e).show(),NoScroll())})),$(".box-index",e).on("click",".auto-head",(function(){$(".menu-auto-detail").is(":visible")?$(".menu-auto-detail").hide():$(".menu-auto-detail").show()}))}},swapLocationAutoMenu:function(e,t){let a=0;$(".cdn-location-menu",e).each((function(){let t=null;0==a&&(t=$("#auto-menu-default",e).html(),$("#auto-menu-default",e).remove()),$(this).replaceWith(t),a+=1})),"undefined"!=t&&t()}},articleInfinityScroll={eleCheckTop:null,timerTimeline:null,flag:!1,arrPage:[],arrUrl:[],delay:500,init:function(){var e=this,t=$(".box-detail-new");t.length>0&&(e.pushArr(),e.eleCheckTop=e.eleCheckTop||$(".end-block-content"),t.addClass("active"),e.arrPage.push({ele:t,title:document.title,url:window.location.pathname,top:0}),null!=e.eleCheckTop&&e.eleCheckTop.length>0&&$(window).on("scroll",e.scrollInit))},pushArr:function(){var e=$("#hdReadMore").val();if(null!=e){var t=JSON.parse(e);if(t.length>0)for(var a=0;a<t.length;a++)this.arrUrl.push("/ajax-detail/article-{randomId}".replace("{randomId}",t[a]))}},scrollInit:function(e){var t=articleInfinityScroll;t.timerTimeline&&(clearTimeout(t.timerTimeline),t.timerTimeline=null),t.timerTimeline=setTimeout((function(){for(var e=0;e<t.arrPage.length;e++)$(this).scrollTop().between(t.arrPage[e].top,e==t.arrPage.length-1?t.arrPage[e].top+t.eleCheckTop.offset().top:t.arrPage[e+1].top)&&(t.arrPage[e].ele.hasClass("active")||($(".box-detail-new").removeClass("active"),t.arrPage[e].ele.addClass("active")));if(!t.flag){var a=t.eleCheckTop.offset().top+t.eleCheckTop.height()-200;$(this).scrollTop()+$(this).height()>=a&&t.getData()}}),100)},getData:function(){var e=this;if(!e.flag){e.flag=!0;var t=e.arrUrl.shift();null!=t?$.ajax({type:"GET",url:t,beforeSend:function(){e.showLoading(!0)},success:function(t){null!=t&&t.length>50?e.successCallBack(t):$(".loader-loadmore").remove()},error:function(t,a,i){e.flag=!1}}):$(".loader-loadmore").remove()}},showLoading:function(e){var t=$(".loader-loadmore");e?t.removeClass("hide"):t.addClass("hide")},successCallBack:function(e){var t=this;$("#article-infinity").append(e),$(".box-detail-new:last .boxLead").remove(),t.eleCheckTop=$(".end-block-content:last");var a=$(".box-detail-new:last");t.arrPage.push({ele:a,title:a.data("title"),url:a.data("url"),top:a.offset().top}),t.flag=!1,t.showLoading(!1),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"VirtualPageview",virtualPageURL:a.data("url"),virtualPageTitle:a.data("title")}),a.height()>=640&&(a.addClass("hidden-news"),a.append('<a href="'+a.data("url")+'" class="bt-keep-reading" data-tracking = "yes" data-action = "Click Keep reading" data-page = "">Đọc tiếp</a>'),$(".bt-keep-reading",a).click((function(){a.removeClass("hidden-news"),$(this).remove();for(var e=0;e<t.arrPage.length;e++)t.arrPage[e].top=$(t.arrPage[e].ele).offset().top}))),"undefined"!=typeof fbClient&&fbClient.fbParse(a.find(".fb-like").parent()[0]),changeTableImageToSlider(a),$("div[data-type='slider-compare']",a).sliderCompare(),$("div[id*='player'][data-type='jwplayer']",a).playVideo(!1),$("div[data-type='embed']",a).playVideo(!1),$(".detail-review-car img",a).not(".dmca, .twentytwenty-before, .twentytwenty-after").lightGalleryNews(),VideoLibrary.Register(),$(".box-vote").length>0&&vote.Init(),$(".apexchart",a).length>0&&renderApexChart(a),$(".box-panorama-image",a).length>0&&panoramaImage.init(a),$(".box-reel-image",a).length>0&&reelImage.init(a),$("table",a).each((function(){!$($(this).parentElement).hasClass("divresponsive")&&$(this).is(":visible")&&$(this).wrap('<div class="divresponsive"></div>')})),$(".video-container").length>0&&($(".video-container").videoYoutubeLoadImage(),$(".video-container").videoYoutubeActive()),lazyLoading.init(),void 0!==articleDetail&&(articleDetail.slideImage(a),articleDetail.slideInContent(a),articleDetail.newsSource(a),articleDetail.boxAutoRelation(a),articleDetail.swapLocationAutoMenu(a,(()=>{articleDetail.autoMenuHeading(a)})),articleDetail.lazyLoadImage(a))}};