function getCookie(t){for(var a=t+"=",e=document.cookie.split(";"),i=0;i<e.length;i++){var n=e[i].replace(/^\s+|\s+$/g,"");if(0==n.indexOf(a))return n.substring(a.length,n.length)}return""}function round(t){return(2*t).toFixed()/2}function removeTooltiplabel(){$(".tooltiplabel").remove(),$(".tooltip-arrow").remove()}$.fn.userRate=function(parameters){var _this=$(this),rate=parameters.defaultrate||0,avgrate="#avgrate",countrate="#countrate",totalRate="#TotalRate";if(null!=parameters.avgrate&&null!=parameters.avgrate&&(avgrate=parameters.avgrate),null!=parameters.countrate&&null!=parameters.countrate&&(countrate=parameters.countrate),null!=parameters.totalRate&&null!=parameters.totalRate&&(totalRate=parameters.totalRate),eval(rate)>0){for(var html="",i=1;i<=5;i++){var half=i-.5;i<=rate?(html+='<i class="icon-star">',html+='   <span class="rating" data-rate="'+half+'"></span>',html+='   <span class="rating" data-rate="'+i+'" ></span> ',html+="</i> "):half==rate?(html+='<i class="icon-star icon-star-half-alt">',html+='   <span class="rating" data-rate="'+half+'"></span>',html+='   <span class="rating" data-rate="'+i+'" ></span> ',html+="</i> "):(html+='<i class="icon-star-empty">',html+='   <span class="rating" data-rate="'+half+'"></span>',html+='   <span class="rating" data-rate="'+i+'" ></span> ',html+="</i> ")}_this.html(html),$(avgrate).text(parameters.defaultrate),$(countrate).text(parameters.newCountRate),$(totalRate).val(parameters.newTotalRate)}},$.fn.defaultRate=function(parameters){var _this=$(this),rate=parameters.defaultrate||0;if(eval(rate)>0){for(var html="",i=1;i<=5;i++){var half=i-.5;i<=rate?(html+='<i class="icon-star">',html+='   <span class="rating" data-rate="'+half+'"></span>',html+='   <span class="rating" data-rate="'+i+'" ></span> ',html+="</i> "):half==rate?(html+='<i class="icon-star-half-alt">',html+='   <span class="rating" data-rate="'+half+'"></span>',html+='   <span class="rating" data-rate="'+i+'" ></span> ',html+="</i> "):(html+='<i class="icon-star-empty">',html+='   <span class="rating" data-rate="'+half+'"></span>',html+='   <span class="rating" data-rate="'+i+'" ></span> ',html+="</i> ")}_this.parent().parent().html(html),$("#ratingsucess").show()}},$.fn.rating=function(parameters){var _this=$(this),_type=parameters.type||0,_makeID=parameters.makeID||0,_modelID=parameters.modelID||0,_year=parameters.year||0,_detailID=parameters.detailID||0,_userID=parameters.userID||0,_authorId=parameters.authorID||0,cookieName=_type+"_"+_makeID+"_"+_modelID+"_"+_year+"_"+_detailID+"_"+_userID;parseInt(_authorId)>0&&(cookieName=_type+"_"+_authorId+"_"+_userID);var valueRating=getCookie(cookieName)||0,countRating=getCookie("CountRate_"+cookieName)||0,idUseVote="#useVote",countrate="#countrate",avgrate="#avgrate",totalRate="#TotalRate",ratingsucess="#ratingsucess",_idUseVote=parameters.idUseVote;if("ArticlePrice"==parameters.typeVote&&(idUseVote="#"+(null==$(_idUseVote).attr("id")?"useVote":$(_idUseVote).attr("id")),countrate="#"+(null==$(parameters.countrate).attr("id")?parameters.countrate:$(parameters.countrate).attr("id")),avgrate="#"+(null==$(parameters.avgrate).attr("id")?parameters.avgrate:$(parameters.avgrate).attr("id")),totalRate="#"+(null==$(parameters.totalRate).attr("id")?parameters.totalRate:$(parameters.totalRate).attr("id")),ratingsucess="#"+(null==$(parameters.ratingsucess).attr("id")?parameters.ratingsucess:$(parameters.ratingsucess).attr("id"))),isNaN(countRating)&&(countRating=0),0==valueRating)_this.mouseover((function(){var t=parseFloat($(this).data("rate")),a=parseInt(t);_this.each((function(){var e=$(this).data("rate");e<=a?$(this).parent().attr("class","icon-star"):e<=t+.5?$(this).parent().attr("class","icon-star-half-alt"):$(this).parent().attr("class","icon-star-empty")}))})).mouseout((function(){var t=parseFloat($("#RatePoint").text().replace(",",".").replace(".0","")),a=parseInt(t);_this.each((function(){var e=$(this).data("rate");e<=a?$(this).parent().attr("class","icon-star"):e<=t+.5?$(this).parent().attr("class","icon-star-half-alt"):$(this).parent().attr("class","icon-star-empty")}))})).click((function(){var _rate=$(this).data("rate"),data={type:_type,makeID:_makeID,modelID:_modelID,year:_year,detailID:_detailID,rate:_rate},url="/rating-click";parseInt(_authorId)>0&&(data={authorId:_authorId,rate:_rate},url="/Rate/ClickRateAuthor"),0==valueRating?$.post(url,data,(function(result){let newRate=0;if(result.Result)newRate=_rate;else{if($(ratingsucess).text(result.Message),$(ratingsucess).show(),newRate=result.Rate,parseInt(newRate)>0==!1)return;alert(result.Message)}$(ratingsucess).show(),document.cookie=cookieName+"="+newRate+";path=/;",$(_this).defaultRate({defaultrate:newRate});var _countrate=0,_totalRate=0,_newCountRate=0,_newAvgRate=0,_newTotalRate=0;_countrate=eval($(countrate).text()),_totalRate=eval($(totalRate).val()),_newCountRate=eval(_countrate+1),_newTotalRate=eval(_totalRate+newRate),_newAvgRate=round(_newTotalRate/_newCountRate),document.cookie="CountRate_"+cookieName+"="+_newCountRate+";path=/;",$(idUseVote).userRate({defaultrate:_newAvgRate,newCountRate:_newCountRate,newTotalRate:_newTotalRate,avgrate:avgrate,countrate:countrate,totalRate:totalRate})})):($(ratingsucess).text("Bạn đã đánh giá trang này rồi!"),$(ratingsucess).show())}));else{$(_this).defaultRate({defaultrate:valueRating}),countRating=eval(countRating),valueRating=eval(valueRating);var _countrate=0,_totalRate=0,_newAvgRate=0,_newTotalRate=0;_countrate=eval($(countrate).text()),_totalRate=eval($(totalRate).val()),countRating>1?(_newTotalRate=eval(_totalRate+valueRating),_newAvgRate=round(eval(_newTotalRate)/eval(countRating)),$(idUseVote).userRate({defaultrate:_newAvgRate,newCountRate:countRating,newTotalRate:_newTotalRate,avgrate:avgrate,countrate:countrate,totalRate:totalRate})):$(idUseVote).userRate({defaultrate:valueRating,newCountRate:countRating,newTotalRate:_totalRate,avgrate:avgrate,countrate:countrate,totalRate:totalRate})}},$.fn.multibanner=function(className){var showMultiBanner=function(t,a){$("."+t).hide(),$($("."+t)[a]).show(),saveCookieMultiBanner(t,a)},saveCookieMultiBanner=function(t,a){var e=new Date;e.setTime(e.getTime()+864e5);var i="expires="+e.toUTCString();document.cookie=t+"Index="+a+"; "+i+"; path=/"},index=getCookie(className+"Index");""!=index?(index=eval(index)+1,index>=$("."+className).length&&(index=0)):index=0,showMultiBanner(className,index)},$.fn.syncHeight=function(t){if(""!=t&&"undefined"!=t&&null!=t){var a=0,e=t;$(this).each((function(t){if($(this).is(":visible")){var i=$($(e)[t]).height();i>a&&(a=i),t%3==2&&($($(e)[t]).height(a),$($(e)[t-1]).height(a),$($(e)[t-2]).height(a),a=0)}}))}else{a=0;$(this).each((function(){if($(this).is(":visible")){var t=$(this).height();t>a&&(a=t)}})),$(this).each((function(){$(this).height(a)}))}return this},$.fn.syncOuterHeight=function(t){if(""!=t&&"undefined"!=t&&null!=t){var a=0,e=t;$(this).each((function(t){if($(this).is(":visible")){var i=$($(e)[t]).outerHeight();i>a&&(a=i),t%3==2&&($($(e)[t]).height(a),$($(e)[t-1]).height(a),$($(e)[t-2]).height(a),a=0)}}))}else a=0,$(this).each((function(){if($(this).is(":visible")){var t=$(this).outerHeight();t>a&&(a=t)}})),$(this).each((function(){$(this).height(a)}));return this},String.prototype.mystringtrim=function(t){var a=this;return null==a||null==t||0==a.length||0==t.length?a:(a.substring(a.length-1)==t&&(a=a.substring(0,a.length-1)),a.substring(0,1)==t&&(a=a.substring(1)),a.toString())},$.fn.pricemask=function(maxleng){$(this).keyup((function(){var val=$(this).val().replace(/\./g,"").replace(/,/g,"");void 0!==maxleng&&"undefined"!=maxleng&&eval(maxleng)>0&&val.length>maxleng&&(val=val.substr(0,maxleng)),$(this).val(val).formatCurrency({roundToDecimalPlace:-1,symbol:""}),val=$(this).val().replace(/,/g,"."),$(this).val(val)}))},$.fn.numbersOnly=function(){this.keyup((function(){this.value=this.value.replace(/[^0-9]/g,"")}))},$.fn.numbersOnly2=function(){this.keyup((function(){this.value=this.value.replace(/[^0-9\.]/g,"")}))},$.fn.monthOnly2=function(){this.keyup((function(){var val=$(this).val().replace(/[^0-9\.,]/g,"").replace(/\./g,"").replace(/,/g,"");eval(val)>84&&(val=84),$(this).val(val)}))},$.fn.numbersFloatOnly2=function(maxleng,maxValue){$(this).keyup((function(){var val=$(this).val();val=val.replace(/[^0-9\.,]/g,""),(val.indexOf(".")<val.indexOf(",")&&val.indexOf(".")>0||val.indexOf(",")<val.indexOf(".")&&val.indexOf(",")>0)&&(val=val.substr(0,val.length-1));var temp=val.split("."),temp2=val.split(",");if((temp.length>2||temp2.length>2)&&(val=val.substr(0,val.length-1)),void 0!==maxleng&&"undefined"!=maxleng&&eval(maxleng)>0&&val.length>maxleng&&(val=val.substr(0,maxleng)),val.indexOf(".")==val.length-1||val.indexOf(",")==val.length-1){var temp=val.substr(0,val.length-1);eval(temp)>=maxValue&&(val=maxValue)}else eval(val)>=maxValue&&(val=maxValue);$(this).val(val)}))},$.fn.replaceDetailHideMobile=function(){var t=$(this).html();if(t.indexOf("callMobile")<0){var a=t.match(/(03|05|07|08|09)+([0-9]{8})/g);if(null!=a&&null!=a){for(var e=a.filter((function(t,a,e){return a===e.indexOf(t)})),i=0;i<e.length;i++){var n=(s=e[i]).substring(0,s.length-3)+" ***",r='<span class="realcall mobile iscontent" data-phone="'+s+'" onclick="callMobile(this)" data-value="Hiện số">'+n+"</span>";const a=new RegExp(s,"g");t=t.replace(a,r)}$(this).html(t)}else{var s;if(null!=(s=$(".phone-contact a").attr("data-phone"))&&""!=s){n=s.substring(0,s.length-3)+" ***";t+='<br/>Liên hệ :<span class="realcall mobile iscontent" data-phone="'+s+'" onclick="callMobile(this)" data-value="Hiện số">'+n+"</span>",$(this).html(t)}}}},$.fn.CheckContent=function(){$(this).each((function(t,a){isEmpty($(this))&&$(this).parent().hide()}))},$.fn.tabs=function(){this.click((function(t){var a=$(this).attr("data-id");return $(this).siblings().removeClass("active"),$(this).addClass("active"),$("#"+a).siblings().hide(),$("#"+a).show(),!1}))},$.fn.tabs_v2=function(){this.click((function(t){var a=$(this).attr("data-id");$(this).siblings().removeClass("active"),$(this).addClass("active");var e=$("#"+a).siblings("[data-tab='tabs']");return $(e).hide(),$("#"+a).show(),!1}))},$.fn.tabs_v3=function(t=""){var a=$(this);a.off("click").on("click","li",(function(){if(!$(this).hasClass("active")){a.find("li").removeClass("active"),$(this).addClass("active");var e=$(this).data("id");$("#"+e,t).siblings().hide(),$("#"+e,t).show()}}))},$.fn.sliderCompare=function(){this.each((function(){var t=$(this),a=t.width()/t.height(),e=t.parent().width(),i=0;i=a>=4/3&&a<1.5?parseInt(3*e/4,0):a>=1.5&&a<16/9?parseInt(2*e/3,0):parseInt(9*e/16,0),t.css("width",e+"px"),t.css("height",i+"px"),t.css("border","none"),t.find("img").each((function(){var t=$(this);t.css("width",e),t.css("height",i)})),t.addClass("twentytwenty-container").twentytwenty({default_offset_pct:.7})}))},$.fn.playVideo=function(t){t||(t=!1),this.each((function(){var a=$(this),e=(a.attr("data-type"),a.attr("data-video")),i=(a.attr("data-width"),a.attr("data-height"),a.attr("data-image"));i||(i="");var n="";if(-1!=e.indexOf("https://youtu.be/")||-1!=e.indexOf("https://www.youtube.com/watch?v=")||-1!=e.indexOf("https://youtube.com/watch?v=")){var r=(e=(e=(e=e.replace("https://youtu.be/","https://www.youtube.com/embed/")).replace("https://www.youtube.com/watch?v=","https://www.youtube.com/embed/")).replace("https://youtube.com/watch?v=","https://www.youtube.com/embed/")).indexOf("&");-1!=r&&(e=e.substring(0,r)),n='<div style="position:relative;height:0;padding-bottom:56.25%;margin-bottom:10px; "><iframe  style="position:absolute;width:100%;height:100%;left:0" src=\''+e+"?showinfo=0&mute=1&autoplay="+t+"' frameborder='0' allowfullscreen></iframe><div>"}a.after(n),a.remove()})),$("#box-big-video .image").length>0&&($("#box-big-video .image").data("width","100%").css("width","100%").data("height","100%").css("margin",0).css("border","none").css("height","calc((100vw - 20px)*9/16)"),$("#box-big-video .image iframe").attr("width","100%").css("width","100%").attr("height","100%").css("height","calc((100vw - 20px)*9/16)"))},$.fn.lightGalleryNews=function(){try{$(this).length;$(this).each((function(t){0;var a=$(this),e=(a.attr("title"),"");if(void 0!==(i=a.attr("data-src"))?e=i:"undefined"!=a.attr("src")&&null!=a.attr("src")&&(e=a.attr("src").replace("/crop/749x419","")),"/assets/img/video.png"!=e&&"/assets/img/embed.png"!=e&&"/content/images/video.png"!=e&&"/images/gl.png"!=e&&"/images/fb.png"!=e){var i,n=a.parent();if(n.hasClass("lozadload-content"))void 0!==(i=a.attr("data-src"))?n.replaceWith("<a data-src='"+i+"' title = '' class='imageGallery' id='imageGallery-"+t+"'>"+n.prop("outerHTML")+"</a>"):n.replaceWith("<a data-src='"+e+"' title = '' class='imageGallery' id='imageGallery-"+t+"'>"+n.prop("outerHTML")+"</a>");else a.replaceWith("<a data-src='"+e+"' title = '' class='imageGallery' id='imageGallery-"+t+"'>"+this.outerHTML+"</a>");lazyLoading.init()}})),$(".detail-review-car").lightGalleryFun(),$(".prettyPhotoFrame").lightGalleryFun()}catch(t){console.log(t)}},$.fn.lightGalleryFun=function(t){$(this).lightGallery({desc:!0,loop:!0,dot:!0,escKey:!0,thumbnail:!1,lang:{allPhotos:"Tất cả ảnh"},selector:".imageGallery"})},$.fn.videoYoutubeLoadImage=function(){$(this).each((function(){var t=$(this),a=$(".rll-youtube-player",t),e=a.attr("data-id");a.css("background-image","url('https://i.ytimg.com/vi/"+e+"/sddefault.jpg')")}))},$.fn.videoYoutubeActive=function(){$(this).off().on("click",(function(){var t=$(this);t.addClass("clean-before-after");var a=$(".rll-youtube-player",t);dataSrc=a.attr("data-src");var e=document.createElement("iframe");e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen",""),e.setAttribute("src",dataSrc+"?rel=0&showinfo=0&autoplay=1"),t.html(""),t.append(e)}))},$.fn.CheckLogoError=function(){var t=$(this),a=t.attr("src"),e=new Image;e.addEventListener("onload",(function(){})),e.addEventListener("error",(function(){t.attr("src","https://img1.oto.com.vn/Static/Images/v3/logo-branch/logo-oto.png")})),e.src=a},$.fn.tabsupcoming=function(){this.click((function(t){var a=$(this).attr("data-id");return $(".upcomingtabs .active").removeClass("active"),$(this).addClass("active"),$(".upcoming_container .box").hide(),$(".upcoming_container ."+a).show(),new Swiper($("."+a+" .swiper-container"),{pagination:"."+a+" .swiper-pagination",nextButton:"."+a+" .swiper-button-next",prevButton:"."+a+" .swiper-button-prev",paginationClickable:!1,paginationType:"fraction"}),!1}))},$.fn.tooltiplabel=function(t=0){var a=$(this).attr("data-title");if(null!=a&&null!=a&&""!=a){t=0==t?220:t,$(this).after('<div class="tooltiplabel" style="width:'+t+'px;"></div><div class="tooltip-arrow"><img src="https://img1.oto.com.vn/Static/Images/v4/vector_1.png" /></div>'),$(".tooltiplabel").html(a);var e=$(this).position().top+$(this).outerHeight()+$(".tooltip-arrow").outerHeight();$(".tooltiplabel").css("top",e+"px");var i=$(this).position().left-($(".tooltiplabel").outerWidth()-$(this).outerWidth());i<0&&(i=0),$(".tooltiplabel").css("left",i+"px"),$(".salon-badges").is($(this))?$(".tooltip-arrow").css("left",$(this).position().left+$(this).outerWidth()/3):$(".tooltip-arrow").css("left",$(this).position().left+$(this).outerWidth()-40),$(".tooltip-arrow").css("top",$(this).position().top+$(this).outerHeight()+4)}},$.fn.playVideoFacebook=function(t){this.each((function(){var a=$(this),e="";/http(?:s?):\/\/(?:www\.)?facebook\.com\/(?:video\?v=\d+|.*?\/videos\/\d+)\/?$/.test(t)&&(e='<div class="fb-video videoplayer" data-href="'+t+'" data-width="458" data-height="344" data-allowfullscreen="true" ></div >'),a.html(e)}))};