var HeaderMenuLeft={isHideBoxApp:!1,init:function(){HeaderMenuLeft.getHeaderMenu(),HeaderMenuLeft.searchHeader(),HeaderMenuLeft.boxDownloadAppAndroid(),$("#header").on("click",".button-user, .bg-user",(function(){HeaderMenuLeft.slideMenuLeft()})),$("#header").on("click",".user-profile",(function(){$(".user-menu",$("#header")).addClass("show"),$(".nav.show",$("#header")).removeClass("show"),$("#action-detail-auto").removeClass("show")})),$("#header").on("click",".button-menu, .bg-menu",(function(){HeaderMenuLeft.slideMenuRight()})),$("#RequestLockAccount").click((function(){$(".lockaccount-popup").fadeIn("slow"),$("body").addClass("no-scroll-other")})),$(".lockaccount-popup .closepopup, .lockaccount-popup .cancel").click((function(){$(".lockaccount-popup").fadeOut("slow"),$("body").removeClass("no-scroll-other")})),$(".lockaccount-popup .confirm").click((function(){$.ajax({type:"POST",cache:!1,url:"/member/sendmail-lockaccount",success:function(e){e.success}}),$(".lockaccount-popup").fadeOut("slow"),$("body").removeClass("no-scroll-other")})),$("#semore-seo").off("click").on("click",(function(){var e=$(this).attr("id");$("."+e).is(":visible")?($("."+e).hide(),$(this).html("Xem thêm")):($("."+e).show(),$(this).html("Rút gọn"))})),$(window).scroll((function(){0!=$(this).scrollTop()?$("#toTop").fadeIn():$("#toTop").fadeOut()})),$("#toTop").click((function(){return $("body,html").animate({scrollTop:0},1e3),!1}));var e=$("#box-International .swiper-container");if(e.length>0)new Swiper(e,{slidesPerView:"auto"})},initBoxApp:function(){var $wrap=$("#box-app"),isHideBoxApp=$.cookie("IsHideBoxApp");1==eval(isHideBoxApp)?($wrap.remove(),HeaderMenuLeft.isHideBoxApp=!0):("ios"==getMobileOperatingSystem()?$(".gg-store",$wrap).remove():$(".app-store",$wrap).remove(),HeaderMenuLeft.isHideBoxApp=!1,$("#header .header").addClass("top-86")),$wrap.off("click").on("click",".close",(function(e){e.preventDefault(),$.cookie("IsHideBoxApp","1",{expires:3}),HeaderMenuLeft.isHideBoxApp=!0,$("#header .header").removeClass("top-86"),$wrap.remove()}))},slideMenuRight:function(){$(".nav").hasClass("show")?($(".nav").removeClass("show"),$("body").css("overflow","auto"),$("#action-detail-auto").addClass("show"),$(".zalo-chat-widget").show()):($(".nav").addClass("show"),$(".user-menu.show").removeClass("show"),$("body").css("overflow","hidden"),$("#action-detail-auto").removeClass("show"),$(".zalo-chat-widget").hide())},slideMenuLeft:function(){$(".user-menu",$("#header")).hasClass("show")?($(".user-menu",$("#header")).removeClass("show"),$("body").css("overflow","auto"),$("#action-detail-auto").addClass("show"),$(".zalo-chat-widget").show()):($(".user-menu",$("#header")).addClass("show"),$(".nav.show",$("#header")).removeClass("show"),$("#action-detail-auto").removeClass("show"),$("body").css("overflow","hidden"),$(".zalo-chat-widget").hide())},getHeaderMenu:function(){$("#header").off("click").on("click",".button-menu, .button-user",(function(){var e=$(this);$("#header").hasClass("header-member")?($(".box-menu li").find("a").click((function(e){"javascript:void(0)"==$(this).attr("href")&&($(this).hasClass("open")?$(this).removeClass("open"):$(this).addClass("open"))})),$("#header").on("click",".box-menu i",(function(e){e.preventDefault();$(this);var o=$(this).parent();if("javascript:void(0)"!=o.attr("href"))if(o.hasClass("open")){o.removeClass("open");var t=o.parent();$("a",t).removeClass("open")}else o.addClass("open")})),$("#action-detail-auto").length>0&&$("#action-detail-auto").removeClass("show")):0==$("#header .box-menu").length?$.ajax({type:"GET",cache:!1,data:{},url:"/Home/HeaderMenu"+window.location.search,success:function(o){$("#header").append(o),HeaderMenuLeft.ShowHideAutoSavingBar(),e.hasClass("button-user")&&HeaderMenuLeft.slideMenuRight(),setTimeout((function(){$(".box-menu li").find("a").click((function(e){"javascript:void(0)"==$(this).attr("href")&&($(this).hasClass("open")?$(this).removeClass("open"):$(this).addClass("open"))})),$("#header").on("click",".box-menu i",(function(e){e.preventDefault();$(this);var o=$(this).parent();if("javascript:void(0)"!=o.attr("href"))if(o.hasClass("open")){o.removeClass("open");var t=o.parent();$("a",t).removeClass("open")}else o.addClass("open")})),$("#action-detail-auto").length>0&&$("#action-detail-auto").removeClass("show"),HeaderMenuLeft.slideMenuLeft()}),500)}}):$("#action-detail-auto").length>0&&$("#action-detail-auto").removeClass("show")}))},activemenuleft2:function(){var e=window.location.href.toLowerCase(),o=null;if("/phien-ban"==(e="/"+(e=e.replace("http://m.oto.com.net/","").replace("http://m.oto.com.org/","").replace("http://m.oto.com.vn/","").replace("https://m.oto.com.vn/","").replace("https://m.oto.com.org/","").replace("http://m.oto.com.org/","").replace("http://s49.m.banxehoi.org/","").replace("http://oto.com.net/","").replace("http://oto.com.vn/","").replace("https://oto.com.vn/","").replace("https://oto.com.org/","").replace("http://oto.com.org/","")))?e="/mua-ban-xe":-1!=e.indexOf("/xe-moi")&&"/xe-moi"==e.substring(0,7)?e="/tin-tuc/xe-moi":-1!=e.indexOf("/xe-")&&"/xe-"==e.substring(0,4)||-1!=e.indexOf("/mua-ban-xe")&&"/mua-ban-xe"==e.substring(0,11)?e="/mua-ban-xe":-1!=e.indexOf("/salons")?e="/salons":-1!=e.indexOf("/danh-ba-nha-kinh-doanh-xe")&&(e="/danh-ba-nha-kinh-doanh-xe"),$(".box-menu ul li a").each((function(){-1==e.indexOf("/member/dang-tin-ban-xe")&&null!=$(this).attr("data-key")&&e.indexOf($(this).attr("data-key").toLowerCase())>-1&&(null==o||o.href.length<=this.href.length)&&(o=this)})),null!=o){if($(o).closest(".sub-menu").length>0)for(var t=$(o).closest(".sub-menu");t.length>0;){var a=t.parent();$("a",a).first().addClass("open"),t=a.closest(".sub-menu")}(o=$(o)).addClass("active")}},searchHeader:function(){$("#btnheadersearch").click((function(e){$("#txtKeyword").val().length>0?execSearchListAuto():(historySuggestSearch.isHidePopup=!1,$("#txtKeyword").focus())})),$("#txtKeyword").keypress((function(e){13==e.which&&(e.preventDefault(),execSearchListAuto())})),$(".submit").click((function(){execSearchListAuto()}))},boxDownloadAppAndroid:function(){var isNewSession=$("#hddIsNewSession");isNewSession="True"==isNewSession,isNewSession&&$.cookie("IsNewSession",1,{path:"/",expires:365});var closeAppValue=$.cookie("CloseDownloadApp");null!=closeAppValue&&1==closeAppValue&&$(".downloadapp").remove();var closeTopBankValue=$.cookie("CloseTopBank");null!=closeTopBankValue&&1==closeTopBankValue&&$(".topbank").remove(),$(".bannerclose").each((function(){var e=$(this).attr("data-id"),o=$.cookie("CloseBanner"+e);null!=o&&1==o&&$("."+e).remove()}));var isHaveBanner=$("#hddIsHaveBaner").val(),isBannerFooterMake=eval(isHaveBanner?"true":"false");isBannerFooterMake&&($(".downloadapp").remove(),$(".topbank").remove(),$(".bannerclose").each((function(){var e=$(this).attr("data-id"),o=$.cookie("CloseBanner"+e);null!=o&&1==o&&$("."+e).remove()})),void 0!==$.cookie("IsNewSession")&&1==$.cookie("IsNewSession")&&($.cookie("StickFooterBannerIndex",3,{path:"/",expires:1}),$.cookie("IsNewSession",0,{path:"/",expires:365}))),$(".imgcloseapp").click((function(){"undefined"==typeof timeExpires?($.cookie("CloseDownloadApp",1,{path:"/",expires:2}),$.cookie("TimeExpireDownloadApp",15,{path:"/"})):$.cookie("CloseDownloadApp",1,{path:"/",expires:15}),$(".downloadapp").hide()})),$(".topbank-close").click((function(){$.cookie("CloseTopBank",1,{path:"/"}),$(".topbank").hide()})),$(".imgdownloadapp").click((function(){$.cookie("ReadyDownloadApp",1,{path:"/"})})),$(".bannerclose").click((function(){var e=$(this).attr("data-id");$("."+e).hide(),$.cookie("CloseBanner"+e,1,{path:"/",expires:1}),$(".ctrl-bottom-btn").is(":visible")&&$(".ctrl-bottom-btn").css("bottom",0)})),$.fn.multibanner("StickFooterBanner");var bannerHeight=0;$(".StickFooterBanner").length>0&&17!=parseInt(pageType)&&$(window).on("load",(function(){for(i=0;i<$(".StickFooterBanner").length;i++)if($(".StickFooterBanner:eq("+i+")").is(":visible")){if(bannerHeight=$(".StickFooterBanner:eq("+i+")").height(),$(".button-Utilities").length>0){var e=$(".button-Utilities").height();bannerHeight+=e,$(".StickFooterBanner:eq("+i+")").css("bottom",e+"px")}break}$("#toTop").css("bottom",bannerHeight+50),$("#toTop").css("margin-bottom",0),$(".ctrl-bottom-btn").css("bottom",bannerHeight)})),$(".bannerView").each((function(){if($(this).is(":visible")){var e=$(this).attr("id").replace("bannerid-",""),o=document.createElement("img");o.async=!0,o.src=websiteDomain+"/viewcount/10/"+e,o.width=1,o.height=1;var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(o,t)}}))},ShowHideAutoSavingBar:function(){var e=$.cookie("SavingAutoIDs");if(void 0!==e&&(e=e.mystringtrim(",")),null==e||""==e)$(".head-nav #BoxAutoSaved").hide();else{var o='<i class="icon-heart-empty"></i> '+e.split(",").length+" tin";$("#BoxAutoSaved .saved").html(o)}}};$(document).ready((function(){HeaderMenuLeft.init()}));