// source --> https://www.lovedayandco.com/wp-content/plugins/interactive-3d-flipbook-powered-physics-engine/assets/js/client-locale-loader.js?ver=1.16.19-b-modified-1773826221 
function fb3dClientLocaleLoader() {
  if(window.jQuery && typeof jQuery.ajax==='function') {
    function fb3dNormalizeUrl(url) {
      return url.replace(/https{0,1}:/, location.protocol);
    }
    function fb3dFetch(url) {
      return new Promise(function(resolve, reject) {
        jQuery.ajax({url: fb3dNormalizeUrl(url), dataType: 'text'}).done(resolve).fail(reject);
      });
    }
    FB3D_CLIENT_LOCALE.render = function() {
      delete FB3D_CLIENT_LOCALE.render;
      var isStable = !Promise.withResolvers || /^((?!chrome|android).)*safari/i.test(navigator.userAgent),
        pdfJs = FB3D_CLIENT_LOCALE.pdfJS, assetsJs = FB3D_CLIENT_LOCALE.pluginurl+'assets/js/';
      window.FB3D_LOCALE = {
        dictionary: FB3D_CLIENT_LOCALE.dictionary
      };
      window.PDFJS_LOCALE = {
        pdfJsCMapUrl: fb3dNormalizeUrl(pdfJs.pdfJsCMapUrl),
        pdfJsWorker: fb3dNormalizeUrl(isStable? pdfJs.stablePdfJsWorker: pdfJs.pdfJsWorker)
      };
      Promise.all([
        fb3dFetch(FB3D_CLIENT_LOCALE.pluginurl+'assets/css/client.css?ver='+FB3D_CLIENT_LOCALE.version),
        fb3dFetch(FB3D_CLIENT_LOCALE.pluginurl+'assets/templates/iframe-init.html?ver='+FB3D_CLIENT_LOCALE.version),
        fb3dFetch(FB3D_CLIENT_LOCALE.cacheurl+'skins.js?ver='+FB3D_CLIENT_LOCALE.version),
        fb3dFetch(isStable? pdfJs.stablePdfJsLib: pdfJs.pdfJsLib),
        fb3dFetch(assetsJs+'three.min.js?ver=125'),
        fb3dFetch(assetsJs+'html2canvas.min.js?ver=0.5'),
        fb3dFetch(assetsJs+'client.min.js?ver='+FB3D_CLIENT_LOCALE.version),
      ]).then(function(fs) {
        jQuery('head').append(['<style type="text/css">', fs[0].replace(/url\('..\//gi, 'url(\''+fb3dNormalizeUrl(FB3D_CLIENT_LOCALE.pluginurl+'assets/')), '</style>'].join(''));
        for(var i = 2; i<fs.length; ++i) {
          eval(fs[i]);
        }
      });
    };
    if(jQuery('._'+FB3D_CLIENT_LOCALE.key).length) {
      FB3D_CLIENT_LOCALE.render();
    }
  }
  else {
    setTimeout(fb3dClientLocaleLoader, 100);
  }
}
fb3dClientLocaleLoader();
// source --> https://www.lovedayandco.com/wp-content/themes/Impreza-child/js/custom.js?ver=7.0-b-modified-1780922362 

// add cta to sub menu A/B test
jQuery(window).on('load', function() {
    if (jQuery(window).width() >= 1367) {
        jQuery('#menu-item-13969 > .w-nav-list.level_2').append(
            '<div class="menu_cta">' +
                '<div class="txt">' +
                    '<p>Not sure what type of care you need? Speak to our team of clinical experts who will be happy to guide you.</p>' +
                '</div>' +
                '<div>' +
                    '<p><a class="btn btn-gold" href="/care-enquiry/">Get in Touch</a></p>' +
                '</div>' +
            '</div>'
        );
    }
});

jQuery(document).ready(function () {
  jQuery(".hero-inner-img").addClass("visible");
});

jQuery(document).ready(function () {
  var runUrlLogic = function () {
    var urlParams = new URLSearchParams(window.location.search);

    var baseUrl = window.location.href.split("?")[0];
    jQuery('input[name="url_trimmed"][data-name="url_trimmed"]').val(baseUrl);

    var campaignNumber = urlParams.get("campaign");
    if (campaignNumber) {
      jQuery('input[name="campaign_id"][data-name="campaign_id"]').val(campaignNumber);
    }
  };

  setTimeout(runUrlLogic, 600);
  setTimeout(runUrlLogic, 1000);
  setTimeout(runUrlLogic, 1500);
  setTimeout(runUrlLogic, 2000);
  setTimeout(runUrlLogic, 5000);
});

jQuery(document).ready(function() {
  jQuery("#menu-item-7614 span.w-nav-title, #menu-item-13968 span.w-nav-title").html('<img src="/wp-content/uploads/2025/09/logo-the-1150-club-btn.svg" alt="logo-the-1150-club">');
});

/* home w video text remove */

jQuery(document).ready(function($) {
  setTimeout(function() {
    jQuery('.videohead')
      .find('.title-heading')
      .css({
        opacity: '0',
        transition: 'opacity 0.4s ease'
      });
  }, 2000);
});



/*
header#page-header
*/

// Phone numbers to header
/*
jQuery(document).ready(function () {
  const $target = jQuery("#mml_topcontact1");
  const $button = jQuery("a.btn.top_call_us");
  const DESKTOP_WIDTH = 1023;

  function setContactBoxPosition() {
    if (window.innerWidth > DESKTOP_WIDTH) {
      // Desktop: prepend to header
      if (!$target.parent().is("header#page-header")) {
        $target.prependTo(jQuery("header#page-header"));
      }
      $target.hide();
      $target.css({ position: "", top: "", left: "", height: "", width: "", background: "", boxShadow: "", zIndex: "", borderRadius: "", padding: "" });
      jQuery("body").removeClass("mml_sidebar_open");
    } else {
      // Mobile/tablet: append to body as sidebar
      if (!$target.parent().is("body")) {
        $target.appendTo(jQuery("body"));
      }
      $target.hide();
      jQuery("body").removeClass("mml_sidebar_open");
    }
  }

  setContactBoxPosition();
  jQuery(window).on("resize", setContactBoxPosition);

  $button.on("click", function (e) {
    e.preventDefault();
    $target.stop(true, true);
    if (window.innerWidth > DESKTOP_WIDTH) {
      // Desktop: slide toggle
      if ($target.is(":visible")) {
        $target.slideUp();
      } else {
        $target.css("display", "flex").hide().slideDown();
      }
    } else {
      // Mobile/tablet: sidebar toggle
      if ($target.is(":visible")) {
        $target.fadeOut(200);
        jQuery("body").removeClass("mml_sidebar_open");
      } else {
        $target.css("display", "flex").hide().fadeIn(200);
        jQuery("body").addClass("mml_sidebar_open");
      }
    }
  });
});
*/
// Add close button handler for sidebar
/*
jQuery(document).on("click", "button.mml_close_sidebar", function () {
  jQuery("body").removeClass("mml_sidebar_open");
});
*/
// phone number in content
/*
jQuery(document).ready(function() {
  // Function to replace link with button on small screens
  function replaceCallLink() {
    if (window.innerWidth < 1023) {
      jQuery('a.incontent.btn.top_call_us').each(function() {
        var button = jQuery('<button class="mml_callus_bottom_btn">Call us</button>');
        jQuery(this).replaceWith(button);
      });
    }
  }

  // Run the replacement on page load
  replaceCallLink();

  // Optional: Re-run when window is resized
  jQuery(window).resize(function() {
    replaceCallLink();
  });
});
*/

//Match height and more
jQuery(document).ready(function () {
  jQuery(".cat-box .heading").matchHeight();
  jQuery(".cat-box").matchHeight();
  // jQuery(".res_boxes .intro_txt").matchHeight();
  jQuery(".service-icon-item h3").matchHeight();
  jQuery(".service-icon-item p").matchHeight();
  jQuery(".featured_post_grid-content").matchHeight();

  jQuery(".service-inner h4").matchHeight();
	
 if (window.matchMedia("(min-width: 768px)").matches) {
  	jQuery(".resi-cont .resi-addr").matchHeight();
  	jQuery(".resi-cont .page-txt").matchHeight(); 
 }
  
  	
	jQuery('.res_boxes').each(function (i, elem) {
		jQuery(elem).find('.item .txt p:nth-child(3)')
			.matchHeight({ 
				byRow: true 
			});	
		jQuery(elem).find('.item .txt .sub-heading')
			.matchHeight({ 
				byRow: true 
			});
	});

  // home post list tabs
  jQuery(".w-vwrapper.post_det").hide().first().show();

  jQuery(".w-post-elm.post_title").click(function () {
    var postDet = jQuery(this).next(".post_det");

    jQuery(".w-vwrapper.post_det").not(postDet).slideUp();

    postDet.slideToggle();
  });
  
   jQuery('#chatUs').on('click', function (e) {
		e.preventDefault();
		jQuery('#transparent-button')[0].click();
  });
  
});

/** not on mobile match height **/

jQuery(document).ready(function () {
  if (window.matchMedia("(min-width: 999px)").matches) {
    jQuery(".post_title").matchHeight();
  }
});


// Disable Magnific Popup for no-popup links
jQuery(document).ready(function () {
  jQuery('a.no-popup').each(function () {
    jQuery(this).removeAttr('ref').removeClass('inited');
    jQuery(this).off('click.magnificPopup'); // remove popup event
  });
});


//Mobile Menu Fix
jQuery(document).ready(function () {
  let isMobile = window.matchMedia("only screen and (max-width: 1198px)").matches;
  if (isMobile) {
    jQuery("ul.w-nav-list.level_1").append(jQuery('<div class="newinmobile"></div>'));
    jQuery(".newinmobile").append(jQuery(".btn-1150, .w-socials.ush_socials_1, .top-contact, .w-vwrapper.ush_vwrapper_1.mob_menu.align_none.valign_top"));
    jQuery(".l-subheader.at_top").remove();
  }
});

//Auto IMG ALT
jQuery(document).ready(function () {
  jQuery("img").each(function () {
    var img_src = jQuery(this).attr("src");
    if (typeof img_src !== typeof undefined && img_src !== false) {
      var img_alt = jQuery(this).attr("alt");
      var str = img_src;
      var pieces = str.split("/");
      var imgName = pieces[pieces.length - 1];
      var imgnameArray = imgName.split(".");
      var alt = imgnameArray[0];
      var alt_final = alt.replace(/-/g, " ");
      if (img_alt == "" || typeof img_alt === typeof undefined || img_alt === false) {
        jQuery(this).attr("alt", alt_final);
      }
    }
  });
});

//Right form
jQuery(document).ready(function () {
  jQuery(".page-id-6409 .right-form-pop .right-form-container, .page-id-326 .right-form-pop .right-form-container, .page-id-4697 .right-form-pop .right-form-container, .page-id-4648 .right-form-pop .right-form-container, .page-id-1362 .right-form-pop .right-form-container, .page-id-1321 .right-form-pop .right-form-container, .page-id-1298 .right-form-pop .right-form-container, .page-id-273 .right-form-pop .right-form-container, .page-id-1218 .right-form-pop .right-form-container, page-id-326 .right-form-pop .right-form-container, .page-id-1145 .right-form-pop .right-form-container").addClass("w3-animate-right");
  jQuery(".right-pop-btn, #enquiry, .pop-btn").click(function () {
    jQuery(".right-form-pop-subscribe .right-form-container").removeClass("w3-animate-right");
    jQuery(".right-form-pop .right-form-container").addClass("w3-animate-right");
  });
  jQuery(".right-form-pop .close-btn, .right-form-pop-subscribe .close-btn").click(function () {
    jQuery(".right-form-pop .right-form-container").removeClass("w3-animate-right");
    jQuery(".right-form-pop-subscribe .right-form-container").removeClass("w3-animate-right");
  });
  jQuery(".bottom-frm-btn").click(function () {
    jQuery(".right-form-pop-subscribe .right-form-container").removeClass("w3-animate-right");
    jQuery(".right-form-pop .right-form-container").addClass("w3-animate-right");
  });

  jQuery(".right-pop-btn-subscribe").click(function () {
    jQuery(".right-form-pop .right-form-container").removeClass("w3-animate-right");
    jQuery(".right-form-pop-subscribe .right-form-container").addClass("w3-animate-right");
  });
});

jQuery(window).on('scroll resize', function () {
  var isScrolled = jQuery(window).scrollTop() >= 600;
  
  if (jQuery(window).width() < 768) {
    jQuery('a.right-pop-btn, a.right-pop-btn-2').toggleClass('vis', isScrolled);
  } else {
    jQuery('a.right-pop-btn, a.right-pop-btn-2').toggleClass('vis', isScrolled);
  }
});



//Banner Comming Soon
jQuery(window).scroll(function () {
  var scrollTop = jQuery(window).scrollTop();
  if (scrollTop > 10) {
    jQuery(".textScroll p").css("display", "block");
    jQuery(".initialText p").css("display", "none");
  } else {
    jQuery(".textScroll p").css("display", "none");
    jQuery(".initialText p").css("display", "block");
  }
});


jQuery(document).ready(function () {
  // Delay to wait for Ruler to inject the number
  setTimeout(function () {
    jQuery(".phone-tracking-btn").each(function () {
      console.log("Hello");
      var text = jQuery(this).text().replace(/\D/g, ""); // digits only
      if (text.length === 11) {
        var formatted = text.replace(/^(\d{3})(\d{4})(\d{4})$/, "$1 $2 $3");
        console.log(formatted);
        jQuery(this).text(formatted);
      }
    });
  }, 2000); // adjust delay if needed
});

// animations
jQuery(document).ready(function() {
  
  function inViewport(){
    jQuery('.rated_logo').each(function(){
      var divPos = jQuery(this).offset().top,
          topOfWindow = jQuery(window).scrollTop() + jQuery(window).height();
     
      if( divPos < topOfWindow - 150 ){
        if( !jQuery(this).hasClass('.rated_logo') ){
          jQuery(this).addClass('w3-animate-spin-fade-up');
          jQuery(this).css('opacity', '1');
        }
      }
    });
  }

  inViewport();

  jQuery(window).scroll(function(){
    inViewport();
  });

  jQuery(window).resize(function(){
    inViewport();
  });

});

// move heading above video
jQuery(document).ready(function() {
    function moveHeadings() {
        if (jQuery(window).width() < 768) {
            jQuery('.row1').each(function() {
                const $row = jQuery(this);
                const $whiteBg = $row.find('.whiteBg.w_border.bottom');
                
                if ($whiteBg.length) {
                    $whiteBg.each(function() {
                        const $currentWhiteBg = jQuery(this);
                        const $txt = $currentWhiteBg.find('.txt');
                        const $w_vid = $currentWhiteBg.find('.w_vid');
                        
                        if ($txt.find('.heading').length && $w_vid.length) {
                            const $heading = $txt.find('.heading');
                            const $h2 = $heading.next('h2');
                            
                            $heading.insertBefore($w_vid);
                            if ($h2.length) {
                                $h2.insertBefore($w_vid);
                            }
                        }
                    });
                }
            });
        }
    }
 
    moveHeadings();
    jQuery(window).on('resize', moveHeadings);
});


/* FROM ADMIN */

// page 8372 - remove designstudio
jQuery(document).ready(function() {
  if (jQuery('body').hasClass('page-id-8372')) {
    setTimeout(function() {
      jQuery('#designstudio-minimize, #designstudio, #designstudio-button').remove();
    }, 1000);
  }
});

jQuery(document).ready(function() {

  if (window.location.pathname.indexOf('/ppc/') !== -1) {
    jQuery('#bottom-links').remove();
  }

});
// source --> https://www.lovedayandco.com/wp-content/themes/Impreza-child/js/jquery.matchHeight.js?ver=7.0-b-modified-1769691648 
/**
* jquery-match-height master by @liabru
* https://brm.io/jquery-match-height/
* License: MIT
*/

;(function(factory) { // eslint-disable-line no-extra-semi
    'use strict';
    if (typeof define === 'function' && define.amd) {
        // AMD
        define(['jquery'], factory);
    } else if (typeof module !== 'undefined' && module.exports) {
        // CommonJS
        module.exports = factory(require('jquery'));
    } else {
        // Global
        factory(jQuery);
    }
})(function($) {
    /*
    *  internal
    */

    var _previousResizeWidth = -1,
        _updateTimeout = -1;

    /*
    *  _parse
    *  value parse utility function
    */

    var _parse = function(value) {
        // parse value and convert NaN to 0
        return parseFloat(value) || 0;
    };

    /*
    *  _rows
    *  utility function returns array of jQuery selections representing each row
    *  (as displayed after float wrapping applied by browser)
    */

    var _rows = function(elements) {
        var tolerance = 1,
            $elements = $(elements),
            lastTop = null,
            rows = [];

        // group elements by their top position
        $elements.each(function(){
            var $that = $(this),
                top = $that.offset().top - _parse($that.css('margin-top')),
                lastRow = rows.length > 0 ? rows[rows.length - 1] : null;

            if (lastRow === null) {
                // first item on the row, so just push it
                rows.push($that);
            } else {
                // if the row top is the same, add to the row group
                if (Math.floor(Math.abs(lastTop - top)) <= tolerance) {
                    rows[rows.length - 1] = lastRow.add($that);
                } else {
                    // otherwise start a new row group
                    rows.push($that);
                }
            }

            // keep track of the last row top
            lastTop = top;
        });

        return rows;
    };

    /*
    *  _parseOptions
    *  handle plugin options
    */

    var _parseOptions = function(options) {
        var opts = {
            byRow: true,
            property: 'height',
            target: null,
            remove: false
        };

        if (typeof options === 'object') {
            return $.extend(opts, options);
        }

        if (typeof options === 'boolean') {
            opts.byRow = options;
        } else if (options === 'remove') {
            opts.remove = true;
        }

        return opts;
    };

    /*
    *  matchHeight
    *  plugin definition
    */

    var matchHeight = $.fn.matchHeight = function(options) {
        var opts = _parseOptions(options);

        // handle remove
        if (opts.remove) {
            var that = this;

            // remove fixed height from all selected elements
            this.css(opts.property, '');

            // remove selected elements from all groups
            $.each(matchHeight._groups, function(key, group) {
                group.elements = group.elements.not(that);
            });

            // TODO: cleanup empty groups

            return this;
        }

        if (this.length <= 1 && !opts.target) {
            return this;
        }

        // keep track of this group so we can re-apply later on load and resize events
        matchHeight._groups.push({
            elements: this,
            options: opts
        });

        // match each element's height to the tallest element in the selection
        matchHeight._apply(this, opts);

        return this;
    };

    /*
    *  plugin global options
    */

    matchHeight.version = 'master';
    matchHeight._groups = [];
    matchHeight._throttle = 80;
    matchHeight._maintainScroll = false;
    matchHeight._beforeUpdate = null;
    matchHeight._afterUpdate = null;
    matchHeight._rows = _rows;
    matchHeight._parse = _parse;
    matchHeight._parseOptions = _parseOptions;

    /*
    *  matchHeight._apply
    *  apply matchHeight to given elements
    */

    matchHeight._apply = function(elements, options) {
        var opts = _parseOptions(options),
            $elements = $(elements),
            rows = [$elements];

        // take note of scroll position
        var scrollTop = $(window).scrollTop(),
            htmlHeight = $('html').outerHeight(true);

        // get hidden parents
        var $hiddenParents = $elements.parents().filter(':hidden');

        // cache the original inline style
        $hiddenParents.each(function() {
            var $that = $(this);
            $that.data('style-cache', $that.attr('style'));
        });

        // temporarily must force hidden parents visible
        $hiddenParents.css('display', 'block');

        // get rows if using byRow, otherwise assume one row
        if (opts.byRow && !opts.target) {

            // must first force an arbitrary equal height so floating elements break evenly
            $elements.each(function() {
                var $that = $(this),
                    display = $that.css('display');

                // temporarily force a usable display value
                if (display !== 'inline-block' && display !== 'flex' && display !== 'inline-flex') {
                    display = 'block';
                }

                // cache the original inline style
                $that.data('style-cache', $that.attr('style'));

                $that.css({
                    'display': display,
                    'padding-top': '0',
                    'padding-bottom': '0',
                    'margin-top': '0',
                    'margin-bottom': '0',
                    'border-top-width': '0',
                    'border-bottom-width': '0',
                    'height': '100px',
                    'overflow': 'hidden'
                });
            });

            // get the array of rows (based on element top position)
            rows = _rows($elements);

            // revert original inline styles
            $elements.each(function() {
                var $that = $(this);
                $that.attr('style', $that.data('style-cache') || '');
            });
        }

        $.each(rows, function(key, row) {
            var $row = $(row),
                targetHeight = 0;

            if (!opts.target) {
                // skip apply to rows with only one item
                if (opts.byRow && $row.length <= 1) {
                    $row.css(opts.property, '');
                    return;
                }

                // iterate the row and find the max height
                $row.each(function(){
                    var $that = $(this),
                        style = $that.attr('style'),
                        display = $that.css('display');

                    // temporarily force a usable display value
                    if (display !== 'inline-block' && display !== 'flex' && display !== 'inline-flex') {
                        display = 'block';
                    }

                    // ensure we get the correct actual height (and not a previously set height value)
                    var css = { 'display': display };
                    css[opts.property] = '';
                    $that.css(css);

                    // find the max height (including padding, but not margin)
                    if ($that.outerHeight(false) > targetHeight) {
                        targetHeight = $that.outerHeight(false);
                    }

                    // revert styles
                    if (style) {
                        $that.attr('style', style);
                    } else {
                        $that.css('display', '');
                    }
                });
            } else {
                // if target set, use the height of the target element
                targetHeight = opts.target.outerHeight(false);
            }

            // iterate the row and apply the height to all elements
            $row.each(function(){
                var $that = $(this),
                    verticalPadding = 0;

                // don't apply to a target
                if (opts.target && $that.is(opts.target)) {
                    return;
                }

                // handle padding and border correctly (required when not using border-box)
                if ($that.css('box-sizing') !== 'border-box') {
                    verticalPadding += _parse($that.css('border-top-width')) + _parse($that.css('border-bottom-width'));
                    verticalPadding += _parse($that.css('padding-top')) + _parse($that.css('padding-bottom'));
                }

                // set the height (accounting for padding and border)
                $that.css(opts.property, (targetHeight - verticalPadding) + 'px');
            });
        });

        // revert hidden parents
        $hiddenParents.each(function() {
            var $that = $(this);
            $that.attr('style', $that.data('style-cache') || null);
        });

        // restore scroll position if enabled
        if (matchHeight._maintainScroll) {
            $(window).scrollTop((scrollTop / htmlHeight) * $('html').outerHeight(true));
        }

        return this;
    };

    /*
    *  matchHeight._applyDataApi
    *  applies matchHeight to all elements with a data-match-height attribute
    */

    matchHeight._applyDataApi = function() {
        var groups = {};

        // generate groups by their groupId set by elements using data-match-height
        $('[data-match-height], [data-mh]').each(function() {
            var $this = $(this),
                groupId = $this.attr('data-mh') || $this.attr('data-match-height');

            if (groupId in groups) {
                groups[groupId] = groups[groupId].add($this);
            } else {
                groups[groupId] = $this;
            }
        });

        // apply matchHeight to each group
        $.each(groups, function() {
            this.matchHeight(true);
        });
    };

    /*
    *  matchHeight._update
    *  updates matchHeight on all current groups with their correct options
    */

    var _update = function(event) {
        if (matchHeight._beforeUpdate) {
            matchHeight._beforeUpdate(event, matchHeight._groups);
        }

        $.each(matchHeight._groups, function() {
            matchHeight._apply(this.elements, this.options);
        });

        if (matchHeight._afterUpdate) {
            matchHeight._afterUpdate(event, matchHeight._groups);
        }
    };

    matchHeight._update = function(throttle, event) {
        // prevent update if fired from a resize event
        // where the viewport width hasn't actually changed
        // fixes an event looping bug in IE8
        if (event && event.type === 'resize') {
            var windowWidth = $(window).width();
            if (windowWidth === _previousResizeWidth) {
                return;
            }
            _previousResizeWidth = windowWidth;
        }

        // throttle updates
        if (!throttle) {
            _update(event);
        } else if (_updateTimeout === -1) {
            _updateTimeout = setTimeout(function() {
                _update(event);
                _updateTimeout = -1;
            }, matchHeight._throttle);
        }
    };

    /*
    *  bind events
    */

    // apply on DOM ready event
    $(matchHeight._applyDataApi);

    // use on or bind where supported
    var on = $.fn.on ? 'on' : 'bind';

    // update heights on load and resize events
    $(window)[on]('load', function(event) {
        matchHeight._update(false, event);
    });

    // throttled update heights on resize events
    $(window)[on]('resize orientationchange', function(event) {
        matchHeight._update(true, event);
    });

});
// source --> https://www.lovedayandco.com/wp-content/themes/Impreza-child/postcode.js?ver=7.0-b-modified-1769691648 
var mml_submitonce = 0;

jQuery(document).ready(function() {
    var pattern = /^[a-z]{1,2}\d[a-z\d]?\s*\d[a-z]{2}$/i;
    var selectElements = document.getElementsByName("mml_address_selector");
    var inputElements = document.getElementsByName("postcodetosend");
    var ignoreChangeEvent = false;
	
// Hide the boxes
    jQuery('select[name="mml_address_selector"]').css('display','none');
	jQuery('input[name="citytosend"]').css('display','none');
	jQuery('input[name="countytosend"]').css('display','none');

    // Function to set the placeholder text
    function setPlaceholder(selectElement, text) {
        jQuery(selectElement).html('<option mml_id="" disabled selected>' + text + '</option');
    }

    // Set the initial placeholder text
    selectElements.forEach(function(selectElement) {
        setPlaceholder(selectElement, "Address");
    });

    // Trigger the function
    inputElements.forEach(function(inputElement, index) {
        jQuery(inputElement).on("input", function() {
            // Empty the select boxes
			if (mml_submitonce =! 1) {
				jQuery(selectElements[index]).html('');
				jQuery('input[name="citytosend"]').val('');
				jQuery('input[name="countytosend"]').val('');
			} else {};
            // ...
            if ((pattern.test(jQuery(inputElement).val())) && (!/[<>&"'$%{}()\\]/.test((jQuery(inputElement).val())) )) {
                checkPostalCode(inputElement, selectElements[index]);
            } else {
                // Reset the placeholder text
                setPlaceholder(selectElements[index], "Address");
            }
        });
    });

// When selected, put in details
selectElements.forEach(function(selectElement) {
    jQuery(selectElement).change(function() {
        if (!ignoreChangeEvent) {
            var selectedOption = jQuery(this).find('option:selected');
            var selectedid = selectedOption.attr('mml_id');
            var index = Array.from(selectElements).indexOf(this);
            jQuery('input[name="citytosend"]').val(selectedOption.attr('mml_city'));
            jQuery('input[name="countytosend"]').val(selectedOption.attr('mml_county'));
            ignoreChangeEvent = true; // Prevent triggering further change events
            
            // Synchronize the selected option with other instances
            selectElements.forEach(function(otherSelectElement, otherIndex) {
                if (otherIndex !== index) {
                    jQuery(otherSelectElement).find('option[mml_id="' + selectedid + '"]').prop('selected', true);
                    jQuery(otherSelectElement).trigger('change');
                }
            });
            
            ignoreChangeEvent = false; // Allow change events again
        }
    });
});



    function checkPostalCode(inputElement, selectElement) {
        var postcode_input = jQuery(inputElement).val();
        var base_url = window.location.origin;

        // Send to API
        console.log("1 search has been done");
        jQuery.ajax({
            url: base_url + "/wp-content/themes/Impreza-child/postcode2.php?postcode=" + postcode_input,
            type: "POST",
            success: function (data) {
                try {
                    var responseData = JSON.parse(data);

                    if (responseData && Array.isArray(responseData.result)) {
                        var addresses = responseData.result;

                        // Insert the contents of input[name="postcodetosend"] to all instances
                        inputElements.forEach(function (element) {
                            jQuery(element).val(postcode_input);
                        });

                        // Update all select boxes and set the placeholder text
                        selectElements.forEach(function (otherSelectElement) {
                            setPlaceholder(otherSelectElement, "Select address");
                            addresses.forEach(function (address) {
                                var optionText = [
                                    address.line_1,
                                    (address.line_2 ? (optionText ? ', ' : '') + address.line_2 : ''),
                                    (address.line_3 ? (optionText ? ', ' : '') + address.line_3 : '')
                                ].filter(Boolean).join(', ');

                                var option = document.createElement("option");
                                option.textContent = optionText;
                                option.setAttribute("mml_id", address.id || "");
                                option.setAttribute("mml_county", address.county || "");
                                option.setAttribute("mml_city", address.post_town || address.ward || "");

                                otherSelectElement.appendChild(option);
                            });
                        });
						
						// Display the boxes
                        selectElements.forEach(function (otherSelectElement) {
                            jQuery(otherSelectElement).css('display', 'block');
							jQuery('input[name="citytosend"]').css('display','block');
							jQuery('input[name="countytosend"]').css('display','block');
                        });

                    } else {
                        console.log("Error: Invalid or empty response data.");
                    }
                } catch (error) {
                    console.log("Error parsing JSON: " + error);
                }
            },
            error: function () {
                console.log("Error occurred during the request.");
            }
        });
    }

    // Function to handle copying select contents and removing it
    function handleButtonClick() {
		

        var addressSelector000 = jQuery('select[data-name="mml_address_selector"]');
            // css probelms
            addressSelector000.closest('.ff-el-group').css('margin-bottom', '20px');


        //jQuery('button[type="submit"]').on("click", function() {
		jQuery('select[data-name="mml_address_selector"]').on('change', function() {	
			if (mml_submitonce != 1) {
			
				var addressSelector = jQuery('select[data-name="mml_address_selector"]');
				var addressTextField = jQuery('input[data-name="mml_address_textfield"]');
				
				// Copy select contents to input field
				addressTextField.val(addressSelector.val());

				// Find the closest .ff-el-group parent and hide it
				addressSelector.closest('.ff-el-group').css('display', 'none');

				// Remove select element
				addressSelector.remove();
				//addressSelector.css('visibility', 'hidden').css('position', 'absolute').css('height', '0').css('width', '0').css('padding', '0').css('margin', '0').css('border', 'none');


				// Display the input field
				addressTextField.css('display', 'block');
				
				//Disable fields so nothing can alter them anymore
				//jQuery('input[data-name="mml_address_textfield"], input[data-name="countytosend"], input[data-name="citytosend"]').prop('disabled', true);
				
				//do not do this again
				mml_submitonce = 1;
			} else {};
        });
    }

    // Call the function
    handleButtonClick();




});

jQuery(document).ready(function() {
    jQuery('button.ff_modal_btn.btn.btn-success').on('click', function(e) {
        e.preventDefault(); // Stop the button's default behavior
        
        var postcode = jQuery('.dropdown input#postcode');
        var productSelect = jQuery('.dropdown select#product_select');
        var isValid = true;
        
        jQuery('.error-message').remove(); // Remove previous error messages
        
        // Validate postcode input
        if (postcode.val().trim() === '') {
			jQuery('div#popup_form_first').append('<span class="error-message" style="color:red;">Postcode is required.</span>');
            //postcode.after('<span class="error-message" style="color:red;">Postcode is required.</span>');
            isValid = false;
        }

        // If validation fails, stop all actions
        if (!isValid) {
            e.stopImmediatePropagation(); // Stops the event from bubbling up or triggering any other event
            return false; // Explicitly prevent any other behavior
        }

        // If valid, you can perform any action here
        // For example: this.form.submit(); or continue your button's intended behavior
    });


jQuery(document).ready(function(jQuery) {
    var form = jQuery('#fluentform_13'); 
    var addressField = jQuery('select[name="mml_address_selector"]'); 
    var errorMessage = '<div class="mml-error" style="color:red;margin-top:5px;">Please select an address.</div>'; 

    form.on('submit', function(e) {
        
        if (addressField.val() === "" || addressField.val() === null) {
            e.preventDefault(); 
            addressField.after(errorMessage); 

            return false; 
        }
        
        jQuery('.mml-error').remove();

        var recaptchaResponse = grecaptcha.getResponse();
        if (recaptchaResponse.length === 0) {
            e.preventDefault(); 
            alert('reCAPTCHA verification failed, please try again.');
            return false; 
        }

        return true;
    });

    addressField.on('change', function() {
        if (addressField.val() !== "") {
            jQuery('.mml-error').remove();
        }
    });
});

});
// source --> https://www.lovedayandco.com/wp-content/themes/Impreza-child/magnific-popup/jquery.magnific-popup.min.js?ver=7.0-b-modified-1769691648 
/*! Magnific Popup - v0.9.9 - 2014-09-06

* http://dimsemenov.com/plugins/magnific-popup/

* Copyright (c) 2014 Dmitry Semenov; */

(function(e){var t,n,i,o,r,a,s,l="Close",c="BeforeClose",d="AfterClose",u="BeforeAppend",p="MarkupParse",f="Open",m="Change",g="mfp",h="."+g,v="mfp-ready",C="mfp-removing",y="mfp-prevent-close",w=function(){},b=!!window.jQuery,I=e(window),x=function(e,n){t.ev.on(g+e+h,n)},k=function(t,n,i,o){var r=document.createElement("div");return r.className="mfp-"+t,i&&(r.innerHTML=i),o?n&&n.appendChild(r):(r=e(r),n&&r.appendTo(n)),r},T=function(n,i){t.ev.triggerHandler(g+n,i),t.st.callbacks&&(n=n.charAt(0).toLowerCase()+n.slice(1),t.st.callbacks[n]&&t.st.callbacks[n].apply(t,e.isArray(i)?i:[i]))},E=function(n){return n===s&&t.currTemplate.closeBtn||(t.currTemplate.closeBtn=e(t.st.closeMarkup.replace("%title%",t.st.tClose)),s=n),t.currTemplate.closeBtn},_=function(){e.magnificPopup.instance||(t=new w,t.init(),e.magnificPopup.instance=t)},S=function(){var e=document.createElement("p").style,t=["ms","O","Moz","Webkit"];if(void 0!==e.transition)return!0;for(;t.length;)if(t.pop()+"Transition"in e)return!0;return!1};w.prototype={constructor:w,init:function(){var n=navigator.appVersion;t.isIE7=-1!==n.indexOf("MSIE 7."),t.isIE8=-1!==n.indexOf("MSIE 8."),t.isLowIE=t.isIE7||t.isIE8,t.isAndroid=/android/gi.test(n),t.isIOS=/iphone|ipad|ipod/gi.test(n),t.supportsTransition=S(),t.probablyMobile=t.isAndroid||t.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent),o=e(document),t.popupsCache={}},open:function(n){i||(i=e(document.body));var r;if(n.isObj===!1){t.items=n.items.toArray(),t.index=0;var s,l=n.items;for(r=0;l.length>r;r++)if(s=l[r],s.parsed&&(s=s.el[0]),s===n.el[0]){t.index=r;break}}else t.items=e.isArray(n.items)?n.items:[n.items],t.index=n.index||0;if(t.isOpen)return t.updateItemHTML(),void 0;t.types=[],a="",t.ev=n.mainEl&&n.mainEl.length?n.mainEl.eq(0):o,n.key?(t.popupsCache[n.key]||(t.popupsCache[n.key]={}),t.currTemplate=t.popupsCache[n.key]):t.currTemplate={},t.st=e.extend(!0,{},e.magnificPopup.defaults,n),t.fixedContentPos="auto"===t.st.fixedContentPos?!t.probablyMobile:t.st.fixedContentPos,t.st.modal&&(t.st.closeOnContentClick=!1,t.st.closeOnBgClick=!1,t.st.showCloseBtn=!1,t.st.enableEscapeKey=!1),t.bgOverlay||(t.bgOverlay=k("bg").on("click"+h,function(){t.close()}),t.wrap=k("wrap").attr("tabindex",-1).on("click"+h,function(e){t._checkIfClose(e.target)&&t.close()}),t.container=k("container",t.wrap)),t.contentContainer=k("content"),t.st.preloader&&(t.preloader=k("preloader",t.container,t.st.tLoading));var c=e.magnificPopup.modules;for(r=0;c.length>r;r++){var d=c[r];d=d.charAt(0).toUpperCase()+d.slice(1),t["init"+d].call(t)}T("BeforeOpen"),t.st.showCloseBtn&&(t.st.closeBtnInside?(x(p,function(e,t,n,i){n.close_replaceWith=E(i.type)}),a+=" mfp-close-btn-in"):t.wrap.append(E())),t.st.alignTop&&(a+=" mfp-align-top"),t.fixedContentPos?t.wrap.css({overflow:t.st.overflowY,overflowX:"hidden",overflowY:t.st.overflowY}):t.wrap.css({top:I.scrollTop(),position:"absolute"}),(t.st.fixedBgPos===!1||"auto"===t.st.fixedBgPos&&!t.fixedContentPos)&&t.bgOverlay.css({height:o.height(),position:"absolute"}),t.st.enableEscapeKey&&o.on("keyup"+h,function(e){27===e.keyCode&&t.close()}),I.on("resize"+h,function(){t.updateSize()}),t.st.closeOnContentClick||(a+=" mfp-auto-cursor"),a&&t.wrap.addClass(a);var u=t.wH=I.height(),m={};if(t.fixedContentPos&&t._hasScrollBar(u)){var g=t._getScrollbarSize();g&&(m.marginRight=g)}t.fixedContentPos&&(t.isIE7?e("body, html").css("overflow","hidden"):m.overflow="hidden");var C=t.st.mainClass;return t.isIE7&&(C+=" mfp-ie7"),C&&t._addClassToMFP(C),t.updateItemHTML(),T("BuildControls"),e("html").css(m),t.bgOverlay.add(t.wrap).prependTo(t.st.prependTo||i),t._lastFocusedEl=document.activeElement,setTimeout(function(){t.content?(t._addClassToMFP(v),t._setFocus()):t.bgOverlay.addClass(v),o.on("focusin"+h,t._onFocusIn)},16),t.isOpen=!0,t.updateSize(u),T(f),n},close:function(){t.isOpen&&(T(c),t.isOpen=!1,t.st.removalDelay&&!t.isLowIE&&t.supportsTransition?(t._addClassToMFP(C),setTimeout(function(){t._close()},t.st.removalDelay)):t._close())},_close:function(){T(l);var n=C+" "+v+" ";if(t.bgOverlay.detach(),t.wrap.detach(),t.container.empty(),t.st.mainClass&&(n+=t.st.mainClass+" "),t._removeClassFromMFP(n),t.fixedContentPos){var i={marginRight:""};t.isIE7?e("body, html").css("overflow",""):i.overflow="",e("html").css(i)}o.off("keyup"+h+" focusin"+h),t.ev.off(h),t.wrap.attr("class","mfp-wrap").removeAttr("style"),t.bgOverlay.attr("class","mfp-bg"),t.container.attr("class","mfp-container"),!t.st.showCloseBtn||t.st.closeBtnInside&&t.currTemplate[t.currItem.type]!==!0||t.currTemplate.closeBtn&&t.currTemplate.closeBtn.detach(),t._lastFocusedEl&&e(t._lastFocusedEl).focus(),t.currItem=null,t.content=null,t.currTemplate=null,t.prevHeight=0,T(d)},updateSize:function(e){if(t.isIOS){var n=document.documentElement.clientWidth/window.innerWidth,i=window.innerHeight*n;t.wrap.css("height",i),t.wH=i}else t.wH=e||I.height();t.fixedContentPos||t.wrap.css("height",t.wH),T("Resize")},updateItemHTML:function(){var n=t.items[t.index];t.contentContainer.detach(),t.content&&t.content.detach(),n.parsed||(n=t.parseEl(t.index));var i=n.type;if(T("BeforeChange",[t.currItem?t.currItem.type:"",i]),t.currItem=n,!t.currTemplate[i]){var o=t.st[i]?t.st[i].markup:!1;T("FirstMarkupParse",o),t.currTemplate[i]=o?e(o):!0}r&&r!==n.type&&t.container.removeClass("mfp-"+r+"-holder");var a=t["get"+i.charAt(0).toUpperCase()+i.slice(1)](n,t.currTemplate[i]);t.appendContent(a,i),n.preloaded=!0,T(m,n),r=n.type,t.container.prepend(t.contentContainer),T("AfterChange")},appendContent:function(e,n){t.content=e,e?t.st.showCloseBtn&&t.st.closeBtnInside&&t.currTemplate[n]===!0?t.content.find(".mfp-close").length||t.content.append(E()):t.content=e:t.content="",T(u),t.container.addClass("mfp-"+n+"-holder"),t.contentContainer.append(t.content)},parseEl:function(n){var i,o=t.items[n];if(o.tagName?o={el:e(o)}:(i=o.type,o={data:o,src:o.src}),o.el){for(var r=t.types,a=0;r.length>a;a++)if(o.el.hasClass("mfp-"+r[a])){i=r[a];break}o.src=o.el.attr("data-mfp-src"),o.src||(o.src=o.el.attr("href"))}return o.type=i||t.st.type||"inline",o.index=n,o.parsed=!0,t.items[n]=o,T("ElementParse",o),t.items[n]},addGroup:function(e,n){var i=function(i){i.mfpEl=this,t._openClick(i,e,n)};n||(n={});var o="click.magnificPopup";n.mainEl=e,n.items?(n.isObj=!0,e.off(o).on(o,i)):(n.isObj=!1,n.delegate?e.off(o).on(o,n.delegate,i):(n.items=e,e.off(o).on(o,i)))},_openClick:function(n,i,o){var r=void 0!==o.midClick?o.midClick:e.magnificPopup.defaults.midClick;if(r||2!==n.which&&!n.ctrlKey&&!n.metaKey){var a=void 0!==o.disableOn?o.disableOn:e.magnificPopup.defaults.disableOn;if(a)if(e.isFunction(a)){if(!a.call(t))return!0}else if(a>I.width())return!0;n.type&&(n.preventDefault(),t.isOpen&&n.stopPropagation()),o.el=e(n.mfpEl),o.delegate&&(o.items=i.find(o.delegate)),t.open(o)}},updateStatus:function(e,i){if(t.preloader){n!==e&&t.container.removeClass("mfp-s-"+n),i||"loading"!==e||(i=t.st.tLoading);var o={status:e,text:i};T("UpdateStatus",o),e=o.status,i=o.text,t.preloader.html(i),t.preloader.find("a").on("click",function(e){e.stopImmediatePropagation()}),t.container.addClass("mfp-s-"+e),n=e}},_checkIfClose:function(n){if(!e(n).hasClass(y)){var i=t.st.closeOnContentClick,o=t.st.closeOnBgClick;if(i&&o)return!0;if(!t.content||e(n).hasClass("mfp-close")||t.preloader&&n===t.preloader[0])return!0;if(n===t.content[0]||e.contains(t.content[0],n)){if(i)return!0}else if(o&&e.contains(document,n))return!0;return!1}},_addClassToMFP:function(e){t.bgOverlay.addClass(e),t.wrap.addClass(e)},_removeClassFromMFP:function(e){this.bgOverlay.removeClass(e),t.wrap.removeClass(e)},_hasScrollBar:function(e){return(t.isIE7?o.height():document.body.scrollHeight)>(e||I.height())},_setFocus:function(){(t.st.focus?t.content.find(t.st.focus).eq(0):t.wrap).focus()},_onFocusIn:function(n){return n.target===t.wrap[0]||e.contains(t.wrap[0],n.target)?void 0:(t._setFocus(),!1)},_parseMarkup:function(t,n,i){var o;i.data&&(n=e.extend(i.data,n)),T(p,[t,n,i]),e.each(n,function(e,n){if(void 0===n||n===!1)return!0;if(o=e.split("_"),o.length>1){var i=t.find(h+"-"+o[0]);if(i.length>0){var r=o[1];"replaceWith"===r?i[0]!==n[0]&&i.replaceWith(n):"img"===r?i.is("img")?i.attr("src",n):i.replaceWith('<img src="'+n+'" class="'+i.attr("class")+'" />'):i.attr(o[1],n)}}else t.find(h+"-"+e).html(n)})},_getScrollbarSize:function(){if(void 0===t.scrollbarSize){var e=document.createElement("div");e.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(e),t.scrollbarSize=e.offsetWidth-e.clientWidth,document.body.removeChild(e)}return t.scrollbarSize}},e.magnificPopup={instance:null,proto:w.prototype,modules:[],open:function(t,n){return _(),t=t?e.extend(!0,{},t):{},t.isObj=!0,t.index=n||0,this.instance.open(t)},close:function(){return e.magnificPopup.instance&&e.magnificPopup.instance.close()},registerModule:function(t,n){n.options&&(e.magnificPopup.defaults[t]=n.options),e.extend(this.proto,n.proto),this.modules.push(t)},defaults:{disableOn:0,key:null,midClick:!1,mainClass:"",preloader:!0,focus:"",closeOnContentClick:!1,closeOnBgClick:!0,closeBtnInside:!0,showCloseBtn:!0,enableEscapeKey:!0,modal:!1,alignTop:!1,removalDelay:0,prependTo:null,fixedContentPos:"auto",fixedBgPos:"auto",overflowY:"auto",closeMarkup:'<button title="%title%" type="button" class="mfp-close">&times;</button>',tClose:"Close (Esc)",tLoading:"Loading..."}},e.fn.magnificPopup=function(n){_();var i=e(this);if("string"==typeof n)if("open"===n){var o,r=b?i.data("magnificPopup"):i[0].magnificPopup,a=parseInt(arguments[1],10)||0;r.items?o=r.items[a]:(o=i,r.delegate&&(o=o.find(r.delegate)),o=o.eq(a)),t._openClick({mfpEl:o},i,r)}else t.isOpen&&t[n].apply(t,Array.prototype.slice.call(arguments,1));else n=e.extend(!0,{},n),b?i.data("magnificPopup",n):i[0].magnificPopup=n,t.addGroup(i,n);return i};var P,O,z,M="inline",B=function(){z&&(O.after(z.addClass(P)).detach(),z=null)};e.magnificPopup.registerModule(M,{options:{hiddenClass:"hide",markup:"",tNotFound:"Content not found"},proto:{initInline:function(){t.types.push(M),x(l+"."+M,function(){B()})},getInline:function(n,i){if(B(),n.src){var o=t.st.inline,r=e(n.src);if(r.length){var a=r[0].parentNode;a&&a.tagName&&(O||(P=o.hiddenClass,O=k(P),P="mfp-"+P),z=r.after(O).detach().removeClass(P)),t.updateStatus("ready")}else t.updateStatus("error",o.tNotFound),r=e("<div>");return n.inlineElement=r,r}return t.updateStatus("ready"),t._parseMarkup(i,{},n),i}}});var F,H="ajax",L=function(){F&&i.removeClass(F)},A=function(){L(),t.req&&t.req.abort()};e.magnificPopup.registerModule(H,{options:{settings:null,cursor:"mfp-ajax-cur",tError:'<a href="%url%">The content</a> could not be loaded.'},proto:{initAjax:function(){t.types.push(H),F=t.st.ajax.cursor,x(l+"."+H,A),x("BeforeChange."+H,A)},getAjax:function(n){F&&i.addClass(F),t.updateStatus("loading");var o=e.extend({url:n.src,success:function(i,o,r){var a={data:i,xhr:r};T("ParseAjax",a),t.appendContent(e(a.data),H),n.finished=!0,L(),t._setFocus(),setTimeout(function(){t.wrap.addClass(v)},16),t.updateStatus("ready"),T("AjaxContentAdded")},error:function(){L(),n.finished=n.loadError=!0,t.updateStatus("error",t.st.ajax.tError.replace("%url%",n.src))}},t.st.ajax.settings);return t.req=e.ajax(o),""}}});var j,N=function(n){if(n.data&&void 0!==n.data.title)return n.data.title;var i=t.st.image.titleSrc;if(i){if(e.isFunction(i))return i.call(t,n);if(n.el)return n.el.attr(i)||""}return""};e.magnificPopup.registerModule("image",{options:{markup:'<div class="mfp-figure"><div class="mfp-close"></div><figure><div class="mfp-img"></div><figcaption><div class="mfp-bottom-bar"><div class="mfp-title"></div><div class="mfp-counter"></div></div></figcaption></figure></div>',cursor:"mfp-zoom-out-cur",titleSrc:"title",verticalFit:!0,tError:'<a href="%url%">The image</a> could not be loaded.'},proto:{initImage:function(){var e=t.st.image,n=".image";t.types.push("image"),x(f+n,function(){"image"===t.currItem.type&&e.cursor&&i.addClass(e.cursor)}),x(l+n,function(){e.cursor&&i.removeClass(e.cursor),I.off("resize"+h)}),x("Resize"+n,t.resizeImage),t.isLowIE&&x("AfterChange",t.resizeImage)},resizeImage:function(){var e=t.currItem;if(e&&e.img&&t.st.image.verticalFit){var n=0;t.isLowIE&&(n=parseInt(e.img.css("padding-top"),10)+parseInt(e.img.css("padding-bottom"),10)),e.img.css("max-height",t.wH-n)}},_onImageHasSize:function(e){e.img&&(e.hasSize=!0,j&&clearInterval(j),e.isCheckingImgSize=!1,T("ImageHasSize",e),e.imgHidden&&(t.content&&t.content.removeClass("mfp-loading"),e.imgHidden=!1))},findImageSize:function(e){var n=0,i=e.img[0],o=function(r){j&&clearInterval(j),j=setInterval(function(){return i.naturalWidth>0?(t._onImageHasSize(e),void 0):(n>200&&clearInterval(j),n++,3===n?o(10):40===n?o(50):100===n&&o(500),void 0)},r)};o(1)},getImage:function(n,i){var o=0,r=function(){n&&(n.img[0].complete?(n.img.off(".mfploader"),n===t.currItem&&(t._onImageHasSize(n),t.updateStatus("ready")),n.hasSize=!0,n.loaded=!0,T("ImageLoadComplete")):(o++,200>o?setTimeout(r,100):a()))},a=function(){n&&(n.img.off(".mfploader"),n===t.currItem&&(t._onImageHasSize(n),t.updateStatus("error",s.tError.replace("%url%",n.src))),n.hasSize=!0,n.loaded=!0,n.loadError=!0)},s=t.st.image,l=i.find(".mfp-img");if(l.length){var c=document.createElement("img");c.className="mfp-img",n.img=e(c).on("load.mfploader",r).on("error.mfploader",a),c.src=n.src,l.is("img")&&(n.img=n.img.clone()),c=n.img[0],c.naturalWidth>0?n.hasSize=!0:c.width||(n.hasSize=!1)}return t._parseMarkup(i,{title:N(n),img_replaceWith:n.img},n),t.resizeImage(),n.hasSize?(j&&clearInterval(j),n.loadError?(i.addClass("mfp-loading"),t.updateStatus("error",s.tError.replace("%url%",n.src))):(i.removeClass("mfp-loading"),t.updateStatus("ready")),i):(t.updateStatus("loading"),n.loading=!0,n.hasSize||(n.imgHidden=!0,i.addClass("mfp-loading"),t.findImageSize(n)),i)}}});var W,R=function(){return void 0===W&&(W=void 0!==document.createElement("p").style.MozTransform),W};e.magnificPopup.registerModule("zoom",{options:{enabled:!1,easing:"ease-in-out",duration:300,opener:function(e){return e.is("img")?e:e.find("img")}},proto:{initZoom:function(){var e,n=t.st.zoom,i=".zoom";if(n.enabled&&t.supportsTransition){var o,r,a=n.duration,s=function(e){var t=e.clone().removeAttr("style").removeAttr("class").addClass("mfp-animated-image"),i="all "+n.duration/1e3+"s "+n.easing,o={position:"fixed",zIndex:9999,left:0,top:0,"-webkit-backface-visibility":"hidden"},r="transition";return o["-webkit-"+r]=o["-moz-"+r]=o["-o-"+r]=o[r]=i,t.css(o),t},d=function(){t.content.css("visibility","visible")};x("BuildControls"+i,function(){if(t._allowZoom()){if(clearTimeout(o),t.content.css("visibility","hidden"),e=t._getItemToZoom(),!e)return d(),void 0;r=s(e),r.css(t._getOffset()),t.wrap.append(r),o=setTimeout(function(){r.css(t._getOffset(!0)),o=setTimeout(function(){d(),setTimeout(function(){r.remove(),e=r=null,T("ZoomAnimationEnded")},16)},a)},16)}}),x(c+i,function(){if(t._allowZoom()){if(clearTimeout(o),t.st.removalDelay=a,!e){if(e=t._getItemToZoom(),!e)return;r=s(e)}r.css(t._getOffset(!0)),t.wrap.append(r),t.content.css("visibility","hidden"),setTimeout(function(){r.css(t._getOffset())},16)}}),x(l+i,function(){t._allowZoom()&&(d(),r&&r.remove(),e=null)})}},_allowZoom:function(){return"image"===t.currItem.type},_getItemToZoom:function(){return t.currItem.hasSize?t.currItem.img:!1},_getOffset:function(n){var i;i=n?t.currItem.img:t.st.zoom.opener(t.currItem.el||t.currItem);var o=i.offset(),r=parseInt(i.css("padding-top"),10),a=parseInt(i.css("padding-bottom"),10);o.top-=e(window).scrollTop()-r;var s={width:i.width(),height:(b?i.innerHeight():i[0].offsetHeight)-a-r};return R()?s["-moz-transform"]=s.transform="translate("+o.left+"px,"+o.top+"px)":(s.left=o.left,s.top=o.top),s}}});var Z="iframe",q="//about:blank",D=function(e){if(t.currTemplate[Z]){var n=t.currTemplate[Z].find("iframe");n.length&&(e||(n[0].src=q),t.isIE8&&n.css("display",e?"block":"none"))}};e.magnificPopup.registerModule(Z,{options:{markup:'<div class="mfp-iframe-scaler"><div class="mfp-close"></div><iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe></div>',srcAction:"iframe_src",patterns:{youtube:{index:"youtube.com",id:"v=",src:"//www.youtube.com/embed/%id%?autoplay=1"},vimeo:{index:"vimeo.com/",id:"/",src:"//player.vimeo.com/video/%id%?autoplay=1"},gmaps:{index:"//maps.google.",src:"%id%&output=embed"}}},proto:{initIframe:function(){t.types.push(Z),x("BeforeChange",function(e,t,n){t!==n&&(t===Z?D():n===Z&&D(!0))}),x(l+"."+Z,function(){D()})},getIframe:function(n,i){var o=n.src,r=t.st.iframe;e.each(r.patterns,function(){return o.indexOf(this.index)>-1?(this.id&&(o="string"==typeof this.id?o.substr(o.lastIndexOf(this.id)+this.id.length,o.length):this.id.call(this,o)),o=this.src.replace("%id%",o),!1):void 0});var a={};return r.srcAction&&(a[r.srcAction]=o),t._parseMarkup(i,a,n),t.updateStatus("ready"),i}}});var K=function(e){var n=t.items.length;return e>n-1?e-n:0>e?n+e:e},Y=function(e,t,n){return e.replace(/%curr%/gi,t+1).replace(/%total%/gi,n)};e.magnificPopup.registerModule("gallery",{options:{enabled:!1,arrowMarkup:'<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',preload:[0,2],navigateByImgClick:!0,arrows:!0,tPrev:"Previous (Left arrow key)",tNext:"Next (Right arrow key)",tCounter:"%curr% of %total%"},proto:{initGallery:function(){var n=t.st.gallery,i=".mfp-gallery",r=Boolean(e.fn.mfpFastClick);return t.direction=!0,n&&n.enabled?(a+=" mfp-gallery",x(f+i,function(){n.navigateByImgClick&&t.wrap.on("click"+i,".mfp-img",function(){return t.items.length>1?(t.next(),!1):void 0}),o.on("keydown"+i,function(e){37===e.keyCode?t.prev():39===e.keyCode&&t.next()})}),x("UpdateStatus"+i,function(e,n){n.text&&(n.text=Y(n.text,t.currItem.index,t.items.length))}),x(p+i,function(e,i,o,r){var a=t.items.length;o.counter=a>1?Y(n.tCounter,r.index,a):""}),x("BuildControls"+i,function(){if(t.items.length>1&&n.arrows&&!t.arrowLeft){var i=n.arrowMarkup,o=t.arrowLeft=e(i.replace(/%title%/gi,n.tPrev).replace(/%dir%/gi,"left")).addClass(y),a=t.arrowRight=e(i.replace(/%title%/gi,n.tNext).replace(/%dir%/gi,"right")).addClass(y),s=r?"mfpFastClick":"click";o[s](function(){t.prev()}),a[s](function(){t.next()}),t.isIE7&&(k("b",o[0],!1,!0),k("a",o[0],!1,!0),k("b",a[0],!1,!0),k("a",a[0],!1,!0)),t.container.append(o.add(a))}}),x(m+i,function(){t._preloadTimeout&&clearTimeout(t._preloadTimeout),t._preloadTimeout=setTimeout(function(){t.preloadNearbyImages(),t._preloadTimeout=null},16)}),x(l+i,function(){o.off(i),t.wrap.off("click"+i),t.arrowLeft&&r&&t.arrowLeft.add(t.arrowRight).destroyMfpFastClick(),t.arrowRight=t.arrowLeft=null}),void 0):!1},next:function(){t.direction=!0,t.index=K(t.index+1),t.updateItemHTML()},prev:function(){t.direction=!1,t.index=K(t.index-1),t.updateItemHTML()},goTo:function(e){t.direction=e>=t.index,t.index=e,t.updateItemHTML()},preloadNearbyImages:function(){var e,n=t.st.gallery.preload,i=Math.min(n[0],t.items.length),o=Math.min(n[1],t.items.length);for(e=1;(t.direction?o:i)>=e;e++)t._preloadItem(t.index+e);for(e=1;(t.direction?i:o)>=e;e++)t._preloadItem(t.index-e)},_preloadItem:function(n){if(n=K(n),!t.items[n].preloaded){var i=t.items[n];i.parsed||(i=t.parseEl(n)),T("LazyLoad",i),"image"===i.type&&(i.img=e('<img class="mfp-img" />').on("load.mfploader",function(){i.hasSize=!0}).on("error.mfploader",function(){i.hasSize=!0,i.loadError=!0,T("LazyLoadError",i)}).attr("src",i.src)),i.preloaded=!0}}}});var U="retina";e.magnificPopup.registerModule(U,{options:{replaceSrc:function(e){return e.src.replace(/\.\w+$/,function(e){return"@2x"+e})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var e=t.st.retina,n=e.ratio;n=isNaN(n)?n():n,n>1&&(x("ImageHasSize."+U,function(e,t){t.img.css({"max-width":t.img[0].naturalWidth/n,width:"100%"})}),x("ElementParse."+U,function(t,i){i.src=e.replaceSrc(i,n)}))}}}}),function(){var t=1e3,n="ontouchstart"in window,i=function(){I.off("touchmove"+r+" touchend"+r)},o="mfpFastClick",r="."+o;e.fn.mfpFastClick=function(o){return e(this).each(function(){var a,s=e(this);if(n){var l,c,d,u,p,f;s.on("touchstart"+r,function(e){u=!1,f=1,p=e.originalEvent?e.originalEvent.touches[0]:e.touches[0],c=p.clientX,d=p.clientY,I.on("touchmove"+r,function(e){p=e.originalEvent?e.originalEvent.touches:e.touches,f=p.length,p=p[0],(Math.abs(p.clientX-c)>10||Math.abs(p.clientY-d)>10)&&(u=!0,i())}).on("touchend"+r,function(e){i(),u||f>1||(a=!0,e.preventDefault(),clearTimeout(l),l=setTimeout(function(){a=!1},t),o())})})}s.on("click"+r,function(){a||o()})})},e.fn.destroyMfpFastClick=function(){e(this).off("touchstart"+r+" click"+r),n&&I.off("touchmove"+r+" touchend"+r)}}(),_()})(window.jQuery||window.Zepto);
// source --> https://www.lovedayandco.com/wp-content/themes/Impreza-child/magnific-popup/jquery.magnific-popup-init.js?ver=7.0-b-modified-1769691648 
jQuery(document).ready(function ($) {
  $(".popup-youtube, .popup-vimeo, .popup-gmaps").magnificPopup({
    disableOn: 300,
    type: "iframe",
    mainClass: "mfp-fade",
    removalDelay: 160,
    preloader: false,
    fixedContentPos: false,
  });
  // $(".opppen-popup-link").magnificPopup({
  //   type: "inline",
  //   midClick: true, // Allow opening popup on middle mouse click. Always set it to true if you don't provide alternative source in href.
  // });

  // $(".open-contact-form").magnificPopup({
  //   type: "inline",
  //   midClick: true,
  //   closeOnBgClick: true,
  //   removalDelay: 300,
  //   mainClass: "mfp-fade",
  // });

});