var app={};(function($,console)
{const model={contact:{lglid:null,fullname:null,email:null,phone:null,shipping:{fullname:null,address:null,address2:null,city:null,state:null,zipcode:null,country:null,},billing:{address:null,address2:null,city:null,state:null,zipcode:null,country:null,},ebookemailed:!1,},};app=new flexapp({config:{apiurl:'/?c=api',enagicURL:'https://www.enagic.com/',sidebarMinHeight:800,flexid:'',products:{},productcodes:[],productsenabled:[],shopurl:'',searchurl:'/affsites/eco/search.php',pageurl:'',currentProductCode:'',motd:'',ctoken:'',c:'',lc:'',locale:'',country:'',country_detected:'',stat:{trackurls:['gclid','fblid'],tags:{id:null},ads:{id:null,addToCart:null,beginCheckout:null,purchase:null}},storage:{storage_key:'website',},},data:{firstInit:!1,notifyme:($.cookie('notifyme')==='1'),products:{},scroll:{previous:0,threshold:25,thresholdStart:0,headerOffset:100,},},lang:{},dict:{},debug:function(msg,context,type)
{if(!window.isDarryl||context==='prefillData')return;type=type||'log';console[type](msg,context)},init:function(config)
{var app=this;if($.isPlainObject(config))
$.extend(!0,app.config,config);app.stat.init(app.config.stat);if(!app.store.contact)
app.store.contact=model.contact;if($.isArray(app.config.productsenabled))
{var $checks=$('.checkbox.pcheck');$checks.each(function(){let $chk=$(this),pcode=$chk.attr('id').replace('lgli_77_','');if(app.config.productsenabled.indexOf(pcode)<0)
{$chk.parents('li').remove()}})}
$('.pchecks').removeClass('is-invisible');$('img[data-lazy-src]:not(.lazyloaded)').each(function(x,el)
{var $el=$(el),newsrc=$el.data('lazy-src');if(!newsrc||newsrc==="0"||newsrc==='none')return;$el.attr('src',newsrc).addClass('lazyloaded')});$('.sharetab').toggleClass('is-info is-bold is-primary');if(!app.store.contact||!app.store.contact.shipping||app.store.contact.shipping.country!==app.config.country)
{app.debug('changed country! clear address!');app.store.contact.shipping={}}
$('body').data('smoothanchor-padding',70+10);if($.xhrtoken)app.getLang();else $(window).one('csrfready',app.getLang.bind(app));$.each(app,function(key,func)
{if(key&&key!=='init'&&key.substr(0,4)==='init'&&typeof func==='function')
{func.call(app)}});app.prefillData();$('.em2').each(function()
{var $this=$(this),$a=$this.parent('a');if(!$a.length)return;$a.attr('href','mailto:'+$this.text())});$header=$('.header-style-1');app.data.scroll.headerOffset=$header.outerHeight();$(window).on('scroll',function(e)
{var currentY=$(this).scrollTop();if(currentY>=app.data.scroll.headerOffset)
{$header.removeClass('video-playing');if(currentY<=app.data.scroll.previous)
{if(!$header.hasClass('sticky'))
{if(!app.data.scroll.thresholdStart)
app.data.scroll.thresholdStart=app.data.scroll.previous;if(Math.abs(currentY-app.data.scroll.thresholdStart)>app.data.scroll.threshold)
{$header.addClass('sticky');app.data.scroll.previous=currentY;app.data.scroll.thresholdStart=0}}else if($header.hasClass('slideup'))
$header.removeClass('slideup')}else{$header.addClass('slideup');app.data.scroll.thresholdStart=0}}else if(currentY<=app.data.scroll.headerOffset)
$header.removeClass('sticky slideup');const $player=window.videos[0].$player;if(currentY<=10&&$player.hasClass('viewportfix')&&$player.hasClass('is-playing'))
$header.addClass('video-playing');app.data.scroll.previous=currentY});if(window.innerWidth>950)
{function inViewport(el){var rect=el.getBoundingClientRect();var innerHeight=window.innerHeight||document.documentElement.clientHeight;var innerWidth=window.innerWidth||document.documentElement.clientWidth;return rect.top>=0&&rect.left>=0&&rect.bottom<=innerHeight&&rect.right<=innerWidth};const video=window.videos[0];if(!inViewport(video.$player[0])){video.$player.addClass('viewportfix');$(window).on('video_played',(e,data)=>{if($.isPlainObject(data)&&data.videoid)
{if(app.config.c==='opportunity'&&data.videoid==="GqY5ozeP")
{$header.addClass('video-playing')}}});$(window).on('video_ended video_paused',(e,data)=>{if($.isPlainObject(data)&&data.videoid)
{if(app.config.c==='opportunity'&&data.videoid==="GqY5ozeP")
{$header.removeClass('video-playing')}}})}else app.debug('video GOOD in viewport')}
if(app.config.flexid==='demo')
{setTimeout(function(){Lobibox.alert('info',{title:'DEMO PURPOSES ONLY',msg:'This website is not fully functional it is ONLY for demonstrating the website that you can subscribe to through your account with www.EnagicWebSystem.com.'})},7000)}
$(window).off('popstate.tabs').on('popstate.tabs',app.initTabs.bind(app));$('.mm-navbar__title').attr('name','mm-navbar');app.bindEvents();$('[data-tooltip]').each(()=>{var $el=$(this),tip=$el.data('tooltip');$el.data('tooltip',app._(tip))});app.data.firstInit=!0},initOptinModal:function(){if(window.doOptinModal)
{var $optinModal=$('#optinModal');if($optinModal.length>0)
{$('#optinModal form.ebook').on('submit',function(){$optinModal.removeClass('is-active').data('hidePerm',!0);$.cookie('optinModal','hide',{expires:3650})});$optinModal.on('modal-close',function(){if($optinModal.data('hidePerm')!==!0)
$.cookie('optinModal','hide',{expires:3})});$(document).on('mouseleave',function(){if($.cookie('optinModal')!=='hide')$optinModal.addClass('is-active')});setTimeout(function(){if($.cookie('optinModal')!=='hide')$optinModal.addClass('is-active')},7*1000)}}},initModals:function()
{let app=this,$modalButtons=$('[data-toggle="modal"]');$(document).off('click.togglemodal');$modalButtons.off('click.modal').on('click.modal',function(){let $but=$(this),$modal=$($but.data('target')),onOpen=$modal.data('bind-open');$modal.toggleClass('is-active');if(onOpen&&app[onOpen])
app[onOpen]()});$('.modal button[aria-label="close"]').off('click.modal').on('click.modal',function(){$(this).parents('.modal').removeClass('is-active').trigger('modal-close')})},checkoutAccordionOpen:function()
{app.cart.accCheckout[0].expand()},countryWarning:function(callback)
{let app=this;app.messenger.confirm(`Country Mismatch`,`
We've detected a mismatch between your selected country and the country you are in.
Detected: ${app.config.country_detected}
Selected: ${app.config.country}
Do you want to continue shopping in ${app.config.country} ?
`,callback)},orderoptin:function(e)
{let app=this,$form=$(e.currentTarget),product=app.config.products[app.config.currentProductCode],data=$form.serializeObject();e.preventDefault();data.do='optinorder';data.lglid=app.store.contact.lglid;if(window.timezone)data.timezone=window.timezone;app.debug(data,'orderoptin submit');$.postJSON('/?c=api',data,function(response)
{app.waiter.off();if($.isPlainObject(response)&&response.status===1)
{if(response.lglid)app.store.contact.lglid=response.lglid;if(data.email)app.store.contact.email=data.email;if(response.phone)app.store.contact.phone=response.phone;app.history.updateReplace({success:'cart-checkout-begin'});app.stat.optin('beginCheckout');app.buynowAction()}}).fail(function(response){app.waiter.off();app.buynowAction()})},buynowAction:function()
{let app=this,product=app.config.products[app.config.currentProductCode];if(product.buylink)
{window.location.href=product.buylink}else{app.cart.addItem(app.config.currentProductCode,1);setTimeout(function(){window.location.href=app.config.carturl},150)}},buynow:function(e)
{let app=this,$button=$(e.currentTarget),product=app.config.products[app.config.currentProductCode],msg=app.getHTMLTemplate('buyoptin');function buyOptin()
{if(app.config.optinBeforeBuy&&product.buylink)
{app.messenger.delay(255).modal(`${app._('Purchase')} ${product.name} - ${app._('Step 1')}`,msg,(lobi,action)=>{if(action==='yes')
{let $form=lobi.$el.find('form').trigger('submit')}},{shown:()=>{app.initForms();app.bindEvents()},})}else app.buynowAction()}
if(app.config.country_detected&&app.config.country_detected!==app.config.country)
{app.countryWarning((lobi,action)=>{if(action==='yes')
{buyOptin()}else{let $toggle=$('.tabcontent li.is-active .buyline');$toggle.addClass('showhelp');setTimeout(()=>{$toggle.removeClass('showhelp')},7000)}})}else buyOptin()},buyTeamSelect:function(e){const app=this;const $modal=$('#modalSelectSponsor');const sponsorHTML=app.getHTMLTemplate('selectsponsor',app.config.team);$modal.find('.modal-card-body').html(sponsorHTML);$modal.addClass('is-active');app.bindEvents()},selectSponsor:function(e){const app=this;const $button=$(e.currentTarget);const sponsorid=$button.data('sponsorid');const data={do:'buylink',product:app.config.currentProductCode,sponsorid:sponsorid,country:app.config.country,};$.postJSON(app.config.apiurl,data).done((response)=>{if($.isPlainObject(response)&&response.status&&response.buylink){app.debug(response.buylink,'buylink');app.config.products[app.config.currentProductCode].buylink=response.buylink;app.buynowAction()}else app.messenger.error('Error','Unknown server error has occurred please try again in a moment.')}).fail(()=>{app.messenger.error('Error','Unknown server error has occurred please try again in a moment.')})},btnGroup:function(e)
{let app=this,$clicked=$(e.target),$button=($clicked.hasClass('.button'))?$clicked:$clicked.parents('.button'),$group=$button.parents('.field.has-addons');$group.find('.button.is-active').removeClass('is-active');$button.toggleClass('is-active')},dropdown:function(e)
{var app=this,$button=$(e.currentTarget).parents('.dropdown');if(e.type&&e.type==='blur')
{setTimeout(()=>{let $search=$button.find('.dropdown-region input.regionsearch:focus, .dropdown-region .dropdown-item > a:focus');if($search.length){return!0}
$button.removeClass('is-active')},175);return!0}
$button.toggleClass('is-active')},regionChange:function(e)
{let app=this;app.waiter.on();app.cart.empty()},regionsearch:function(e)
{let app=this,$field=$(e.currentTarget);var value=$field.val();var $items=$field.parents('.dropdown-region').find('> ul > li:not(:first-of-type)');if(value===''){$items.show()}
else{$items.not(':icontains('+value+')').hide();$items.filter(':icontains('+value+')').show()}},megaoptinXXX:function(formElement)
{var $form=$(formElement),$submit=$form.find('button[type=submit]'),app=this,$comments=$form.find('textarea[name=comments]'),$campaign=$form.find('input[name=campaign]'),fullname=$form.find('input[name=fullname]').val(),$fname=$form.find('input[name=lgl_fname]'),$lname=$form.find('input[name=lgl_lname]');app.debug(data);$submit.prop('disabled',!0);app.spinner.show();if(!$comments.val())
$campaign.prop('disabled',!0);else $campaign.prop('disabled',!1);if(fullname)
{var split=fullname.split(' ');$fname.val(split[0]);$lname.val(split.splice(1).join(' '))}
var data=$form.serialize()+'&jsonapi=1';$.ajax({url:'/index.php',type:"POST",dataType:'json',data:data,success:function(result)
{app.spinner.hide();$submit.prop('disabled',!1);app.debug(result,'optin post result');if(typeof result==='object'&&result.status===!0)
{app.store.contact=$form.serializeObject();if($form.parent().attr('id')==='videoOptin')
{app.data.videoOpted=!0;jwplayer().play()}else $.messenger.success('Message Received!','We have received your message and will get back to you soon!')}else if(typeof result==='object'&&result.error)
{$.messenger.alert('Form Validation Failed',result.error)}else{$.messenger.tell('Unknown Error','An unknown error has occurred, please try again later. [result not object]')}},error:function(xhr,resp,text){app.spinner.hide();$submit.prop('disabled',!1);app.debug(xhr,resp,text);$.messenger.alert('Error','An unknown error has occurred, please try again later. [server 503]')}});return!1},nav:function(e)
{let app=this,$el=$(e.currentTarget),url=$el.data('url');if(url)
window.location.href=url},tabResize:function($tabcontent)
{let app=this;app.debug('tabResize');$tabcontent=$tabcontent||$('.tabcontent > ul > li.is-active');if(!$tabcontent.length)return;let $tabcontainer=$tabcontent.parents('.tabcontent');if(!$tabcontainer.length)return;$tabcontainer.css('height',$tabcontent.outerHeight()+20+'px')},initTabs:function(e){let app=this,event=($.type(e)==='object'&&e.type)?e.type:!1;$('.tabcontent > ul > li.is-active').addClass('pb-5');let tabName='';if(window.location.hash.substr(0,4)==='#tab')
{tabName=window.location.hash.replace('#','')}else if($get('tab'))
{tabName=$get('tab');scrollToHash('#tabkangen')}else if(event==='popstate')
{tabName='tabk8'}
if(tabName)
app.tab({currentTarget:$(`a[name="${tabName}"]`),autonav:1});app.loadProductDetails(app.config.currentProductCode,app.tabResize.bind(app).delay(500))},tab:function(e)
{let app=this,$a=$(e.currentTarget),$tab=$a.parent(),productcode=$a.data('code'),tabName=$a.attr('name'),$allTabs=$a.parents('.tabs').find('li');if(!$a.length)return;$allTabs.removeClass('is-active');$tab.addClass('is-active');let tabid=0;$allTabs.each(function(i){if(this===$tab[0])tabid=i});let $allTabContent=$('.tabcontent > ul > li');let $tabcontent=$allTabContent.eq(tabid);$allTabContent.removeClass('is-active pb-5');if(!e.autonav)
{let title1=$tabcontent.find('.tab-title1').text();let title2=$tabcontent.find('.tab-title2').text();let titleuser=window.document.title.substr(window.document.title.indexOf(' | ')+3);let title=(title1)?`${title1} ยป ${title2} | ${titleuser}`:undefined;app.history.push(`${app.config.pageurl}#${tabName}`,title)}
setTimeout(function(){$tabcontent.addClass('is-active pb-5');app.config.currentProductCode=productcode;app.loadProductDetails(productcode,app.tabResize.bind(app).delay(500));app.tabResize()},175)},getLang:function()
{},loadProductDetails:function(code,callback)
{let app=this;if($.type(code)==='object')
{var $productDetails=code;code=app.config.currentProductCode}else{var $productDetails=$(`#tabcontent-${code}`).find('.product-details')}
if(!$productDetails.length||$productDetails.data('loaded'))return;if($productDetails.hasClass('page-server-load'))
{$productDetails.data('loaded',!0);app.onBeforeInjectEnagic($productDetails);$productDetails.find('td:first-of-type').each(function(){$(this).replaceWith(''+this.innerHTML+' ')});return}
$productDetails.loadElement(`https://www.enagic.com/?c=product-${code}&lc=${app.config.lc}`,'.info-container table.half tbody > tr',($newElements)=>{$productDetails.data('loaded',!0);app.onBeforeInjectEnagic($newElements);$newElements.find('td:first-of-type').each(function(){$(this).replaceWith(''+this.innerHTML+' ')})},function($newElements)
{if($.type(callback)==='function')
setTimeout(callback,50)})},initShopProduct:function()
{var app=this,$productDetails=$('#product-details');if(!$productDetails.length)return;app.loadProductDetails($productDetails)},initProductPageEco:function()
{var app=this,$productPage=$('#productPage'),$prodlogo=$('#prodlogo');if(!$productPage.length||!app.config.productcodes)return;function GetCodeFromURL(url)
{url=url||window.location.href;var code=url.split('/');code=code[code.length-1];app.debug([code,$get('p',url),url.substr(url.indexOf('/products/')+10)],'GetCodeFromURL');return $get('p',url)||code||''}
function GetCurrentCode()
{var code=GetCodeFromURL();if(!code)code='k8';return code}
function GetNextCode(from)
{if(from===undefined)from=GetCurrentCode();var index=app.config.productcodes.indexOf(from)+1;if(!app.config.productcodes[index])index=0;return app.config.productcodes[index]}
function GetPrevCode(from)
{if(from===undefined)from=GetCurrentCode();var index=app.config.productcodes.indexOf(from)-1;if(!app.config.productcodes[index])index=app.config.productcodes.length-1;return app.config.productcodes[index]}
function LoadProduct(code)
{if($productPage.find('#page-server-load').length)
{$productPage.find('#page-server-load').remove();onBeforeInject($productPage);onAfterInject($productPage)}else{$productPage.loadElement('/?c=-econtent&qs='+encodeURIComponent('c=product-'+code),'#main',onBeforeInject,onAfterInject)}}
var onBeforeInject=function($newElements)
{app.onBeforeInjectEnagic($newElements);$('.banner .btn.btn-warning',$newElements).prop('href',app.config.shopurl+'/'+GetCurrentCode());$('.certification-area a',$newElements).remove();$('.certification-list li',$newElements).wrapInner($(' '))};var onAfterInject=function($newElements)
{$('.bg-stretch',$newElements).retinaCover();$.initLightbox($newElements)};$('.prodnav').off('click.prodnav').on('click.prodnav',function(e)
{e.preventDefault();window.stop();var $this=$(this),$anext=$('#aNext'),$aprev=$('#aPrev'),gotocode=$this.data('code');$prodlogo.prop('src',app.config.enagicURL+'images/product_logos/'+gotocode+'.png');LoadProduct(gotocode);history.pushState(null,gotocode,$this.attr('href'));document.title=app.config.products[gotocode].name+' - '+app.config.products[gotocode].tagline;$aprev.prop('href',$aprev.attr('href').replace(GetCodeFromURL($aprev.attr('href')),GetPrevCode(gotocode))).data('code',GetPrevCode(gotocode));$anext.prop('href',$anext.attr('href').replace(GetCodeFromURL($anext.attr('href')),GetNextCode(gotocode))).data('code',GetNextCode(gotocode))});LoadProduct(app.config.currentProductCode);$(window).off('popstate.products').on('popstate.products',function(event){var gotocode=GetCodeFromURL();LoadProduct(gotocode);$prodlogo.prop('src',app.config.enagicURL+'images/product_logos/'+gotocode+'.png')})},initProductPage:function()
{let app=this,$certs=$('.certificates-additional'),$newElements=$certs.find('.partners-section');$(window).on('resize',app.tabResize.bind(app));$(window).on('timezoneData',function()
{if(app.config.country&&app.config.country!==window.timezoneData.countryCode)
{var $li=$('li.region_'+window.timezoneData.countryCode);if($li.length>0)
$('.dropdown-region > ul > li').eq(0).after($li.addClass('recommend'))}});if($certs.hasClass('page-server-load'))
{$certs.data('loaded',!0);app.onBeforeInjectEnagic($newElements);$newElements.find('.col:last-of-type').remove();$newElements.find('.text-wrap').toggleClass('text-wrap columns is-multiline has-text-centered');$newElements.find('.col').toggleClass('col column').each(function(){let $this=$(this),$img=$this.find('img'),$picture=$this.find('picture');$picture.replaceWith($img)}).find('p').remove();$newElements.find('.column').find('.link-holder').each(function(){let $aparent=$(this),$a=$aparent.find('a'),$img=$a.parents('.column').find('.img-holder').eq(0);$a.empty();$img.wrapInner($a);$a.remove()});return}
$certs.loadElement('https://www.enagic.com/?c=product-certified','.partners-section',($newElements)=>{app.onBeforeInjectEnagic($newElements);$newElements.find('.col:last-of-type').remove();$newElements.find('.text-wrap').toggleClass('text-wrap columns is-multiline has-text-centered');$newElements.find('.col').toggleClass('col column').each(function(){let $this=$(this),$img=$this.find('img'),$picture=$this.find('picture');$picture.replaceWith($img)}).find('p').remove();$newElements.find('.column').find('.link-holder').each(function(){let $aparent=$(this),$a=$aparent.find('a'),$img=$a.parents('.column').find('.img-holder').eq(0);$a.empty();$img.wrapInner($a);$a.remove()})},$.initLightbox)},onBeforeInjectEnagic:function($newElements)
{const app=this;$('[srcset]',$newElements).prop('srcset',function(i,origsrc){origsrc=origsrc.split(',');$.each(origsrc,function(x,src)
{src=src.trim();src=(!src||src.indexOf('http')===0)?src:app.config.enagicURL+src;origsrc[x]=src});return origsrc.join(', ')});$('[src]',$newElements).attr('src',function(i,origsrc){return(!origsrc||origsrc.indexOf('http')===0)?origsrc:app.config.enagicURL+origsrc});$('[data-srcset]',$newElements).attr('data-srcset',function(i,origsrc){return(!origsrc||origsrc.indexOf('http')===0)?origsrc:app.config.enagicURL+origsrc});$('[href]',$newElements).attr('href',function(i,origsrc){return(!origsrc||origsrc.indexOf('http')===0)?origsrc:app.config.enagicURL+origsrc});$newElements.find('.fa-question-circle-o').toggleClass('fa-question-circle-o fa-question-circle has-text-primary');$('.viewport-section',$newElements).removeClass('viewport-section');$('.info-icon[title]',$newElements).each(function(){var $this=$(this),title=$this.eq(0).parent().text().trim();$this.data('helpMsg',$this.attr('title'))}).helpModal()},initWaterPage:function()
{var app=this,$page=$('#waterPage');if(!$page.length)
return;var onBeforeInject=function($newElements)
{$('[srcset]',$newElements).prop('srcset',function(i,origsrc){origsrc=origsrc.split(',');$.each(origsrc,function(x,src)
{src=src.trim();src=(!src||src.indexOf('http')===0)?src:app.config.enagicURL+src;origsrc[x]=src});return origsrc.join(', ')});$('[src]',$newElements).attr('src',function(i,origsrc){return(!origsrc||origsrc.indexOf('http')===0)?origsrc:app.config.enagicURL+origsrc});$('[data-srcset]',$newElements).attr('data-srcset',function(i,origsrc){return(!origsrc||origsrc.indexOf('http')===0)?origsrc:app.config.enagicURL+origsrc});$('[href]',$newElements).attr('href',function(i,origsrc){return(!origsrc||origsrc.indexOf('http')===0)?origsrc:app.config.enagicURL+origsrc});$('.container-fluid',$newElements).toggleClass('container-fluid container');$('.more-block a.btn-success',$newElements).prop('href','/kangen-water/uses');$('.fa-question-circle-o',$newElements).toggleClass('fa-question-circle-o fa-question-circle');$('.viewport-section',$newElements).removeClass('viewport-section');$('.certification-area a',$newElements).prop('href','/certifications');$('.certification-list li',$newElements).wrapInner($(' '));$('.info-icon[title]',$newElements).each(function(){var $this=$(this),title=$this.eq(0).parent().text().trim();$this.data('helpMsg',$this.attr('title'))}).helpModal()};var onAfterInject=function($newElements)
{$('.bg-stretch',$newElements).retinaCover();$.initLightbox($newElements)};if($page.is(':empty'))
{$page.loadElement('https://www.enagic.com/?c=water','#main',onBeforeInject,onAfterInject)}else{onBeforeInject($page);onAfterInject($page)}},initFAQPage:function()
{var app=this,$page=$('#faqPage');if(!$page.length)
return;var onBeforeInject=function($newElements)
{$('[srcset]',$newElements).prop('srcset',function(i,origsrc){origsrc=origsrc.split(',');$.each(origsrc,function(x,src)
{src=src.trim();src=(!src||src.indexOf('http')===0)?src:app.config.enagicURL+src;origsrc[x]=src});return origsrc.join(', ')});$('[src]',$newElements).attr('src',function(i,origsrc){return(!origsrc||origsrc.indexOf('http')===0)?origsrc:app.config.enagicURL+origsrc});$('[data-srcset]',$newElements).attr('data-srcset',function(i,origsrc){return(!origsrc||origsrc.indexOf('http')===0)?origsrc:app.config.enagicURL+origsrc});$('[href]',$newElements).attr('href',function(i,origsrc){return(!origsrc||origsrc.indexOf('http')===0)?origsrc:app.config.enagicURL+origsrc});$('.container-fluid',$newElements).toggleClass('container-fluid container');$('.more-block a.btn-success',$newElements).prop('href','/kangen-water/uses');$('.fa-question-circle-o',$newElements).toggleClass('fa-question-circle-o fa-question-circle');$('.viewport-section',$newElements).removeClass('viewport-section');$('.certification-area a',$newElements).prop('href','/certifications');$('.certification-list li',$newElements).wrapInner($(' '));$('.info-icon[title]',$newElements).each(function(){var $this=$(this),title=$this.eq(0).parent().text().trim();$this.data('helpMsg',$this.attr('title'))}).helpModal()};var onAfterInject=function($newElements)
{$('.bg-stretch',$newElements).retinaCover();$.initLightbox($newElements);$('#main .faq-area .container').prepend(' ').find('#inputFilter').on('keyup',debounce(filterFAQ,500))};$page.loadElement('https://www.enagic.com/?c=water-faq','#main',onBeforeInject,onAfterInject)},initProductComparisonPage:function()
{var app=this,$page=$('#products-comparison');if(!$page.length)
return;$('html,body').scrollTop(0);var onBeforeInject=function($newElements)
{$('[srcset]',$newElements).prop('srcset',function(i,origsrc){origsrc=origsrc.split(',');$.each(origsrc,function(x,src)
{src=src.trim();src=(!src||src.indexOf('http')===0)?src:app.config.enagicURL+src;origsrc[x]=src});return origsrc.join(', ')});$('[src]',$newElements).attr('src',function(i,origsrc){return(!origsrc||origsrc.indexOf('http')===0)?origsrc:app.config.enagicURL+origsrc});$('[data-srcset]',$newElements).attr('data-srcset',function(i,origsrc){return(!origsrc||origsrc.indexOf('http')===0)?origsrc:app.config.enagicURL+origsrc});$('[href]',$newElements).attr('href',function(i,origsrc){origsrc=origsrc.replace('https://www.enagic.com','');return(!origsrc||origsrc.indexOf('http')===0)?origsrc:origsrc.replace('/?c=product-','/products/').replace('/products/videos','/videos')});$('.container-fluid',$newElements).toggleClass('container-fluid container');$('.more-block a.btn-success',$newElements).prop('href','/kangen-water/uses');$('.fa-question-circle-o',$newElements).toggleClass('fa-question-circle-o fa-question-circle');$('.viewport-section',$newElements).removeClass('viewport-section');$('.certification-area a',$newElements).prop('href','/certifications');$('.certification-list li',$newElements).wrapInner($(' '));$('.info-icon[title]',$newElements).each(function(){var $this=$(this),title=$this.eq(0).parent().text().trim();$this.data('helpMsg',$this.attr('title'))}).helpModal();$('.spec-block-container',$newElements).mobileNav({menuActiveClass:'height-active',menuOpener:'.height-opener',onToggle:function(app){setTimeout(function(){jQuery(window).trigger('resize')},400)}});$('.block').hide();$.each(app.config.productcodes,function(i,code){$('.'+code).show()})};var onAfterInject=function($newElements)
{$('html,body').scrollTop(0);$('.bg-stretch',$newElements).retinaCover();$.initLightbox($newElements)};if($page.is(':empty'))
{$page.loadElement('https://www.enagic.com/?c=product-comparison','#main',onBeforeInject,onAfterInject)}else{onBeforeInject($page);onAfterInject($page)}},initUsesPage:function()
{var app=this,$page=$('#usesPage');if(!$page.length)
return;var onBeforeInject=function($newElements)
{$('[srcset]',$newElements).prop('srcset',function(i,origsrc){origsrc=origsrc.split(',');$.each(origsrc,function(x,src)
{src=src.trim();src=(!src||src.indexOf('http')===0)?src:app.config.enagicURL+src;origsrc[x]=src});return origsrc.join(', ')});$('[src]',$newElements).attr('src',function(i,origsrc){return(!origsrc||origsrc.indexOf('http')===0)?origsrc:app.config.enagicURL+origsrc});$('[data-srcset]',$newElements).attr('data-srcset',function(i,origsrc){return(!origsrc||origsrc.indexOf('http')===0)?origsrc:app.config.enagicURL+origsrc});$('.container-fluid',$newElements).toggleClass('container-fluid container');$('.more-block a.btn-success',$newElements).prop('href','/kangen-water-uses');$('.fa-question-circle-o',$newElements).toggleClass('fa-question-circle-o fa-question-circle');$('.viewport-section',$newElements).removeClass('viewport-section');$('.certification-area a',$newElements).prop('href','/certifications');$('.certification-list li',$newElements).wrapInner($(' '));$('.info-icon[title]',$newElements).each(function(){var $this=$(this),title=$this.eq(0).parent().text().trim();$this.data('helpMsg',$this.attr('title'))}).helpModal()};var onAfterInject=function($newElements)
{$('.bg-stretch',$newElements).retinaCover();$.initLightbox($newElements)};if($page.is(':empty'))
{$page.loadElement('https://www.enagic.com/?c=water-usage','#main',onBeforeInject,onAfterInject)}else{onBeforeInject($page);onAfterInject($page)}},initSearchBar:function()
{var app=this,$header=$('#searchui'),$headerForm=$header.find('form'),$butOpen=$('.nav-search'),$butClose=$('#nav-search-close'),$headerInput=$header.find('input.searchquery'),$inputs=$('input.searchquery');var openHeaderSearch=function(e)
{if(e&&['click','touchstart'].indexOf(e.originalEvent.type)>=0)e.preventDefault();$header.addClass('open');setTimeout(function(){$('#searchui form input')[0].focus()},500);return!1};var closeHeaderSearch=function(e)
{if(e&&e.originalEvent&&['click','touchstart'].indexOf(e.originalEvent.type)>=0)e.preventDefault();$('body').removeClass('modal-open');$header.removeClass('open');$headerInput.val('');return!1};$butOpen.on('click touchstart',openHeaderSearch);$butClose.on('click touchstart',closeHeaderSearch);$headerInput.on('blur',function(){if($headerInput.val())return;closeHeaderSearch()});$inputs.on('blur',function(){$(this).parents('form').find('.search-results').fadeOut()}).on('focus',function(){var $this=$(this);if($this.val()!=='')$this.parents('form').find('.search-results').fadeIn()});$('.search-form').on('keypress',function(e)
{if(e.which===13)
{e.preventDefault();return!1}});var thread=null;$inputs.on('keyup',function(key)
{var $this=$(this),searchtext=$this.val(),$results=$this.parents('.search-form-container').find('.search-results');if(key.which===27)
{$this.val('').blur();$results.fadeOut();return!1}
if(key.which===13)
{key.preventDefault();return!1}
if(searchtext===$this.data('lastsearch'))return!1;$results.html(' ');clearTimeout(thread);thread=setTimeout(function(){searchSite($this.val(),$results)},750);$results.fadeIn();$('body').addClass('modal-open');$this.data('lastsearch',searchtext);return!1});function searchSite(str,$results)
{if(!str)return!1;app.debug({url:app.config.searchurl,s:str,locale:app.config.locale},'searchSite');$.getJSON(app.config.searchurl,{s:str,locale:app.config.locale},function(data)
{var items=[];if(data.length===0)
{$("#search-noresults").clone().prop('id','').appendTo($results.empty());return}
$.each(data,function(key,match)
{match.baseurl=app.config.baseurl;items.push(app.getHTMLTemplate('search-result-item',match))});$("",{"class":"my-new-list",html:items.join("")}).appendTo($results.empty())})}},initForms:function()
{var app=this;formStyleInit();app.debug('initForms','','warn');if(app.store.contact.fullname)
$('input[name=fullname]').val(app.store.contact.fullname).trigger('change');if(app.store.contact.phone)
{const e=$.Event('keydown');e.shiftKey=!0;e.which=e.keyCode=16;$('input[name=phone]').val(app.store.contact.phone).trigger('change').trigger(e)}
if(app.store.contact.email)
{$('input[name=email]').val(app.store.contact.email).trigger('change');$('input[name=rememberme]').prop('checked',!0).trigger('change')}
if($.fn.teleinput)
{var $phoneInputs=$('input[type=tel]:not("#schedule input"):not([id^="template-"])'),$dialCodeInputs=$('input[name=dialCode]'),$countryInputs=$('input[name=country]'),country=($.isPlainObject(window.timezoneData))?window.timezoneData.country:null;$phoneInputs.teleinput({initialCountry:country,separateDialCode:!0,nationalMode:!1,hiddenInput:'fullphone'});$phoneInputs.on('countrychange',function(e,countryData)
{countryData=$(this).data('plugin_teleinput').getSelectedCountryData();if($.isEmptyObject(countryData))return;$dialCodeInputs.val(countryData.dialCode);$countryInputs.val(countryData.iso2.toUpperCase())});$phoneInputs.each(function()
{var $this=$(this);var countryData=$this.teleinput('getSelectedCountryData');if($.isPlainObject(countryData)&&!$.isEmptyObject(countryData)&&countryData.dialCode)
{$dialCodeInputs.val(countryData.dialCode);$countryInputs.val(countryData.iso2.toUpperCase())}
$this.teleinput('refreshUI')})}
$(window).off('timezoneData.tzinit').on('timezoneData.tzinit',function(){if(window.timezoneData.country)
{$phoneInputs.teleinput('setCountry',window.timezoneData.country);app.config.country_detected=window.timezoneData.country.toUpperCase()}});if(app.config.optinrequire==2){$('input[name="phone"]').each(function(){let $el=$(this);let placeholder=$el.attr('placeholder');if(!placeholder.indexOf('*'))
$el.attr('placeholder',`${placeholder} *`)})}},initeBook:function()
{var app=this;$('input[required][placeholder]').each(function(){var $input=$(this),cVal=$input.prop('placeholder');if(cVal.substr(-1)==='*')return;$input.prop('placeholder',cVal+' *')});$('form.ebook:not(.pop)').on('submit',function(e)
{e.preventDefault();var $form=$(this);if(!$form[0].checkValidity())return!1;var data=$form.serializeObject();data.do='ebook';data.lglid=app.store.contact.lglid;if(window.timezone)data.timezone=window.timezone;app.waiter.on();$.postJSON('/?c=api',data,function(response)
{app.waiter.off();if(response.status)
{if(response.lglid)app.store.contact.lglid=response.lglid;if(data.email)app.store.contact.email=data.email;if(data.fullname)app.store.contact.fullname=data.fullname;if(response.phone)app.store.contact.phone=response.phone;$.messenger.success(app.__('Success!'),response.message);app.history.updateReplace({success:'ebook'});app.stat.optin('ebook')}else $.messenger.alert('Error',response.error)}).fail(function(response)
{app.waiter.off();var msg=(response&&response.error)?response.error:app.__('Unknown server error has occurred please try again in a moment.');$.messenger.alert('Server Error',msg)})});$('form.ebook.pop').off('submit').on('submit',function(e)
{var $form=$(this);var odata=$form.serializeObject();odata.do='ebook';odata.lglid=app.store.contact.lglid;app.debug(odata,'ebook optin data 1');$.each(odata,function(key,val)
{if(val===''||val===null||val===undefined)
delete odata[key]});app.debug(odata,'ebook optin data 2');e.preventDefault();if(!odata.email)
return app.messenger.error('Error','Failed to submit request. Please check the form and try again.');if(!app.config.optinrequire)
{if(app.store.contact.email&&app.store.contact.email===odata.email)
{if(app.store.contact.fullname)
odata.fullname=app.store.contact.fullname;if(app.store.contact.phone)
odata.phone=app.store.contact.phone}
$.postJSON('/?c=api',odata,function(response)
{if(response.status)
{if(response.lglid)app.store.contact.lglid=response.lglid;if(odata.email)app.store.contact.email=odata.email;if(odata.fullname)app.store.contact.fullname=odata.fullname;if(odata.phone)app.store.contact.phone=odata.phone;app.store.contact.ebookemailed=1;odata.ebookemailed=1;app.history.updateReplace({success:'ebook'});app.initForms()}else{$.messenger.alert('Error',response.error)}})}
app.messenger.confirm('Send Kangen eBook',app.getHTMLTemplate('#ebookinfo',app.store.contact),function(lobi,response){var yesdata=lobi.$el.find('form').serializeObject();app.debug(response,'confirm response');if(response==='yes'){$.extend(!0,yesdata,odata);yesdata.sendsms=yesdata.phone?'1':'0';if(window.timezone)yesdata.timezone=window.timezone;if(app.store.contact.ebookemailed)
yesdata.ebookemailed=app.store.contact.ebookemailed;if(app.store.contact.lglid)
yesdata.lglid=app.store.contact.lglid;app.debug(yesdata,'yesdata');var requireFail=!yesdata;var optinrequire=[];if(app.config.optinrequire>=1)
optinrequire.push('fullname');if(app.config.optinrequire>=2)
optinrequire.push('phone');app.debug(optinrequire,'optinrequire');$.each(optinrequire,function(){requireFail=requireFail||(!yesdata[this])});app.debug(requireFail,'requireFail');if(requireFail){app.notify(app.__('A required field was not filled in your form submission:'),'error');setTimeout(function(){$form.trigger('submit')},750);return!1}
app.waiter.on();$.postJSON('/?c=api',yesdata,function(response){app.store.contact.ebookemailed=0;app.waiter.off();if(response.status){$.messenger.success(app.__('Success!'),response.message);if(response.lglid)app.store.contact.lglid=response.lglid;if(yesdata.email)app.store.contact.email=yesdata.email;if(yesdata.fullname)app.store.contact.fullname=yesdata.fullname;if(response.phone)app.store.contact.phone=response.phone;app.history.updateReplace({success:'ebook'});app.initForms()}else $.messenger.alert('Error',response.error)}).fail(function(response){app.waiter.off();var msg=(response&&response.error)?response.error:app.__('Unknown server error has occurred please try again in a moment.');$.messenger.alert('Server Error',msg)})}else{$.extend(!0,odata,yesdata);app.waiter.on();$.postJSON('/?c=api',odata,function(response){app.waiter.off();if(response.status){$.messenger.success(app.__('Success!'),response.message);if(response.lglid)app.store.contact.lglid=response.lglid;if(odata.email)app.store.contact.email=odata.email;if(odata.fullname)app.store.contact.fullname=odata.fullname;if(response.phone)app.store.contact.phone=response.phone;app.history.updateReplace({success:'ebook'})}else $.messenger.alert('Error',response.error)}).fail(function(response){app.waiter.off();var msg=(response&&response.error)?response.error:app.__('Unknown server error has occurred please try again in a moment.');$.messenger.alert('Server Error',msg)})}},{shown:function(){app.initForms()},buttons:{yes:{text:app._('Submit')},},})})},initComments:function(context,onAfterHide)
{var app=this,$forms=$('.form-comment,.form-review',context),$hideme=$('.hideme'),$textareas=$forms.find('textarea'),$replyButtons=$('.butReply',context),$likeButtons=$('.butLike',context),$submitButtons=$forms.find('button[type=submit]');$hideme.slideUp(1,function(){if(typeof onAfterHide==='function')
{if($hideme.last().is(this))
onAfterHide()}});$('.helpModal',context).helpModal();formStyleInit();$('.rateit,.ratings',context).each(function()
{var $this=$(this),$input=$this.siblings('input[type=range]');$input.hide();var options={rating:$this.data('rateit-value')||$this.data('ratings-value'),maxValue:$this.data('ratings-max'),numStars:$this.data('ratings-numstars'),spacing:$this.data('ratings-spacing'),rtl:$this.data('ratings-rtl')?!0:!1,halfStar:!0,readOnly:$this.data('rateit-readonly')||$this.data('ratings-readonly'),};$.each(options,function(key,val)
{if(val===undefined)
delete options[key]});$this.rateYo(options).on('rateyo.change',function(e,data)
{$input.val(data.rating)})});var $totalcomments=$('#totalcomments'),totalcomments=parseInt($totalcomments.text())||0;$('.commentsTotal').text(totalcomments);$likeButtons.off('click.initComments').on('click.initComments',function(e)
{if(e)e.preventDefault();var $this=$(this),$badge=$this.siblings('.badge'),badgeCount=parseInt($badge.text())||0,commentid=$this.data('commentid');if(!commentid)return!1;$.postJSON('/?c=api',{do:'like',commentid:commentid,contact:app.store.contact},function(response)
{if(response.status)
$badge.text(badgeCount+1)}).fail(function(){$.messenger.alert('Server Error','The was a server side error, please retry in a few seconds.')})});$replyButtons.off('click.initComments').on('click.initComments',function(e){if(e)e.preventDefault();var $this=$(this),$parent=$this.parents('.the-comment'),$formToggle=$parent.find('.formtoggle'),formOpen=($formToggle.css('display')==='block');$formToggle.find('form').data('reply_to',$this.data('reply_to'));if(formOpen)
$formToggle.slideUp();else $formToggle.slideDown()});$textareas.off('openform.initComments').on('openform.initComments',function(e,e2)
{var $this=$(this),$form=$(this).parents('form'),$myhideme=$form.find('.hideme'),$rating=$form.find('input[name="rating"]'),$title=$form.find('input[name=title]'),count=$this.val().length||$title.val(),$ratecontrol=$rating.siblings('.rateit');if($rating.length&&!parseFloat($rating.val()))
{$ratecontrol.trigger('tipshow');$rating.off('change.initComments').on('change.initComments',function(){$ratecontrol.trigger('tiphide')});return}
if(count){if(e2)e2.preventDefault();$myhideme.slideDown(function(){$myhideme.find('input[name=fullname]').focus();$form.data('ready',!0)})}else{$form.data('ready',!1);$myhideme.slideUp()}});$submitButtons.off('click.initComments').on('click.initComments',function(e)
{var $form=$(this).parents('form');if(!$form.data('ready'))
{$form.find('textarea').trigger('openform',e)}});$forms.off('submit.initComments').on('submit.initComments',function(e)
{e.preventDefault();var $form=$(this);if($form.data('ready')&&$form[0].checkValidity())
{var data=$form.serializeObject();data.do='comment';data.lglid=app.store.contact.lglid;if(window.timezone)data.timezone=window.timezone;data.asset=$form.data('asset')||app.config.content;data.reply_to=$form.data('reply_to')||null;data.url=app.config.pageurl;$.cookie('commentor',data.email,{expires:90,path:'/'});if(data.rememberme!=='1')
{app.store.contact.fullname='';app.store.contact.email=''}
app.waiter.on();$.postJSON('/?c=api',data,function(response)
{app.debug(response);app.waiter.off();if(response.status)
{if(response.lglid)app.store.contact.lglid=response.lglid;if(data.fullname&&!app.store.contact.fullname)app.store.contact.fullname=data.fullname;if(data.email&&!app.store.contact.email)app.store.contact.email=data.email;app.initForms();var comment=response.comment;if(comment.rating)
{$form.find('.rateit').rateYo().rateYo('rating',0);$('.comment-area-form').hide()}else{comment.hideStars='hidden'}
var html=app.getHTMLTemplate('#templateComment',response.comment),$parent=(comment.reply_to)?$('#comment'+comment.reply_to+' + .children'):$('ol.comment-list'),$newComment=$(' ').append(html),$totalcomments=$('#totalcomments'),totalcomments=parseInt($totalcomments.text())||0,$commentsTotal=$('.commentsTotal');$('.comment-area').parents('div.row.hidden').removeClass('hidden');$parent.append($newComment);$commentsTotal.text(totalcomments+1);$form.find('textarea').val('');$form.find('input[name=title]').val('');app.initComments($newComment,function(){app.debug('onAfterHide','call');window.history.pushState(null,null,'#comment'+comment.autoid);window.scrollToHash('#comment'+comment.autoid)});if(response.message)
{$.messenger.success('Success!',response.message);app.history.updateReplace({success:'comment'})}}else{$.messenger.alert('Error',response.error)}}).fail(function(){app.waiter.off();$.messenger.alert('Server Error','The was a server side error, please retry in a few seconds.')})}else $form.find('textarea').trigger('openform')})},initSideWidget:function()
{var app=this,$articleList=$('#sidebar .widgetArticleList'),setHeight=$('article').eq(0).height()-$('#sidebar > .widgetDistributor').height()-100;if(setHeight{var total=$playtotal.data('total')||0;total++;$playtotal.data('total',total);$playtotal.text(app.humanreadable(total))});$(document).on('click',function(e)
{if($(e.target).parents('.jw-plugin-sharing').length<1)
$('#videoplayer .jw-plugin-sharing.jw-show.reposition').removeClass('jw-show reposition').css({top:'',left:''})});$btnShare.off('click.share').on('click.share',function(e)
{e.stopPropagation();$('.sharetab').trigger('click');return;function getPosition(el){var xPosition=0;var yPosition=0;while(el){if(el.tagName=="BODY"){var xScrollPos=el.scrollLeft||document.documentElement.scrollLeft;var yScrollPos=el.scrollTop||document.documentElement.scrollTop;xPosition+=(el.offsetLeft-xScrollPos+el.clientLeft);yPosition+=(el.offsetTop-yScrollPos+el.clientTop)}else{xPosition+=(el.offsetLeft-el.scrollLeft+el.clientLeft);yPosition+=(el.offsetTop-el.scrollTop+el.clientTop)}
el=el.offsetParent}
return{left:xPosition,top:yPosition}}
var $sharebar=$('#videoplayer .jw-plugin-sharing');if($(window).width()<420)
{if($sharebar.hasClass('jw-show'))
{$sharebar.parents('.jwplayer').removeClass('jw-flag-overlay-open-sharing');$sharebar.removeClass('jw-show')}else{$sharebar.parents('.jwplayer').addClass('jw-flag-overlay-open-sharing');$sharebar.addClass('jw-show')}
return}
if($sharebar.hasClass('reposition'))
$sharebar.removeClass('reposition jw-show').css({top:'',left:''});else{var xy=getPosition(e.currentTarget);xy.top+=30;xy.top+='px';xy.left-=$sharebar.width()-60;xy.left+='px';$sharebar.css(xy).addClass('jw-show reposition')}});$btnLike.off('click.like').on('click.like',function()
{var $btn=$(this),data={do:'videolike',videoid:videoid,'lglid':app.store.contact.lglid};$.postJSON('/?c=api',data,function(response)
{if(response&&response.status===1)
{$btn.siblings('.btnDislike').removeClass('text-primary');$btn.addClass('text-primary');var $liketotal=$('.liketotal');var total=parseInt($liketotal.data('total'))||0;total++;$liketotal.data('total',total);$liketotal.text(app.humanreadable(total))}})});$btnDislike.off('click.dislike').on('click.dislike',function()
{var $btn=$(this),videoid=$videoplayer.data('videoid'),data={do:'videodislike',videoid:videoid,'lglid':app.store.contact.lglid};$.postJSON('/?c=api',data,function(response)
{if(response&&response.status===1)
{$btn.siblings('.btnLike').removeClass('text-primary');$btn.addClass('text-primary');var $disliketotal=$('.disliketotal');var total=parseInt($disliketotal.data('total'))||0;total++;$disliketotal.data('total',total);$disliketotal.text(app.humanreadable(total))}})})},initMOTD:function()
{let app=this;if(!app.config.motd)return;const $html=app.getHTMLTemplate('motd',app.config);$('body').append($html);if(!$.cookie('motd'))
setTimeout(app.toggleMOTD.bind(app),3500)},toggleMOTD:function(event)
{let app=this,$modal=(typeof event==='object')?$(event.currentTarget).parents('.modal'):$('#modalMOTD');if($modal.hasClass('is-active'))
{$modal.find('.modal-card').removeClass('is-active');setTimeout(()=>{$modal.removeClass('is-active')},500);$.cookie('motd',1,{expires:1})}else{$modal.toggleClass('is-active');setTimeout(()=>{$modal.find('.modal-card').toggleClass('is-active')},50)}},initCart:function(){this.cart.firstInit=!0;this.cart.init(this)},cart:new flexapp({app:{},data:{},shop:{products:[],shipping:[],taxrate:null,taxpercent:null,totals:{subtotal:null,shipping:null,tax:null,total:null}},config:{storage:{storage_key:'shopcart'}},firstInit:!0,init:function(app)
{var cart=this;cart.app=app;app.debug('*** cart init ***');if($('.showIfCartEmpty').eq(0).css('display')==='none')
{app.debug('run calculator','initCart');if($.xhrtoken)cart.calculate();else $(window).one('csrfready',cart.calculate.bind(cart))}
cart.load();cart.updateUI();cart.firstInit=!1;var $geofind1=$("#geofind1").geocomplete({details:'#form-shipping',detailsAttribute:'data-geofind1',country:app.config.country});$geofind1.on('geocode:filled',function(event,data){$geofind1.val('')});var $geofind2=$("#geofind2").geocomplete({details:'#form-billing-address',detailsAttribute:'data-geofind2',country:app.config.country});$geofind2.on('geocode:filled',function(event,data){$geofind2.val('')});cart.attachEvents();function startping()
{cart.pingTimer=setTimeout(function()
{app.debug('ping on timer');cart.ping();startping()},1000*60*5)}
startping();$(window).off('focus.ping').on('focus.ping',function()
{app.debug('focus event ping');clearTimeout(cart.pingTimer);cart.ping();startping()});$('input[type=tel]').teleinput('refreshUI');cart.accCheckout=bulmaCollapsible.attach('#accordion-checkout .is-collapsible')},ping:function()
{var cart=this,app=cart.app;$.postJSON('/?c=api',{do:'ping','lglid':app.store.contact.lglid},function(response)
{if($.isPlainObject(response)&&response.status)
{if(response.reload)
cart.load()}else $(window).one('csrfready',cart.ping.bind(cart))})},checkout:function(callback)
{var cart=this,app=this.app;$.postJSON('/?c=api',{do:'checkout',contact:app.store.contact,},function(response)
{if($.isFunction(callback))
if(!callback.call(cart,response))
return!1;if(response&&response.status)
{if(response.lglid)
app.store.contact.lglid=response.lglid;app.store.contact.checkouturl=response.url;if(response.url)
{cart.openCheckout(response.url);cart.app.stat.beginCheckout(cart.shop.totals.subtotal,app.data.products[Object.keys(app.data.products)[0]].selectedcurrency);app.stat.optin('beginCheckout');app.history.push('?success=cart-checkout-begin')}
else{cart.empty();Lobibox.alert('success',{title:app.__('Order Request Received!'),msg:app.__('We have received your order request and will be contacting you very soon to complete the order.')});app.history.push('?success=cart-checkout-complete');cart.app.stat.beginCheckout(cart.shop.totals.subtotal,app.data.products[Object.keys(app.data.products)[0]].selectedcurrency)}}})},openCheckout:function(url)
{var lb=lity(url,{bgClick2Close:!1})},attachEvents:function()
{var cart=this,app=this.app;$('input.minus').on('click',function()
{var $this=$(this),$qty=$this.siblings('input.qty'),qty=parseInt($qty.val())-1;if(qty<0)qty=0;$qty.val(qty)});$('input.plus').on('click',function()
{var $this=$(this),$qty=$this.siblings('input.qty'),qty=parseInt($qty.val())+1;if(qty<0)qty=0;$qty.val(qty)});var $butAddToCart=$('.js-action-add-cart');var $butRemoveItem=$('.js-action-remove-item');var itemWishList=$('.js-notify-add-wish-list');var $butSaveAddress=$('.js-action-saveaddress');var $butUpdateCart=$('.js-action-update-cart');var $formCart=$('#form-cart');var $butSaveContact=$('.js-action-savecontact');var $chkBillingSame=$('.js-action-billingsame');var $butSaveBilling=$('.js-action-savebilling');$chkBillingSame.off('change.initCart').on('change.initCart',function(e)
{var $this=$(this),checked=$this.is(':checked');if(checked)
$('#geofind2').parent().slideUp();else $('#geofind2').parent().slideDown();$('#form-billing-address input[data-prefill]').each(function()
{var $input=$(this),prefill=$input.data('prefill'),val='';if($input.prop('name').substr(0,7)==='billing')
{if(checked)
{prefill=prefill.replace('.billing.','.shipping.');try{val=eval('app.'+prefill)}catch(err){app.debug(err,'prefillData','warn')}
if(val)
$input.val(val).attr('readonly',!0)}else $input.attr('readonly',!1)}})});$butUpdateCart.off('click.initCart').on('click.initCart',function(e)
{if(e)e.preventDefault();var updates=[];var $qtys=$formCart.find('.qty').each(function()
{var $this=$(this),code=$this.data('product'),qty=($this.val()+'').toInt();app.debug([code,qty],'updateCart');if(cart.data[code].qty!==qty)
{updates.push({code:code,qty:qty});app.notify(cart.data[code].name+' '+app.__('quantity has been adjusted!'),'cartadd')}});$(window).one('cartsavecomplete',cart.refresh.bind(cart));cart.setQty(updates)});$butAddToCart.off('click.initCart').on('click.initCart',function(e)
{e.preventDefault();var $this=$(this),$form=$this.parents('form'),data=$form.serializeObject();$this.addClass('is-added');cart.addItem(data.code,data.qty);setTimeout(function(){app.notify(data.title+' '+app.__('has been added to the cart!'),'cartadd');$this.removeClass('is-added')},750)});$butRemoveItem.off('click.initCart').on('click.initCart',function(e)
{e.preventDefault();var $this=$(this),code=$this.data('code'),$cartEntry=$this.parents('.product-remove').parents('tr');app.debug('remove item',[code,$cartEntry]);cart.removeItem(code,999999,!0);$cartEntry.fadeOut(400,function(){$cartEntry.remove();cart.updateUI();if(!$.isEmptyObject(cart.data))
cart.calculate();app.notify(app.data.products[code].name+' '+app.__('has been removed from your cart!'))})});function saveContact(e)
{if(e)e.preventDefault();var $form=$('#form-contact-info');if(!$form[0].checkValidity())
{$.messenger.tell(app.__('Incomplete Form'),app.__('Please complete the form or close popup to cancel.'));return!1}
var formData=$form.serializeObject();$.each(formData.contact,function(key,val)
{app.debug(`${key} = ${val}`,formData);if(key==='phone'&&formData.dialCode)
{val=$form.find('input[name="contact[phone]"]').teleinput('getNumber')}
app.store.contact[key]=val});cart.accCheckout[1].expand()}
function saveBilling(e)
{if(e)e.preventDefault();var $form=$('#form-billing-address'),$form2=$('#form-contact-info'),$button=$(e.currentTarget);if(!$form[0].checkValidity())
{$.messenger.tell(app.__('Incomplete Form'),app.__('Please complete the form or close popup to cancel.'));return!1}
if(!$form2[0].checkValidity())
{cart.accCheckout[0].expand();$.messenger.tell(app.__('Incomplete Form'),app.__('Please complete the form or close popup to cancel.'));return!1}
var formData=$form.serializeObject().billing;if(!$.isPlainObject(app.store.contact.billing))app.store.contact.billing={};$.each(formData,function(key,val){app.store.contact.billing[key]=val});var $modal=$('.modal.is-active');$button.addClass('is-loading');cart.checkout(function(response)
{$button.removeClass('is-loading');app.debug(response,'checkout callback response');if(response&&response.status)
{$modal.removeClass('is-active')}else{$.messenger.alert('Error',response.error)}
return!0})}
$('.js-action-checkoutnext').off('click.checkoutnext').on('click.checkoutnext',function(e)
{e.preventDefault();let onStep1=cart.accCheckout[1].collapsed();if(onStep1)saveContact(e);else saveBilling(e)});function addToWishList(productName){$.notify({title:productName,icon:'lnr lnr-heart',message:"is added to wish list"},{type:'success',animate:{enter:'animated fadeInUp',exit:'animated fadeOut'},placement:{from:"bottom",align:"right"},offset:20,spacing:10,z_index:1031})}
function removeFromWishList(productName){$.notify({title:productName,icon:'lnr lnr-heart',message:"is removed from wish list"},{type:'danger',animate:{enter:'animated fadeInUp',exit:'animated fadeOut'},placement:{from:"bottom",align:"right"},offset:20,spacing:10,z_index:1031,})}
itemWishList.on("click",function(e){e.preventDefault();$(this).toggleClass('active');var productName=$(this).closest('.product').find('.product-name').text();if($(this).hasClass('active')){addToWishList(productName)}else{removeFromWishList(productName)}});$butSaveAddress.off('click.initCart').on('click.initCart',function(e)
{if(e)e.preventDefault();var $form=$('#form-shipping');if(!$form[0].checkValidity())
{$.messenger.tell(app.__('Incomplete Address'),app.__('Cannot save this address. Please complete the form or close popup to cancel.'));return!1}
var formData=$form.serializeObject();if(!app.store.contact.fullname&&formData.shipping.fullname)
app.store.contact.fullname=formData.shipping.fullname;app.store.contact.shipping=formData.shipping;cart.calculate()})},calculate:function(shipping)
{var cart=this,app=this.app;if(typeof shipping==='object'&&shipping.type==='csrfready')shipping=undefined;shipping=shipping||app.store.contact.shipping;if(typeof shipping!=='object'||!shipping.address||!shipping.city||!shipping.state||!shipping.zipcode)
return!1;$('.modal.is-active').removeClass('is-active');$('.cart_totals').addClass('is-loading');$.postJSON('/?c=api',{do:'calculate',shipping:shipping},function(response)
{$('.cart_totals').removeClass('is-loading');if(response.status)
{app.debug(response);$.extend(!0,cart.shop,response.shop);app.prefillData();$fullName=$('input[name="contact[fullname]"]');if(!$fullName.val())$fullName.val(shipping.fullname);$('.js-action-checkout').removeClass('hidden');if(response.shop.totals.estimate)
$('.cart_totals').addClass('is-estimate');app.history.push('?success=cart-calculate')}else{var error=response.error||app.__('Unknown server error has occurred please try again in a moment.');$.messenger.alert(app.__('Error'),error)}}).fail(function(){$.messenger.alert(app.__('Server Error'),app.__('Unknown server error has occurred please try again in a moment.'))});return!0},save:function(isInit)
{var cart=this,app=cart.app;$.totalStorage('cart',cart.data);app.debug('saving cart','cart.save');$.postJSON('/?c=api',{do:'cartsave',contact:app.store.contact,cart:cart.data,isInit:isInit,},function(response)
{if(response.status)
{if(response.refreshcart&&app.config.c==='shop_cart')
{app.debug('save complete, refresh cart','cart.save');cart.refresh()}}
$(window).trigger('cartsavecomplete')})},refresh:function()
{var cart=this,app=this.app;if(app.config.c!=='shop_cart')return;$('#cart').addClass('is-loading').loadElement(app.config.carturl,'#cart > *',{},null,function(){app.debug('refresh cart complete','cart.refresh');app.initCart();$('#cart').removeClass('is-loading')},!1)},load:function()
{var cart=this,app=cart.app;cart.data=$.totalStorage('cart')||{};if(!$.isEmptyObject(app.data.products))
{$.each(cart.data,function(key,val)
{if(!$.isPlainObject(val)||val.qty===undefined)return!0;var qty=val.qty;if(app.data.products[key])
{cart.data[key]=app.data.products[key];cart.data[key].qty=qty}else app.debug([key,app.data.products],'missing products data???')})}
if($.xhrtoken)cart.save(!0);else $(window).one('csrfready',function(){cart.save(!0)})},reload:function()
{var cart=this,app=this.app;$(window).one('cartsavecomplete',function(){cart.refresh()});cart.load()},addItem:function(code,qty)
{var cart=this,app=cart.app;if(!qty)qty=1;else qty=parseInt(qty);if(cart.data[code])
cart.data[code].qty+=qty;else{cart.data[code]=app.data.products[code];cart.data[code].qty=qty}
cart.save();cart.app.stat.addToCart(app.data.products[code].selectedprice,app.data.products[code].selectedcurrency);var total=cart.totalItems();cart.updateUI(total);return total},setQty:function(code,qty)
{var cart=this,app=cart.app;if($.isArray(code))
{app.debug(`array passed in as argument`,'setQty');$.each(code,function()
{cart.setQty(this.code,this.qty)})}else{app.debug(`${code} with ${qty} passed`,'setQty');qty=parseInt(qty);if(isNaN(qty))return!1;if(qty<=0)return cart.removeItem(code,9999);else if(!cart.data[code])return cart.addItem(code,qty);cart.data[code].qty=qty}
cart.save();var total=cart.totalItems();cart.updateUI(total);return total},removeItem:function(code,qty,noUpdateUI)
{var cart=this,app=cart.app;if(!qty)qty=1;else qty=parseInt(qty);if(!cart.data[code])return;if(cart.data[code].qty>qty)
cart.data[code].qty-=qty;else delete cart.data[code];cart.save();var total=cart.totalItems();if(!noUpdateUI){cart.updateUI(total);cart.calculate()}
return total},empty:function()
{var cart=this,app=cart.app,$cartelements=$('.js-action-remove-item');if($cartelements.length)
$cartelements.trigger('click');else{cart.data={}}
$(window).one('cartsavecomplete',function(){cart.updateUI(0)});cart.save()},totalItems:function()
{var cart=this,app=cart.app,qty=0;$.each(cart.data,function()
{qty+=this.qty});return qty},updateUI:function(totalItems)
{var cart=this,$cartIcon=$('.js-widget-shop-cart'),$cartCounter=$cartIcon.find('.counter'),animDuration=(cart.firstInit)?0:400;$('.header-style-1').removeClass('slideup').addClass('sticky');if(totalItems===undefined)
totalItems=cart.totalItems();if(totalItems>0)
{$cartIcon.addClass('items-added');$('.showIfCartEmpty').removeClass('hidden').slideUp(animDuration);$('.hideIfCartEmpty').slideDown(animDuration)}else{$cartIcon.removeClass('items-added');$('.showIfCartEmpty').slideDown(animDuration);$('.hideIfCartEmpty').removeClass('hidden').slideUp(animDuration)}
$cartCounter.text(totalItems)},}),stat:new flexapp({config:{debug:!0},init:function(config)
{var app=this;if($.isPlainObject(config))
$.extend(!0,app.config,config);var track=$.totalStorage('trackingcodes')||{};$.each(app.config.trackurls,function()
{if($_GET[this])
track[this]=$_GET[this]});$.totalStorage('trackingcodes',track)},comment:function(){},rating:function(){},page:function(){},optin:function(type){var app=this;if(typeof gtag!=='function'||!app.config.ads.id||!app.config.ads.optin)return;gtag('event','conversion',{'send_to':app.config.ads.id+'/'+app.config.ads.optin,})},addToCart:function(value,currency){var app=this;if(typeof gtag!=='function'||!app.config.ads.id||!app.config.ads.addToCart)return;gtag('event','conversion',{'send_to':app.config.ads.id+'/'+app.config.ads.addToCart,'value':value||0.0,'currency':currency||'USD'})},beginCheckout:function(value,currency){var app=this;if(typeof gtag!=='function'||!app.config.ads.id||!app.config.ads.beginCheckout)return;gtag('event','conversion',{'send_to':app.config.ads.id+'/'+app.config.ads.beginCheckout,'value':value||0.0,'currency':currency||'USD'})},purchase:function(){var app=this;if(typeof gtag!=='function'||!app.config.ads.id||!app.config.ads.purchase)return;gtag('event','conversion',{'send_to':app.config.ads.id+'/'+app.config.ads.purchase,'value':value||0.0,'currency':currency||'USD'})},},app),prefillData:function(data)
{var app=this;data=data||app;$('[data-prefill]').each(function()
{var $this=$(this),val='',args=$this.data('prefill-args')||[];try{val=eval('data.'+$this.data('prefill'))}catch(err){app.debug(err,'prefillData','warn')}
if(typeof val==='function')
val=val.call(app,args);if((val+'').length===0)return!0;if(this.hasOwnProperty('value')||['INPUT','OPTION'].indexOf(this.tagName)>=0)
$this.val(val);else $this.html(val)})},notify:function(msg,type,icon,placement)
{switch(type)
{case 'error':case 'danger':type='danger';if(!icon)icon='fad fa-exclamation-square';break;case 'warning':type='warning';if(!icon)icon='fad fa-exclamation-triangle';break;case 'success':case 'cartadd':if(type==='cartadd'&&!icon)icon='fa fa-cart-plus';if(!icon)icon='fad fa-check-circle';type='success';break;case 'info':type='info';if(!icon)icon='fad fa-info-circle';break;default:if(!icon)icon='fad fa-info-circle';break}
if(!placement)placement={from:'bottom',align:'right'};$.notify({icon:icon,message:msg},{type:type,animate:{enter:'animated fadeInUp',exit:'animated fadeOut'},placement:placement,offset:20,spacing:10,z_index:991031,})},humanreadable:function(num,digits)
{if(digits===undefined)digits=1;var si=[{value:1,symbol:""},{value:1E3,symbol:"K"},{value:1E6,symbol:"M"},{value:1E9,symbol:"G"},{value:1E12,symbol:"T"},{value:1E15,symbol:"P"},{value:1E18,symbol:"E"}];var rx=/\.0+$|(\.[0-9]*[1-9])0+$/;var i;for(i=si.length-1;i>0;i--){if(num>=si[i].value){break}}
return(num/si[i].value).toFixed(digits).replace(rx,"$1")+si[i].symbol},__:function(token)
{var app=this;if(app.lang[token])return app.lang[token];return token},})}(jQuery,window.console))