// source --> https://agilestorelocator.com/wp-content/plugins/agile-store-locator/public/js/asl-form.js?ver=5.2.0 
/*
 * Note that this is atoastr v2.1.3, the "latest" version in url has no more maintenance,
 * please go to https://cdnjs.com/libraries/atoastr.js and pick a certain version you want to use,
 * make sure you copy the url from the website since the url may change between versions.
 * */
window.atoastr=function(h){var v,t,C,w=0,n="error",o="info",i="success",a="warning",e={clear:function(e,t){var s=b();v||T(s);r(e,s,t)||function(e){for(var t=v.children(),s=t.length-1;0<=s;s--)r(h(t[s]),e)}(s)},remove:function(e){var t=b();v||T(t);if(e&&0===h(":focus",e).length)return void D(e);v.children().length&&v.remove()},error:function(e,t,s){return l({type:n,iconClass:b().iconClasses.error,message:e,optionsOverride:s,title:t})},getContainer:T,info:function(e,t,s){return l({type:o,iconClass:b().iconClasses.info,message:e,optionsOverride:s,title:t})},options:{},subscribe:function(e){t=e},success:function(e,t,s){return l({type:i,iconClass:b().iconClasses.success,message:e,optionsOverride:s,title:t})},version:"2.1.4",warning:function(e,t,s){return l({type:a,iconClass:b().iconClasses.warning,message:e,optionsOverride:s,title:t})}};return e;function T(e,t){return e||(e=b()),(v=h("#"+e.containerId)).length||t&&(s=e,(v=h("<div/>").attr("id",s.containerId).addClass(s.positionClass)).appendTo(h(s.target)),v=v),v;var s}function r(e,t,s){var n=!(!s||!s.force)&&s.force;return!(!e||!n&&0!==h(":focus",e).length)&&(e[t.hideMethod]({duration:t.hideDuration,easing:t.hideEasing,complete:function(){D(e)}}),!0)}function O(e){t&&t(e)}function l(t){var o=b(),e=t.iconClass||o.iconClass;if(void 0!==t.optionsOverride&&(o=h.extend(o,t.optionsOverride),e=t.optionsOverride.iconClass||e),!function(e,t){if(e.preventDuplicates){if(t.message===C)return!0;C=t.message}return!1}(o,t)){w++,v=T(o,!0);var i=null,a=h("<div/>"),s=h("<div/>"),n=h("<div/>"),r=h("<div/>"),l=h(o.closeHtml),c={intervalId:null,hideEta:null,maxHideTime:null},d={atoastId:w,state:"visible",startTime:new Date,options:o,map:t};return t.iconClass&&a.addClass(o.atoastClass).addClass(e),function(){if(t.title){var e=t.title;o.escapeHtml&&(e=u(t.title)),s.append(e).addClass(o.titleClass),a.append(s)}}(),function(){if(t.message){var e=t.message;o.escapeHtml&&(e=u(t.message)),n.append(e).addClass(o.messageClass),a.append(n)}}(),o.closeButton&&(l.addClass(o.closeClass).attr("role","button"),a.prepend(l)),o.progressBar&&(r.addClass(o.progressClass),a.prepend(r)),o.rtl&&a.addClass("rtl"),o.newestOnTop?v.prepend(a):v.append(a),function(){var e="";switch(t.iconClass){case"atoast-success":case"atoast-info":e="polite";break;default:e="assertive"}a.attr("aria-live",e)}(),a.hide(),a[o.showMethod]({duration:o.showDuration,easing:o.showEasing,complete:o.onShown}),0<o.timeOut&&(i=setTimeout(p,o.timeOut),c.maxHideTime=parseFloat(o.timeOut),c.hideEta=(new Date).getTime()+c.maxHideTime,o.progressBar&&(c.intervalId=setInterval(f,10))),function(){o.closeOnHover&&a.hover(m,g);!o.onclick&&o.tapToDismiss&&a.click(p);o.closeButton&&l&&l.click(function(e){e.stopPropagation?e.stopPropagation():void 0!==e.cancelBubble&&!0!==e.cancelBubble&&(e.cancelBubble=!0),o.onCloseClick&&o.onCloseClick(e),p(!0)});o.onclick&&a.click(function(e){o.onclick(e),p()})}(),O(d),o.debug&&console&&console.log(d),a}function u(e){return null==e&&(e=""),e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function p(e){var t=e&&!1!==o.closeMethod?o.closeMethod:o.hideMethod,s=e&&!1!==o.closeDuration?o.closeDuration:o.hideDuration,n=e&&!1!==o.closeEasing?o.closeEasing:o.hideEasing;if(!h(":focus",a).length||e)return clearTimeout(c.intervalId),a[t]({duration:s,easing:n,complete:function(){D(a),clearTimeout(i),o.onHidden&&"hidden"!==d.state&&o.onHidden(),d.state="hidden",d.endTime=new Date,O(d)}})}function g(){(0<o.timeOut||0<o.extendedTimeOut)&&(i=setTimeout(p,o.extendedTimeOut),c.maxHideTime=parseFloat(o.extendedTimeOut),c.hideEta=(new Date).getTime()+c.maxHideTime)}function m(){clearTimeout(i),c.hideEta=0,a.stop(!0,!0)[o.showMethod]({duration:o.showDuration,easing:o.showEasing})}function f(){var e=(c.hideEta-(new Date).getTime())/c.maxHideTime*100;r.width(e+"%")}}function b(){return h.extend({},{tapToDismiss:!0,atoastClass:"atoast",containerId:"atoast-container",debug:!1,showMethod:"fadeIn",showDuration:300,showEasing:"swing",onShown:void 0,hideMethod:"fadeOut",hideDuration:1e3,hideEasing:"swing",onHidden:void 0,closeMethod:!1,closeDuration:!1,closeEasing:!1,closeOnHover:!0,extendedTimeOut:1e3,iconClasses:{error:"atoast-error",info:"atoast-info",success:"atoast-success",warning:"atoast-warning"},iconClass:"atoast-info",positionClass:"atoast-top-right",timeOut:5e3,titleClass:"atoast-title",messageClass:"atoast-message",escapeHtml:!1,target:"body",closeHtml:'<button type="button">&times;</button>',closeClass:"atoast-close-button",newestOnTop:!0,preventDuplicates:!1,progressBar:!1,progressClass:"atoast-progress",rtl:!1},e.options)}function D(e){v||(v=T()),e.is(":visible")||(e.remove(),e=null,0===v.children().length&&(v.remove(),C=void 0))}}(window.jQuery);

(function($) {

    
  var container = document.querySelector('#sl-frm.asl-form');

  //  Main container is missing!
  if(!container) {
    return;
  }

  // Disable keyboard tabbing into the map iframe/controls
  (function disableMapKeyboardFocus() {
    var mapEl = document.getElementById('asl-register-map');

    if (!mapEl || typeof MutationObserver === 'undefined') {
      return;
    }

    mapEl.setAttribute('tabindex', '-1');
    mapEl.setAttribute('aria-hidden', 'true');

    var stripTabStops = function() {
      var tabbables = mapEl.querySelectorAll('a, area, button, input, select, textarea, [tabindex]');
      tabbables.forEach(function(node) {
        node.setAttribute('tabindex', '-1');
        node.setAttribute('aria-hidden', 'true');
      });
    };

    stripTabStops();

    var observer = new MutationObserver(stripTabStops);
    observer.observe(mapEl, { childList: true, subtree: true });

    mapEl.addEventListener('focus', function(e) {
      e.target.blur();
    }, true);
  })();

  /*! bootstrap-asltimepicker v0.2.5 
  * http://jdewit.github.com/bootstrap-asltimepicker 
  * Copyright (c) 2013 Joris de Wit 
  * MIT License 
  */
  /*!
  * Timepicker Component for Twitter Bootstrap
  *
  * Copyright 2013 Joris de Wit
  *
  * Contributors https://github.com/jdewit/bootstrap-asltimepicker/graphs/contributors
  *
  * For the full copyright and license information, please view the LICENSE
  * file that was distributed with this source code.
  */
  !function(t,i,e){"use strict";var s=function(i,e){this.widget="",this.$element=t(i),this.defaultTime=e.defaultTime,this.disableFocus=e.disableFocus,this.disableMousewheel=e.disableMousewheel,this.isOpen=e.isOpen,this.minuteStep=e.minuteStep,this.modalBackdrop=e.modalBackdrop,this.orientation=e.orientation,this.secondStep=e.secondStep,this.snapToStep=e.snapToStep,this.showInputs=e.showInputs,this.showMeridian=e.showMeridian,this.showSeconds=e.showSeconds,this.template=e.template,this.appendWidgetTo=e.appendWidgetTo,this.showWidgetOnAddonClick=e.showWidgetOnAddonClick,this.maxHours=e.maxHours,this.explicitMode=e.explicitMode,this.twoDigitsHour=!0,this.handleDocumentClick=function(t){var i=t.data.scope;i.$element.parent().find(t.target).length||i.$widget.is(t.target)||i.$widget.find(t.target).length||i.hideWidget()},this._init()};s.prototype={constructor:s,_init:function(){var i=this;this.showWidgetOnAddonClick&&this.$element.parent().hasClass("input-group")&&this.$element.parent().hasClass("bootstrap-asltimepicker")?(this.$element.parent(".input-group.bootstrap-asltimepicker").find(".input-group-append").on({"click.asltimepicker":t.proxy(this.showWidget,this)}),this.$element.on({"focus.asltimepicker":t.proxy(this.highlightUnit,this),"click.asltimepicker":t.proxy(this.highlightUnit,this),"keydown.asltimepicker":t.proxy(this.elementKeydown,this),"blur.asltimepicker":t.proxy(this.blurElement,this),"mousewheel.asltimepicker DOMMouseScroll.asltimepicker":t.proxy(this.mousewheel,this)})):this.template?this.$element.on({"focus.asltimepicker":t.proxy(this.showWidget,this),"click.asltimepicker":t.proxy(this.showWidget,this),"blur.asltimepicker":t.proxy(this.blurElement,this),"mousewheel.asltimepicker DOMMouseScroll.asltimepicker":t.proxy(this.mousewheel,this)}):this.$element.on({"focus.asltimepicker":t.proxy(this.highlightUnit,this),"click.asltimepicker":t.proxy(this.highlightUnit,this),"keydown.asltimepicker":t.proxy(this.elementKeydown,this),"blur.asltimepicker":t.proxy(this.blurElement,this),"mousewheel.asltimepicker DOMMouseScroll.asltimepicker":t.proxy(this.mousewheel,this)}),this.template!==!1?this.$widget=t(this.getTemplate()).on("click",t.proxy(this.widgetClick,this)):this.$widget=!1,this.showInputs&&this.$widget!==!1&&this.$widget.find("input").each(function(){t(this).on({"click.asltimepicker":function(){t(this).select()},"keydown.asltimepicker":t.proxy(i.widgetKeydown,i),"keyup.asltimepicker":t.proxy(i.widgetKeyup,i)})}),this.setDefaultTime(this.defaultTime)},blurElement:function(){this.highlightedUnit=null,this.updateFromElementVal()},clear:function(){this.hour="",this.minute="",this.second="",this.meridian="",this.$element.val("")},decrementHour:function(){if(this.showMeridian)if(1===this.hour)this.hour=12;else{if(12===this.hour)return this.hour--,this.toggleMeridian();if(0===this.hour)return this.hour=11,this.toggleMeridian();this.hour--}else this.hour<=0?this.hour=this.maxHours-1:this.hour--},decrementMinute:function(t){var i;i=t?this.minute-t:this.minute-this.minuteStep,i<0?(this.decrementHour(),this.minute=i+60):this.minute=i},decrementSecond:function(){var t=this.second-this.secondStep;t<0?(this.decrementMinute(!0),this.second=t+60):this.second=t},elementKeydown:function(t){switch(t.which){case 9:if(t.shiftKey){if("hour"===this.highlightedUnit)break;this.highlightPrevUnit()}else{if(this.showMeridian&&"meridian"===this.highlightedUnit||this.showSeconds&&"second"===this.highlightedUnit||!this.showMeridian&&!this.showSeconds&&"minute"===this.highlightedUnit)break;this.highlightNextUnit()}t.preventDefault(),this.updateFromElementVal();break;case 27:this.updateFromElementVal();break;case 37:t.preventDefault(),this.highlightPrevUnit(),this.updateFromElementVal();break;case 38:switch(t.preventDefault(),this.highlightedUnit){case"hour":this.incrementHour(),this.highlightHour();break;case"minute":this.incrementMinute(),this.highlightMinute();break;case"second":this.incrementSecond(),this.highlightSecond();break;case"meridian":this.toggleMeridian(),this.highlightMeridian()}this.update();break;case 39:t.preventDefault(),this.highlightNextUnit(),this.updateFromElementVal();break;case 40:switch(t.preventDefault(),this.highlightedUnit){case"hour":this.decrementHour(),this.highlightHour();break;case"minute":this.decrementMinute(),this.highlightMinute();break;case"second":this.decrementSecond(),this.highlightSecond();break;case"meridian":this.toggleMeridian(),this.highlightMeridian()}this.update()}},getCursorPosition:function(){var t=this.$element.get(0);if("selectionStart"in t)return t.selectionStart;if(e.selection){t.focus();var i=e.selection.createRange(),s=e.selection.createRange().text.length;return i.moveStart("character",-t.value.length),i.text.length-s}},getTemplate:function(){var t,i,e,s,h,n;switch(this.showInputs?(i='<input type="text" class="bootstrap-asltimepicker-hour" maxlength="2"/>',e='<input type="text" class="bootstrap-asltimepicker-minute" maxlength="2"/>',s='<input type="text" class="bootstrap-asltimepicker-second" maxlength="2"/>',h='<input type="text" class="bootstrap-asltimepicker-meridian" maxlength="2"/>'):(i='<span class="bootstrap-asltimepicker-hour"></span>',e='<span class="bootstrap-asltimepicker-minute"></span>',s='<span class="bootstrap-asltimepicker-second"></span>',h='<span class="bootstrap-asltimepicker-meridian"></span>'),n='<table><tr><td><a href="#" data-action="incrementHour"><svg width="16" height="16"><use xlink:href="#i-chevron-top"></use></svg></a></td><td class="separator">&nbsp;</td><td><a href="#" data-action="incrementMinute"><svg width="16" height="16"><use xlink:href="#i-chevron-top"></use></svg></a></td>'+(this.showSeconds?'<td class="separator">&nbsp;</td><td><a href="#" data-action="incrementSecond"><svg width="16" height="16"><use xlink:href="#i-chevron-top"></use></svg></a></td>':"")+(this.showMeridian?'<td class="separator">&nbsp;</td><td class="meridian-column"><a href="#" data-action="toggleMeridian"><svg width="16" height="16"><use xlink:href="#i-chevron-top"></use></svg></a></td>':"")+"</tr><tr><td>"+i+'</td> <td class="separator">:</td><td>'+e+"</td> "+(this.showSeconds?'<td class="separator">:</td><td>'+s+"</td>":"")+(this.showMeridian?'<td class="separator">&nbsp;</td><td>'+h+"</td>":"")+'</tr><tr><td><a href="#" data-action="decrementHour"><svg width="16" height="16"><use xlink:href="#i-chevron-bottom"></use></svg></a></td><td class="separator"></td><td><a href="#" data-action="decrementMinute"><svg width="16" height="16"><use xlink:href="#i-chevron-bottom"></use></svg></a></td>'+(this.showSeconds?'<td class="separator">&nbsp;</td><td><a href="#" data-action="decrementSecond"><svg width="16" height="16"><use xlink:href="#i-chevron-bottom"></use></svg></a></td>':"")+(this.showMeridian?'<td class="separator">&nbsp;</td><td><a href="#" data-action="toggleMeridian"><svg width="16" height="16"><use xlink:href="#i-chevron-bottom"></use></svg></a></td>':"")+"</tr></table>",this.template){case"modal":t='<div class="bootstrap-asltimepicker-widget modal hide fade in" data-backdrop="'+(this.modalBackdrop?"true":"false")+'"><div class="modal-header"><a href="#" class="close" data-dismiss="modal">Ã—</a><h3>Pick a Time</h3></div><div class="modal-content">'+n+'</div><div class="modal-footer"><a href="#" class="btn btn-primary" data-dismiss="modal">OK</a></div></div>';break;case"dropdown":t='<div class="bootstrap-asltimepicker-widget dropdown-menu">'+n+"</div>"}return t},getTime:function(){return""===this.hour?"":this.getFormattedHour()+":"+(1===this.minute.toString().length?"0"+this.minute:this.minute)+(this.showSeconds?":"+(1===this.second.toString().length?"0"+this.second:this.second):"")+(this.showMeridian?" "+this.meridian:"")},getFormattedHour:function(){var t=""+this.hour;return 1===t.length&&this.twoDigitsHour&&(t="0"+t),t},hideWidget:function(){this.isOpen!==!1&&(this.$element.trigger({type:"hide.asltimepicker",time:{value:this.getTime(),hours:this.hour,minutes:this.minute,seconds:this.second,meridian:this.meridian}}),"modal"===this.template&&this.$widget.modal?this.$widget.modal("hide"):this.$widget.removeClass("open"),t(e).off("mousedown.asltimepicker, touchend.asltimepicker",this.handleDocumentClick),this.isOpen=!1,this.$widget.detach())},highlightUnit:function(){this.position=this.getCursorPosition(),this.position>=0&&this.position<=2?this.highlightHour():this.position>=3&&this.position<=5?this.highlightMinute():this.position>=6&&this.position<=8?this.showSeconds?this.highlightSecond():this.highlightMeridian():this.position>=9&&this.position<=11&&this.highlightMeridian()},highlightNextUnit:function(){switch(this.highlightedUnit){case"hour":this.highlightMinute();break;case"minute":this.showSeconds?this.highlightSecond():this.showMeridian?this.highlightMeridian():this.highlightHour();break;case"second":this.showMeridian?this.highlightMeridian():this.highlightHour();break;case"meridian":this.highlightHour()}},highlightPrevUnit:function(){switch(this.highlightedUnit){case"hour":this.showMeridian?this.highlightMeridian():this.showSeconds?this.highlightSecond():this.highlightMinute();break;case"minute":this.highlightHour();break;case"second":this.highlightMinute();break;case"meridian":this.showSeconds?this.highlightSecond():this.highlightMinute()}},highlightHour:function(){var t=this.$element.get(0),i=this;this.highlightedUnit="hour",t.setSelectionRange&&setTimeout(function(){var e=i.getFormattedHour();t.setSelectionRange(0,e.length)},0)},highlightMinute:function(){var t=this.$element.get(0),i=this;this.highlightedUnit="minute",t.setSelectionRange&&setTimeout(function(){var e=i.getFormattedHour(),s=1+e.length;t.setSelectionRange(s,s+2)},0)},highlightSecond:function(){var t=this.$element.get(0),i=this;this.highlightedUnit="second",t.setSelectionRange&&setTimeout(function(){var e=i.getFormattedHour(),s=4+e.length;t.setSelectionRange(s,s+2)},0)},highlightMeridian:function(){var t=this.$element.get(0),i=this;if(this.highlightedUnit="meridian",t.setSelectionRange){var e,s=i.getFormattedHour();e=this.showSeconds?7+s.length:4+s.length,setTimeout(function(){t.setSelectionRange(e,e+i.meridian.length)},0)}},incrementHour:function(){if(this.showMeridian){if(11===this.hour)return this.hour++,this.toggleMeridian();12===this.hour&&(this.hour=0)}return this.hour===this.maxHours-1?void(this.hour=0):void this.hour++},incrementMinute:function(t){var i;i=t?this.minute+t:this.minute+this.minuteStep-this.minute%this.minuteStep,i>59?(this.incrementHour(),this.minute=i-60):this.minute=i},incrementSecond:function(){var t=this.second+this.secondStep-this.second%this.secondStep;t>59?(this.incrementMinute(!0),this.second=t-60):this.second=t},mousewheel:function(i){if(!this.disableMousewheel){i.preventDefault(),i.stopPropagation();var e=i.originalEvent.wheelDelta||-i.originalEvent.detail,s=null;switch("mousewheel"===i.type?s=i.originalEvent.wheelDelta*-1:"DOMMouseScroll"===i.type&&(s=40*i.originalEvent.detail),s&&(i.preventDefault(),t(this).scrollTop(s+t(this).scrollTop())),this.highlightedUnit){case"minute":e>0?this.incrementMinute():this.decrementMinute(),this.highlightMinute();break;case"second":e>0?this.incrementSecond():this.decrementSecond(),this.highlightSecond();break;case"meridian":this.toggleMeridian(),this.highlightMeridian();break;default:e>0?this.incrementHour():this.decrementHour(),this.highlightHour()}return!1}},changeToNearestStep:function(t,i){return t%i===0?t:Math.round(t%i/i)?(t+(i-t%i))%60:t-t%i},place:function(){if(!this.isInline){var e=this.$widget.outerWidth(),s=this.$widget.outerHeight(),h=10,n=t(i).width(),o=t(i).height(),r=t(i).scrollTop(),a=parseInt(this.$element.parents().filter(function(){return"auto"!==t(this).css("z-index")}).first().css("z-index"),10)+10,d=this.component?this.component.parent().offset():this.$element.offset(),c=this.component?this.component.outerHeight(!0):this.$element.outerHeight(!1),l=this.component?this.component.outerWidth(!0):this.$element.outerWidth(!1),p=d.left,u=d.top;this.$widget.removeClass("asltimepicker-orient-top asltimepicker-orient-bottom asltimepicker-orient-right asltimepicker-orient-left"),"auto"!==this.orientation.x?(this.picker.addClass("datepicker-orient-"+this.orientation.x),"right"===this.orientation.x&&(p-=e-l)):(this.$widget.addClass("asltimepicker-orient-left"),d.left<0?p-=d.left-h:d.left+e>n&&(p=n-e-h));var m,g,w=this.orientation.y;"auto"===w&&(m=-r+d.top-s,g=r+o-(d.top+c+s),w=Math.max(m,g)===g?"top":"bottom"),this.$widget.addClass("asltimepicker-orient-"+w),"top"===w?u+=c:u-=s+parseInt(this.$widget.css("padding-top"),10),this.$widget.css({top:u,left:p,zIndex:a})}},remove:function(){t("document").off(".asltimepicker"),this.$widget&&this.$widget.remove(),delete this.$element.data().asltimepicker},setDefaultTime:function(t){if(this.$element.val())this.updateFromElementVal();else if("current"===t){var i=new Date,e=i.getHours(),s=i.getMinutes(),h=i.getSeconds(),n="AM";0!==h&&(h=Math.ceil(i.getSeconds()/this.secondStep)*this.secondStep,60===h&&(s+=1,h=0)),0!==s&&(s=Math.ceil(i.getMinutes()/this.minuteStep)*this.minuteStep,60===s&&(e+=1,s=0)),this.showMeridian&&(0===e?e=12:e>=12?(e>12&&(e-=12),n="PM"):n="AM"),this.hour=e,this.minute=s,this.second=h,this.meridian=n,this.update()}else t===!1?(this.hour=0,this.minute=0,this.second=0,this.meridian="AM"):this.setTime(t)},setTime:function(t,i){if(!t)return void this.clear();var e,s,h,n,o,r;if("object"==typeof t&&t.getMonth)h=t.getHours(),n=t.getMinutes(),o=t.getSeconds(),this.showMeridian&&(r="AM",h>12&&(r="PM",h%=12),12===h&&(r="PM"));else{if(e=(/a/i.test(t)?1:0)+(/p/i.test(t)?2:0),e>2)return void this.clear();if(s=t.replace(/[^0-9\:]/g,"").split(":"),h=s[0]?s[0].toString():s.toString(),this.explicitMode&&h.length>2&&h.length%2!==0)return void this.clear();n=s[1]?s[1].toString():"",o=s[2]?s[2].toString():"",h.length>4&&(o=h.slice(-2),h=h.slice(0,-2)),h.length>2&&(n=h.slice(-2),h=h.slice(0,-2)),n.length>2&&(o=n.slice(-2),n=n.slice(0,-2)),h=parseInt(h,10),n=parseInt(n,10),o=parseInt(o,10),isNaN(h)&&(h=0),isNaN(n)&&(n=0),isNaN(o)&&(o=0),o>59&&(o=59),n>59&&(n=59),h>=this.maxHours&&(h=this.maxHours-1),this.showMeridian?(h>12&&(e=2,h-=12),e||(e=1),0===h&&(h=12),r=1===e?"AM":"PM"):h<12&&2===e?h+=12:h>=this.maxHours?h=this.maxHours-1:h<0&&(h=0)}this.hour=h,this.snapToStep?(this.minute=this.changeToNearestStep(n,this.minuteStep),this.second=this.changeToNearestStep(o,this.secondStep)):(this.minute=n,this.second=o),this.meridian=r,this.update(i)},showWidget:function(){this.isOpen||this.$element.is(":disabled")||(this.$widget.appendTo(this.appendWidgetTo),t(e).on("mousedown.asltimepicker, touchend.asltimepicker",{scope:this},this.handleDocumentClick),this.$element.trigger({type:"show.asltimepicker",time:{value:this.getTime(),hours:this.hour,minutes:this.minute,seconds:this.second,meridian:this.meridian}}),this.place(),this.disableFocus&&this.$element.blur(),""===this.hour&&(this.defaultTime?this.setDefaultTime(this.defaultTime):this.setTime("0:0:0")),"modal"===this.template&&this.$widget.modal?this.$widget.modal("show").on("hidden",t.proxy(this.hideWidget,this)):this.isOpen===!1&&this.$widget.addClass("open"),this.isOpen=!0)},toggleMeridian:function(){this.meridian="AM"===this.meridian?"PM":"AM"},update:function(t){this.updateElement(),t||this.updateWidget(),this.$element.trigger({type:"changeTime.asltimepicker",time:{value:this.getTime(),hours:this.hour,minutes:this.minute,seconds:this.second,meridian:this.meridian}})},updateElement:function(){this.$element.val(this.getTime()).change()},updateFromElementVal:function(){this.setTime(this.$element.val())},updateWidget:function(){if(this.$widget!==!1){var t=this.getFormattedHour(),i=1===this.minute.toString().length?"0"+this.minute:this.minute,e=1===this.second.toString().length?"0"+this.second:this.second;this.showInputs?(this.$widget.find("input.bootstrap-asltimepicker-hour").val(t),this.$widget.find("input.bootstrap-asltimepicker-minute").val(i),this.showSeconds&&this.$widget.find("input.bootstrap-asltimepicker-second").val(e),this.showMeridian&&this.$widget.find("input.bootstrap-asltimepicker-meridian").val(this.meridian)):(this.$widget.find("span.bootstrap-asltimepicker-hour").text(t),this.$widget.find("span.bootstrap-asltimepicker-minute").text(i),this.showSeconds&&this.$widget.find("span.bootstrap-asltimepicker-second").text(e),this.showMeridian&&this.$widget.find("span.bootstrap-asltimepicker-meridian").text(this.meridian))}},updateFromWidgetInputs:function(){if(this.$widget!==!1){var t=this.$widget.find("input.bootstrap-asltimepicker-hour").val()+":"+this.$widget.find("input.bootstrap-asltimepicker-minute").val()+(this.showSeconds?":"+this.$widget.find("input.bootstrap-asltimepicker-second").val():"")+(this.showMeridian?this.$widget.find("input.bootstrap-asltimepicker-meridian").val():"");this.setTime(t,!0)}},widgetClick:function(i){i.stopPropagation(),i.preventDefault();var e=t(i.target),s=e.closest("a").data("action");s&&this[s](),this.update(),e.is("input")&&e.get(0).setSelectionRange(0,2)},widgetKeydown:function(i){var e=t(i.target),s=e.attr("class").replace("bootstrap-asltimepicker-","");switch(i.which){case 9:if(i.shiftKey){if("hour"===s)return this.hideWidget()}else if(this.showMeridian&&"meridian"===s||this.showSeconds&&"second"===s||!this.showMeridian&&!this.showSeconds&&"minute"===s)return this.hideWidget();break;case 27:this.hideWidget();break;case 38:switch(i.preventDefault(),s){case"hour":this.incrementHour();break;case"minute":this.incrementMinute();break;case"second":this.incrementSecond();break;case"meridian":this.toggleMeridian()}this.setTime(this.getTime()),e.get(0).setSelectionRange(0,2);break;case 40:switch(i.preventDefault(),s){case"hour":this.decrementHour();break;case"minute":this.decrementMinute();break;case"second":this.decrementSecond();break;case"meridian":this.toggleMeridian()}this.setTime(this.getTime()),e.get(0).setSelectionRange(0,2)}},widgetKeyup:function(t){(65===t.which||77===t.which||80===t.which||46===t.which||8===t.which||t.which>=48&&t.which<=57||t.which>=96&&t.which<=105)&&this.updateFromWidgetInputs()}},t.fn.asltimepicker=function(i){var e=Array.apply(null,arguments);return e.shift(),this.each(function(){var h=t(this),n=h.data("asltimepicker"),o="object"==typeof i&&i;n||h.data("asltimepicker",n=new s(this,t.extend({},t.fn.asltimepicker.defaults,o,t(this).data()))),"string"==typeof i&&n[i].apply(n,e)})},t.fn.asltimepicker.defaults={defaultTime:"current",disableFocus:!1,disableMousewheel:!1,isOpen:!1,minuteStep:15,modalBackdrop:!1,orientation:{x:"auto",y:"auto"},secondStep:15,snapToStep:!1,showSeconds:!1,showInputs:!0,showMeridian:!0,template:"dropdown",appendWidgetTo:"body",showWidgetOnAddonClick:!0,maxHours:24,explicitMode:!1,twoDigitsHour:!1},t.fn.asltimepicker.Constructor=s,t(e).on("focus.asltimepicker.data-api click.asltimepicker.data-api",'[data-provide="asltimepicker"]',function(i){var e=t(this);e.data("asltimepicker")||(i.preventDefault(),e.asltimepicker())})}(jQuery,window,document);


  /**
   * [asl_register_store_changed Responsible to update the lat/lng fields]
   * @param  {[type]} _location [description]
   * @return {[type]}           [description]
   */
  function asl_register_store_changed(_location) {

    document.querySelector('#sl-frm.asl-form #sl-lat').value = _location[0];

    document.querySelector('#sl-frm.asl-form #sl-lng').value = _location[1];
  };

  /**
   * [isEmpty description]
   * @param  {[type]}  obj [description]
   * @return {Boolean}     [description]
   */
  function isEmpty(obj) {

    if (obj == null) return true;
    if (typeof(obj) == 'string' && obj == '') return true;
    return Object.keys(obj).length === 0;
  };



  ///////////////////////
  // Asynchronous Maps //
  ///////////////////////
  var map,
      map_object = {
        is_loaded: true,
        marker: null,
        changed: false,
        store_location: null,
        map_marker: null,
        /**
         * [intialize description]
         * @param  {[type]} _callback [description]
         * @return {[type]}           [description]
         */
        intialize: function(_callback) {

          var API_KEY = '';
          if (asl_form_configuration && asl_form_configuration.api_key) {
            API_KEY = '&key=' + asl_form_configuration.api_key;
          }

          var script = document.createElement('script');
          script.type = 'text/javascript';
          script.src = '//maps.googleapis.com/maps/api/js?libraries=places,drawing&' +
            'callback=asl_map_intialized' + API_KEY;
          //+'callback=asl_map_intialized';
          document.body.appendChild(script);
          this.cb = _callback;
        },
        /**
         * [render_a_map description]
         * @param  {[type]} _lat [description]
         * @param  {[type]} _lng [description]
         * @return {[type]}      [description]
         */
        render_a_map: function(_lat, _lng) {

          var hdlr      = this,
            map_div     = document.getElementById('asl-register-map'),
            _draggable  = true;

          
          hdlr.store_location = (_lat && _lng) ? [parseFloat(_lat), parseFloat(_lng)] : [-37.815, 144.965];

          var latlng = new google.maps.LatLng(hdlr.store_location[0], hdlr.store_location[1]);

          if (!map_div) return false;

          var mapOptions = {
            zoom: 5,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            styles: [{ "stylers": [{ "saturation": -100 }, { "gamma": 1 }] }, { "elementType": "labels.text.stroke", "stylers": [{ "visibility": "off" }] }, { "featureType": "poi.business", "elementType": "labels.text", "stylers": [{ "visibility": "off" }] }, { "featureType": "poi.business", "elementType": "labels.icon", "stylers": [{ "visibility": "off" }] }, { "featureType": "poi.place_of_worship", "elementType": "labels.text", "stylers": [{ "visibility": "off" }] }, { "featureType": "poi.place_of_worship", "elementType": "labels.icon", "stylers": [{ "visibility": "off" }] }, { "featureType": "road", "elementType": "geometry", "stylers": [{ "visibility": "simplified" }] }, { "featureType": "water", "stylers": [{ "visibility": "on" }, { "saturation": 50 }, { "gamma": 0 }, { "hue": "#50a5d1" }] }, { "featureType": "administrative.neighborhood", "elementType": "labels.text.fill", "stylers": [{ "color": "#333333" }] }, { "featureType": "road.local", "elementType": "labels.text", "stylers": [{ "weight": 0.5 }, { "color": "#333333" }] }, { "featureType": "transit.station", "elementType": "labels.icon", "stylers": [{ "gamma": 1 }, { "saturation": 50 }] }]
          };

          hdlr.map_instance = map = new google.maps.Map(map_div, mapOptions);

          // && navigator.geolocation && _draggable
          if (!hdlr.store_location) {

            hdlr.add_marker(latlng);
          }
          else if (hdlr.store_location) {
            if (isNaN(hdlr.store_location[0]) || isNaN(hdlr.store_location[1])) return;
            //var loc = new google.maps.LatLng(hdlr.store_location[0], hdlr.store_location[1]);
            hdlr.add_marker(latlng);
            map.panTo(latlng);
          }
        },
        /**
         * [add_marker description]
         * @param {[type]} _loc [description]
         */
        add_marker: function(_loc) {

          var hdlr = this;

          hdlr.map_marker = new google.maps.Marker({
            draggable: true,
            position: _loc,
            map: map
          });

          var marker_icon = new google.maps.MarkerImage(asl_form_configuration.URL + 'icon/default.png');
          
          //marker_icon.size    = new google.maps.Size(24, 39);
          //marker_icon.anchor  = new google.maps.Point(24, 39);
          
          hdlr.map_marker.setIcon(marker_icon);
          hdlr.map_instance.panTo(_loc);

          google.maps.event.addListener(
            hdlr.map_marker,
            'dragend',
            function() {

              hdlr.store_location = [hdlr.map_marker.position.lat(), hdlr.map_marker.position.lng()];
              hdlr.changed = true;
              var loc = new google.maps.LatLng(hdlr.map_marker.position.lat(), hdlr.map_marker.position.lng());
              //map.setPosition(loc);
              map.panTo(loc);

              asl_register_store_changed(hdlr.store_location);
            });
        }
    };


  /**
   * [codeAddress description]
   * @param  {[type]} _address  [description]
   * @param  {[type]} _callback [description]
   * @return {[type]}           [description]
   */
  function codeAddress(_address, _callback) {

    var geocoder = new google.maps.Geocoder();

    geocoder.geocode({ 'address': _address }, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        var hasMapInstance = (typeof map !== 'undefined' && map && typeof map.setCenter === 'function');

        if (hasMapInstance) {
          map.setCenter(results[0].geometry.location);
        }

        if (typeof _callback === 'function') {
          _callback(results[0].geometry);
        }
      }
      //else atoastr.error(ASL_REMOTE.LANG.geocode_fail + status);
    });
  };

  /**
   * [bState Change Button State]
   * @param  {[type]} _state [description]
   * @return {[type]}        [description]
   */
  jQuery.fn.bootButton = function(_state) {

    //  Empty
    if(!this[0])return;

    if(_state == 'loading')
      this.attr('data-reset-text',this.html());

    if(_state == 'loading') {

      if(!this[0].dataset.resetText) {
        this[0].dataset.resetText = this.html();
      }

      this.addClass('disabled').attr('disabled','disabled').html('<i class="fa fa-circle-o-notch fa-spin"></i> ' + this[0].dataset.loadingText);
    }
    else if(_state == 'reset')
      this.removeClass('disabled').removeAttr('disabled').html(this[0].dataset.resetText);
    else if(_state == 'update')
      this.removeClass('disabled').removeAttr('disabled').html(this[0].dataset.updateText);
    else
      this.addClass('disabled').attr('disabled','disabled').html(this[0].dataset[_state+'Text']);
  };

  //  Serialize the Form
  jQuery.fn.ASLSerializeObject = function(){var o={};var a=this.serializeArray();jQuery.each(a,function(){if(o[this.name]!==undefined){if(!o[this.name].push){o[this.name]=[o[this.name]];}o[this.name].push(this.value||'');}else{o[this.name]=this.value||'';}});return o;};


  //http://getbootstrap.com/customize/?id=23dc7cc41297275c7297bb237a95bbd7
  if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(t){"use strict";var e=t.fn.jquery.split(" ")[0].split(".");if(e[0]<2&&e[1]<9||1==e[0]&&9==e[1]&&e[2]<1||e[0]>3){}}(jQuery),+function(t){"use strict";function e(e){var n=e.attr("data-target");n||(n=e.attr("href"),n=n&&/#[A-Za-z]/.test(n)&&n.replace(/.*(?=#[^\s]*$)/,""));var i=n&&t(n);return i&&i.length?i:e.parent()}function n(n){n&&3===n.which||(t(a).remove(),t(o).each(function(){var i=t(this),a=e(i),o={relatedTarget:this};a.hasClass("open")&&(n&&"click"==n.type&&/input|textarea/i.test(n.target.tagName)&&t.contains(a[0],n.target)||(a.trigger(n=t.Event("hide.bs.adropdown",o)),n.isDefaultPrevented()||(i.attr("aria-expanded","false"),a.removeClass("open").trigger(t.Event("hidden.bs.adropdown",o)))))}))}function i(e){return this.each(function(){var n=t(this),i=n.data("bs.adropdown");i||n.data("bs.adropdown",i=new r(this)),"string"==typeof e&&i[e].call(n)})}var a=".adropdown-backdrop",o='[data-toggle="adropdown"]',r=function(e){t(e).on("click.bs.adropdown",this.toggle)};r.VERSION="3.3.7",r.prototype.toggle=function(i){var a=t(this);if(!a.is(".disabled, :disabled")){var o=e(a),r=o.hasClass("open");if(n(),!r){"ontouchstart"in document.documentElement&&!o.closest(".navbar-nav").length&&t(document.createElement("div")).addClass("adropdown-backdrop").insertAfter(t(this)).on("click",n);var s={relatedTarget:this};if(o.trigger(i=t.Event("show.bs.adropdown",s)),i.isDefaultPrevented())return;a.trigger("focus").attr("aria-expanded","true"),o.toggleClass("open").trigger(t.Event("shown.bs.adropdown",s))}return!1}},r.prototype.keydown=function(n){if(/(38|40|27|32)/.test(n.which)&&!/input|textarea/i.test(n.target.tagName)){var i=t(this);if(n.preventDefault(),n.stopPropagation(),!i.is(".disabled, :disabled")){var a=e(i),r=a.hasClass("open");if(!r&&27!=n.which||r&&27==n.which)return 27==n.which&&a.find(o).trigger("focus"),i.trigger("click");var s=" li:not(.disabled):visible a",l=a.find(".adropdown-menu"+s);if(l.length){var d=l.index(n.target);38==n.which&&d>0&&d--,40==n.which&&d<l.length-1&&d++,~d||(d=0),l.eq(d).trigger("focus")}}}};var s=t.fn.adropdown;t.fn.adropdown=i,t.fn.adropdown.Constructor=r,t.fn.adropdown.noConflict=function(){return t.fn.adropdown=s,this},t(document).on("click.bs.adropdown.data-api",n).on("click.bs.adropdown.data-api",".adropdown form",function(t){t.stopPropagation()}).on("click.bs.adropdown.data-api",o,r.prototype.toggle).on("keydown.bs.adropdown.data-api",o,r.prototype.keydown).on("keydown.bs.adropdown.data-api",".adropdown-menu",r.prototype.keydown)}(jQuery),+function(t){"use strict";function e(e){var n,i=e.attr("data-target")||(n=e.attr("href"))&&n.replace(/.*(?=#[^\s]+$)/,"");return t(i)}function n(e){return this.each(function(){var n=t(this),a=n.data("bs.collapse"),o=t.extend({},i.DEFAULTS,n.data(),"object"==typeof e&&e);!a&&o.toggle&&/show|hide/.test(e)&&(o.toggle=!1),a||n.data("bs.collapse",a=new i(this,o)),"string"==typeof e&&a[e]()})}var i=function(e,n){this.$element=t(e),this.options=t.extend({},i.DEFAULTS,n),this.$trigger=t('[data-toggle="collapse"][href="#'+e.id+'"],[data-toggle="collapse"][data-target="#'+e.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};i.VERSION="3.3.7",i.TRANSITION_DURATION=350,i.DEFAULTS={toggle:!0},i.prototype.dimension=function(){var t=this.$element.hasClass("width");return t?"width":"height"},i.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var e,a=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(a&&a.length&&(e=a.data("bs.collapse"),e&&e.transitioning))){var o=t.Event("show.bs.collapse");if(this.$element.trigger(o),!o.isDefaultPrevented()){a&&a.length&&(n.call(a,"hide"),e||a.data("bs.collapse",null));var r=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[r](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var s=function(){this.$element.removeClass("collapsing").addClass("collapse in")[r](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!t.support.transition)return s.call(this);var l=t.camelCase(["scroll",r].join("-"));this.$element.one("bsTransitionEnd",t.proxy(s,this)).emulateTransitionEnd(i.TRANSITION_DURATION)[r](this.$element[0][l])}}}},i.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var e=t.Event("hide.bs.collapse");if(this.$element.trigger(e),!e.isDefaultPrevented()){var n=this.dimension();this.$element[n](this.$element[n]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var a=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};return t.support.transition?void this.$element[n](0).one("bsTransitionEnd",t.proxy(a,this)).emulateTransitionEnd(i.TRANSITION_DURATION):a.call(this)}}},i.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},i.prototype.getParent=function(){return t(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(t.proxy(function(n,i){var a=t(i);this.addAriaAndCollapsedClass(e(a),a)},this)).end()},i.prototype.addAriaAndCollapsedClass=function(t,e){var n=t.hasClass("in");t.attr("aria-expanded",n),e.toggleClass("collapsed",!n).attr("aria-expanded",n)};var a=t.fn.collapse;t.fn.collapse=n,t.fn.collapse.Constructor=i,t.fn.collapse.noConflict=function(){return t.fn.collapse=a,this},t(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(i){var a=t(this);a.attr("data-target")||i.preventDefault();var o=e(a),r=o.data("bs.collapse"),s=r?"toggle":a.data();n.call(o,s)})}(jQuery),+function(t){"use strict";function e(){var t=document.createElement("bootstrap"),e={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var n in e)if(void 0!==t.style[n])return{end:e[n]};return!1}t.fn.emulateTransitionEnd=function(e){var n=!1,i=this;t(this).one("bsTransitionEnd",function(){n=!0});var a=function(){n||t(i).trigger(t.support.transition.end)};return setTimeout(a,e),this},t(function(){t.support.transition=e(),t.support.transition&&(t.event.special.bsTransitionEnd={bindType:t.support.transition.end,delegateType:t.support.transition.end,handle:function(e){return t(e.target).is(this)?e.handleObj.handler.apply(this,arguments):void 0}})})}(jQuery);

  // fetch all the forms we want to apply custom style
  var inputs = container.querySelectorAll('.asl-form .form-control,.asl-form .form-check-input');

  // loop over each input and watch blue event
  var validation = Array.prototype.filter.call(inputs, function(input) {
    
    input.addEventListener('focus', function(event) {

      input.parentNode.classList.add('is-focused');
    });

    input.addEventListener('blur', function(event) {
      
      input.parentNode.classList.remove('is-focused');

      // reset
      //input.parentNode.classList.remove('is-invalid')
      input.parentNode.classList.remove('has-error');
      
      if (input.checkValidity && input.checkValidity() === false) {
          input.parentNode.classList.add('has-error');
      }
      /*else {
        input.parentNode.classList.add('is-valid')
      }*/

    }, false);
  });

  ///////////////////////
  //  Add Multi-Select //
  ///////////////////////
  var sl_ddl = container.querySelectorAll('.custom-select');

  if(sl_ddl) {

    //  Multiple Categories
    if(asl_form_configuration.single_cat_select == '1') {
    
    }


    sl_ddl = $(sl_ddl);

    
    sl_ddl.multiselect({
      enableFiltering: false,
      includeFilterClearBtn: false,
      disableIfEmpty: true,
      nonSelectedText: asl_form_configuration.words.select_option,
      filterPlaceholder: asl_form_configuration.words.search || "Search",
      nonSelectedText: asl_form_configuration.words.none_selected || "None Selected",
      nSelectedText: asl_form_configuration.words.selected || "selected",
      allSelectedText: (asl_form_configuration.words.all_selected || "All selected"),
      includeSelectAllOption: false,
      numberDisplayed: 1,
      maxHeight: 400,
      onInitialized: function($select, $container) {
        // Ensure the multiselect toggle stays in the natural tab order
        var $button = $container ? $container.find('button.multiselect') : $();
        if (!$button.length) {
          return;
        }

        var tabIndex = $select && $select.length ? $select[0].tabIndex : 0;
        if (tabIndex < 0) {
          tabIndex = 0;
        }

        $button.attr('tabindex', tabIndex);
      },
      onChange: function(option, checked) {
        var $select = $(option).closest('select');
        var values = $select.val();
        var hasSelection = Array.isArray(values) ? values.length > 0 : !!values;
        var $group = $select.closest('.sl-form-group');

        $group.removeClass('has-error');

        if ($select.prop('required') && !hasSelection) {
          $group.addClass('has-error');
        }
      }
    });
  }

  var open_time_tmpl = '9:30 AM',
      close_time_tmpl = '6:30 PM';

  var $timeTable = container ? $(container).find('.asl-time-details') : $(),
      defaultOpenHoursHTML = '',
      startPlaceholder = '',
      endPlaceholder = '';

  function timeChangeEvent(e) {

    if ($(e.currentTarget).hasClass('asl-start-time')) {
      open_time_tmpl = (e.time && e.time.value) ? e.time.value : open_time_tmpl;
    } else {
      close_time_tmpl = (e.time && e.time.value) ? e.time.value : close_time_tmpl;
    }
  };

  function initTimePickers($scope) {

    if (!$scope || !$scope.length || !$.fn.asltimepicker) {
      return;
    }

    $scope.find('.asltimepicker').asltimepicker({
      showMeridian: (asl_form_configuration && asl_form_configuration.time_format == '1') ? false : true,
      appendWidgetTo: '.asl-store-form'
    })
    .on('changeTime.asltimepicker', timeChangeEvent);
  };

  function restoreTimeSlotToggles($wrapper, index) {

    $wrapper.find('.a-swith label').attr('for', 'cmn-toggle-' + index);
    $wrapper.find('.a-swith input').attr('id', 'cmn-toggle-' + index);
  };

  if ($timeTable.length) {

    defaultOpenHoursHTML = $timeTable.find('tbody').html();

    var $firstStart = $timeTable.find('.asl-start-time').first(),
        $firstEnd   = $timeTable.find('.asl-end-time').first();

    if ($firstStart.length) {
      open_time_tmpl = $firstStart.val() || open_time_tmpl;
      startPlaceholder = $firstStart.attr('placeholder') || startPlaceholder;
    }

    if ($firstEnd.length) {
      close_time_tmpl = $firstEnd.val() || close_time_tmpl;
      endPlaceholder = $firstEnd.attr('placeholder') || endPlaceholder;
    }

    initTimePickers($timeTable);

    $timeTable.find('tbody').on('click', '.add-k-add', function(e) {

      e.preventDefault();

      var $newSlot = $('<div class="form-group">\
                <div class="input-group bootstrap-asltimepicker">\
                  <input type="text" class="form-control asltimepicker asl-start-time validate[required,funcCall[ASLmatchTime]]" placeholder="' + startPlaceholder + '" value="' + open_time_tmpl + '">\
                  <span class="input-group-append add-on"><span class="input-group-text"><svg width="20" height="18"><use xlink:href="#i-clock"></use></svg></span></span>\
                </div>\
                <div class="input-group bootstrap-asltimepicker">\
                  <input type="text" class="form-control asltimepicker asl-end-time validate[required]" placeholder="' + endPlaceholder + '" value="' + close_time_tmpl + '">\
                  <span class="input-group-append add-on"><span class="input-group-text"><svg width="20" height="18"><use xlink:href="#i-clock"></use></svg></span></span>\
                </div>\
                <span class="add-k-delete glyp-trash text-danger">\
                  <svg width="16" height="16"><use xlink:href="#i-trash"></use></svg>\
                </span>\
              </div>');

      var $toggleHolder = $(this).parent().prev().find('.asl-all-day-times .asl-closed-lbl');

      $toggleHolder.before($newSlot);

      var $newStart = $newSlot.find('input.asltimepicker').eq(0),
          $newEnd   = $newSlot.find('input.asltimepicker').eq(1);

      $newStart.removeAttr('id').attr('class', 'form-control asltimepicker asl-start-time validate[required,funcCall[ASLmatchTime]]');
      $newEnd.removeAttr('id').attr('class', 'form-control asltimepicker asl-end-time validate[required]');

      initTimePickers($newSlot);
    });

    $timeTable.find('tbody').on('click', '.add-k-delete', function(e) {

      e.preventDefault();
      $(this).parent().remove();
    });

    $(container).find('#asl-time-cp').on('click', function(e) {

      e.preventDefault();

      var $groups = $timeTable.find('.asl-all-day-times'),
          $monday = $groups.eq(0),
          mondayToggleChecked = $monday.find('.a-swith input').prop('checked');

      $groups.not(':first').each(function(idx) {

        var $dayGroup = $(this),
            cloneIndex = idx + 1;

        $dayGroup.html($monday.children().clone(true, true));
        restoreTimeSlotToggles($dayGroup, cloneIndex);
        $dayGroup.find('.a-swith input').prop('checked', mondayToggleChecked);
      });

      initTimePickers($timeTable);
    });
  }

  function getOpenHours() {

    if (!$timeTable.length) {
      return '{"mon":"1","tue":"1","wed":"1","thu":"1","fri":"1","sat":"1","sun":"1"}';
    }

    var open_hours = {};

    $timeTable.find('.asl-all-day-times').each(function() {

      var $day       = $(this),
          day_index  = String($day.data('day'));

      open_hours[day_index] = null;

      if ($day.find('.form-group').length > 0) {

        open_hours[day_index] = [];
      } else {

        var toggle = $day.find('.asl-closed-lbl input')[0];
        open_hours[day_index] = (toggle && toggle.checked) ? '1' : '0';
      }

      $day.find('.form-group').each(function() {

        var $hours = $(this).find('input');
        open_hours[day_index].push(($hours.eq(0).val() || '') + ' - ' + ($hours.eq(1).val() || ''));
      });
    });

    return JSON.stringify(open_hours);
  };

  function resetOpenHours() {

    if (!$timeTable.length) {
      return;
    }

    if (defaultOpenHoursHTML) {
      $timeTable.find('tbody').html(defaultOpenHoursHTML);
    }

    var $firstStart = $timeTable.find('.asl-start-time').first(),
        $firstEnd   = $timeTable.find('.asl-end-time').first();

    open_time_tmpl = $firstStart.length ? ($firstStart.val() || open_time_tmpl) : open_time_tmpl;
    close_time_tmpl = $firstEnd.length ? ($firstEnd.val() || close_time_tmpl) : close_time_tmpl;
    startPlaceholder = $firstStart.length ? ($firstStart.attr('placeholder') || startPlaceholder) : startPlaceholder;
    endPlaceholder = $firstEnd.length ? ($firstEnd.attr('placeholder') || endPlaceholder) : endPlaceholder;

    initTimePickers($timeTable);
  };
    
  //////////////////
  //  Add the Map //
  //////////////////

  //  Load the Map for the register store form
  function load_register_map() {

    // Initialize the Google Maps
    if(asl_form_configuration.map != '0') {
      
      window['asl_map_intialized'] = function() {
        map_object.render_a_map(parseFloat(asl_form_configuration.default_lat), parseFloat(asl_form_configuration.default_lng));
      };

      if (!(window['google'] && google.maps)) {
        map_object.intialize();
      } 
      else
        asl_map_intialized();
    }
  };

  //  ASL GDPR Borlabs Callback
  window.asl_gdpr = function() {

    //  Run the script
    load_register_map();
  };

  // Run the widget script
  /* 
  aslInitializeWhenGAPIReady(function(){
    
    //  Run the script
    load_register_map();
  }); 
  */

  //  Run the script
  load_register_map();
    
  //  Register button
  var $reg_btn    = $('.asl-cont #sl-btn-save');

  //  Agree Checkbox
  var agree_check = container.querySelector('#sl-agr-check');
  
  if(agree_check) {

    var updateRegisterBtnState = function() {
      if(!$reg_btn.length) return;
      if (agree_check.checked) {
        $reg_btn.removeClass('disabled').removeAttr('disabled');
      } else {
        $reg_btn.addClass('disabled').attr('disabled','disabled');
      }
    };

    $(agree_check).on('change click', function() {
      updateRegisterBtnState();
    });

    // initial state
    updateRegisterBtnState();
  }

  // Fallback: delegate change handler to ensure button toggles even if direct binding missed
  $(document).on('change', '#sl-agr-check', function() {
    var $btn = $('.asl-cont #sl-btn-save');
    if (!$btn.length) return;
    if (this.checked) {
      $btn.removeClass('disabled').removeAttr('disabled');
    } else {
      $btn.addClass('disabled').attr('disabled','disabled');
    }
  });


  /**
   * [resetRegisterForm Reset the register form]
   * @return {[type]} [description]
   */
  function resetRegisterForm() {

    Array.prototype.filter.call(inputs, function(input) {

      input.value = '';
    });

    resetOpenHours();

    // Disable until agree to check
    if(agree_check) {
      agree_check.checked = false;
      $reg_btn.addClass('disabled');
    }
  };



  /////////////////
  //  Blur Event //
  /////////////////
  if(asl_form_configuration['map'] != '0')
    $(container).find('#sl-state,#sl-city,#sl-postal_code').bind('blur', function(e) {    
      
      if (!isEmpty(container.querySelector('#sl-city').value)) {

        var address   = [container.querySelector('#sl-street').value, container.querySelector('#sl-city').value, container.querySelector('#sl-postal_code').value, container.querySelector('#sl-state').value];

        var q_address = [];

        for (var i = 0; i < address.length; i++) {

          if (address[i])
            q_address.push(address[i]);
        }

        var _country = $(container).find('#sl-country option:selected').text();

        //Add country if available
        if (_country) {
          q_address.push(_country);
        }

        address = q_address.join(', ');

        codeAddress(address, function(_geometry) {

          var s_location = [_geometry.location.lat(), _geometry.location.lng()];
          var loc = new google.maps.LatLng(s_location[0], s_location[1]);
          if (map_object.map_marker) {
            map_object.map_marker.setPosition(_geometry.location);
          }
          if (typeof map !== 'undefined' && map && typeof map.panTo === 'function') {
            map.panTo(_geometry.location);
            if (typeof map.setZoom === 'function') {
              map.setZoom(14);
            }
          }
          asl_register_store_changed(s_location);

        });
      }
    });

  //  Click Event of the save button
  $reg_btn.bind('click', function(e) {

    //  Clear previous messages
    atoastr.clear();

    //  Validate  the agree checkbox
    if(agree_check && !agree_check.checked) {
      agree_check.classList.add('is-invalid');
      return;
    }


    //var form_data = {categories: ((sl_ddl)? sl_ddl.val(): null)},
    var form_data = {},
    is_valid  = true;

    var ddl_fields = ['categories', 'brand', 'special'];

    for(var d in ddl_fields) {

      if (!ddl_fields.hasOwnProperty(d)) continue;

      var _field = ddl_fields[d];

      var $field_ele    = $(container).find('#sl-' + _field);
      
      form_data[_field] = $field_ele.val();
      
      if(form_data[_field] && Array.isArray(form_data[_field]) && form_data[_field].length > 0) {

        form_data[_field] = form_data[_field].join(',');
      }
    }

    ////////////////////////////
    //  Validate these fields //
    ////////////////////////////
    var validation_fields = [];
    Array.prototype.filter.call(inputs, function(_input) {

      if(_input.required || $(_input).hasClass('validate[required]')) {
        validation_fields.push(_input.name);
      }
    });


    Array.prototype.filter.call(inputs, function(_input) {

      //  Radio
      if(_input.type == 'radio') {
          
          //  Only the check valued
          if(_input.checked) {
            form_data[_input.name] =_input.value;
          }
        
      }
      // checkbox
      else if(_input.type == 'checkbox') {
        form_data[_input.name] = (_input.checked)? _input.value: false;
      }
      else {

        form_data[_input.name] = _input.value;
      }

      if(validation_fields.indexOf(_input.name) != -1 && !$.trim(_input.value)) {
        _input.parentNode.classList.add('has-error');
        is_valid = false;
      }
    });

    form_data['open_hours'] = getOpenHours();

    
    // Validate the Data 
    if(!is_valid) {
      atoastr.error((asl_form_configuration.words.fill_form || 'Please fill up the form.')); 
      return;
    }

    $reg_btn.bootButton('loading');


    var form_request_data = {action: 'asl_reg_store', form_params: form_data, vkey: ASL_FORM.vkey};

    // Add Recaptcha data
    var recaptcha_container = container.querySelector('.sl-form-recaptcha');
    if (recaptcha_container) {
      var recaptcha_inputs = recaptcha_container.querySelectorAll('input');
      var recaptcha_data = {};
      recaptcha_inputs.forEach(function(input) {
        recaptcha_data[input.name] = input.value;
      });
      form_request_data = {...form_request_data, ...recaptcha_data};
    }

    //  Add the nounce
    $.ajax({
      url: ASL_FORM.ajax_url,
      data: form_request_data,
      type: 'POST',
      dataType: 'json',
      /**
       * [success description]
       * @param  {[type]} _data [description]
       * @return {[type]}       [description]
       */
      success: function(_response) {

        //  Reset the button
        $reg_btn.bootButton('reset');

        if (_response.success) {
          atoastr.success(_response.message);
          resetRegisterForm();

          //  When there is a redirect URL
          if(asl_form_configuration.redirect) {
            window.location = asl_form_configuration.redirect;
          }
          
        } else {
          atoastr.error((_response.message || 'Error in registering the form.'));
        }
      },
      /**
       * [error description]
       * @param  {[type]} _data [description]
       * @return {[type]}       [description]
       */
      error: function(_data) {}
    });
    
  });

  })(jQuery);