function refreshNewCaptcha(n){$("#"+n).attr("src","/HandlerWeb/CaptchaHandler.ashx?t="+(new Date).getMilliseconds())}function HideSubscribe(n){$(".subscribe-suggestion-container").hide();setCookieHideSubscribePopup(n)}function CheckExistCookieHideSubscribe(n){var t="hidePopupSubscribeId"+n,i=Utility.GetCookie(t);return i!=""?!0:!1}function setCookieHideSubscribePopup(n){var t="hidePopupSubscribeId"+n;Utility.SetCookie(t,!0,1);$("#popup").empty()}function ClosePopup(){$("#popup").empty();CommonsEvent.RemoveNoScroll()}function ClosePopup(){$("#popup").empty();$("body").removeClass("no-scroll")}function setCookieHideBanner(n){var t="hideBannerId"+n;Utility.SetCookie(t,!0,1)}function checkCookieIsHideBanner(n){var t="hideBannerId"+n;return Utility.CheckCookie(t)}function parseFromPriceCode(n){var t=/\d+/g,i=undefined,r=undefined,u;return!n||n==="0"||n.trim()===""||(n.indexOf("mlt")>-1?r=n.match(t).join([]):n.indexOf("mgt")>-1?i=n.match(t).join([]):(u=n.split("-"),i=u[0].match(t).join([]),r=u[1].match(t).join([]))),{minprice:i,maxprice:r}}function checkTermAndConditionPopup(n){if(typeof n!="undefined"&&n!=""&&$("#popup").length>0)$("#popup").on("change","#termsAgreedPopup",function(){$(this).is(":checked")?$(n,"#popup").removeClass("readonly-btn"):$(n,"#popup").addClass("readonly-btn")})}function checkTermAndConditionPopupOtherButton(n,t){if(typeof n!="undefined"&&n!=""&&$(t).length>0)$(t).on("change",".termsAgreedPopup",function(){$(this).is(":checked")?$(n,t).removeClass("readonly-btn"):$(n,t).addClass("readonly-btn")})}var Utility={EscapeRegExp:function(n){return n.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")},EncodeTextSearch:function(n){return n.replace(/[&\/\\#,+()$~%.'":*?<>{}^@]/g,"")},SetCookie:function(n,t,i,r){var u,f;i?(u=new Date,u.setTime(u.getTime()+i*864e5),f="expires="+u.toUTCString(),document.cookie=n+"="+t+";"+f+";path=/",document.cookie=r?n+"="+t+";"+f+";max-age="+r+";path=/":n+"="+t+";"+f+";path=/"):document.cookie=r?n+"="+t+";max-age="+r+";path=/":n+"="+t+";path=/"},GetCookie:function(n){for(var r=n+"=",f=decodeURIComponent(document.cookie),u=f.split(";"),t,i=0;i<u.length;i++){for(t=u[i];t.charAt(0)==" ";)t=t.substring(1);if(t.indexOf(r)==0)return t.substring(r.length,t.length)}return""},CheckCookie:function(n){const t=this;let i=t.GetCookie(n);return i!=""?!0:!1},DeleteCookie:function(n){const i=this;let t=i.GetCookie(n);t&&(document.cookie=n+"="+t+"; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;")},RemoveHtmlTags:function(n){return n!=""?n.replace(/<[^>]*>/g,""):n},ValidateEmail:function(n){return/^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9_]+)*)@([A-Za-z0-9]+)(([\.\-‌​]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$/.test(n)},ValidateNumber:function(n){return/^[0-9]+$/.test(n)},ValidateLinkYoutube:function(n){return/^(?:http(?:s) ?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&\''<> #]+)/.test(n)},ValidateLinkFacebook:function(n){return/^(https?:\/\/)?(www\.)?facebook.com\/[a-zA-Z0-9(\.\?)?]/.test(n)},IsDoubleClicked:function(n,t){return n.data("isclicked")?!0:(t=typeof t!="undefined"?t:100,n.data("isclicked",!0),setTimeout(function(){n.removeData("isclicked")},t),!1)},FormatPrice:function(n){n+="";for(var i=n.split("."),t=i[0],u=i.length>1?"."+i[1]:"",r=/(\d+)(\d{3})/;r.test(t);)t=t.replace(r,"$1,$2");return t+u},scrollToBottom:function(n){if(!($("#"+n).length<1)){var t=document.getElementById(n);$("#"+n).animate({scrollTop:t.scrollHeight-t.clientHeight},500)}},scrollToTop:function(n,t){$("#"+n).animate({scrollTop:t!=undefined?t:0},300)},formatPhoneNumber:function(n){var t=n.length;return t>8&&t<12&&(n=n.insertAt(t-4,"-"),n=n.insertAt(t-7,"-")),n},RemoveHashTag:function(){if(window.location.hash="",window.history.pushState){var n=document.location.href.replace("#","");window.history.replaceState(null,null,n)}}},tabUtilities,loginSuggest,markSoldPopup,OneSignalApp,oneSignalStatus,PostForm;$.fn.numbersOnly=function(){this.keyup(function(){this.value=this.value.replace(/[^0-9]/g,"")})};$.fn.pricemask=function(){$(this).keyup(function(){var n=$(this).val().replace(/\./g,"").replace(/,/g,"");$(this).val(n).formatCurrency({roundToDecimalPlace:-1,symbol:""});n=$(this).val().replace(/,/g,",");$(this).val(n)})};String.prototype.replaceAll=function(n,t){var i=this;return i.replace(new RegExp(n,"g"),t)};String.prototype.replaceAllToLower=function(n,t){var i=this;return i.replace(new RegExp(n,"gi"),t)};String.prototype.insertAt=function(n,t){return this.substr(0,n)+t+this.substr(n)};$.fn.slidingTabMenu=function(){var n=this,t=[],i=$(n).children().length;$(n).children().click(function(){var e=this,f=$(e).index(),r,u;for($(n).children().each(function(){t.push($(this).outerWidth())}),r=0,u=0;u<f;u++)r+=t[u];f!==0&&f!==i-1&&(r+=($(e).outerWidth()-$(n).outerWidth())/2);$(n).animate({scrollLeft:r},200)})};$.fn.serializeObject=function(){var n={},t=this.serializeArray();return $.each(t,function(){n[this.name]!==undefined?(n[this.name].push||(n[this.name]=[n[this.name]]),n[this.name].push(this.value||"")):n[this.name]=this.value||""}),n};$.fn.trimSpace=function(){$(this).on("blur focus",function(){$(this).val($.trim($(this).val()))})};var GtmUtils={pushOtpFailedEvent:function(n,t){window.dataLayer=window.dataLayer||[];window.dataLayer.push({event:"insurance_OTP_not_successful",phoneNumber:n,email:t})},pushEmailSubmission:function(n,t){window.dataLayer=window.dataLayer||[];window.dataLayer.push({event:n,email:t})},pushDataEvent:function(n){console.log(n);window.dataLayer=window.dataLayer||[];window.dataLayer.push(n)},formatCurrency:function(n){$(n).val($(n).val()).formatCurrency({roundToDecimalPlace:-1,symbol:""})}},CommonsEvent={InitLozadLoadImg:function(n){let t="img.lazy, img.lazy-hidden, .lazy-no-bg, .lozad";if(!n||(t=n+" .lazy, "+n+" .lazy-hidden, "+n+" .lazy-no-bg, "+n+" .lozad"),t.indexOf(".lozad")>-1){let n=lozad(t,{rootMargin:"10px 0px",threshold:.1});n.observe()}else{let n=lozad(t,{threshold:.1});n.observe()}},ShowPopup:function(){$("#popup").show();CommonsEvent.AddNoScroll()},ClosePopup:function(){$("#popup").empty();CommonsEvent.RemoveNoScroll()},AddNoScroll:function(){$("body").addClass("no-scroll")},RemoveNoScroll:function(){$("body").removeClass("no-scroll")},Loading:function(){$("#loadding").html('<div class="bg-popup-loading"> <img src="/ContentV2/Wap/img/loading300.gif" alt="loading" class="loading"/><\/div><div class="modal-backdrop in"><\/div>');CommonsEvent.AddNoScroll()},Loaded:function(){$("#loadding").empty();CommonsEvent.RemoveNoScroll()},ReloadPage:function(){document.location.reload()},RedirectPage:function(n){window.location.href=n!=""&&n!=undefined?n:"/"},RefreshCaptcha:function(n){$("#"+n).attr("src","/HandlerWeb/CaptchaHandler.ashx?t="+(new Date).getMilliseconds())},RefreshCaptchaPrefix:function(n,t){$("#"+n).attr("src","/HandlerWeb/CaptchaHandlerV2.ashx?type="+t+"&t="+(new Date).getMilliseconds())},LogOut:function(){window.location.href="/account/logout"},initLightGalleryV2:function(){$("#lightgallery").length>0&&$("#lightgallery").lightGallery({showThumbByDefault:!1})},initLightGalleryByBoxId:function(n){$(".lightgallery",n).length>0&&$(".lightgallery",n).lightGallery({showThumbByDefault:!1})},initEventClickLightGallery:function(n){$(n+" .show-img img").click(function(){var t=$(this).attr("rel");$(n+" #"+t).click()})},getLocationIP:function(n){try{jQuery.get("https://ipinfo.io",function(t){if(typeof t!="undefined")return console.log("Location IP = "+t.ip),n(t.ip)},"jsonp")}catch(t){console.log("Cannot get location IP, error: "+t)}return""},submitDataLayer:function(n,t,i,r,u,f){try{n||(n="");t||(t="");i||(i="");r||(r=0);u||(u=0);f||(f=0);let e={event:n,action:t,pageType:i,productID:r,sellerID:u,userID:f};typeof GtmUtils!="undefined"&&GtmUtils.pushDataEvent(e)}catch(e){console.error("Exception : Common => CommonsEvent.submitDataLayer() => "+e)}}},mapDirection={getDirectionForm:function(n,t){$.ajax({type:"GET",url:"/Auto/GetDirection?sellerId="+n,success:function(n){t(n)}})},getDirectionLink:function(n,t){return!n||!t||n.trim()===""||t.trim()===""?"":"https://www.google.com/maps?saddr="+encodeURIComponent(n).replace(/[!'()*]/g,escape)+"&daddr="+encodeURIComponent(t).replace(/[!'()*]/g,escape)},getLocationLink:function(n,t){return"http://www.google.com/maps/place/"+n+","+t}},userAddress={saveUserAddress:function(n,t){$.ajax({type:"POST",url:"/MyAccount/SaveUserAddress",data:n,success:function(n){t(n)},error:function(){t({Title:"An error occurred! Please try again later!",Error:!0})}})}},phoneNumberValidate={MobilePhoneRegex:new RegExp(/^(09|08)\d{9}$/),PhoneRegex:new RegExp(/^0\d{9,10}$/),PhoneNumberEg:"eg: 09012345678 | 08112345678",isValidMobilePhoneNumber:function(n){return phoneNumberValidate.MobilePhoneRegex.test(n)}},emailValidate={EmailRegex:new RegExp(/^[\w+][\w\.\-]+@[\w\-]+(\.\w{2,4})+$/),isValidEmail:function(n){return emailValidate.EmailRegex.test(n)}};if(typeof refreshCaptcha!="function"){function refreshCaptcha(){refreshNewCaptcha("imgCaptchaNew")}}tabUtilities={Init:function(){var n=tabUtilities.GetCurrentTabCount();n++;$.cookie("OpenTabCount",n,{path:"/"});$(window).on("beforeunload",function(){n=tabUtilities.GetCurrentTabCount();n>0&&n--;$.cookie("OpenTabCount",n,{path:"/"});tabUtilities.OnTabCloseCallbacks.forEach(function(n){n()})})},GetCurrentTabCount:function(){var n=$.cookie("OpenTabCount");return n===undefined&&(n=0),parseInt(n)},OnTabCloseCallbacks:[],BindOnTabClose:function(n){n instanceof Function&&tabUtilities.OnTabCloseCallbacks.push(n)}};loginSuggest={Init:function(){var t;tabUtilities.Init();var i=5,r=window.location.protocol+"//"+window.location.hostname,n=$.cookie("ListingsVisitCount");n===undefined&&(n=0);tabUtilities.GetCurrentTabCount()===1&&performance.navigation.type===0&&!document.referrer.indexOf(r)>-1&&(n=0);t=$("#hddUserId").val();(t==null||t==undefined||t<1)&&$("#hddListId").length==1&&(n=parseInt(n),n<=i&&n++,n>i+1&&(n=0),n===i&&MsgBox.MessageConfirmLogin());$.cookie("ListingsVisitCount",n,{path:"/"})},loginGoogle:function(){var i=$("#hddUserId").val(),u=$("#hddProductId").val(),r=$("#hddFlatform").val(),n,t;(r=="Wap"||r!="")&&u>0||(i!==undefined&&i!=null&&i>0?Utility.SetCookie("_isFirstRequest",0,1):(n=Utility.GetCookie("_isFirstRequest"),n!=""&&n!=undefined?(t=parseInt(parseInt(n)+1),t==3&&$("body #g_id_onload").length&&$("body").append('<script src="https://accounts.google.com/gsi/client" defer><\/script>'),parseInt(t)<3&&Utility.SetCookie("_isFirstRequest",parseInt(t),1)):Utility.SetCookie("_isFirstRequest",1,1)))}};const articleTypeIdConst={carNewsTypeId:1,carTipsTypeId:5,carComparisonTypeId:3,carReviewTypeId:2},articleCateConst={CarBuyingAndSelling:1,CarMaintenance:2,SafeDriving:3,MarketNews:4,NewReleases:5,CarEvents:6};markSoldPopup={getMarkSoldForm:function(n,t){$.ajax({type:"GET",url:"/MyAccount/MarkSold",data:{productId:n},success:function(n){t(n)}})},submitForm:function(n,t,i,r,u){$.ajax({type:"POST",url:"/MyAccount/MarkSoldGift",data:{productId:n,channelId:t,channelInfo:i,soldType:r},success:function(n){u(n)},error:function(){u({Title:"An error occurred! Please try again later!",Error:!0})}})}};const feedbackDealerTypeEnum={getQuote:1,inquire:2,requestTestDrive:3,callRequest:4,promoRequest:5,availPromo:6,bookAnAppointment:7},carCondition={NewCar:2,UsedCar:3},DealerPromosPage={Home:1,List:2,Detail:3,Eastwest:4},Enum_ActionAfterProcessLinkChat={Display_LoginPopupForBuyer:1,Display_LoginPopupForSeller:2,Display_Message_NoPhone:3,Display_Message_LoginInfoNotMatch:4};OneSignalApp={Init:function(){if(window.location.host!="philkotse.local"){let n=$("#hddOneSignalAppId").val();if(typeof n!="undefined"&&n!=""){let i=$("#hddUserId").val(),t=window.OneSignal||[];t.push(function(){let r=t.isPushNotificationsSupported();if(r)oneSignalStatus.IsBrowserSupported=!0;else{oneSignalStatus.IsBrowserSupported=!1;return}t.init({appId:n,notifyButton:{enable:!0},autoRegister:!0,requiresUserPrivacyConsent:!1});$(document).trigger("one_signal_inited");(i==undefined||i<0)&&(i=0);t.sendTags({userId:i}).then(function(){})});t.getUserId(function(n){console.log("OneSignal User Id:",n);OneSignalApp.OneSignal_SendTags(n,i)});t.isPushNotificationsEnabled(function(n){n?oneSignalStatus.IsSubscribed=!0:(oneSignalStatus.IsSubscribed=!1,t.showNativePrompt())})}}},OneSignal_SendTags:function(n,t){t>0&&n!=null&&OneSignal.getTags(function(n){console.log("OneSignal User tag:",n.userId);n.userId=="0"&&OneSignal.sendTags({userId:t})})}};oneSignalStatus={Initialized:!1,IsSubscribed:!1,IsBrowserSupported:!0,OnListChat:2,Popup:3};$(document).on("one_signal_inited",function(){oneSignalStatus.Initialized=!0});PostForm={InitForm:function(n){$("button[type=reset]").click(function(){$(".field-validation-error").empty()});$(n).off("click");$(n).on("click",function(t){var i=$(this).parents("form:first");return PostForm.clickButton(n,i),t.stopPropagation(),!1})},clickButton:function(n,t){var r,i,u;return((t==undefined||t==null)&&(t=$(this).parents("form:first")),t.valid()&&PostForm.customValidate())?(console.log("FORM VALID"),r=$(n).attr("id"),r=="btnLogin"&&(console.log("remove accessTokenApi"),$.removeCookie("accessTokenApi")),i=t.serializeObject(),this.beenSubmitted==i?!1:(CommonsEvent.Loading(),this.beenSubmitted=i,$.post(t.attr("action"),i).done(function(n){if(n.toString().indexOf("<!DOCTYPE html>")!=-1)return location.reload(),!1;if(n.Error)$("#lblMessage").length?$("#popup #lblMessage").length?($("#popup #lblMessage").empty().html(n.Title).removeClass("hidden"),$("#popup").is(":hidden")&&$("#popup").show(),Utility.scrollToBottom("popupModel")):($("#lblMessage").empty().html(n.Title).removeClass("hidden"),CommonsEvent.Loaded()):typeof MsgBox!="undefined"&&MsgBox.MessageError(n.Title),$(".lblMessage",t).length>0&&($(".lblMessage",t).empty().html(n.Title).removeClass("hidden"),setTimeout(function(){$(".lblMessage",t).empty().addClass("hidden")},5e3)),$(".resetCapchar").length&&$(".resetCapchar").click();else{CommonsEvent.Loaded();switch(n.NextAction){case 1:CommonsEvent.ReloadPage();break;case 2:location.href=n.Title;break;case 3:window.open("/Auto/PreviewAuto");break;case 4:PostForm.callBackFunction();t[0].reset();typeof MsgBox!="undefined"&&MsgBox.MessageSuccessText(n.Title,t[0]);break;case 5:PostForm.callBackFunction();t[0].reset();typeof MsgBox!="undefined"&&MsgBox.MessageSuccess(n.Title);break;case 9:PostForm.callBackFunction();t[0].reset();typeof MsgBox!="undefined"&&MsgBox.MessageSuccessRedirect(n.Title,"/");break;case 10:PostForm.callBackFunction();t[0].reset();typeof MsgBox!="undefined"&&MsgBox.MessageSuccessReloadPage(n.Title);break;default:PostForm.callBackFunction();$(".resetCapchar").length&&($(".resetCapchar").click(),$(".formReset").click(),$(".text-erro").empty());typeof MsgBox!="undefined"&&MsgBox.MessageSuccess(n.Title)}return!1}$("#loadding").empty()}).fail(function(n,t){var i=PostForm.SysError(n.status,t,n.responseText);alert(i)}),!1)):($("#lblMessage").empty(),console.warn("FORM INVALID"),u=t.validate(),$.each(u.errorMap,function(n,t){console.warn("Id: "+n+" Message: "+t)}),!1)},LoadPopupFromUrl:function(n,t,i,r){typeof r!="undefined"&&r||CommonsEvent.Loading();$.ajax({type:"GET",cache:!1,url:n,data:t,beforeSend:function(){CommonsEvent.Loading()},success:function(n){typeof r!="undefined"&&r||CommonsEvent.Loaded();n!=""?(CommonsEvent.AddNoScroll(),$("#popup").empty().html(n).append(i).show()):typeof r!="undefined"&&r||MsgBox.MessageError("An error occurred, please try again later")},error:function(n,t){var i=PostForm.SysError(jqXhr.status,t,jqXhr.responseText);CommonsEvent.Loaded();alert(i)},complete:function(){CommonsEvent.Loaded()}})},LoadFromUrl:function(n,t,i){$.get(n,t).done(function(n){i(n)}).fail(function(n,t){i("");var r=PostForm.SysError(n.status,t,n.responseText);console.warn(r)})},PostUrl:function(n,t){$.ajax({type:"POST",cache:!1,url:n,beforeSend:function(){CommonsEvent.Loading()},success:function(n){n.Error?MsgBox.MessageError(n.Title):(n.Title!==""&&MsgBox.MessageSuccess(n.Title),t!==null&&typeof t=="function"&&t());CommonsEvent.Loaded()},error:function(){CommonsEvent.Loaded()}})},SysError:function(n,t,i){return n===0?"Not connect.\n Verify Network.":n==404?"Requested page not found. [404]":n==500?"Internal Server Error [500].":t==="parsererror"?"Requested JSON parse failed.":t==="timeout"?"Time out error.":t==="abort"?"Ajax request aborted.":"Uncaught Error.\n"+i},LoadAjaxMultiCallBack:function(n,t,i,r,u){$.ajax({url:n,type:"POST",dataType:"html",cache:!1,data:t,async:!1,beforeSend:function(){i!=null&&i!=undefined&&i()},success:function(n){var u=window.location.pathname,i=t!=null&&t.url!=undefined?t.url:"/login";t===null||t.login===undefined||t.login?t===null||t.access===undefined||t.access||(window.location.href=i):window.location.href=i+"?returnUrl="+u;r!=null&&r!=undefined&&r(n)},error:function(n){console.log(n.statusText);u!=null&&u!=undefined&&u()}})},callBackFunction:function(){let functionName=$("#hddFunctionCallback").val();if($("#hddFunctionCallback").length==1&&functionName!=""&&typeof functionName!="undefined")try{eval(functionName)}catch(e){console.error("Exception : PostForm.callBackFunction() => "+e)}},customValidate:function(){return!0}};$(document).ready(function(){PostForm.InitForm(".btn_valid");$("#popup").off("click",".btn_valid_popup");$("#popup").on("click",".btn_valid_popup",function(n){var t=$(this).parents("form:first");return $(t).removeData("validator"),$(t).removeData("unobtrusiveValidation"),$.validator.unobtrusive.parse(t),PostForm.clickButton("#popup .btn_valid_popup",t),n.stopPropagation(),!1});$("#popup").off("click",".close_login, .close-popup");$("#popup").on("click",".close_login, .close-popup",function(n){return $("#popup").empty(),n.stopPropagation(),!1})})