alert("start of MY JS file");
window.addEventListener("error", handleError, true);

function handleError(evt) {
    if (evt.message) { // Chrome sometimes provides this
      alert("error: "+evt.message +" at linenumber: "+evt.lineno+" of file: "+evt.filename);
    } else {
      alert("error: "+evt.type+" from element: "+(evt.srcElement || evt.target));
    }
}

function CustomInvalidMsg(textbox, message) {
  if (textbox.validity.patternMismatch) {
    textbox.setCustomValidity(message);
  } else {
    textbox.setCustomValidity("");
  }
  return true;
}
function showNotyMessage(type, message, position, timeout) {
  noty({
    text: message,
    layout: typeof position !== "undefined" ? position : "bottomRight",
    type: type,
    timeout: typeof timeout !== "undefined" ? timeout : 3000,
  });
}
function showCoreModalMessage(title, message) {
  $("#core-modal-message .modal-title").html(title);
  $("#core-modal-message .modal-body").html(message);
  $("#core-modal-message").modal("show");
}
function showCoreModalErrorMessage(message) {
  $("#error-modal .modal-body p").html(message);
  $("#error-modal").modal("show");
}
function showAjaxErrorMessage(jqXHR, exception) {
  var msg = "";
  if (jqXHR.status === 0) {
    msg = "Not connect.\n Verify Network.";
  } else if (jqXHR.status == 404) {
    msg = "Requested page not found. [404]";
  } else if (jqXHR.status == 500) {
    msg = "Internal Server Error [500].";
  } else if (exception === "parsererror") {
    msg = "Requested JSON parse failed.";
  } else if (exception === "timeout") {
    msg = "Time out error.";
  } else if (exception === "abort") {
    msg = "Ajax request aborted.";
  } else {
    msg = "Uncaught Error.\n" + jqXHR.responseText;
  }
  showCoreModalMessage("System Alert", msg);
}
function copyStringToClipboard(str) {
  var el = document.createElement("textarea");
  el.value = str;
  el.setAttribute("readonly", "");
  el.style = { position: "absolute", left: "-9999px" };
  activeModal = document.querySelector(
    ".modal.fade.in .modal-dialog .modal-content"
  );
  if (activeModal != null) activeModal.appendChild(el);
  else document.body.appendChild(el);
  el.select();
  document.execCommand("copy");
  if (activeModal != null) activeModal.removeChild(el);
  else document.body.removeChild(el);
}
(function ($) {
  if ($.fn.style) {
    return;
  }
  var escape = function (text) {
    return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
  };
  var isStyleFuncSupported = !!CSSStyleDeclaration.prototype.getPropertyValue;
  if (!isStyleFuncSupported) {
    CSSStyleDeclaration.prototype.getPropertyValue = function (a) {
      return this.getAttribute(a);
    };
    CSSStyleDeclaration.prototype.setProperty = function (
      styleName,
      value,
      priority
    ) {
      this.setAttribute(styleName, value);
      var priority = typeof priority != "undefined" ? priority : "";
      if (priority != "") {
        var rule = new RegExp(
          escape(styleName) + "\\s*:\\s*" + escape(value) + "(\\s*;)?",
          "gmi"
        );
        this.cssText = this.cssText.replace(
          rule,
          styleName + ": " + value + " !" + priority + ";"
        );
      }
    };
    CSSStyleDeclaration.prototype.removeProperty = function (a) {
      return this.removeAttribute(a);
    };
    CSSStyleDeclaration.prototype.getPropertyPriority = function (styleName) {
      var rule = new RegExp(
        escape(styleName) + "\\s*:\\s*[^\\s]*\\s*!important(\\s*;)?",
        "gmi"
      );
      return rule.test(this.cssText) ? "important" : "";
    };
  }
  $.fn.style = function (styleName, value, priority) {
    var node = this.get(0);
    if (typeof node == "undefined") {
      return this;
    }
    var style = this.get(0).style;
    if (typeof styleName != "undefined") {
      if (typeof value != "undefined") {
        priority = typeof priority != "undefined" ? priority : "";
        style.setProperty(styleName, value, priority);
        return this;
      } else {
        return style.getPropertyValue(styleName);
      }
    } else {
      return style;
    }
  };
})(jQuery);
function getRandomNumber() {
  return Math.floor(Math.random() * 10000000000 + 1);
}
function findClosestBackgroundColor($el) {
  var background;
  background = "white";
  $.merge($el, $el.parents()).each(function () {
    var bg;
    bg = $(this).css("background-color");
    if (bg !== "transparent" && !/rgba/.test(bg)) {
      background = bg;
      return false;
    }
  });
  return background;
}
function strip(html) {
  var tmp = document.createElement("DIV");
  tmp.innerHTML = html;
  return tmp.textContent || tmp.innerText || "";
}
function resizePageContent() {
  vpw = $(window).width();
  vph = $(window).height();
  $(".pages-main-wrapper").css({ height: vph - 430 + "px" });
}
function isUrlValid(url) {
  return /^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(
    url
  );
}
function inIFrame() {
  var inFrame = false;
  try {
    inFrame = window.self !== window.top;
  } catch (e) {
    inFrame = true;
  }
  if (inFrame) {
    window.location.href = siteUrl + "iframe";
  }
}
function findGetParameter(parameterName) {
  var result = null,
    tmp = [];
  var items = location.search.substr(1).split("&");
  for (var index = 0; index < items.length; index++) {
    tmp = items[index].split("=");
    if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
  }
  return result;
}
function b64encode(str) {
  if (str) {
    str = str.replace("’", "'");
  }
  return btoa(unescape(encodeURIComponent(str)));
}
function b64decode(str) {
  return decodeURIComponent(escape(atob(str)));
}
(function ($) {
  if ($.fn.style) {
    return;
  }
  var escape = function (text) {
    return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
  };
  var isStyleFuncSupported = !!CSSStyleDeclaration.prototype.getPropertyValue;
  if (!isStyleFuncSupported) {
    CSSStyleDeclaration.prototype.getPropertyValue = function (a) {
      return this.getAttribute(a);
    };
    CSSStyleDeclaration.prototype.setProperty = function (
      styleName,
      value,
      priority
    ) {
      this.setAttribute(styleName, value);
      var priority = typeof priority != "undefined" ? priority : "";
      if (priority != "") {
        var rule = new RegExp(
          escape(styleName) + "\\s*:\\s*" + escape(value) + "(\\s*;)?",
          "gmi"
        );
        this.cssText = this.cssText.replace(
          rule,
          styleName + ": " + value + " !" + priority + ";"
        );
      }
    };
    CSSStyleDeclaration.prototype.removeProperty = function (a) {
      return this.removeAttribute(a);
    };
    CSSStyleDeclaration.prototype.getPropertyPriority = function (styleName) {
      var rule = new RegExp(
        escape(styleName) + "\\s*:\\s*[^\\s]*\\s*!important(\\s*;)?",
        "gmi"
      );
      return rule.test(this.cssText) ? "important" : "";
    };
  }
  $.fn.style = function (styleName, value, priority) {
    var node = this.get(0);
    if (typeof node == "undefined") {
      return this;
    }
    var style = this.get(0).style;
    if (typeof styleName != "undefined") {
      if (typeof value != "undefined") {
        priority = typeof priority != "undefined" ? priority : "";
        style.setProperty(styleName, value, priority);
        return this;
      } else {
        return style.getPropertyValue(styleName);
      }
    } else {
      return style;
    }
  };
})(jQuery);
var aggregation = (baseClass, ...mixins) => {
  let base = class _Combined extends baseClass {
    constructor(...args) {
      super(...args);
      mixins.forEach((mixin) => {
        mixin.prototype.initializer.call(this);
      });
    }
  };
  let copyProps = (target, source) => {
    Object.getOwnPropertyNames(source)
      .concat(Object.getOwnPropertySymbols(source))
      .forEach((prop) => {
        if (
          prop.match(
            /^(?:constructor|prototype|arguments|caller|name|bind|call|apply|toString|length)$/
          )
        )
          return;
        Object.defineProperty(
          target,
          prop,
          Object.getOwnPropertyDescriptor(source, prop)
        );
      });
  };
  mixins.forEach((mixin) => {
    copyProps(base.prototype, mixin.prototype);
    copyProps(base, mixin);
  });
  return base;
};
function stripHtml(html) {
  let temporalDivElement = document.createElement("div");
  let text;
  temporalDivElement.innerHTML = html;
  text = temporalDivElement.textContent || temporalDivElement.innerText || "";
  return text.replace(/(^[ \t]*\n)/gm, "");
}
$.fn.clearValidation = function () {
  var v = $(this).validate();
  $("[name]", this).each(function () {
    v.successList.push(this);
    v.showErrors();
  });
  v.resetForm();
  v.reset();
};
let FormPublicPageClass;
class Forms_PublicPage {
  modalFormInvoker;
  constructor() {
    this.gdprIsInEurope = false;
    this.formsList = [];
    this.initInlineForms();
    this.initModalForms();
    this.initRoshdi();
    this.initGDPRPlugin();
  }
  initInlineForms() {
    let classResource = this;
    $("div.droppableElementArea.formElement").each(function (i, formElement) {
      let formClass = new Forms_PublicPage_Entity(formElement);
      if (formClass.isValid() === false) {
        console.log("ERROR IN INLINE FORM: " + formClass.validateError());
        return;
      }
      formClass.setFormLayout();
      formClass.setFormFields();
      formClass.setEvents();
      classResource.formsList.push(formClass);
    });
  }
  initModalForms() {
    // alert("initModalForms");
    let classResource = this;
    $(".droppableElementArea.btnElement").each(function (i, btnElement) {
      let btnClass = new Forms_PublicPage_Entity(btnElement);
      if (btnClass.isValid() === false) {
        console.log("ERROR IN BTN FORM: " + btnClass.validateError());
        return;
      }
      btnClass.setEvents();
      classResource.formsList.push(btnClass);
    });
    $("#popup-form-modal .buttonSubmitPopup button").click(function () {
      FormPublicPageClass.modalFormInvoker.EventActionClass = new Forms_PublicPage_Events_Modal_Actions(
        FormPublicPageClass.modalFormInvoker.entityClass
      );
      FormPublicPageClass.modalFormInvoker.EventActionClass.btnSubmitElementResource = $(
        this
      );
      FormPublicPageClass.modalFormInvoker.EventActionClass.formDOMFormResource = $(
        "#button-form"
      );
      if (
        !FormPublicPageClass.modalFormInvoker.EventActionClass.validateForm()
      ) {
        return;
      }
      FormPublicPageClass.modalFormInvoker.EventActionClass.setSubmitButtonStatus(
        true
      );
      FormPublicPageClass.modalFormInvoker.ContactClass = new Forms_PublicPage_Contacts(
        FormPublicPageClass.modalFormInvoker.entityClass
      );
      setTimeout(() => {
        FormPublicPageClass.modalFormInvoker.ContactClass.save();
      }, 100);
    });
  }
  initGDPRPlugin() {
    let HttpRequestObject = new XMLHttpRequest();
    HttpRequestObject.open(
      "GET",
      "https://pro.ip-api.com/xml/?key=R5xiO0FwQoC0t9D&fields=timezone",
      true
    );
    HttpRequestObject.onreadystatechange = function () {
      let doc, region;
      if (
        HttpRequestObject.readyState === 4 &&
        HttpRequestObject.status === 200
      ) {
        doc = HttpRequestObject.responseXML;
        region = doc
          .getElementsByTagName("timezone")[0]
          .firstChild.nodeValue.toString();
        if (region.toString().toLowerCase().includes("europe")) {
          FormPublicPageClass.gdprIsInEurope = true;
        }
        FormPublicPageClass.setGDPRPlugin();
      }
    };
    HttpRequestObject.send(null);
  }
  setGDPRPlugin() {
    $.each(FormPublicPageClass.formsList, function (i, element) {
      if (element.SettingsClass.formType !== "inline") {
        return;
      }
      element.FieldsClass.fieldGDPRClass.setData();
    });
  }
}
$(document).ready(function () {
  FormPublicPageClass = new Forms_PublicPage();
});
class Forms_PublicPage_Base {
  constructor(entityClass) {
    this.isValidForm = false;
    this.formValidateError = "";
    this.formDomResource = "";
    this.formSettings = {};
    this.formSettingsId = 0;
    this.formType = "";
    this.domHolderSelector = "";
    this.formFields = {};
    this.formContent = {};
    this.entityClass = entityClass;
    this.formDomResource = entityClass.formDomResource;
    this.formType = this.formDomResource.hasClass("formElement")
      ? "inline"
      : "modal";
    this.domHolderSelector =
      this.formType === "inline"
        ? this.formDomResource
        : $("#popup-form-modal");
    if (this.entityClass.SettingsClass !== null) {
      this.formSettingsId = this.entityClass.SettingsClass.formSettingsId;
      this.formSettings = this.entityClass.SettingsClass.formSettings;
      this.formFields = this.entityClass.SettingsClass.formSettings.optin_type.fields;
      this.formContent = this.entityClass.SettingsClass.formSettings.content;
    }
  }
}
class Forms_PublicPage_Entity {
  constructor(domResourceSelector) {
    this.formDomResource = "";
    this.formValidateError = "";
    this.isValidForm = false;
    this.SettingsClass = null;
    this.LayoutClass = null;
    this.FieldsClass = null;
    this.EventsClass = null;
    this.formDomResource = $(domResourceSelector);
    if (this.formDomResource.length === 0) {
      this.isValidForm = false;
      this.formValidateError =
        "Invalid jQuery DOM resource while parse form settings!";
      return;
    }
    this.setFormSettings();
    // alert("Forms_PublicPage_Entity CONS");
  }
  setFormSettings() {
    this.SettingsClass = new Forms_PublicPage_Settings(this);
    this.isValidForm = this.SettingsClass.isValidForm;
    this.formValidateError = this.SettingsClass.formValidateError;
  }
  setFormLayout() {
    this.LayoutClass = new Forms_PublicPage_Layout(this);
  }
  setFormFields() {
    this.FieldsClass = new Forms_PublicPage_Fields(this);
    this.FieldsClass.setFieldsAddons();
  }
  setEvents() {
    this.EventsClass = new Forms_PublicPage_Events(this);
    // alert("Forms_PublicPage_Entity CONS");
  }
  isValid() {
    return this.isValidForm;
  }
  validateError() {
    return this.formValidateError;
  }
}
class Forms_PublicPage_Settings extends Forms_PublicPage_Base {
  constructor(entityClass) {
    super(entityClass);
    this.init();
  }
  init() {
    let defaultSettingsHolderResource = this.formDomResource
      .closest("div.elements-control")
      .find(".buttonModalsSettingsHolder");
    let parentElement = this.formDomResource
      .closest("div.elements-control")
      .data("parent");
    let formSettings = defaultSettingsHolderResource;
    if (typeof parentElement !== "undefined" && parentElement != "0") {
      formSettings = $('div.formElement[data-name="' + parent + '"]').find(
        ".buttonModalsSettingsHolder"
      );
    }
    if (formSettings.length === 0 || formSettings.html().trim() === "") {
      this.isValidForm = false;
      this.formValidateError = "Missing inline/btn holder with form settings!";
      return;
    }
    try {
      this.formSettings = jQuery.parseJSON(formSettings.html().trim());
    } catch (e) {
      this.isValidForm = false;
      this.formValidateError =
        "Invalid JSON in inline/btn form settings holder!";
      console.log(e);
      return;
    }
    if (typeof defaultSettingsHolderResource.attr("data-id") === "undefined") {
      this.isValidForm = false;
      this.formValidateError = "Invalid Form ID in settings holder";
      return;
    }
    this.formSettingsId = defaultSettingsHolderResource.attr("data-id");
    this.isValidForm = true;
  }
}
class Forms_PublicPage_Layout extends Forms_PublicPage_Base {
  constructor(entityClass) {
    super(entityClass);
    this.formLayoutContentClass = null;
    this.formLayoutDesignClass = null;
    this.initText();
    this.initDesign();
  }
  initText() {
    this.formLayoutContentClass = new Forms_PublicPage_Layout_Content(
      this.entityClass
    );
    this.formLayoutContentClass.execute();
  }
  initDesign() {
    this.formLayoutDesignClass = new Forms_PublicPage_Layout_Design(
      this.entityClass
    );
    this.formLayoutDesignClass.execute();
  }
}
class Forms_PublicPage_Layout_Content extends Forms_PublicPage_Base {
  constructor(entityClass) {
    super(entityClass);
    this.formTextContent = null;
    this.formTextContent = this.formSettings.content;
  }
  execute() {
    let domHolderSelector =
      this.formType === "inline"
        ? this.formDomResource
        : $("#popup-form-modal");
    this.prepare();
    this.apply(domHolderSelector);
  }
  prepare() {
    if (this.formTextContent.sms_text === this.formTextContent.sms_text2) {
      this.formTextContent.sms_text2 = b64encode(
        "I Accept To Receive Additional Info"
      );
    }
  }
  apply(formDomSelectorResource) {
    let agreementLabels = this.getAgreementLabelsText(this.formTextContent);
    formDomSelectorResource
      .find(".popupTitle")
      .html(b64decode(this.formTextContent.header_text));
    formDomSelectorResource
      .find(".popupSubTitle")
      .html(b64decode(this.formTextContent.content_text));
    formDomSelectorResource
      .find(".spamText")
      .html(b64decode(this.formTextContent.spam_text));
    formDomSelectorResource
      .find(".bookingBtnText")
      .html(b64decode(this.formTextContent.button_text));
    formDomSelectorResource
      .find(".spots-sms-checkboxwrapper .SMSLabelText")
      .html(agreementLabels.labelSMSAgreementTextDecrypt);
    formDomSelectorResource
      .find(".gdprAgreement .SMSLabelText")
      .html(agreementLabels.labelGDPRAgreementTextDecrypt);
  }
  getAgreementLabelsText(contentData) {
    let labelSMSAgreementTextCrypt =
      typeof contentData.sms_text !== undefined ? contentData.sms_text : false;
    let labelGDPRAgreementTextCrypt =
      typeof contentData.sms_text2 !== undefined
        ? contentData.sms_text2
        : false;
    let labelSMSAgreementTextDefault =
      "Receive SMS Text Updates - <span>optional</span>";
    let labelGDPRAgreementText = "I Accept To Receive Additional Info";
    let labelSMSAgreementTextDecrypt;
    let labelGDPRAgreementTextDecrypt;
    if (labelSMSAgreementTextCrypt) {
      labelSMSAgreementTextDecrypt = b64decode(labelSMSAgreementTextCrypt);
    }
    if (labelGDPRAgreementTextCrypt) {
      labelGDPRAgreementTextDecrypt = b64decode(labelGDPRAgreementTextCrypt);
    }
    if (
      !labelSMSAgreementTextDecrypt ||
      labelSMSAgreementTextDecrypt === "" ||
      labelSMSAgreementTextDecrypt === "undefined"
    ) {
      labelSMSAgreementTextDecrypt = labelSMSAgreementTextDefault;
    }
    if (
      !labelGDPRAgreementTextDecrypt ||
      labelGDPRAgreementTextDecrypt === "" ||
      labelGDPRAgreementTextDecrypt === "undefined"
    ) {
      labelGDPRAgreementTextDecrypt = labelGDPRAgreementText;
    }
    return {
      labelSMSAgreementTextDecrypt: labelSMSAgreementTextDecrypt,
      labelGDPRAgreementTextDecrypt: labelGDPRAgreementTextDecrypt,
    };
  }
}
class Forms_PublicPage_Layout_Design extends Forms_PublicPage_Base {
  constructor(entityClass) {
    super(entityClass);
    this.domHolderSelector = null;
    this.formDesignData = this.formSettings.optin_type.design;
    this.enableLayouts = parseInt(this.formSettings.optin_type.showLabels);
    if (isNaN(this.enableLayouts)) {
      this.enableLayouts = 0;
    }
    if (
      this.formType === "inline" &&
      typeof this.formDomResource.data("showformlabel") !== "undefined"
    ) {
      this.enableLayouts =
        this.formDomResource.attr("data-showformlabel") == "true" ? 1 : 0;
    }
  }
  execute() {
    this.prepare();
    this.apply();
    this.applyIcons();
    this.applyLabels();
    this.applyFieldsSize();
    this.applyInputColor();
  }
  prepare() {
    this.domHolderSelector =
      this.formType === "inline"
        ? this.formDomResource
        : $("#popup-form-modal");
  }
  apply() {
    const _this = this;
    if (this.formType === "inline") {
    } else {
      setTimeout(function () {
        _this.domHolderSelector
          .find(".modal-content")
          .css("background", _this.formDesignData.form_background_color);
        _this.domHolderSelector
          .find("input.form-control,select.form-control")
          .css("border-color", _this.formDesignData.field_stroke.color);
        _this.domHolderSelector
          .find("input.form-control,select.form-control")
          .css("borderWidth", _this.formDesignData.field_stroke.size + "px");
        _this.domHolderSelector
          .find(".buttonSubmitPopup button")
          .css("border-color", _this.formDesignData.button_stroke.color);
        _this.domHolderSelector
          .find(".buttonSubmitPopup button")
          .css("borderWidth", _this.formDesignData.button_stroke.size + "px");
        _this.domHolderSelector
          .find(".buttonSubmitPopup button")
          .css("background", _this.formDesignData.button_color);
        _this.domHolderSelector
          .find(".buttonSubmitPopup button")
          .css("border-style", "solid");
        if (_this.formDesignData.button_box_shadow_color != undefined) {
          _this.domHolderSelector
            .find(".buttonSubmitPopup button")
            .css("box-shadow", _this.formDesignData.button_box_shadow_color);
        }
      }, 300);
    }
  }
  applyIcons() {
    let field_icons = true;
    if (this.formType === "modal") {
      field_icons = parseInt(this.formDesignData.field_icons) === 1;
    } else if (this.formType === "inline") {
      if (
        typeof this.domHolderSelector.attr("data-fieldicons") !== "undefined"
      ) {
        field_icons = this.domHolderSelector.data("fieldicons");
      } else {
        field_icons = true;
      }
    }
    if (field_icons) {
      this.domHolderSelector
        .find(
          'input[type="text"], input[type="phone"], input[type="email"], input[type="url"], input.form-control, textarea, select'
        )
        .each(function () {
          $(this).style("padding-left", "35px", "important");
        });
      this.domHolderSelector.find(".inner-addon i.fa").show();
    } else {
      this.domHolderSelector.find("textarea").each(function () {
        $(this).style("padding-left", "12px", "important");
      });
      if (this.formType === "modal") {
        this.domHolderSelector
          .find(
            'input[type="text"], input[type="phone"], input[type="email"], input[type="url"], textarea, select'
          )
          .each(function () {
            $(this).style("padding-left", "12px", "important");
          });
      }
      this.domHolderSelector.find(".inner-addon i.fa").hide();
    }
  }
  applyLabels() {
    let labelColor = false;
    let labelSize = false;
    if (this.enableLayouts === 0) {
      this.domHolderSelector.find(".spLabelControl").hide();
    } else {
      this.domHolderSelector.find(".spLabelControl").show();
    }
    if (
      this.formType === "modal" &&
      typeof this.formDesignData.label_color !== "undefined"
    ) {
      labelColor = this.formDesignData.label_color;
    } else if (
      this.formType === "inline" &&
      typeof this.domHolderSelector.attr("data-labelcolor") !== "undefined"
    ) {
      labelColor = this.domHolderSelector.attr("data-labelcolor");
    }
    if (
      this.formType === "modal" &&
      typeof this.formDesignData.label_size !== "undefined"
    ) {
      labelSize = this.formDesignData.label_size;
    } else if (
      this.formType === "inline" &&
      typeof this.domHolderSelector.attr("data-labelfontsize") !== "undefined"
    ) {
      labelSize = this.domHolderSelector.attr("data-labelcolor");
    }
    if (labelColor) {
      this.domHolderSelector.find(".spLabelControl").css("color", labelColor);
    }
    if (labelSize) {
      this.domHolderSelector
        .find(".spLabelControl")
        .css("font-size", labelSize + "px");
    }
  }
  applyInputColor() {
    let _this = this;
    if (this.formType !== "modal") {
      return;
    }
    if (typeof this.formDesignData.input_color !== "undefined") {
      $(document).on(
        "click",
        "#popup-form-modal .checkbox_item input, #popup-form-modal .radioButton_item input, #popup-form-modal .sms-checkbox-wrapper input",
        function () {
          if (typeof _this.formDesignData.input_color !== "undefined") {
            if ($(this).attr("type") === "radio") {
              $(this)
                .parent()
                .parent()
                .parent()
                .find(".rb_checkmark")
                .css("background-color", "rgb(255,255,255)");
            }
            if ($(this).is(":checked")) {
              $(this)
                .parent()
                .find(".cc_checkmark")
                .css("background-color", _this.formDesignData.input_color);
              $(this)
                .parent()
                .find(".rb_checkmark")
                .css("background-color", _this.formDesignData.input_color);
            } else {
              $(this)
                .parent()
                .find(".cc_checkmark")
                .css("background-color", "rgb(255,255,255)");
            }
          }
        }
      );
      setTimeout(function () {
        if (typeof _this.formDesignData.control_text_color !== "undefined") {
          $("#popup-form-modal .custom_styled_choice").css(
            "font-size",
            _this.formDesignData.control_text_size + "px"
          );
          $("#popup-form-modal .custom_styled_choice").css(
            "color",
            _this.formDesignData.control_text_color
          );
        }
      }, 400);
    }
  }
  applyFieldsSize() {
    let fieldSize =
      typeof this.formDesignData.field_size !== "undefined" &&
      this.formDesignData.field_size !== ""
        ? this.formDesignData.field_size
        : "small";
    if (this.formType === "modal") {
      $("#popup-form-modal .optinForm").addClass(fieldSize);
    }
  }
}
class Forms_PublicPage_Fields extends Forms_PublicPage_Base {
  constructor(entityClass) {
    super(entityClass);
    this.fieldNamesClass = null;
    this.fieldEmailClass = null;
    this.fieldPhoneClass = null;
    this.fieldCaptchaClass = null;
    this.fieldGDPRClass = null;
    this.customFieldsClass = null;
    this.init();
    this.setFieldsProperties();
  }
  init() {
    this.fieldNamesClass = new Forms_PublicPage_Fields_Name(this.entityClass);
    this.fieldEmailClass = new Forms_PublicPage_Fields_Email(this.entityClass);
    this.fieldPhoneClass = new Forms_PublicPage_Fields_Phone(this.entityClass);
    this.fieldCaptchaClass = new Forms_PublicPage_Fields_Captcha(
      this.entityClass
    );
    this.fieldGDPRClass = new Forms_PublicPage_Fields_GDPR(this.entityClass);
    if (this.formType === "modal") {
      this.fieldGDPRClass.setData();
    }
  }
  setFieldsProperties() {
    this.domHolderSelector
      .find("input.form-control, select.form-control, textarea.form-control")
      .each(function (fieldIndex, field) {
        let fieldResource = $(field);
        let currentFieldName = fieldResource.attr("name");
        let randomNumber = Math.floor(Math.random() * 1000 + 1);
        let fieldNewName = `field_${randomNumber}_${fieldIndex}`;
        if (typeof currentFieldName === "undefined") {
          fieldResource.attr("name", fieldNewName);
        }
      });
    this.domHolderSelector
      .find(".form-group.checkBoxField, .form-group.radioButtonField")
      .each(function (fieldIndex, filedHolder) {
        let checkBoxHolderResource = $(filedHolder);
        let randomNumber = Math.floor(Math.random() * 1000 + 1);
        let fieldNewName = `field_${randomNumber}_${fieldIndex}`;
        let isRequired =
          checkBoxHolderResource.find("span.required:visible").length > 0;
        checkBoxHolderResource
          .find("input")
          .attr("name", fieldNewName)
          .attr("required", isRequired ? "required" : false);
      });
    this.domHolderSelector
      .find(".form-group .inner-addon.datePickerTextField input.form-control")
      .each(function (fieldIndex, filedHolder) {
        $(filedHolder)
          .datepicker({ format: "mm/dd/yyyy", autoclose: true })
          .on("changeDate", function (ev) {
            $(this).datepicker("hide");
          });
      });
  }
  setFieldsAddons() {}
  addCustomFields() {
    this.customFieldsClass = new Forms_PublicPage_CustomFields(
      this.entityClass
    );
  }
  syncCustomFieldsChange() {
    this.domHolderSelector
      .find(".inner-addon.left-addon.custom-field")
      .each(function (customFieldsInViewIndex, customFieldsInView) {
        let fieldId = $(customFieldsInView).data("id");
        let fieldExist = false;
        $.each(Public_PB_Forms.CustomFields.list, function (c, customField) {
          let customFieldType = parseInt(customField.type);
          if (fieldId == customField.id) {
            fieldExist = true;
            $(customFieldsInView)
              .find("input.form-control, textarea.form-control")
              .attr("placeholder", customField.placeholder);
            if (customFieldType == CUSTOMFIELD_DropDown) {
              let dopDownOptionsResource = $.parseJSON(customField.options)[
                "dropDown"
              ];
              let dopDownOptions =
                typeof dopDownOptionsResource === "string"
                  ? dopDownOptionsResource.split(/\n/)
                  : dopDownOptionsResource;
              $(customFieldsInView).find("select").find("option").remove();
              $(customFieldsInView)
                .find("select")
                .append(
                  '<option value="">' + customField.placeholder + "</option>"
                );
              for (let o = 0; o < dopDownOptions.length; o++) {
                let option = dopDownOptions[o];
                if (option != "") {
                  $(customFieldsInView)
                    .find("select")
                    .append(
                      '<option value="' + option + '">' + option + "</option>"
                    );
                }
              }
            }
            if (customField.type == 3) {
              let datePlaceholder = $.parseJSON(customField.placeholder_date);
              $(customFieldsInView)
                .find("label")
                .each(function (i, domElement) {
                  if (i == 0) {
                    $(domElement).html(
                      '<i class="fa fa-calendar"></i> ' +
                        datePlaceholder.month +
                        ""
                    );
                  } else {
                    $(domElement).html(
                      '<i class="fa fa-calendar"></i> ' +
                        datePlaceholder.day +
                        ""
                    );
                  }
                });
            }
          }
        });
        if (!fieldExist) {
          $(customFieldsInView).remove();
        }
      });
  }
}
class Forms_PublicPage_Fields_Core extends Forms_PublicPage_Base {
  constructor(entityClass) {
    super(entityClass);
  }
  setVisibleField(fieldDOMResource, isVisible) {
    if (isVisible) {
      fieldDOMResource.show();
    } else {
      fieldDOMResource.hide();
    }
  }
  setRequiredField(fieldDOMResource, isRequired) {
    let fieldSelector = fieldDOMResource.find(
      "input.form-control, select.form-control, textarea.form-control"
    );
    let fieldHolderResource = fieldDOMResource.find("div.inner-addon");
    fieldDOMResource.find("span.required").remove();
    if (isRequired) {
      fieldSelector.attr("required", "required");
      if (
        fieldHolderResource.hasClass("checkBoxField") ||
        fieldHolderResource.hasClass("radioButtonField")
      ) {
        fieldHolderResource
          .parent()
          .find(".spLabelControl")
          .append('<span class="required">*</span>');
      } else {
        fieldHolderResource.append('<span class="required">*</span>');
      }
    } else {
      fieldSelector.attr("required", false);
    }
  }
}
class Forms_PublicPage_Fields_Name extends Forms_PublicPage_Fields_Core {
  constructor(entityClass) {
    super(entityClass);
    this.data = {
      first: { visible: 0, required: 0 },
      last: { visible: 0, required: 0 },
      placeholder: "Enter Your Full Name",
    };
    this.getData();
    this.setData();
  }
  getData() {
    let classReference = this;
    $.each(this.formFields, function (i, field) {
      if (field.name === "first_name") {
        classReference.data.first.visible = parseInt(field.visible);
        classReference.data.first.required = parseInt(field.required);
        classReference.data.placeholder = field.placeholder;
      }
      if (field.name === "last_name") {
        classReference.data.last.visible = parseInt(field.visible);
        classReference.data.last.required = parseInt(field.required);
        classReference.data.placeholder = field.placeholder;
      }
    });
  }
  setData() {
    let fieldNameDOMResource = $(this.domHolderSelector).find(
      ".spots-field-name"
    );
    let isVisible =
      this.data.first.visible === 1 || this.data.last.visible === 1;
    let isFullName =
      this.data.first.visible === 1 && this.data.last.visible === 1;
    let isRequired =
      isVisible &&
      (this.data.first.required === 1 || this.data.last.required === 1);
    this.setVisibleField(fieldNameDOMResource, isVisible);
    this.setRequiredField(fieldNameDOMResource, isRequired);
    fieldNameDOMResource
      .find("input.form-control")
      .attr("placeholder", this.data.placeholder);
    if (isFullName) {
      fieldNameDOMResource.find("input.form-control").addClass("fullname");
    } else {
      fieldNameDOMResource.find("input.form-control").removeClass("fullname");
    }
  }
}
class Forms_PublicPage_Fields_Email extends Forms_PublicPage_Fields_Core {
  constructor(entityClass) {
    super(entityClass);
    this.data = { visible: 0, required: 0, placeholder: "Enter Your Email" };
    this.getData();
    this.setData();
  }
  getData() {
    let classReference = this;
    $.each(this.formFields, function (i, field) {
      if (field.name === "email") {
        classReference.data.visible = parseInt(field.visible);
        classReference.data.required = parseInt(field.required);
        classReference.data.placeholder = field.placeholder;
      }
    });
  }
  setData() {
    let fieldEmailDOMResource = $(this.domHolderSelector).find(
      ".spots-field-email"
    );
    let isVisible = this.data.visible === 1;
    let isRequired = isVisible && this.data.required;
    this.setVisibleField(fieldEmailDOMResource, isVisible);
    this.setRequiredField(fieldEmailDOMResource, isRequired);
    fieldEmailDOMResource
      .find("input.form-control")
      .attr("placeholder", this.data.placeholder);
  }
}
class Forms_PublicPage_Fields_Phone extends Forms_PublicPage_Fields_Core {
  constructor(entityClass) {
    super(entityClass);
    this.data = {
      visible: 0,
      required: 0,
      placeholder: "Enter Your Mobile Phone",
      smsPermissionVisible: 0,
    };
    let _this = this;
    this.getData();
    this.setData();
    setTimeout(function () {
      _this.setMask();
    }, 500);
  }
  getData() {
    let classReference = this;
    $.each(this.formFields, function (i, field) {
      if (field.name === "mobile_phone") {
        classReference.data.visible = parseInt(field.visible);
        classReference.data.required = parseInt(field.required);
        classReference.data.placeholder = field.placeholder;
      }
    });
  }
  setData() {
    let fieldPhoneDOMResource = $(this.domHolderSelector).find(
      ".spots-phone-number"
    );
    let isVisible = this.data.visible === 1;
    let isRequired = isVisible && this.data.required;
    this.setVisibleField(fieldPhoneDOMResource, isVisible);
    this.setRequiredField(fieldPhoneDOMResource, isRequired);
    if (isVisible) {
      fieldPhoneDOMResource.find(".spots-sms-checkboxwrapper").show();
    } else {
      fieldPhoneDOMResource.find(".spots-sms-checkboxwrapper").hide();
    }
    fieldPhoneDOMResource
      .find("input.form-control")
      .attr("placeholder", this.data.placeholder);
  }
  setMask() {
    let fieldPhoneDOMResource = $(this.domHolderSelector).find(
      ".spots-phone-number, .phoneTextField.custom-field"
    );
    fieldPhoneDOMResource.each(function (i, fieldPhoneDOMResourceElement) {
      let inputPhoneDOMResource = $(fieldPhoneDOMResourceElement).find(
        ".intl-tel-input input"
      );
      let maskResource = inputPhoneDOMResource[0];
      inputPhoneDOMResource.closest(".flag-dropdown").remove();
      inputPhoneDOMResource.attr(
        "data-placeholder",
        $(inputPhoneDOMResource).attr("placeholder")
      );
      inputPhoneDOMResource.removeAttr("placeholder");
      setTimeout(function () {
        window.intlTelInput(maskResource, {
          utilsScript:
            "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/8.4.6/js/utils.js",
          formatOnDisplay: true,
        });
        maskResource.addEventListener("countrychange", function () {
          let maskText = $(inputPhoneDOMResource[0])
            .attr("placeholder")
            .replace(/[0-9]/g, "9");
          $(inputPhoneDOMResource[0]).mask(maskText);
        });
        $(inputPhoneDOMResource[0]).mask("(999) 999-9999");
      }, 500);
      $(fieldPhoneDOMResourceElement)
        .find(".inner-addon.left-addon.spots-sms-checkboxwrapper span.required")
        .remove();
      $(fieldPhoneDOMResourceElement)
        .find(".inner-addon.left-addon.spots-sms-checkboxwrapper input")
        .attr("required", false);
    });
  }
}
class Forms_PublicPage_Fields_Captcha extends Forms_PublicPage_Fields_Core {
  constructor(entityClass) {
    super(entityClass);
    this.data = { visible: 0 };
    this.getData();
    this.setData();
  }
  getData() {
    let classReference = this;
    $.each(this.formFields, function (i, field) {
      if (field.name === "captcha") {
        classReference.data.visible = parseInt(field.visible);
      }
    });
  }
  setData() {
    let fieldPhoneDOMResource = $(this.domHolderSelector).find(
      ".inner-addon.left-addon.captcha"
    );
    let isVisible = this.data.visible === 1;
    if (isVisible) {
      fieldPhoneDOMResource.show();
    } else {
      fieldPhoneDOMResource.hide();
    }
  }
}
class Forms_PublicPage_Fields_GDPR extends Forms_PublicPage_Fields_Core {
  constructor(entityClass) {
    super(entityClass);
    this.data = { visible: 0, sms_permission: 0, gdpr_optin_approval: 0 };
    this.resetUI();
    this.getData();
  }
  getData() {
    let classReference = this;
    $.each(this.formFields, function (i, field) {
      if (field.name === "gdpr_optin_approval") {
        classReference.data = {
          visible: parseInt(field.visible),
          sms_permission: parseInt(field.additional.sms_permission),
          gdpr_optin_approval: parseInt(field.additional.gdpr_optin_approval),
        };
        if (isNaN(classReference.data.sms_permission)) {
          classReference.data.sms_permission = 0;
        }
        if (isNaN(classReference.data.gdpr_optin_approval)) {
          classReference.data.gdpr_optin_approval = 1;
        }
      }
    });
  }
  resetUI() {
    let fieldSMSResource = $(this.domHolderSelector).find(
      ".spots-sms-checkboxwrapper"
    );
    let fieldGDPRDOMResource = $(this.domHolderSelector).find(".gdprAgreement");
    fieldSMSResource.hide();
    fieldGDPRDOMResource.hide();
  }
  setData() {
    let fieldSMSResource = $(this.domHolderSelector).find(
      ".spots-sms-checkboxwrapper"
    );
    let fieldGDPRDOMResource = $(this.domHolderSelector).find(".gdprAgreement");
    if (this.data.visible === 0) {
      return;
    }
    if (this.data.sms_permission === 1) {
      fieldSMSResource.show();
      return;
    }
    if (this.data.gdpr_optin_approval === 2) {
      fieldGDPRDOMResource.show();
      return;
    }
    if (
      this.data.gdpr_optin_approval === 1 &&
      FormPublicPageClass.gdprIsInEurope
    ) {
      fieldGDPRDOMResource.show();
    }
  }
}
class Forms_PublicPage_CustomFields extends Forms_PublicPage_Fields_Core {
  constructor(entityClass) {
    super(entityClass);
    let classReference = this;
    let customFields =
      typeof this.formSettings.optin_type.customFields !== "undefined"
        ? this.formSettings.optin_type.customFields
        : [];
    $(
      "#popup-form-modal .modal-body .spots-fields-wrapper .spots-for-custom-field"
    ).html("");
    $.each(customFields, function (i, customField) {
      let fieldId = customField.name;
      let selectedType = 0;
      let htmlForPreview;
      let fieldExist = false;
      let isRequired = parseInt(customField.required) === 1;
      $.each(Public_PB_Forms.CustomFields.list, function (
        c,
        customFieldOriginal
      ) {
        if (fieldId == customFieldOriginal.id) {
          fieldExist = true;
          customField.additional = customFieldOriginal;
        }
      });
      if (!fieldExist) {
        return;
      }
      selectedType = parseInt(customField.additional.type);
      Public_PB_Forms.display.Builder.fieldDetails = customField.additional;
      switch (selectedType) {
        case CUSTOMFIELD_AlphaNumeric:
          htmlForPreview = Public_PB_Forms.display.Builder.alphaNumericPreview();
          break;
        case CUSTOMFIELD_DropDown:
          htmlForPreview = Public_PB_Forms.display.Builder.dropDownPreview();
          break;
        case CUSTOMFIELD_Date:
          htmlForPreview = Public_PB_Forms.display.Builder.datePreview();
          break;
        case CUSTOMFIELD_DatePicker:
          htmlForPreview = Public_PB_Forms.display.Builder.datePickerPreview();
          break;
        case CUSTOMFIELD_Numeric:
          htmlForPreview = Public_PB_Forms.display.Builder.numberPreview();
          break;
        case CUSTOMFIELD_Paragraph:
          htmlForPreview = Public_PB_Forms.display.Builder.textareaPreview();
          break;
        case CUSTOMFIELD_URL:
          htmlForPreview = Public_PB_Forms.display.Builder.urlPreview();
          break;
        case CUSTOMFIELD_Email:
          htmlForPreview = Public_PB_Forms.display.Builder.emailPreview();
          break;
        case CUSTOMFIELD_Phone:
          htmlForPreview = Public_PB_Forms.display.Builder.phonePreview();
          break;
        case CUSTOMFIELD_CheckBoxes:
          htmlForPreview = Public_PB_Forms.display.Builder.checkBoxesPreview();
          break;
        case CUSTOMFIELD_Radio:
          htmlForPreview = Public_PB_Forms.display.Builder.radioButtonsPreview();
          break;
      }
      $(
        "#popup-form-modal .modal-body .spots-fields-wrapper .spots-for-custom-field"
      ).append(htmlForPreview);
      classReference.setRequiredField(
        $(
          "#popup-form-modal .modal-body .spots-fields-wrapper .spots-for-custom-field .form-group"
        ).last(),
        isRequired
      );
    });
    setTimeout(function () {
      classReference.entityClass.FieldsClass.setFieldsProperties();
      classReference.entityClass.FieldsClass.setFieldsAddons();
    }, 1000);
  }
}
class Forms_PublicPage_Events extends Forms_PublicPage_Base {
  constructor(entityClass) {
    super(entityClass);
    this.formActionType = "";
    this.EventActionClass = null;
    this.ContactClass = null;
    this.formActionType = this.formSettings.action_type;
    if (typeof this.formActionType === "undefined") {
      console.log(
        "ERROR while exec BTN action type\n",
        "---------",
        this.formSettings,
        "---------"
      );
      return;
    }
    // alert("Forms_PublicPage_Events CONS");
    if (this.formType === "modal") {
      this.initModalFormEvents();
      // alert("Forms_PublicPage_Events initModalFormEvents CALL");
    } else {
      this.initInlineFormEvents();
    }
  }
  initModalFormEvents() {
    // alert("Forms_PublicPage_Events initModalFormEvents INSIDE");
    let classReference = this;
    let modalButtonControlExec = [
      "div.button.submitBtn",
      "div.button.btnControls",
      "button.btnControls",
      "div.btnElement div.btnControls",
      "div.elementWrapper div.btnControls",
    ];
    this.formDomResource.find(modalButtonControlExec.join(", ")).bind("touchstart ", function () {
      // alert("touchend")
      this.click();
    });

    this.formDomResource.find(modalButtonControlExec.join(", ")).bind("click  ", function () {
      // alert("clicked");
        classReference.EventActionClass = new Forms_PublicPage_Events_Modal_Actions(
          classReference.entityClass
        );
        classReference.EventActionClass.exec(classReference.formActionType);
        FormPublicPageClass.modalFormInvoker = classReference;
      });
  }
  initInlineFormEvents() {
    let classReference = this;
    let inlineButtonControlExec = [
      "div.button.submitBtn",
      "button.submitBtn",
      "div.submitBtn",
    ];
    if ($(this.formDomResource).hasClass("signinFormElement")) {
      return;
    }
    classReference.EventActionClass = new Forms_PublicPage_Events_Inline_Actions(
      classReference.entityClass
    );
    $(this.formDomResource)
      .find(inlineButtonControlExec.join(", "))
      .bind("click", function () {
        classReference.EventActionClass.btnSubmitElementResource = $(this);
        if (!classReference.EventActionClass.validateForm()) {
          return;
        }
        classReference.EventActionClass.setSubmitButtonStatus(true);
        classReference._countClickButtonEvent();
        classReference.ContactClass = new Forms_PublicPage_Contacts(
          classReference.entityClass
        );
        classReference.ContactClass.save();
      });
  }
  _countClickButtonEvent() {
    let formElementId = this.formSettingsId;
    $.ajax({
      type: "POST",
      data: { element_id: formElementId },
      url: siteUrl + "funnels/show/add_click_to_buttons_forms",
      success: function () {},
    });
  }
}
function _countClickButtonEvent(formElementId) {
  $.ajax({
    type: "POST",
    data: { element_id: formElementId },
    url: siteUrl + "funnels/show/add_click_to_buttons_forms",
    success: function () {},
  });
}
class Forms_PublicPage_Events_Base extends Forms_PublicPage_Base {
  isMobileDevice = false;
  constructor(entityClass) {
    super(entityClass);
    this.formDOMFormResource = "";
    this.btnSubmitElementResource = "";
    this.formDOMFormResource = $(entityClass.formDomResource).find("form");
    this.isMobile();
  }
  isMobile() {
    if (
      /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
        navigator.userAgent
      )
    ) {
      this.isMobileDevice = true;
    }
  }
  validateForm() {
    let formDisabled =
      this.btnSubmitElementResource.attr("disabled") === "disabled";
    let validFieldForm;
    this.formDOMFormResource.validate();
    validFieldForm = this.formDOMFormResource.valid();
    return !(formDisabled || !validFieldForm);
  }
  setSubmitButtonStatus(disabled) {
    let btnTextLastElement = this.btnSubmitElementResource;
    if (disabled) {
      this.btnSubmitElementResource
        .attr("data-text", btnTextLastElement.html())
        .attr("disabled", "disabled");
      btnTextLastElement.html("processing...");
    } else {
      this.btnSubmitElementResource.attr("disabled", false);
      btnTextLastElement.html(this.btnSubmitElementResource.attr("data-text"));
    }
  }
  resetForm() {
    if (this.formType === "modal") {
      $("#popup-form-modal").closest("form").find("input, textarea").val("");
      $("#popup-form-modal").modal("hide");
    } else {
      $(this.entityClass.formDomResource).find("input, textarea").val("");
      $(this.entityClass.formDomResource)
        .find("select")
        .each(function (i, element) {
          $(element).prop("selectedIndex", 0);
        });
      $(this.entityClass.formDomResource)
        .find('input[type="radio"], input[type="checkbox"]')
        .each(function (i, element) {
          $(element).prop("checked", false);
          $(element).parent().find(".cc_checkmark").removeAttr("style");
          $(element).parent().find(".rb_checkmark").removeAttr("style");
        });
    }
  }
  toPhone() {
    let toPhoneDetails = this.formSettings.click_to_call;
    if (
      typeof toPhoneDetails === "undefined" ||
      typeof toPhoneDetails.value === "undefined"
    ) {
      console.log(
        "ERROR while exec BTN action type: ClickToCall\n",
        "---------",
        toPhoneDetails,
        "---------"
      );
      return;
    }
    window.location.href = "tel://" + toPhoneDetails.value;
  }
  toEmail() {
    let toEmailDetails = this.formSettings.click_to_email;
    if (
      typeof toEmailDetails === "undefined" ||
      typeof toEmailDetails.value === "undefined"
    ) {
      console.log(
        "ERROR while exec BTN action type: ClickToEmail\n",
        "---------",
        toEmailDetails,
        "---------"
      );
      return;
    }
    window.location.href = "mailto:" + toEmailDetails.value;
  }
  collectFields() {
    let formResource;
    let formFields = [];
    let firstNameFieldEnable = false;
    let lastNameFieldEnable = false;
    let hasGtwGrIntegration = false;
    $.each(this.formSettings.optin_type.fields, function (i, field) {
      if (field.name === "first_name" && parseInt(field.visible) === 1) {
        firstNameFieldEnable = true;
      }
      if (field.name === "last_name" && parseInt(field.visible) === 1) {
        lastNameFieldEnable = true;
      }
    });
    if (this.formType === "modal") {
      formResource = $("#popup-form-modal").find(
        ".spots-fields-wrapper div.inner-addon"
      );
    } else {
      formResource = $(this.entityClass.formDomResource)
        .closest("div.elements-control")
        .find(".spots-fields-wrapper div.inner-addon");
    }
    formResource.each(function (i, _field) {
      let $this = $(this);
      let _requiredInfo = $this.find("input").attr("required");
      let fieldName = "";
      let required = false;
      let fieldValue = "";
      let fieldArrayValues = [];
      let customFieldId = 0;
      if (!$this.is(":visible")) {
        return;
      }
      if (
        $this.hasClass("spots-field-name2") ||
        $this.hasClass("spots-field-name")
      ) {
        if (firstNameFieldEnable === true && lastNameFieldEnable === true) {
          fieldName = "full_name";
        } else if (
          firstNameFieldEnable === true &&
          lastNameFieldEnable === false
        ) {
          fieldName = "first_name";
        } else if (
          firstNameFieldEnable === false &&
          lastNameFieldEnable === true
        ) {
          fieldName = "last_name";
        } else {
          fieldName = "full_name";
        }
      } else if (
        $this.hasClass("spots-field-email2") ||
        $this.hasClass("spots-field-email")
      ) {
        fieldName = "email";
      } else if (
        $this.hasClass("sms-spots-check2") ||
        $this.hasClass("sms-spots-check")
      ) {
        fieldName = "phone";
      } else if (
        $this.hasClass("spots-phone-number2") ||
        $this.hasClass("spots-phone-number")
      ) {
        fieldName = "phone";
      } else if ($this.hasClass("spots-sms-checkboxwrapper")) {
        fieldName = "sms";
      } else if ($this.hasClass("textField")) {
        fieldName = "sms";
      }
      if ($this.find("input").attr("type") === "checkbox") {
        fieldValue = $this.find("input").is(":checked") ? 1 : 0;
      } else {
        fieldValue = $this.find("input").val();
      }
      if ($this.hasClass("custom-field")) {
        $.each(Public_PB_Forms.CustomFields.list, function (
          i,
          customFieldItem
        ) {
          let fieldType = parseInt(customFieldItem.type);
          if (customFieldItem.id == $this.data("id")) {
            customFieldId = customFieldItem.id;
            fieldName = "input_" + customFieldId;
            if (fieldType == CUSTOMFIELD_DropDown) {
              fieldValue = $this.find("select").val();
              _requiredInfo =
                typeof $this.find("select").attr("required") !== "undefined"
                  ? $this.find("select").attr("required")
                  : false;
            } else if (fieldType == CUSTOMFIELD_CheckBoxes) {
              $this
                .find('input[type="checkbox"]:checked')
                .each(function (i, inputItem) {
                  fieldArrayValues.push($(inputItem).val());
                });
              fieldValue = fieldArrayValues.join(", ");
              _requiredInfo =
                $this.parent().find("label .required").length == 0
                  ? false
                  : true;
            } else if (fieldType == CUSTOMFIELD_Radio) {
              fieldValue =
                typeof $this.find('input[type="radio"]:checked').val() !==
                "undefined"
                  ? $this.find('input[type="radio"]:checked').val()
                  : "";
              _requiredInfo =
                $this.parent().find("label .required").length == 0
                  ? false
                  : true;
            } else if (fieldType == CUSTOMFIELD_Date) {
              if (
                $this.find("select.monthSelectList option:selected").val() !=
                  "" &&
                $this.find("select.daySelectList").val() != ""
              ) {
                fieldValue =
                  $this.find("select.monthSelectList option:selected").text() +
                  " " +
                  $this.find("select.daySelectList").val();
              } else {
                fieldValue = "";
              }
              _requiredInfo = $this
                .find("select.monthSelectList")
                .attr("required");
            } else if (fieldType == CUSTOMFIELD_Paragraph) {
              fieldValue = $this.find("textarea").val();
              _requiredInfo =
                typeof $this.find("textarea").attr("required") !== "undefined"
                  ? $this.find("textarea").attr("required")
                  : false;
            }
          }
        });
      }
      if (typeof _requiredInfo !== undefined && _requiredInfo !== false) {
        required = true;
      }
      formFields.push({
        name: fieldName,
        required: required,
        value: fieldValue,
        customFieldId: customFieldId,
      });
    });
    return formFields;
  }
}
class Forms_PublicPage_Events_Inline_Actions extends Forms_PublicPage_Events_Base {
  constructor(entityClass) {
    super(entityClass);
    this.AFTER_OPTIN_EVENTS = {
      THANK_YOU_POPUP: "1",
      REDIRECT: "2",
      NextPage: "3",
      ClickToCall: "4",
      ClickToEmail: "5",
    };
  }
  execAfterContactAdded(responseData) {
    let formAfterOptinAction = this.formSettings.form_redirect_type;
    switch (formAfterOptinAction) {
      case this.AFTER_OPTIN_EVENTS.THANK_YOU_POPUP:
        this.showThankYouPopUp();
        break;
      case this.AFTER_OPTIN_EVENTS.REDIRECT:
        this.redirect();
        break;
      case this.AFTER_OPTIN_EVENTS.ClickToCall:
        this.toPhone();
        break;
      case this.AFTER_OPTIN_EVENTS.ClickToEmail:
        this.toEmail();
        break;
      case this.AFTER_OPTIN_EVENTS.NextPage:
        this.toNextPage();
        break;
      default:
        console.log(
          "ERROR while exec FORM action type with number:" +
            formAfterOptinAction
        );
    }
  }
  showThankYouPopUp() {
    let settings = this.formSettings.thank_you.popup_options;
    if (typeof settings === "undefined") {
      return;
    }
    $("#form-popup-thank-you").modal("show");
    $("#form-popup-thank-you .modal-content").css(
      "background-color",
      settings.background_color
    );
    $("#form-popup-thank-you button.ok-button").css(
      "background",
      settings.button_color
    );
    $("#form-popup-thank-you button.ok-button").css("box-shadow", "none");
    $("#form-popup-thank-you button.ok-button").html(
      b64decode(settings.button_text)
    );
    if (settings.button_visible == 0) {
      $("#form-popup-thank-you button.ok-button").hide();
    }
    $("#form-popup-thank-you .title").html(b64decode(settings.headline_text));
    if (settings.headline_visible == 0) {
      $("#form-popup-thank-you .title").hide();
    }
    $("#form-popup-thank-you .details").html(
      b64decode(settings.subeadline_text)
    );
    if (settings.subheadline_visible == 0) {
      $("#form-popup-thank-you .details").hide();
    }
    $("#form-popup-thank-you .icon-image").attr("src", settings.icon_url);
    if (settings.icon_visible == 0) {
      $("#form-popup-thank-you .icon-image").hide();
    }
    $("#form-popup-thank-you").on("hidden.bs.modal", function () {});
  }
  redirect() {
    let linkAddress = this.formSettings.form_redirect_custom_url;
    let linkTarget = "_blank";
    if (typeof linkAddress === "undefined" || linkAddress === "") {
      console.log(
        "ERROR while exec FORM action type: REDIRECT\n",
        "---------",
        this.formSettings,
        "---------"
      );
      return;
    }
    linkAddress = linkAddress.replace(/\&amp;/gi, "&");
    if (this.isMobileDevice) {
      linkTarget = "_self";
    }
    window.open(linkAddress, linkTarget);
  }
  toNextPage() {
    window.location.href =
      siteUrl + "show-page/" + this.formSettings.form_redirect_funnel_url;
  }
}
class Forms_PublicPage_Events_Modal_Actions extends Forms_PublicPage_Events_Base {
  constructor(entityClass) {
    super(entityClass);
    this.BTN_EVENTS = {
      REDIRECT: "1",
      ClickToEmail: "2",
      ClickToCall: "3",
      JumpToBlock: "4",
      NexTPage: "5",
    };
    this.AFTER_OPTIN_EVENTS = {
      REDIRECT: "1",
      ClickToEmail: "2",
      ClickToCall: "3",
      JumToBlock: "4",
      NexTPage: "5",
    };
    this.BTN_CLICK_COUNTER = ["1", "2", "3", "4", "5"];
  }
  exec(formActionType) {
    if ($.inArray(formActionType, this.BTN_CLICK_COUNTER) !== -1) {
      _countClickButtonEvent(this.formSettingsId);
    }
    switch (formActionType) {
      case this.BTN_EVENTS.REDIRECT:
        this.redirect();
        break;
      case this.BTN_EVENTS.ClickToEmail:
        this.toEmail();
        break;
      case this.BTN_EVENTS.ClickToCall:
        this.toPhone();
        break;
      case this.BTN_EVENTS.JumpToBlock:
        this.toPageBlock();
        break;
      case this.BTN_EVENTS.NexTPage:
        this.toNextPage();
        break;
      default:
        this.doOptin();
    }
  }
  execAfterContactAdded(responseData) {
    let formAfterOptinAction = this.formSettings.optin_action_type;
    switch (formAfterOptinAction) {
      case this.AFTER_OPTIN_EVENTS.REDIRECT:
        this.afterOptinRedirect();
        break;
      case this.AFTER_OPTIN_EVENTS.ClickToCall:
        this.toPhone();
        break;
      case this.AFTER_OPTIN_EVENTS.ClickToEmail:
        this.toEmail();
        break;
      case this.AFTER_OPTIN_EVENTS.JumToBlock:
        this.afterOptinJumToBlock();
        break;
      case this.AFTER_OPTIN_EVENTS.NexTPage:
        this.afterOptinNexTPage();
        break;
      default:
        this.afterOptinNexTPage();
    }
  }
  afterOptinRedirect() {
    let linkAddress = this.formSettings.redirect_type.url;
    let linkTarget = "_blank";
    if (typeof linkAddress === "undefined" || linkAddress === "") {
      console.log(
        "ERROR while exec BTN action type: REDIRECT\n",
        "---------",
        this.formSettings,
        "---------"
      );
      return;
    }
    linkAddress = linkAddress.replace(/\&amp;/gi, "&");
    if (this.isMobileDevice) {
      linkTarget = "_self";
    }
    window.open(linkAddress, linkTarget);
  }
  afterOptinJumToBlock() {
    let domBlock = this.formSettings.jump_to_block.value;
    $([document.documentElement, document.body]).animate(
      { scrollTop: $('section[data-id="' + domBlock + '"]').offset().top },
      500
    );
  }
  afterOptinNexTPage() {
    let nextPageUrl = this.formSettings.form_redirect_funnel_url;
    if (nextPageUrl !== "" && nextPageUrl !== "next-funnel") {
      window.location.href = siteUrl + "show-page/" + nextPageUrl;
    }
  }
  doOptin() {
    $("#popup-form-modal").modal("show");
    this.entityClass.setFormLayout();
    this.entityClass.setFormFields();
    this.entityClass.FieldsClass.addCustomFields();
    this.entityClass.FieldsClass.setFieldsAddons();
    this.entityClass.LayoutClass.formLayoutDesignClass.applyLabels();
    this.entityClass.LayoutClass.formLayoutDesignClass.applyIcons();
    $("#button-form").clearValidation();
  }
  redirect() {
    let redirectDetails = this.formSettings.redirect_type;
    let linkTarget = "_blank";
    let linkAddress = "";
    if (
      typeof redirectDetails === "undefined" ||
      typeof redirectDetails.url === "undefined"
    ) {
      console.log(
        "ERROR while exec BTN action type: REDIRECT\n",
        "---------",
        redirectDetails,
        "---------"
      );
      return;
    }
    if (
      typeof redirectDetails.target !== "undefined" &&
      parseInt(redirectDetails.target) === 1
    ) {
      linkTarget = "_self";
    }
    if (this.isMobileDevice) {
      linkTarget = "_self";
    }
    linkAddress = redirectDetails.url.replace(/\&amp;/gi, "&");
    window.open(linkAddress, linkTarget);
  }
  toPageBlock() {
    let toBlockDetails = this.formSettings.jump_to_block;
    if (
      typeof toBlockDetails === "undefined" ||
      typeof toBlockDetails.value === "undefined"
    ) {
      console.log(
        "ERROR while exec BTN action type: JumpToBlock\n",
        "---------",
        toBlockDetails,
        "---------"
      );
      return;
    }
    $([document.documentElement, document.body]).animate(
      {
        scrollTop: $('section[data-id="' + toBlockDetails.value + '"]').offset()
          .top,
      },
      500
    );
  }
  toNextPage() {
    let toNextPageDetails = this.formSettings.next_step;
    if (
      typeof toNextPageDetails === "undefined" ||
      typeof toNextPageDetails.value === "undefined"
    ) {
      console.log(
        "ERROR while exec BTN action type: NexTPage\n",
        "---------",
        toNextPageDetails,
        "---------"
      );
      return;
    }
    window.location.href = siteUrl + "show-page/" + toNextPageDetails.value;
  }
}
class Forms_PublicPage_Contacts extends Forms_PublicPage_Base {
  constructor(entityClass) {
    super(entityClass);
  }
  save() {
    let classReference = this;
    let formFields = this.entityClass.EventsClass.EventActionClass.collectFields();
    let ajaxData = {
      action_type: "optin",
      formSettingsId: this.formSettingsId,
      optin_occurred: this.formSettings.name,
      rawFields: formFields,
    };
    $.each(formFields, function (i, field) {
      ajaxData[field.name] = field.value;
    });
    if (!pageBuilderData.id) {
      if (typeof isPreview !== "undefined" && isPreview === "true") {
        showCoreModalMessage(
          "error",
          "In Preview mode contact will not be saved"
        );
        this.entityClass.EventsClass.EventActionClass.setSubmitButtonStatus(
          false
        );
        this.entityClass.EventsClass.EventActionClass.resetForm();
      }
      return false;
    }
    $.ajax({
      type: "POST",
      crossDomain: true,
      dataType: "json",
      url: siteUrl + "contacts/save/" + pageBuilderData.id + "/" + testMode,
      data: ajaxData,
      cache: false,
      async: false,
      success: function (responseData) {
        classReference.afterSave(responseData);
      },
    });
  }
  afterSave(responseData) {
    this.entityClass.EventsClass.EventActionClass.setSubmitButtonStatus(false);
    this.entityClass.EventsClass.EventActionClass.resetForm();
    if (responseData.status === "success") {
      this.entityClass.EventsClass.EventActionClass.execAfterContactAdded(
        responseData
      );
    } else {
      if (typeof responseData.message !== "undefined") {
        showCoreModalMessage("error", responseData.message);
      }
    }
  }
}
// /*! lazysizes - v4.1.5 */
// !(function (a, b) {
//   var c = b(a, a.document);
//   (a.lazySizes = c),
//     "object" == typeof module && module.exports && (module.exports = c);
// })(window, function (a, b) {
//   "use strict";
//   if (b.getElementsByClassName) {
//     var c,
//       d,
//       e = b.documentElement,
//       f = a.Date,
//       g = a.HTMLPictureElement,
//       h = "addEventListener",
//       i = "getAttribute",
//       j = a[h],
//       k = a.setTimeout,
//       l = a.requestAnimationFrame || k,
//       m = a.requestIdleCallback,
//       n = /^picture$/i,
//       o = ["load", "error", "lazyincluded", "_lazyloaded"],
//       p = {},
//       q = Array.prototype.forEach,
//       r = function (a, b) {
//         return (
//           p[b] || (p[b] = new RegExp("(\\s|^)" + b + "(\\s|$)")),
//           p[b].test(a[i]("class") || "") && p[b]
//         );
//       },
//       s = function (a, b) {
//         r(a, b) ||
//           a.setAttribute("class", (a[i]("class") || "").trim() + " " + b);
//       },
//       t = function (a, b) {
//         var c;
//         (c = r(a, b)) &&
//           a.setAttribute("class", (a[i]("class") || "").replace(c, " "));
//       },
//       u = function (a, b, c) {
//         var d = c ? h : "removeEventListener";
//         c && u(a, b),
//           o.forEach(function (c) {
//             a[d](c, b);
//           });
//       },
//       v = function (a, d, e, f, g) {
//         var h = b.createEvent("Event");
//         return (
//           e || (e = {}),
//           (e.instance = c),
//           h.initEvent(d, !f, !g),
//           (h.detail = e),
//           a.dispatchEvent(h),
//           h
//         );
//       },
//       w = function (b, c) {
//         var e;
//         !g && (e = a.picturefill || d.pf)
//           ? (c && c.src && !b[i]("srcset") && b.setAttribute("srcset", c.src),
//             e({ reevaluate: !0, elements: [b] }))
//           : c && c.src && (b.src = c.src);
//       },
//       x = function (a, b) {
//         return (getComputedStyle(a, null) || {})[b];
//       },
//       y = function (a, b, c) {
//         for (c = c || a.offsetWidth; c < d.minSize && b && !a._lazysizesWidth; )
//           (c = b.offsetWidth), (b = b.parentNode);
//         return c;
//       },
//       z = (function () {
//         var a,
//           c,
//           d = [],
//           e = [],
//           f = d,
//           g = function () {
//             var b = f;
//             for (f = d.length ? e : d, a = !0, c = !1; b.length; ) b.shift()();
//             a = !1;
//           },
//           h = function (d, e) {
//             a && !e
//               ? d.apply(this, arguments)
//               : (f.push(d), c || ((c = !0), (b.hidden ? k : l)(g)));
//           };
//         return (h._lsFlush = g), h;
//       })(),
//       A = function (a, b) {
//         return b
//           ? function () {
//               z(a);
//             }
//           : function () {
//               var b = this,
//                 c = arguments;
//               z(function () {
//                 a.apply(b, c);
//               });
//             };
//       },
//       B = function (a) {
//         var b,
//           c = 0,
//           e = d.throttleDelay,
//           g = d.ricTimeout,
//           h = function () {
//             (b = !1), (c = f.now()), a();
//           },
//           i =
//             m && g > 49
//               ? function () {
//                   m(h, { timeout: g }),
//                     g !== d.ricTimeout && (g = d.ricTimeout);
//                 }
//               : A(function () {
//                   k(h);
//                 }, !0);
//         return function (a) {
//           var d;
//           (a = !0 === a) && (g = 33),
//             b ||
//               ((b = !0),
//               (d = e - (f.now() - c)),
//               d < 0 && (d = 0),
//               a || d < 9 ? i() : k(i, d));
//         };
//       },
//       C = function (a) {
//         var b,
//           c,
//           d = 99,
//           e = function () {
//             (b = null), a();
//           },
//           g = function () {
//             var a = f.now() - c;
//             a < d ? k(g, d - a) : (m || e)(e);
//           };
//         return function () {
//           (c = f.now()), b || (b = k(g, d));
//         };
//       };
//     !(function () {
//       var b,
//         c = {
//           lazyClass: "lazyload-public",
//           loadedClass: "lazyloaded",
//           loadingClass: "lazyloading",
//           preloadClass: "lazypreload",
//           errorClass: "lazyerror",
//           autosizesClass: "lazyautosizes",
//           srcAttr: "data-src",
//           srcsetAttr: "data-srcset",
//           sizesAttr: "data-sizes",
//           minSize: 40,
//           customMedia: {},
//           init: !0,
//           expFactor: 1.5,
//           hFac: 0.8,
//           loadMode: 2,
//           loadHidden: !0,
//           ricTimeout: 0,
//           throttleDelay: 125,
//         };
//       d = a.lazySizesConfig || a.lazysizesConfig || {};
//       for (b in c) b in d || (d[b] = c[b]);
//       (a.lazySizesConfig = d),
//         k(function () {
//           d.init && F();
//         });
//     })();
//     var D = (function () {
//         var g,
//           l,
//           m,
//           o,
//           p,
//           y,
//           D,
//           F,
//           G,
//           H,
//           I,
//           J = /^img$/i,
//           K = /^iframe$/i,
//           L = "onscroll" in a && !/(gle|ing)bot/.test(navigator.userAgent),
//           M = 0,
//           N = 0,
//           O = 0,
//           P = -1,
//           Q = function (a) {
//             O--,
//               a && a.target && u(a.target, Q),
//               (!a || O < 0 || !a.target) && (O = 0);
//           },
//           R = function (a, c) {
//             var d,
//               f = a,
//               g =
//                 "hidden" == x(b.body, "visibility") ||
//                 ("hidden" != x(a.parentNode, "visibility") &&
//                   "hidden" != x(a, "visibility"));
//             for (
//               F -= c, I += c, G -= c, H += c;
//               g && (f = f.offsetParent) && f != b.body && f != e;

//             )
//               (g = (x(f, "opacity") || 1) > 0) &&
//                 "visible" != x(f, "overflow") &&
//                 ((d = f.getBoundingClientRect()),
//                 (g =
//                   H > d.left &&
//                   G < d.right &&
//                   I > d.top - 1 &&
//                   F < d.bottom + 1));
//             return g;
//           },
//           S = function () {
//             var a,
//               f,
//               h,
//               j,
//               k,
//               m,
//               n,
//               p,
//               q,
//               r,
//               s,
//               t,
//               u = c.elements;
//             if ((o = d.loadMode) && O < 8 && (a = u.length)) {
//               for (
//                 f = 0,
//                   P++,
//                   r =
//                     !d.expand || d.expand < 1
//                       ? e.clientHeight > 500 && e.clientWidth > 500
//                         ? 500
//                         : 370
//                       : d.expand,
//                   s = r * d.expFactor,
//                   t = d.hFac,
//                   N < s && O < 1 && P > 2 && o > 2 && !b.hidden
//                     ? ((N = s), (P = 0))
//                     : (N = o > 1 && P > 1 && O < 6 ? r : M);
//                 f < a;
//                 f++
//               )
//                 if (u[f] && !u[f]._lazyRace)
//                   if (L)
//                     if (
//                       (((p = u[f][i]("data-expand")) && (m = 1 * p)) || (m = N),
//                       q !== m &&
//                         ((y = innerWidth + m * t),
//                         (D = innerHeight + m),
//                         (n = -1 * m),
//                         (q = m)),
//                       (h = u[f].getBoundingClientRect()),
//                       (I = h.bottom) >= n &&
//                         (F = h.top) <= D &&
//                         (H = h.right) >= n * t &&
//                         (G = h.left) <= y &&
//                         (I || H || G || F) &&
//                         (d.loadHidden || "hidden" != x(u[f], "visibility")) &&
//                         ((l && O < 3 && !p && (o < 3 || P < 4)) || R(u[f], m)))
//                     ) {
//                       if (($(u[f]), (k = !0), O > 9)) break;
//                     } else
//                       !k &&
//                         l &&
//                         !j &&
//                         O < 4 &&
//                         P < 4 &&
//                         o > 2 &&
//                         (g[0] || d.preloadAfterLoad) &&
//                         (g[0] ||
//                           (!p &&
//                             (I ||
//                               H ||
//                               G ||
//                               F ||
//                               "auto" != u[f][i](d.sizesAttr)))) &&
//                         (j = g[0] || u[f]);
//                   else $(u[f]);
//               j && !k && $(j);
//             }
//           },
//           T = B(S),
//           U = function (a) {
//             s(a.target, d.loadedClass),
//               t(a.target, d.loadingClass),
//               u(a.target, W),
//               v(a.target, "lazyloaded");
//           },
//           V = A(U),
//           W = function (a) {
//             V({ target: a.target });
//           },
//           X = function (a, b) {
//             try {
//               a.contentWindow.location.replace(b);
//             } catch (c) {
//               a.src = b;
//             }
//           },
//           Y = function (a) {
//             var b,
//               c = a[i](d.srcsetAttr);
//             (b = d.customMedia[a[i]("data-media") || a[i]("media")]) &&
//               a.setAttribute("media", b),
//               c && a.setAttribute("srcset", c);
//           },
//           Z = A(function (a, b, c, e, f) {
//             var g, h, j, l, o, p;
//             (o = v(a, "lazybeforeunveil", b)).defaultPrevented ||
//               (e && (c ? s(a, d.autosizesClass) : a.setAttribute("sizes", e)),
//               (h = a[i](d.srcsetAttr)),
//               (g = a[i](d.srcAttr)),
//               f && ((j = a.parentNode), (l = j && n.test(j.nodeName || ""))),
//               (p = b.firesLoad || ("src" in a && (h || g || l))),
//               (o = { target: a }),
//               p &&
//                 (u(a, Q, !0),
//                 clearTimeout(m),
//                 (m = k(Q, 2500)),
//                 s(a, d.loadingClass),
//                 u(a, W, !0)),
//               l && q.call(j.getElementsByTagName("source"), Y),
//               h
//                 ? a.setAttribute("srcset", h)
//                 : g && !l && (K.test(a.nodeName) ? X(a, g) : (a.src = g)),
//               f && (h || l) && w(a, { src: g })),
//               a._lazyRace && delete a._lazyRace,
//               t(a, d.lazyClass),
//               z(function () {
//                 (!p || (a.complete && a.naturalWidth > 1)) &&
//                   (p ? Q(o) : O--, U(o));
//               }, !0);
//           }),
//           $ = function (a) {
//             var b,
//               c = J.test(a.nodeName),
//               e = c && (a[i](d.sizesAttr) || a[i]("sizes")),
//               f = "auto" == e;
//             ((!f && l) ||
//               !c ||
//               (!a[i]("src") && !a.srcset) ||
//               a.complete ||
//               r(a, d.errorClass) ||
//               !r(a, d.lazyClass)) &&
//               ((b = v(a, "lazyunveilread").detail),
//               f && E.updateElem(a, !0, a.offsetWidth),
//               (a._lazyRace = !0),
//               O++,
//               Z(a, b, f, e, c));
//           },
//           _ = function () {
//             if (!l) {
//               if (f.now() - p < 999) return void k(_, 999);
//               var a = C(function () {
//                 (d.loadMode = 3), T();
//               });
//               (l = !0),
//                 (d.loadMode = 3),
//                 T(),
//                 j(
//                   "scroll",
//                   function () {
//                     3 == d.loadMode && (d.loadMode = 2), a();
//                   },
//                   !0
//                 );
//             }
//           };
//         return {
//           _: function () {
//             (p = f.now()),
//               (c.elements = b.getElementsByClassName(d.lazyClass)),
//               (g = b.getElementsByClassName(
//                 d.lazyClass + " " + d.preloadClass
//               )),
//               j("scroll", T, !0),
//               j("resize", T, !0),
//               a.MutationObserver
//                 ? new MutationObserver(T).observe(e, {
//                     childList: !0,
//                     subtree: !0,
//                     attributes: !0,
//                   })
//                 : (e[h]("DOMNodeInserted", T, !0),
//                   e[h]("DOMAttrModified", T, !0),
//                   setInterval(T, 999)),
//               j("hashchange", T, !0),
//               [
//                 "focus",
//                 "mouseover",
//                 "click",
//                 "load",
//                 "transitionend",
//                 "animationend",
//                 "webkitAnimationEnd",
//               ].forEach(function (a) {
//                 b[h](a, T, !0);
//               }),
//               /d$|^c/.test(b.readyState)
//                 ? _()
//                 : (j("load", _), b[h]("DOMContentLoaded", T), k(_, 2e4)),
//               c.elements.length ? (S(), z._lsFlush()) : T();
//           },
//           checkElems: T,
//           unveil: $,
//         };
//       })(),
//       E = (function () {
//         var a,
//           c = A(function (a, b, c, d) {
//             var e, f, g;
//             if (
//               ((a._lazysizesWidth = d),
//               (d += "px"),
//               a.setAttribute("sizes", d),
//               n.test(b.nodeName || ""))
//             )
//               for (
//                 e = b.getElementsByTagName("source"), f = 0, g = e.length;
//                 f < g;
//                 f++
//               )
//                 e[f].setAttribute("sizes", d);
//             c.detail.dataAttr || w(a, c.detail);
//           }),
//           e = function (a, b, d) {
//             var e,
//               f = a.parentNode;
//             f &&
//               ((d = y(a, f, d)),
//               (e = v(a, "lazybeforesizes", { width: d, dataAttr: !!b })),
//               e.defaultPrevented ||
//                 ((d = e.detail.width) &&
//                   d !== a._lazysizesWidth &&
//                   c(a, f, e, d)));
//           },
//           f = function () {
//             var b,
//               c = a.length;
//             if (c) for (b = 0; b < c; b++) e(a[b]);
//           },
//           g = C(f);
//         return {
//           _: function () {
//             (a = b.getElementsByClassName(d.autosizesClass)), j("resize", g);
//           },
//           checkElems: g,
//           updateElem: e,
//         };
//       })(),
//       F = function () {
//         F.i || ((F.i = !0), E._(), D._());
//       };
//     return (c = {
//       cfg: d,
//       autoSizer: E,
//       loader: D,
//       init: F,
//       uP: w,
//       aC: s,
//       rC: t,
//       hC: r,
//       fire: v,
//       gW: y,
//       rAF: z,
//     });
//   }
// });
// document.addEventListener("lazybeforeunveil", function (e) {
//   var bg = e.target.getAttribute("data-bg");
//   if (bg) {
//     e.target.style.backgroundImage = bg;
//   }
// });
(function (factory) {
  if (typeof define === "function" && define.amd) {
    define(["jquery"], factory);
  } else if (typeof exports === "object") {
    factory(require("jquery"));
  } else {
    factory(jQuery);
  }
})(function ($) {
  var CountTo = function (element, options) {
    this.$element = $(element);
    this.options = $.extend({}, CountTo.DEFAULTS, this.dataOptions(), options);
    this.init();
  };
  CountTo.DEFAULTS = {
    from: 0,
    to: 0,
    speed: 1000,
    refreshInterval: 100,
    decimals: 0,
    formatter: formatter,
    onUpdate: null,
    onComplete: null,
  };
  CountTo.prototype.init = function () {
    this.value = this.options.from;
    this.loops = Math.ceil(this.options.speed / this.options.refreshInterval);
    this.loopCount = 0;
    this.increment = (this.options.to - this.options.from) / this.loops;
  };
  CountTo.prototype.dataOptions = function () {
    var options = {
      from: this.$element.data("from"),
      to: this.$element.data("to"),
      speed: this.$element.data("speed"),
      refreshInterval: this.$element.data("refresh-interval"),
      decimals: this.$element.data("decimals"),
    };
    var keys = Object.keys(options);
    for (var i in keys) {
      var key = keys[i];
      if (typeof options[key] === "undefined") {
        delete options[key];
      }
    }
    return options;
  };
  CountTo.prototype.update = function () {
    this.value += this.increment;
    this.loopCount++;
    this.render();
    if (typeof this.options.onUpdate == "function") {
      this.options.onUpdate.call(this.$element, this.value);
    }
    if (this.loopCount >= this.loops) {
      clearInterval(this.interval);
      this.value = this.options.to;
      if (typeof this.options.onComplete == "function") {
        this.options.onComplete.call(this.$element, this.value);
      }
    }
  };
  CountTo.prototype.render = function () {
    var formattedValue = this.options.formatter.call(
      this.$element,
      this.value,
      this.options
    );
    this.$element.text(formattedValue);
  };
  CountTo.prototype.restart = function () {
    this.stop();
    this.init();
    this.start();
  };
  CountTo.prototype.start = function () {
    this.stop();
    this.render();
    this.interval = setInterval(
      this.update.bind(this),
      this.options.refreshInterval
    );
  };
  CountTo.prototype.stop = function () {
    if (this.interval) {
      clearInterval(this.interval);
    }
  };
  CountTo.prototype.toggle = function () {
    if (this.interval) {
      this.stop();
    } else {
      this.start();
    }
  };
  function formatter(value, options) {
    return value.toFixed(options.decimals);
  }
  $.fn.countTo = function (option) {
    return this.each(function () {
      var $this = $(this);
      var data = $this.data("countTo");
      var init = !data || typeof option === "object";
      var options = typeof option === "object" ? option : {};
      var method = typeof option === "string" ? option : "start";
      if (init) {
        if (data) data.stop();
        $this.data("countTo", (data = new CountTo(this, options)));
      }
      data[method].call(data);
    });
  };
});
function resetFormContent() {
  $(".radioButton_item input").each(function (i, element) {
    if ($(element).is(":checked")) {
      $(element).attr("checked", false);
      $(element).parent().find(".rb_checkmark").removeAttr("style");
    }
  });
  $(".checkbox_item input").each(function (i, element) {
    if ($(element).is(":checked")) {
      $(element).attr("checked", false);
      $(element).parent().find(".cc_checkmark").removeAttr("style");
    }
  });
}
$(document).on("click", ".cc_container input[type='checkbox']", function () {
  var color = $(this).parent().attr("data-selectedColor");
  var affectedObj = $(this).parent().find(".cc_checkmark");
  if (color == "" || color == "undefined" || color == null) {
    color = "#3498db";
  }
  if ($(this).is(":checked")) {
    affectedObj.css("background-color", color);
  } else {
    affectedObj.css("background-color", "");
  }
});
$(document).on("click", ".rb_container input[type='radio']", function () {
  var color = $(this).parent().attr("data-selectedColor");
  var affectedObj = $(this).parent().find(".rb_checkmark");
  if (color == "" || color == "undefined" || color == null) {
    color = "#3498db";
  }
  $(this)
    .closest(".radioButtonField")
    .find(".rb_checkmark")
    .css("background-color", "");
  affectedObj.css("background-color", color);
});
function colorPickerQBElements() {
  window.parent.$(".QBBgColor").spectrum({
    color: '""' + $(this).data("color") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(".formElementHolder").css(
        "background",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-bgcolor", color.toRgbString());
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(".formElementHolder").css(
        "background",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-bgcolor", color.toRgbString());
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$(".QBTitleBarColor").spectrum({
    color: '""' + $(this).data("color") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(".header").css("background", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-titlebarcolor", color.toRgbString());
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(".header").css("background", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-titlebarcolor", color.toRgbString());
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
}
function colorPickerOpeningHoursElements() {
  window.parent.$(".OH-bgColor").spectrum({
    color: '""' + $(this).attr("data-bgcolor") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(".body-open-now").css(
        "background",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-bgcolor", color.toRgbString());
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(".body-open-now").css(
        "background",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-bgcolor", color.toRgbString());
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$(".OH-headerBgColor").spectrum({
    color: '""' + $(this).attr("data-bgcolor") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(".header-open-now").css(
        "background",
        color.toRgbString()
      );
      var borderColor = color
        .toRgbString()
        .replace(")", ", 0.21)")
        .replace("rgb", "rgba");
      console.log(borderColor);
      CurrentSelectedObj.find(".opend-now-row").css(
        "border-color",
        borderColor
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-headerBgcolor", color.toRgbString());
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(".header-open-now").css(
        "background",
        color.toRgbString()
      );
      var borderColor = color
        .toRgbString()
        .replace(")", ", 0.21)")
        .replace("rgb", "rgba");
      CurrentSelectedObj.find(".opend-now-row").css(
        "border-color",
        borderColor
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-headerBgcolor", color.toRgbString());
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$(".OH-headerTextColor").spectrum({
    color: '""' + $(this).attr("data-bgcolor") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(".header-open-now").css(
        "color",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-headerTextcolor", color.toRgbString());
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(".header-open-now").css(
        "color",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-headerTextcolor", color.toRgbString());
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$(".OH-DaysTextColor").spectrum({
    color: '""' + $(this).attr("data-bgcolor") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(".day").css("color", color.toRgbString());
      CurrentSelectedObj.find(".open-now").css("color", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-DaysTextColor", color.toRgbString());
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(".day-row .day").css(
        "color",
        color.toRgbString()
      );
      CurrentSelectedObj.find(".open-now").css("color", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-DaysTextColor", color.toRgbString());
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$(".OH-TimeColor").spectrum({
    color: '""' + $(this).attr("data-bgcolor") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(".time").css("color", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-TimeColor", color.toRgbString());
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(".time").css("color", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-TimeColor", color.toRgbString());
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
}
function colorPickerOrderElements() {
  window.parent.$(".orderElementFieldStroke").spectrum({
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(
        ".form-group input, .form-group select, .inner-addon.left-addon input, .inner-addon.left-addon select"
      ).css("border-color", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-fieldstrokecolor", color.toRgbString());
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(
        ".form-group input, .form-group select, .inner-addon.left-addon input, .inner-addon.left-addon select"
      ).css("border-color", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-fieldstrokecolor", color.toRgbString());
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
}
function showOHModal() {
  $("#opening-hours-modal").modal("show");
}
function showOHModalForDrop(currentObj) {
  CurrentSelectedObj = currentObj;
  var Days = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
  var today = new Date();
  var CurrentDay = Days[today.getDay()];
  CurrentSelectedObj.find(
    ".body-open-now .row." + CurrentDay + " .day-row"
  ).addClass("opend-now-row");
  $("#opening-hours-modal").modal("show");
}
function OHShowHide(selectedOpt) {
  var val = selectedOpt;
  if (val === true) {
    CurrentSelectedObj.attr("data-status", "checked");
    CurrentSelectedObj.removeClass("no-open");
    CurrentSelectedObj.find(".time-header strong").html("");
    CurrentSelectedObj.attr("stopCounter", "false");
  } else {
    CurrentSelectedObj.attr("data-status", "notChecked");
    var weekday = [
      "Sunday",
      "Monday",
      "Tuesday",
      "Wednesday",
      "Thursday",
      "Friday",
      "Saturday",
    ];
    var a = new Date();
    var Today = weekday[a.getDay()];
    CurrentSelectedObj.find(".time-header strong").html(Today);
    CurrentSelectedObj.addClass("no-open");
    CurrentSelectedObj.attr("stopCounter", "true");
  }
}
$("#opening-hours-modal").on("show.bs.modal", function () {
  CurrentSelectedObj.find(".time").each(function () {
    var closedItems = "";
    if ($(this).html() == "Closed") {
      closedItems = $(this).parents(".row").attr("class").replace("row ", "");
      $("#opening-hours-modal")
        .find("." + closedItems)
        .find(".Closed")
        .trigger("click");
    } else {
      var closedItems = "";
      closedItems = $(this).parents(".row").attr("class").replace("row ", "");
      $("#opening-hours-modal")
        .find("." + closedItems)
        .find(".Open")
        .trigger("click");
      var parentDay = $(this).parents(".row").attr("class").replace("row ", "");
      if ($(this).text().trim().toLowerCase() == "open 24 hours") {
        $("#opening-hours-modal")
          .find("." + parentDay + " .oh-start-hour")
          .val("24 hrs")
          .trigger("change");
      } else {
        var StartHour = $(this).find(".start-hour").html();
        $("#opening-hours-modal")
          .find("." + parentDay + " .oh-start-hour")
          .val(StartHour)
          .trigger("change");
        var StartTime = $(this).find(".start-time").html();
        $("#opening-hours-modal")
          .find("." + parentDay + " .oh-start-time")
          .val(StartTime);
        var StartType = $(this).find(".start-type").html();
        if (StartType != "" && StartType != null) {
          $("#opening-hours-modal")
            .find("." + parentDay + " .oh-start-type")
            .val(StartType.toUpperCase());
        }
        var EndHour = $(this).find(".end-hour").html();
        $("#opening-hours-modal")
          .find("." + parentDay + " .oh-end-hour")
          .val(EndHour);
        var EndTime = $(this).find(".end-time").html();
        $("#opening-hours-modal")
          .find("." + parentDay + " .oh-end-time")
          .val(EndTime);
        var EndType = $(this).find(".end-type").html();
        if (EndType != "" && EndType != null) {
          $("#opening-hours-modal")
            .find("." + parentDay + " .oh-end-type")
            .val(EndType.toUpperCase());
        }
      }
    }
  });
  var TimeZone = CurrentSelectedObj.attr("data-zone")
    ? CurrentSelectedObj.attr("data-zone")
    : "America/New_York";
  $("#opening-hours-modal").find(".time-zone").val(TimeZone).trigger("click");
});
$("#opening-hours-modal .saveBtn").on("click", function () {
  CurrentSelectedObj.find("meta").remove();
  $("#opening-hours-modal")
    .find(".row")
    .each(function () {
      var Days = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
      var today = new Date();
      var CurrentDay = Days[today.getDay()];
      var parentDay = $(this).attr("class").replace("row ", "");
      if ($(this).find(".Closed.active").length > 0) {
        CurrentSelectedObj.find("." + parentDay + " .time").html("Closed");
        if (parentDay == CurrentDay) {
          CurrentSelectedObj.find(".time-header span").html("Today");
          CurrentSelectedObj.find(".time-header strong").html("CLOSED");
          CurrentSelectedObj.attr("stopCounter", true);
        }
      } else {
        var today = new Date();
        var ohHours = parseInt($(this).find(".oh-start-hour").val());
        var ohMins = parseInt($(this).find(".oh-start-time").val());
        var ohType = $(this).find(".oh-start-type").val();
        if (ohType == "PM") {
          ohHours += 12;
        }
        var ohHoursEnd = parseInt($(this).find(".oh-end-hour").val());
        var ohMinsEnd = parseInt($(this).find(".oh-end-time").val());
        var ohTypeEnd = $(this).find(".oh-end-type").val();
        if (ohTypeEnd == "PM") {
          ohHoursEnd += 12;
        }
        var StartP = new Date(
          today.getMonth() +
            " " +
            today.getDate() +
            ", " +
            today.getFullYear() +
            " " +
            OHpad(ohHours, 2) +
            ":" +
            OHpad(ohMins, 2) +
            ":00"
        );
        var EndP;
        if (ohTypeEnd == "PM") {
          EndP = new Date(
            today.getMonth() +
              " " +
              today.getDate() +
              ", " +
              today.getFullYear() +
              " " +
              OHpad(ohHoursEnd, 2) +
              ":" +
              OHpad(ohMinsEnd, 2) +
              ":00"
          );
        } else if (ohTypeEnd == "AM") {
          var nextDay = new Date();
          nextDay.setDate(today.getDate() + 1);
          EndP = new Date(
            nextDay.getMonth() +
              " " +
              nextDay.getDate() +
              ", " +
              nextDay.getFullYear() +
              " " +
              OHpad(ohHoursEnd, 2) +
              ":" +
              OHpad(ohMinsEnd, 2) +
              ":00"
          );
        }
        if (parentDay != null) {
          if (
            StartP < EndP ||
            $(this).find(".oh-start-hour").val() == "24 hrs"
          ) {
            CurrentSelectedObj.attr("stopCounter", false);
            var StartHour = $(this).find(".oh-start-hour").val();
            var StartTime = $(this).find(".oh-start-time").val();
            var StartType = $(this).find(".oh-start-type").val();
            var EndHour = $(this).find(".oh-end-hour").val();
            var EndTime = $(this).find(".oh-end-time").val();
            var EndType = $(this).find(".oh-end-type").val();
            if (EndType != null) {
              EndType = EndType.toLowerCase();
            }
            if (StartType != null) {
              StartType = StartType.toLowerCase();
            }
            if (StartHour.trim() == "24 hrs") {
              CurrentSelectedObj.find("." + parentDay + " .time").html(
                "Open 24 Hours"
              );
            } else {
              CurrentSelectedObj.find("." + parentDay + " .time").html(
                '<span class="start-hour">' +
                  StartHour +
                  '</span>:<span class="start-time">' +
                  StartTime +
                  '</span><span class="start-type">' +
                  StartType +
                  '</span> - <span class="end-hour">' +
                  EndHour +
                  '</span>:<span class="end-time">' +
                  EndTime +
                  '</span><span class="end-type">' +
                  EndType +
                  "</span>"
              );
            }
            if (
              parentDay == "mon" ||
              parentDay == "tue" ||
              parentDay == "wed" ||
              parentDay == "thu" ||
              parentDay == "fri" ||
              parentDay == "sat" ||
              parentDay == "sun"
            ) {
              var metaDay = "";
              if (parentDay == "mon") {
                metaDay = "Mo";
              }
              if (parentDay == "tue") {
                metaDay = "Tu";
              }
              if (parentDay == "wed") {
                metaDay = "We";
              }
              if (parentDay == "thu") {
                metaDay = "Th";
              }
              if (parentDay == "fri") {
                metaDay = "Fr";
              }
              if (parentDay == "sat") {
                metaDay = "Sa";
              }
              if (parentDay == "Sun") {
                metaDay = "Su";
              }
              var startmeta = parseInt(StartHour);
              if (StartType == "pm") {
                startmeta += 12;
              }
              var endmeta = parseInt(EndHour);
              if (EndType == "pm") {
                endmeta += 12;
              }
              var html = "";
              if (StartHour.trim() == "24 hrs") {
                html =
                  '<meta itemprop="openingHours" content="' +
                  metaDay +
                  ' Open 24 Hours">';
              } else {
                html =
                  '<meta itemprop="openingHours" content="' +
                  metaDay +
                  " " +
                  OHpad(startmeta, 2) +
                  ":" +
                  OHpad(StartTime, 2) +
                  "-" +
                  OHpad(endmeta, 2) +
                  ":" +
                  OHpad(EndTime, 2) +
                  '">';
              }
              CurrentSelectedObj.find(".body-open-now").append(html);
            }
            if (StartHour.trim() == "24 hrs") {
              if (parentDay == CurrentDay) {
                CurrentSelectedObj.find(".time-header span").html(
                  "Today Open 24 Hours"
                );
                if (CurrentSelectedObj.hasClass("openingHours-style2")) {
                  CurrentSelectedObj.find(".today-time").html("Open 24 Hours");
                  CurrentSelectedObj.find(".time-header p").html(
                    "Open 24 Hours"
                  );
                } else {
                  CurrentSelectedObj.find(".time-header span").html(
                    "Today Open 24 Hours"
                  );
                }
              }
            } else {
              if (parentDay == CurrentDay) {
                CurrentSelectedObj.find(".time-header span").html(
                  "Today " +
                    StartHour +
                    ":" +
                    StartTime +
                    " " +
                    StartType +
                    " - " +
                    EndHour +
                    ":" +
                    EndTime +
                    " " +
                    EndType +
                    ""
                );
                if (CurrentSelectedObj.hasClass("openingHours-style2")) {
                  CurrentSelectedObj.find(".today-time").html(
                    StartHour +
                      ":" +
                      StartTime +
                      " " +
                      StartType +
                      " - " +
                      EndHour +
                      ":" +
                      EndTime +
                      " " +
                      EndType
                  );
                  CurrentSelectedObj.find(".time-header p").html(
                    StartHour +
                      ":" +
                      StartTime +
                      " " +
                      StartType +
                      "<br>" +
                      EndHour +
                      ":" +
                      EndTime +
                      " " +
                      EndType
                  );
                } else {
                  if (StartHour.trim() == "24 hrs") {
                    CurrentSelectedObj.find(".time-header span").html(
                      "Open 24 Hours"
                    );
                  } else {
                    CurrentSelectedObj.find(".time-header span").html(
                      "Today " +
                        StartHour +
                        ":" +
                        StartTime +
                        " " +
                        StartType +
                        " - " +
                        EndHour +
                        ":" +
                        EndTime +
                        " " +
                        EndType
                    );
                  }
                }
              }
            }
          } else {
            if (parentDay != "row" && parentDay != "timezone") {
              noty({
                text:
                  "Please Insert Correct Open And Close Time Values. Opening Time Should Be Earlier Than Closing Time",
                layout: "topCenter",
                type: "error",
                timeout: 2500,
              });
              $("#opening-hours-modal ." + parentDay).addClass("OHerror");
            }
          }
        }
      }
    });
  if ($("#opening-hours-modal .OHerror").length == 0) {
    CurrentSelectedObj.attr("data-zone", $("").find(".time-zone").val());
    $("#opening-hours-modal").modal("hide");
    OHUpdateTimers();
  }
});
$("#opening-hours-modal .start-time").on("change", function () {
  var parentRow = $(this).closest(".row");
  var openHour = parentRow.find(".oh-start-hour");
  if (openHour.val().trim() == "24 hrs") {
    openHour.addClass("bigSelect");
    parentRow.find(".start-time").not(openHour).hide();
    parentRow.find(".time").hide();
  } else {
    openHour.removeClass("bigSelect");
    parentRow.find(".start-time").show();
    parentRow.find(".time").show();
    var parentDay = parentRow.attr("class").replace("row ", "");
    var today = new Date();
    var ohHours = parseInt(parentRow.find(".oh-start-hour").val());
    var ohMins = parseInt(parentRow.find(".oh-start-time").val());
    var ohType = parentRow.find(".oh-start-type").val();
    if (ohType == "PM") {
      ohHours += 12;
    }
    var ohHoursEnd = parseInt(parentRow.find(".oh-end-hour").val());
    var ohMinsEnd = parseInt(parentRow.find(".oh-end-time").val());
    var ohTypeEnd = parentRow.find(".oh-end-type").val();
    var StartP = new Date(
      today.getMonth() +
        " " +
        today.getDate() +
        ", " +
        today.getFullYear() +
        " " +
        OHpad(ohHours, 2) +
        ":" +
        OHpad(ohMins, 2) +
        ":00"
    );
    var EndP;
    if (ohTypeEnd == "PM") {
      ohHoursEnd += 12;
      if (ohHoursEnd == 24) {
        ohHoursEnd = "00";
        EndP = new Date(
          today.getMonth() +
            " " +
            today.getDate() +
            ", " +
            today.getFullYear() +
            " " +
            OHpad(ohHoursEnd, 2) +
            ":" +
            OHpad(ohMinsEnd, 2) +
            ":00"
        );
        EndP.setDate(EndP.getDate() + 1);
      } else {
        EndP = new Date(
          today.getMonth() +
            " " +
            today.getDate() +
            ", " +
            today.getFullYear() +
            " " +
            OHpad(ohHoursEnd, 2) +
            ":" +
            OHpad(ohMinsEnd, 2) +
            ":00"
        );
      }
      parentRow.find(".oh-end-hour").children("option").show();
    } else if (ohTypeEnd == "AM") {
      var nextDay = new Date();
      nextDay.setDate(today.getDate() + 1);
      EndP = new Date(
        nextDay.getMonth() +
          " " +
          nextDay.getDate() +
          ", " +
          nextDay.getFullYear() +
          " " +
          OHpad(ohHoursEnd, 2) +
          ":" +
          OHpad(ohMinsEnd, 2) +
          ":00"
      );
      let openHourVal = parseInt(parentRow.find(".oh-start-hour").val());
      parentRow
        .find(".oh-end-hour")
        .children("option")
        .each(function () {
          if (parseInt($(this).val()) >= openHourVal) $(this).hide();
        });
      if (parentDay != null) {
        if (StartP < EndP) {
          parentRow.removeClass("OHerror");
        } else {
          parentRow.addClass("OHerror");
        }
      }
    }
  }
});
var OHTimerCounter = setInterval(function () {
  if ($(".openingHours-all").length > 0) {
    OHUpdateTimers();
  }
}, 1000);
function OHUpdateTimers() {
  var today = new Date();
  var Days = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
  var CurrentDay = Days[today.getDay()];
  var Hours = today.getHours();
  var Minutes = today.getMinutes();
  $(".openingHours-all").each(function () {
    var OHparent = $(this);
    if (OHparent.attr("stopCounter") == "false") {
      $(this)
        .find(".body-open-now .row")
        .each(function () {
          var parentDay = $(this).attr("class").replace("row ", "");
          if (parentDay == CurrentDay) {
            if (
              $(this).find(".time").text().trim().toLowerCase() ==
              "open 24 hours"
            ) {
              OHparent.find(".header-open-now strong").html("OPEN NOW");
            } else {
              var ohHours = parseInt($(this).find(".start-hour").html());
              var ohMins = parseInt($(this).find(".start-time").html());
              var ohType = $(this).find(".start-type").html();
              if (ohType == "pm") {
                ohHours += 12;
              } else {
                if (ohHours == 12) {
                  ohHours = 0;
                }
              }
              var ohHoursEnd = parseInt($(this).find(".end-hour").html());
              var ohMinsEnd = parseInt($(this).find(".end-time").html());
              var ohTypeEnd = $(this).find(".end-type").html();
              if (ohTypeEnd == "pm") {
                ohHoursEnd += 12;
              } else {
                if (ohHoursEnd == 12) {
                  ohHoursEnd = 0;
                }
              }
              var StartP = new Date(
                today.getMonth() +
                  " " +
                  today.getDate() +
                  ", " +
                  today.getFullYear() +
                  " " +
                  OHpad(ohHours, 2) +
                  ":" +
                  OHpad(ohMins, 2) +
                  ":00"
              );
              var CurrentTime = new Date(
                today.getMonth() +
                  " " +
                  today.getDate() +
                  ", " +
                  today.getFullYear() +
                  " " +
                  OHpad(Hours, 2) +
                  ":" +
                  OHpad(Minutes, 2) +
                  ":00"
              );
              var EndP = new Date(
                today.getMonth() +
                  " " +
                  today.getDate() +
                  ", " +
                  today.getFullYear() +
                  " " +
                  OHpad(ohHoursEnd, 2) +
                  ":" +
                  OHpad(ohMinsEnd, 2) +
                  ":00"
              );
              if (ohTypeEnd == "am") {
                EndP.setDate(EndP.getDate() + 1);
              }
              if (OHparent.attr("data-status") == "notChecked") {
              } else {
                if (StartP <= CurrentTime && CurrentTime < EndP) {
                  OHparent.find(".header-open-now strong").html("OPEN NOW");
                } else {
                  OHparent.find(".header-open-now strong").html("CLOSED");
                }
              }
            }
          }
        });
    }
    false;
  });
}
function OHpad(num, size) {
  var s = num + "";
  while (s.length < size) s = "0" + s;
  return s;
}
function colorPickerButtonElements() {
  window.parent.$(".signInLinkColorSpectrum").spectrum({
    color: CurrentSelectedObj.find("forgetPassLink").css("color"),
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: false,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(
        ".forgetPassLink, .forgetPassLink a,.backToLoginLink, .backToLoginLink a, .forgetForm .h2 *,.succesForm .h2 * , .forgetText"
      ).css("color", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-btnbackgroundcolor", color.toRgbString());
    },
    show: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(
        ".forgetPassLink, .forgetPassLink a,.backToLoginLink, .backToLoginLink a, .forgetForm .h2 *,.succesForm .h2 * , .forgetText"
      ).css("color", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-btnbackgroundcolor", color.toRgbString());
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  function ColorLuminance(hex, lum) {
    hex = String(hex).replace(/[^0-9a-f]/gi, "");
    if (hex.length < 6) {
      hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
    }
    lum = lum || 0;
    var rgb = "#",
      c,
      i;
    for (i = 0; i < 3; i++) {
      c = parseInt(hex.substr(i * 2, 2), 16);
      c = Math.round(Math.min(Math.max(0, c + c * lum), 255)).toString(16);
      rgb += ("00" + c).substr(c.length);
    }
    return rgb;
  }
}
function colorPickerFormElements() {}
function colorPickerCountDownElements() {}
function colorPickerCountUpElements() {}
function updateCountDownCont() {}
function colorPickerFAQelements() {
  window.parent.$(".faqBoxColor").spectrum({
    color:
      '""' +
      CurrentSelectedObj.find(".main-faq-container").css("background") +
      '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(".main-faq-container").css(
        "background",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(".main-faq-container").css(
        "background",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$(".faqIconBg").spectrum({
    color: '""' + CurrentSelectedObj.find(".faq-icon").css("background") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(".faq-icon").css(
        "background",
        color.toRgbString()
      );
      CurrentSelectedObj.find(".faq-icon-arrow").css(
        "border-left-color",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(".faq-icon").css(
        "background",
        color.toRgbString()
      );
      CurrentSelectedObj.find(".faq-icon-arrow").css(
        "border-left-color",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$(".faqIconColor").spectrum({
    color: '""' + CurrentSelectedObj.find(".faq-icon").css("color") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(".faq-icon").css("color", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(".faq-icon").css("color", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$(".faqStrokeColor").spectrum({
    color:
      '""' +
      CurrentSelectedObj.find(".main-faq-container").css("border-color") +
      '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(".main-faq-container").css(
        "border-color",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(".main-faq-container").css(
        "border-color",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$(".faqShodwColor").spectrum({
    color: '""' + CurrentSelectedObj.attr("data-shadowColor") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(".main-faq-container").css(
        "box-shadow",
        "0 " +
          CurrentSelectedObj.attr("data-boxShdowDistance") +
          "px " +
          CurrentSelectedObj.attr("data-boxShdowSize") +
          "px " +
          color.toRgbString()
      );
      CurrentSelectedObj.attr("data-shadowColor", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(".main-faq-container").css(
        "box-shadow",
        "0 " +
          CurrentSelectedObj.attr("data-boxShdowDistance") +
          "px " +
          CurrentSelectedObj.attr("data-boxShdowSize") +
          "px " +
          color.toRgbString()
      );
      CurrentSelectedObj.attr("data-shadowColor", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$(".faqQuestionColor").spectrum({
    color:
      '""' + CurrentSelectedObj.find(".faq-title p > span").css("color") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(".faq-title p > span").css(
        "color",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(".faq-title p > span").css(
        "color",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$(".faqAnswerColor").spectrum({
    color:
      '""' + CurrentSelectedObj.find(".faq-text p > span").css("color") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(".faq-text p > span").css(
        "color",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(".faq-text p > span").css(
        "color",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
}
function colorPickerTabelements() {
  window.parent.$(".activeTabColor").spectrum({
    color: '""' + PC.CurrentSelectedObj.attr("data-activeTabColor") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      PC.CurrentSelectedObj.find(".element-tabs-nav li.active a").css(
        "background",
        color.toRgbString()
      );
      PC.CurrentSelectedObj.find(
        ".element-tabs-nav li.active a .active-arrow"
      ).css("border-top-color", color.toRgbString());
      PC.CurrentSelectedObj.attr("data-activeTabColor", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      PC.CurrentSelectedObj.find(".element-tabs-nav li.active a").css(
        "background",
        color.toRgbString()
      );
      PC.CurrentSelectedObj.find(
        ".element-tabs-nav li.active a .active-arrow"
      ).css("border-top-color", color.toRgbString());
      PC.CurrentSelectedObj.attr("data-activeTabColor", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$(".activeTabTextColor").spectrum({
    color: '""' + PC.CurrentSelectedObj.attr("data-activeTabTextColor") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      PC.CurrentSelectedObj.find(".element-tabs-nav li.active a").css(
        "color",
        color.toRgbString()
      );
      PC.CurrentSelectedObj.attr(
        "data-activeTabTextColor",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      PC.CurrentSelectedObj.find(".element-tabs-nav li.active a").css(
        "color",
        color.toRgbString()
      );
      PC.CurrentSelectedObj.attr(
        "data-activeTabTextColor",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$(".inactiveTabColor").spectrum({
    color: '""' + PC.CurrentSelectedObj.attr("data-inactiveTabColor") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      PC.CurrentSelectedObj.find(".element-tabs-nav li:not(.active) a").css(
        "background",
        color.toRgbString()
      );
      PC.CurrentSelectedObj.find(".element-tabs-nav").css(
        "background",
        color.toRgbString()
      );
      PC.CurrentSelectedObj.attr("data-inactiveTabColor", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      PC.CurrentSelectedObj.find(".element-tabs-nav li:not(.active) a").css(
        "background",
        color.toRgbString()
      );
      PC.CurrentSelectedObj.find(".element-tabs-nav").css(
        "background",
        color.toRgbString()
      );
      PC.CurrentSelectedObj.attr("data-inactiveTabColor", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$(".inactiveTabTextColor").spectrum({
    color: '""' + PC.CurrentSelectedObj.attr("data-inactiveTabTextColor") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      PC.CurrentSelectedObj.find(".element-tabs-nav li:not(.active) a").css(
        "color",
        color.toRgbString()
      );
      PC.CurrentSelectedObj.attr(
        "data-inactiveTabTextColor",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      PC.CurrentSelectedObj.find(".element-tabs-nav li:not(.active) a").css(
        "color",
        color.toRgbString()
      );
      PC.CurrentSelectedObj.attr(
        "data-inactiveTabTextColor",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$(".tabInnerBg").spectrum({
    color: '""' + PC.CurrentSelectedObj.css("background") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      PC.CurrentSelectedObj.css("background", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      PC.CurrentSelectedObj.css("background", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$(".tabContainerBgColor").spectrum({
    color: '""' + PC.CurrentSelectedObj.attr("data-containerColor") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      PC.CurrentSelectedObj.find(".tab-pane").css(
        "background",
        color.toRgbString()
      );
      PC.CurrentSelectedObj.attr("data-containerColor", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      PC.CurrentSelectedObj.find(".tab-pane").css(
        "background",
        color.toRgbString()
      );
      PC.CurrentSelectedObj.attr("data-containerColor", color.toRgbString());
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
}
function makeTabsResponsive(section) {
  $(section)
    .find(".element-tabs-nav")
    .each(function () {
      $(this).tabCollapse();
    });
}
function generateNewIdsForTabs(section) {
  $(section)
    .find(".tabs-element")
    .each(function (index, tabElement) {
      $(this)
        .find(".element-tabs-nav li a")
        .each(function (tabIndex) {
          randmoNumber = (Math.floor(Math.random() * 10000) + 10000).toString();
          newTabId = "tab" + (tabIndex + 1) + "-" + randmoNumber;
          $(this).attr("href", "#" + newTabId);
          $(this).attr("aria-controls", newTabId);
          $(tabElement)
            .find(".tab-content .tab-pane")
            .eq(tabIndex)
            .attr("id", newTabId);
        });
    });
}
function resetTabsColorandText(tabElementObjecy) {
  myTabObject = tabElementObjecy;
  if (tabElementObjecy.hasClass("tab-pane")) {
    myTabObject = tabElementObjecy.parent().parent().parent();
  }
  myTabObject
    .find(".element-tabs-nav li.active a")
    .css("background", myTabObject.attr("data-activeTabColor"));
  myTabObject
    .find(".element-tabs-nav li.active a")
    .css("color", myTabObject.attr("data-activeTabTextColor"));
  myTabObject
    .find(".element-tabs-nav li.active a .active-arrow")
    .css("border-top-color", myTabObject.attr("data-activeTabColor"));
  myTabObject
    .find(".element-tabs-nav li:not(.active) a")
    .css("background", myTabObject.attr("data-inactiveTabColor"));
  myTabObject
    .find(".element-tabs-nav li:not(.active) a")
    .css("color", myTabObject.attr("data-inactiveTabTextColor"));
  myTabObject
    .find(".element-tabs-nav li:not(.active) a .active-arrow")
    .css("border-top-color", myTabObject.attr("data-inactiveTabColor"));
  myTabObject
    .find(".panel-group .panel-heading a[aria-expanded='true']")
    .css("background", myTabObject.attr("data-activeTabColor"));
  myTabObject
    .find(".panel-group .panel-heading a[aria-expanded='true']")
    .css("color", myTabObject.attr("data-activeTabTextColor"));
  myTabObject
    .find(".panel-group .panel-heading a[aria-expanded='false']")
    .css("background", myTabObject.attr("data-inactiveTabColor"));
  myTabObject
    .find(".panel-group .panel-heading a[aria-expanded='false']")
    .css("color", myTabObject.attr("data-inactiveTabTextColor"));
}
$(document).on(
  "click",
  ".tabs-element .element-tabs-nav a[data-toggle='tab']",
  function (e) {
    myTabElement = $(this).closest(".droppableElementArea.tabs-element");
    setTimeout(function () {
      resetTabsColorandText(myTabElement);
    }, 50);
  }
);
$(document).on("click", ".tabs-element .panel-title a span", function (e) {
  myTabElement = $(this).closest(".droppableElementArea.tabs-element");
  setTimeout(function () {
    resetTabsColorandText(myTabElement);
  }, 50);
});
$(document).on(
  "shown-accordion.bs.tabcollapse",
  ".tabs-element .element-tabs-nav",
  function (e) {
    parentTabElemnt = $(this).closest(".tabs-element");
    parentTabElemnt.find(".panel-collapse").each(function (i) {
      targetTabPaneId = $(this).attr("id").substring(0, 4);
      bgTabColor = "";
      parentTabElemnt.find(".tab-pane").each(function (i) {
        if (
          $(this)
            .attr("id")
            .indexOf(targetTabPaneId + "-") != -1
        ) {
          bgTabColor = $(this).css("background-color");
        }
      });
      $(this).find(".panel-body").css("background-color", bgTabColor);
    });
  }
);
function formatDate(date) {
  var monthNames = [
    "January",
    "February",
    "March",
    "April",
    "May",
    "June",
    "July",
    "August",
    "September",
    "October",
    "November",
    "December",
  ];
  var day = date.getDate();
  var monthIndex = date.getMonth();
  var year = date.getFullYear();
  return monthNames[monthIndex] + " " + day + " " + year;
}
function initFunctions() {
  window.parent.$(".video-cover").on("click", function () {
    CurrentSelectedObj.hide();
    CurrentSelectedObj.closest(".mainCoverMediaWrapper")
      .find(".droppableElementArea.vidElement")
      .fadeIn(200);
    CurrentSelectedObj.attr("data-covertype", "video");
    CurrentSelectedObj = CurrentSelectedObj.closest(
      ".mainCoverMediaWrapper"
    ).find(".droppableElementArea.vidElement");
    var galleryUp = $("#gallery").hasClass("in");
    if (galleryUp) {
      $("#gallery").modal("hide");
    }
    var videoUp = $("#videoElementModal").hasClass("in");
    if (!videoUp) {
      CurrentSelectedObj.find(".videoModalTrigger").trigger("click");
    }
    CurrentSelectedObj.attr("data-covertype", "video");
  });
  window.parent.$(".image-cover").on("click", function () {
    CurrentSelectedObj.hide();
    CurrentSelectedObj.closest(".mainCoverMediaWrapper")
      .find(".droppableElementArea.imgElement")
      .fadeIn(200);
    CurrentSelectedObj.attr("data-covertype", "image");
    CurrentSelectedObj = CurrentSelectedObj.closest(
      ".mainCoverMediaWrapper"
    ).find(".droppableElementArea.imgElement");
    var videoUp = $("#videoElementModal").hasClass("in");
    if (videoUp) {
      $("#videoElementModal").modal("hide");
    }
    var galleryUp = $("#gallery").hasClass("in");
    if (!galleryUp) {
      CurrentSelectedObj.find('a[href="#gallery"]').trigger("click");
    }
    CurrentSelectedObj.attr("data-covertype", "image");
  });
  window.parent.$(".alignmentImgIcons .fa").on("click", function () {
    window.parent.$(".alignmentImgIcons .fa").removeClass("active");
    $(this).addClass("active");
    var obj = CurrentSelectedObj.find(".elementImageHolder img");
    obj.removeClass("alignLeft alignRight");
    if ($(this).hasClass("fa-align-left")) {
      obj.addClass("alignLeft");
      CurrentSelectedObj.attr("data-Imgalign", "left");
    } else if ($(this).hasClass("fa-align-right")) {
      obj.addClass("alignRight");
      CurrentSelectedObj.attr("data-Imgalign", "right");
    } else {
      CurrentSelectedObj.attr("data-Imgalign", "center");
    }
  });
  window.parent.$(".dark-theme-option").on("click", function () {
    CurrentSelectedObj.find(".fb-comments").attr("data-colorscheme", "dark");
    var fbObject = CurrentSelectedObj.find(".fb-comments").clone();
    CurrentSelectedObj.find(".fb-comments").remove();
    CurrentSelectedObj.find(".elementWrapper").append(fbObject);
    CurrentSelectedObj.attr("data-colorscheme", "dark");
    FB.XFBML.parse();
  });
  window.parent.$(".light-theme-option").on("click", function () {
    CurrentSelectedObj.find(".fb-comments").attr("data-colorscheme", "light");
    var fbObject = CurrentSelectedObj.find(".fb-comments").clone();
    CurrentSelectedObj.find(".fb-comments").remove();
    CurrentSelectedObj.find(".elementWrapper").append(fbObject);
    CurrentSelectedObj.attr("data-colorscheme", "light");
    FB.XFBML.parse();
  });
  window.parent.$(".postsNumber.formsInput").on("change", function () {
    var val = $(this).val();
    CurrentSelectedObj.find(".fb-comments").attr("data-numposts", val);
    var fbObject = CurrentSelectedObj.find(".fb-comments").clone();
    CurrentSelectedObj.find(".fb-comments").remove();
    CurrentSelectedObj.find(".elementWrapper").append(fbObject);
    CurrentSelectedObj.attr("data-numposts", val);
    FB.XFBML.parse();
  });
  window.parent.$("#redirect-modal .btn.btn-primary").on("click", function (e) {
    e.preventDefault();
    var valid = $(this).closest(".modal").find("form").valid();
    if (valid) {
      checkSetupMode();
      window.parent.$("#redirect-modal").modal("hide");
    }
  });
  window.parent.$("#popup-delay-switch").on("change", function () {
    var CurrentSelectedObj = window.parent.$(".holderPopUpPreview");
    var currentParent = window.parent.$("#buttonDesign");
    var val = $(this).is(":checked");
    if (val === true) {
      currentParent.find(".delayOptions").fadeIn(200);
    } else {
      currentParent.find(".delayOptions").fadeOut(200);
    }
    CurrentSelectedObj.attr("data-delay", val);
  });
  window.parent.$("#delay-switch").on("change", function () {
    var val = $(this).is(":checked");
    if (val === true) {
      window.parent.$(".delayOptions").fadeIn(200);
    } else {
      window.parent.$(".delayOptions").fadeOut(200);
    }
    CurrentSelectedObj.attr("data-delay", val);
  });
  window.parent.$(".optin-option").on("click", function () {
    window.parent
      .$("#defaultWrapper")
      .css({
        visibility: "hidden",
        opacity: 0.0,
        transition: "visibility 0.2s, opacity 0.2s",
      });
    window.parent.$("#buttonEditorWrapper").fadeIn(200);
    CurrentSelectedObj.attr("data-actiontype", "optin");
  });
  window.parent.$(".redirect-option").on("click", function () {
    window.parent.$("#redirect-modal").modal("show");
    CurrentSelectedObj.attr("data-actiontype", "redirect");
  });
  window.parent
    .$("#optin-modal")
    .find(".step1OptinBtn")
    .on("click", function () {
      $(this)
        .closest(".modal")
        .find("#optinSteps li, #optinSteps li a")
        .removeClass("active");
      $(this)
        .closest(".modal")
        .find("#optinSteps li.step2, #optinSteps li.step2 a")
        .addClass("active");
      $(this).closest(".modal").find(".optinPanelStep1").hide();
      $(this).closest(".modal").find(".optinPanelStep2").show();
    });
  window.parent
    .$("#optin-modal")
    .find(".step2OptinBtn")
    .on("click", function () {
      $(this)
        .closest(".modal")
        .find("#optinSteps li, #optinSteps li a")
        .removeClass("active");
      $(this)
        .closest(".modal")
        .find("#optinSteps li.step3, #optinSteps li.step3 a")
        .addClass("active");
      $(this).closest(".modal").find(".optinPanelStep2").hide();
      $(this).closest(".modal").find(".optinPanelStep3").show();
    });
  window.parent
    .$("#optin-modal")
    .find(".step2OptinBtnBack")
    .on("click", function () {
      $(this)
        .closest(".modal")
        .find("#optinSteps li, #optinSteps li a")
        .removeClass("active");
      $(this)
        .closest(".modal")
        .find("#optinSteps li.step1, #optinSteps li.step1 a")
        .addClass("active");
      $(this).closest(".modal").find(".optinPanelStep2").hide();
      $(this).closest(".modal").find(".optinPanelStep1").show();
    });
  window.parent
    .$("#optin-modal")
    .find(".step3OptinBtnBack")
    .on("click", function () {
      $(this)
        .closest(".modal")
        .find("#optinSteps li, #optinSteps li a")
        .removeClass("active");
      $(this)
        .closest(".modal")
        .find("#optinSteps li.step2, #optinSteps li.step2 a")
        .addClass("active");
      $(this).closest(".modal").find(".optinPanelStep3").hide();
      $(this).closest(".modal").find(".optinPanelStep2").show();
    });
  window.parent.$(".image-option").on("click", function () {
    window.parent
      .$(".btnColorGrp, .btnStrokeSizeGrp, .btnStrokeColorGrp")
      .hide();
    window.parent.$(".imgBtnGroup").fadeIn(200);
    window.parent.$(".imgBtnSizeGrp").fadeIn(200);
    CurrentSelectedObj.attr("data-btndesign", "image");
  });
  window.parent.$(".text-option").on("click", function () {
    window.parent.$(".imgBtnGroup").hide();
    window.parent.$(".imgBtnSizeGrp").hide();
    window.parent
      .$(".btnColorGrp, .btnStrokeSizeGrp, .btnStrokeColorGrp")
      .fadeIn(200);
    CurrentSelectedObj.find(".imageButton").hide();
    CurrentSelectedObj.find("button").show();
    CurrentSelectedObj.attr("data-btndesign", "text");
  });
  window.parent.$(".popup-text-option").on("click", function () {
    var currentParent = window.parent.$("#buttonDesign");
    var CurrentSelectedObj = window.parent.$(".holderPopUpPreview");
    currentParent.find(".imgBtnGroup").hide();
    currentParent.find(".imgBtnSizeGrp").hide();
    currentParent
      .find(".btnColorGrp, .btnStrokeSizeGrp, .btnStrokeColorGrp")
      .fadeIn(200);
    CurrentSelectedObj.find(".imageButton").hide();
    CurrentSelectedObj.find("button").show();
    CurrentSelectedObj.attr("data-btndesign", "text");
  });
  window.parent.$(".popup-image-option").on("click", function () {
    var currentParent = window.parent.$("#buttonDesign");
    var CurrentSelectedObj = window.parent.$(".holderPopUpPreview");
    currentParent
      .find(".btnColorGrp, .btnStrokeSizeGrp, .btnStrokeColorGrp")
      .hide();
    currentParent.find(".imgBtnGroup").fadeIn(200);
    currentParent.find(".imgBtnSizeGrp").fadeIn(200);
    CurrentSelectedObj.attr("data-btndesign", "image");
  });
  window.parent.$(".popupBtnImageSelect").on("change", function () {
    var currentParent = window.parent.$("#buttonDesign");
    var CurrentSelectedObj = window.parent.$(".holderPopUpPreview");
    var val = $(this).find("option:selected").val();
    var checkLength = CurrentSelectedObj.find("button:visible").length;
    if (checkLength > 0) {
      CurrentSelectedObj.find("button").hide();
    } else {
      var checkImages = CurrentSelectedObj.find(".imageButton:visible").length;
      if (checkImages > 0) {
        CurrentSelectedObj.find(".imageButton").attr(
          "src",
          "../../assets/images/" + val + ".png"
        );
      } else {
        CurrentSelectedObj.find(".buttonSubmitPopup").append(
          '<img class="imageButton" src="../../assets/images/' +
            val +
            '.png" />'
        );
      }
    }
    CurrentSelectedObj.attr("data-btnimagesrc", val);
  });
  window.parent.$(".btnImageSelect").on("change", function () {
    if (CurrentSelectedObj.hasClass("formElement") != true) {
      var val = $(this).find("option:selected").val();
      var checkLength = CurrentSelectedObj.find("button:visible").length;
      if (checkLength > 0) {
        CurrentSelectedObj.find("button").hide();
      } else {
        var checkImages = CurrentSelectedObj.find(".imageButton:visible")
          .length;
        if (checkImages > 0) {
          CurrentSelectedObj.find(".imageButton").attr(
            "src",
            "../../assets/images/" + val + ".png"
          );
        } else {
          CurrentSelectedObj.find(".elementWrapper").append(
            '<img class="imageButton" src="../../assets/images/' +
              val +
              '.png" />'
          );
        }
      }
      CurrentSelectedObj.attr("data-btnimagesrc", val);
    } else {
      var val = $(this).find("option:selected").val();
      var checkLength = CurrentSelectedObj.find(
        ".formElementHolder button:visible"
      ).length;
      if (checkLength > 0) {
        CurrentSelectedObj.find(".formElementHolder button").hide();
      } else {
        var checkImages = CurrentSelectedObj.find(
          ".formElementHolder .imageButton:visible"
        ).length;
        if (checkImages > 0) {
          CurrentSelectedObj.find(".formElementHolder .imageButton").attr(
            "src",
            "../../assets/images/" + val + ".png"
          );
        } else {
          CurrentSelectedObj.find(".elementWrapper .formElementHolder ").append(
            '<img class="imageButton" src="../../assets/images/' +
              val +
              '.png" />'
          );
        }
      }
      CurrentSelectedObj.attr("data-btnimagesrc", val);
    }
  });
  var actionType = CurrentSelectedObj.attr("data-actiontype");
  var btnDesign = CurrentSelectedObj.attr("data-btndesign");
  var btnImage = CurrentSelectedObj.attr("data-btnimagesrc");
  var btnDelay = CurrentSelectedObj.attr("data-delay");
  var btnImgSize = CurrentSelectedObj.attr("data-btnimgsize");
  if (actionType == "optin") {
    window.parent.$(".optin-option").addClass("active");
    window.parent.$(".redirect-option").removeClass("active");
  }
  if (actionType == "redirect") {
    window.parent.$(".redirect-option").addClass("active");
    window.parent.$(".optin-option").removeClass("active");
  }
  if (btnDesign == "text") {
    window.parent.$(".text-option").trigger("click");
  }
  if (btnDesign == "image") {
    window.parent.$(".image-option").trigger("click");
  }
  if (
    btnImgSize == "large" ||
    btnImgSize == "medium" ||
    btnImgSize == "small"
  ) {
    var btnClick = window.parent.$(".imgBtnSizeGrp .imgsize-" + btnImgSize);
    btnClick.trigger("click").addClass("active");
  }
  if (btnImage != undefined) {
    window.parent.$(".btnImageSelect").val(btnImage);
    window.parent.$(".btnImageSelect").selectpicker("render");
  }
  if (btnDelay === "true") {
    window.parent.$("#delay-switch").trigger("click");
  }
  window.parent.$("#redirect-modal").on("shown.bs.modal", function () {
    $(this).find("#InputNameEmail3").val("");
  });
  window.parent.$("#optin-modal").on("shown.bs.modal", function () {
    $(this)
      .closest(".modal")
      .find("#optinSteps li, #optinSteps li a")
      .removeClass("active");
    $(this)
      .closest(".modal")
      .find("#optinSteps li.step1, #optinSteps li.step1 a")
      .addClass("active");
    $(this).closest(".modal").find(".optinPanelStep2").hide();
    $(this).closest(".modal").find(".optinPanelStep3").hide();
    $(this).closest(".modal").find(".optinPanelStep1").show();
  });
  window.parent
    .$(".imgBtnSizeGrp:not(.popupBtnImg) a")
    .on("click", function () {
      $img = CurrentSelectedObj.find(".imageButton");
      CurrentSelectedObj.find(".imageButton").removeClass("large medium small");
      window.parent.$(".imgBtnSizeGrp a").removeClass("active");
      $(this).addClass("active");
      if ($(this).hasClass("imgsize-large")) {
        $img.css("width", "");
        $img.width($img.width() * 1);
        CurrentSelectedObj.attr("data-btnimgsize", "large");
      }
      if ($(this).hasClass("imgsize-medium")) {
        $img.css("width", "");
        $img.width($img.width() * 0.75);
        CurrentSelectedObj.attr("data-btnimgsize", "medium");
      }
      if ($(this).hasClass("imgsize-small")) {
        $img.css("width", "");
        $img.width($img.width() * 0.5);
        CurrentSelectedObj.attr("data-btnimgsize", "small");
      }
    });
  window.parent.$(".imgBtnSizeGrp.popupBtnImg a").on("click", function () {
    var CurrentSelectedObj = window.parent.$(".holderPopUpPreview");
    var currentParent = window.parent.$("#buttonDesign");
    $img = CurrentSelectedObj.find(".imageButton");
    CurrentSelectedObj.find(".imageButton").removeClass("large medium small");
    window.parent.$(".imgBtnSizeGrp a").removeClass("active");
    $(this).addClass("active");
    if ($(this).hasClass("imgsize-large")) {
      $img.css("width", "");
      $img.width($img.width() * 1);
      CurrentSelectedObj.attr("data-btnimgsize", "large");
    }
    if ($(this).hasClass("imgsize-medium")) {
      $img.css("width", "");
      $img.width($img.width() * 0.75);
      CurrentSelectedObj.attr("data-btnimgsize", "medium");
    }
    if ($(this).hasClass("imgsize-small")) {
      $img.css("width", "");
      $img.width($img.width() * 0.5);
      CurrentSelectedObj.attr("data-btnimgsize", "small");
    }
  });
  window.parent.$(".qbAddEmail").on("click", function (e) {
    e.preventDefault();
    window.parent.$(".QBemail2").fadeIn(200);
    $(this).addClass("disabled");
    window.parent
      .$(".qbAddEmail.disabled")
      .popover({
        content:
          '<span style="width:180px; font-size: 12px; font-weight:700; color:#333;">Max 2 Emails .. Remove One<br>To Add A New Email</span>',
        html: true,
        placement: "bottom",
        trigger: "hover",
        container: $(this).closest("body"),
      });
  });
  window.parent.$(".removeQBEmail").on("click", function () {
    $(this).closest(".QBemail2").hide();
    window.parent.$(".qbAddEmail").removeClass("disabled");
    window.parent.$(".qbAddEmail").popover("destroy");
  });
  window.parent.$(".qbInput").on("change", function () {
    var validator = $(this).closest("form").validate();
    var validForm = $(this).closest("form").valid();
    var valid = $(this).valid();
    if (!valid) {
      $(this).closest(".input-group").removeClass("success");
      $(this).closest(".input-group").addClass("error");
      $(this).closest(".input-group").prev(".qbIcon").removeClass("active");
      $(this).closest(".input-group").prev(".qbIcon").addClass("error");
    } else {
      $(this).closest(".input-group").removeClass("error");
      $(this).closest(".input-group").addClass("success");
      $(this).closest(".input-group").prev(".qbIcon").removeClass("error");
      $(this).closest(".input-group").prev(".qbIcon").addClass("active");
    }
    if (validForm) {
      CurrentSelectedObj.removeClass("setupMode");
    } else {
      CurrentSelectedObj.addClass("setupMode");
    }
  });
  window.parent
    .$("#showFormLabels")
    .on("change", function (e, manualEventData) {
      let isShown = $(this).is(":checked");
      if (typeof manualEventData !== "undefined") {
        isShown = manualEventData.checked;
      }
      window.parent.$(".labelStyleContainer").toggle(isShown);
      CurrentSelectedObj.attr("data-showFormLabel", isShown);
      if (isShown) {
        CurrentSelectedObj.find(".optinForm label.spLabelControl").show();
      } else {
        CurrentSelectedObj.find(".optinForm label.spLabelControl").hide();
      }
    });
  window.parent.$(".labelFontSize").on("change", function () {
    var val = $(this).find("option:selected").val();
    CurrentSelectedObj.find("label.spLabelControl").css(
      "font-size",
      val + "px"
    );
    CurrentSelectedObj.attr("data-labelFontSize", val + "px");
  });
  window.parent.$(".eye-view.qb-branding-image").on("click", function () {
    var check = $(this).hasClass("eye-not-active");
    if (!check) {
      CurrentSelectedObj.find(".speakerImageHolder").fadeOut(200);
      CurrentSelectedObj.find(".askEditor, .asktoEditor").addClass("centerIt");
    } else {
      CurrentSelectedObj.find(".speakerImageHolder").fadeIn(200);
      CurrentSelectedObj.find(".askEditor, .asktoEditor").removeClass(
        "centerIt"
      );
    }
  });
  window.parent.$(".QBBrandingImage").on("click", function () {
    CurrentSelectedObj.find(
      '.speakerImageHolder a[href="#gallery"]'
    )[0].click();
  });
  window.parent.$(".formChoicesFontSize").on("change", function () {
    var val = $(this).find("option:selected").val();
    CurrentSelectedObj.find(".custom_styled_choice").css(
      "font-size",
      val + "px"
    );
    CurrentSelectedObj.attr("data-choicesFontSize", val + "px");
  });
  window.parent.$(".formChoicesFontColor2").spectrum({
    color: '""' + $(this).data("color") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(".custom_styled_choice ").css(
        "color",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-choicesColor", color.toRgbString());
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(".custom_styled_choice").css(
        "color",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
      CurrentSelectedObj.attr("data-choicesColor", color.toRgbString());
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$("#designer-panel .formChoicesControls2").spectrum({
    color: '""' + $(this).data("color") + '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(
        ".custom_styled_choice input:checked~.cc_checkmark,.custom_styled_choice input:checked~.rb_checkmark"
      ).css("background-color", color.toRgbString());
      CurrentSelectedObj.find(".custom_styled_choice").attr(
        "data-selectedColor",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(
        ".custom_styled_choice input:checked~.cc_checkmark,.custom_styled_choice input:checked~.rb_checkmark"
      ).css("background-color", color.toRgbString());
      CurrentSelectedObj.find(".custom_styled_choice").attr(
        "data-selectedColor",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  var ImageAlign = CurrentSelectedObj.attr("data-Imgalign");
  var myWidthSelect = window.parent.$(".image-size-select");
  parentWidth = CurrentSelectedObj.find(".elementImageHolder").width();
  myImageWidth = CurrentSelectedObj.find(".elementImageHolder img").width();
  myprecentage = myImageWidth / parentWidth;
  if (myWidthSelect !== "undefined") {
    if (myImageWidth >= parentWidth || myprecentage > 0.76) {
      myWidthSelect.val(4);
    } else if (myprecentage > 0.51) {
      myWidthSelect.val(3);
    } else if (myprecentage > 0.26) {
      myWidthSelect.val(2);
    } else if (myprecentage > 0.11) {
      myWidthSelect.val(1);
    } else {
      myWidthSelect.val(0);
    }
  }
  if (ImageAlign != undefined) {
    if (ImageAlign == "left") {
      window.parent.$(".alignmentImgIcons .fa-align-left").trigger("click");
    }
    if (ImageAlign == "center") {
      window.parent.$(".alignmentImgIcons .fa-align-center").trigger("click");
    }
    if (ImageAlign == "right") {
      window.parent.$(".alignmentImgIcons .fa-align-right").trigger("click");
    }
  }
  var coverType = CurrentSelectedObj.attr("data-covertype");
  if (coverType != undefined) {
    window.parent.$(".video-cover, .image-cover").removeClass("active");
    window.parent.$(".video-cover, .image-cover").prop("checked", false);
    if (coverType == "video") {
      window.parent.$(".video-cover").addClass("active");
      window.parent.$(".video-cover").prop("checked", true);
    } else {
      window.parent.$(".image-cover").addClass("active");
      window.parent.$(".image-cover").prop("checked", true);
    }
  }
}
$(document).on("click", ".gearNavMenu", function () {
  $(this)
    .closest(".navElement")
    .find(".menuContainer .fa-cog:first")[0]
    .click();
});
$(document).on("click", "a.imageElmGear", function (e) {
  e.preventDefault();
  Gallery.showGallery({
    target: $(this).closest(".imgElement").find(".elementImageHolder img"),
    type: "image",
    ratio: "16:9,9:16,4:3,3:4,1:1",
    showLogosGallery: false,
    activeSection: "cropper",
  });
});
$(document).on("click", ".gearImageList", function (e) {
  e.preventDefault();
  Gallery.showGallery({
    target: $(this).closest(".imageListElement").find("ul.listUL"),
    type: "li-list-icon",
    ratio: "1:1",
    enableCropper: false,
    showMyGallery: false,
    showStockGallery: false,
    showLogosGallery: true,
    activeSection: "icons",
    showSEO: false,
  });
});
$(document).on("click", ".gearVidElement", function () {
  $(this)
    .closest(".vidElement")
    .find(".elementVideoHolder .vid-overlay a.videoModalTrigger")
    .trigger("click");
});
$(document).on(
  "click",
  ".gearTriggerElement:not(.formGearTrigger)",
  function () {
    window.parent.$(".controlsDivGeneral").hide();
    window.parent.$(".controlsDivGeneral.formElementControlsWrapper").hide();
  }
);
function checkSetupMode() {
  if (CurrentSelectedObj.hasClass("setupMode") == true) {
    CurrentSelectedObj.removeClass("setupMode");
  }
}
function refreshPhoneFieldsAutoComplete() {
  CurrentSelectedObj.find(".phoneNumber").intlTelInput("destroy");
  CurrentSelectedObj.find(".phoneNumber").attr(
    "data-iso",
    businessDetails.contact_phone_iso
  );
  CurrentSelectedObj.find(".phoneNumber").intlTelInput({
    dropdownContainer: "body",
    defaultCountry: businessDetails.contact_phone_iso,
    allowDropdown: false,
  });
  CurrentSelectedObj.find(
    ".formElementHolder .spots-phone-number .spots-phonenumberpopup"
  ).attr("data-iso", businessDetails.contact_phone_iso);
  CurrentSelectedObj.find(
    ".formElementHolder .spots-phone-number .spots-phonenumberpopup"
  ).intlTelInput({
    defaultCountry: businessDetails.contact_phone_iso,
    allowDropdown: false,
  });
}
$(document).on("click", ".main-faq-container.slide .faq-icon", function () {
  mainFAQcontainer = $(this).parent().parent();
  mainFAQcontainer.toggleClass("open");
  mainFAQcontainer
    .find(".faq-icon > i")
    .toggleClass("fa-minus")
    .toggleClass("fa-plus");
  mainFAQcontainer.find(".faq-body").slideToggle();
});
(function ($) {
  if ($.fn.style) {
    return;
  }
  var escape = function (text) {
    return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
  };
  var isStyleFuncSupported = !!CSSStyleDeclaration.prototype.getPropertyValue;
  if (!isStyleFuncSupported) {
    CSSStyleDeclaration.prototype.getPropertyValue = function (a) {
      return this.getAttribute(a);
    };
    CSSStyleDeclaration.prototype.setProperty = function (
      styleName,
      value,
      priority
    ) {
      this.setAttribute(styleName, value);
      var priority = typeof priority != "undefined" ? priority : "";
      if (priority != "") {
        var rule = new RegExp(
          escape(styleName) + "\\s*:\\s*" + escape(value) + "(\\s*;)?",
          "gmi"
        );
        this.cssText = this.cssText.replace(
          rule,
          styleName + ": " + value + " !" + priority + ";"
        );
      }
    };
    CSSStyleDeclaration.prototype.removeProperty = function (a) {
      return this.removeAttribute(a);
    };
    CSSStyleDeclaration.prototype.getPropertyPriority = function (styleName) {
      var rule = new RegExp(
        escape(styleName) + "\\s*:\\s*[^\\s]*\\s*!important(\\s*;)?",
        "gmi"
      );
      return rule.test(this.cssText) ? "important" : "";
    };
  }
  $.fn.style = function (styleName, value, priority) {
    var node = this.get(0);
    if (typeof node == "undefined") {
      return this;
    }
    var style = this.get(0).style;
    if (typeof styleName != "undefined") {
      if (typeof value != "undefined") {
        priority = typeof priority != "undefined" ? priority : "";
        style.setProperty(styleName, value, priority);
        return this;
      } else {
        return style.getPropertyValue(styleName);
      }
    } else {
      return style;
    }
  };
})(jQuery);
if (self == top) {
  window.parent.$(".toogleBtnOptions").click(function () {
    $(this).parent().parent().find(".optionsSubContainer").slideToggle();
    $(this).parent().parent().find(".optionsSubContainer").toggleClass("close");
    if (
      $(this).parent().parent().find(".optionsSubContainer").hasClass("close")
    ) {
      $(this).html("<i class='fa fa-plus'></i> Open");
    } else {
      $(this).html("<i class='fa fa-minus'></i> Close");
    }
  });
}
function updateImageSize(size) {
  targetSize = 0;
  if (size == "0") {
    targetSize = "10%";
  } else if (size == "1") {
    targetSize = "25%";
  } else if (size == "2") {
    targetSize = "50%";
  } else if (size == "3") {
    targetSize = "75%";
  } else if (size == "4") {
    targetSize = "100%";
  }
  CurrentSelectedObj.find(".elementImageHolder img").css("width", targetSize);
}
function refreshRssPosts(data, CurrentSelectedRssObj) {
  CurrentSelectedRssObj.find(".post-main-container").hide();
  var itemLength = data.items.length;
  var rssPostCount = 3;
  if (CurrentSelectedRssObj.attr("data-postcount") != undefined) {
    rssPostCount = CurrentSelectedRssObj.attr("data-postcount");
  }
  if (itemLength == 0) {
    CurrentSelectedRssObj.find(".empty-rss").show();
  } else {
    CurrentSelectedRssObj.find(".empty-rss").hide();
    for (i = 0; i < itemLength; i++) {
      if (i < rssPostCount) {
        var targetpost = CurrentSelectedRssObj.find(
          ".post-main-container.post-" + (i + 1)
        );
        targetpost.css("display", "inline-block");
        if (data.items[i].enclosure.thumbnail != undefined) {
          targetpost
            .find(".post-img-container img")
            .attr("src", data.items[i].enclosure.thumbnail);
          targetpost.find(".post-img-container .image-placeholder").hide();
        } else if (
          data.items[i].thumbnail != undefined &&
          data.items[i].thumbnail
        ) {
          targetpost
            .find(".post-img-container img")
            .attr("src", data.items[i].thumbnail);
        } else {
          targetpost.find(".post-img-container img").attr("src", "");
          targetpost.find(".post-img-container .image-placeholder").show();
        }
        targetpost
          .find(".post-container .post-date span")
          .html(formatDate(new Date(data.items[i].pubDate)));
        targetpost
          .find(".post-container .post-title")
          .html(data.items[i].title);
        targetpost
          .find(".post-container .post-title")
          .attr("title", data.items[i].title);
        targetpost
          .find(".post-container .post-details")
          .html(data.items[i].description);
        targetpost
          .find(".post-container .post-button")
          .attr("data-button-url", data.items[i].link);
        targetpost
          .find(".post-container .post-button")
          .attr("href", data.items[i].link);
      } else {
        break;
      }
    }
  }
}
function colorPickerImageGalleryElements() {
  window.parent.$(".hoverOverlayBg").spectrum({
    color:
      '""' +
      CurrentSelectedObj.find(".gallery-hover-overlay").css("background") +
      '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(".gallery-hover-overlay").css(
        "background",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(".gallery-hover-overlay").css(
        "background",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$(".hoverOverlayTextColor").spectrum({
    color:
      '""' +
      CurrentSelectedObj.find(".gallery-hover-overlay").css("color") +
      '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(".gallery-hover-overlay").css(
        "color",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(".gallery-hover-overlay").css(
        "color",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
  window.parent.$(".imageBorderColor").spectrum({
    color:
      '""' +
      CurrentSelectedObj.find(".outerImageContainer").css("border-color") +
      '"',
    showInput: true,
    className: "full-color-spectrum",
    showInitial: true,
    showPalette: true,
    showPaletteOnly: false,
    showAlpha: true,
    showSelectionPalette: true,
    maxSelectionSize: 10,
    preferredFormat: "hex",
    chooseText: "Save",
    cancelText: "Cancel",
    togglePaletteOnly: true,
    togglePaletteMoreText: "Advanced",
    togglePaletteLessText: "Simple",
    move: function (color) {
      CurrentSelectedObj.find(".outerImageContainer").css(
        "border-color",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    show: function () {},
    beforeShow: function () {},
    hide: function (color) {
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    change: function (color) {
      CurrentSelectedObj.find(".outerImageContainer").css(
        "border-color",
        color.toRgbString()
      );
      var cval =
        "rgba(" +
        Math.floor(color._r) +
        "," +
        Math.floor(color._g) +
        "," +
        Math.floor(color._b) +
        "," +
        color._a +
        ")";
    },
    palette: [
      ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
      ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
      [
        "#f4cccc",
        "#fce5cd",
        "#fff2cc",
        "#d9ead3",
        "#d0e0e3",
        "#cfe2f3",
        "#d9d2e9",
        "#ead1dc",
      ],
      [
        "#ea9999",
        "#f9cb9c",
        "#ffe599",
        "#b6d7a8",
        "#a2c4c9",
        "#9fc5e8",
        "#b4a7d6",
        "#d5a6bd",
      ],
      [
        "#F79999",
        "#F9DD9C",
        "#FFF399",
        "#B6E6A8",
        "#A2C4DA",
        "#8eb9e1",
        "#B4A7EB",
        "#E8AABD",
      ],
      [
        "#e06666",
        "#f6b26b",
        "#ffd966",
        "#93c47d",
        "#76a5af",
        "#6fa8dc",
        "#8e7cc3",
        "#c27ba0",
      ],
      [
        "#c00",
        "#e69138",
        "#f1c232",
        "#6aa84f",
        "#45818e",
        "#3d85c6",
        "#674ea7",
        "#a64d79",
      ],
      [
        "#900",
        "#b45f06",
        "#bf9000",
        "#38761d",
        "#134f5c",
        "#0b5394",
        "#351c75",
        "#741b47",
      ],
      [
        "#AB0000",
        "#C76906",
        "#CF6E00",
        "#33601D",
        "#123549",
        "#07457C",
        "#3F2368",
        "#5c0e34",
      ],
      [
        "#600",
        "#783f04",
        "#7f6000",
        "#274e13",
        "#0c343d",
        "#073763",
        "#20124d",
        "#4c1130",
      ],
    ],
  });
}
$(document).ready(function () {
  $("div.droppableElementArea").each(function () {
    if ($(this).hasClass("blogpost-element") === true) {
      var CurrentSelectedRssObj = $(this);
      if (CurrentSelectedRssObj.attr("data-rssurl") != undefined) {
        $.ajax({
          type: "GET",
          url:
            "https://api.rss2json.com/v1/api.json?rss_url=" +
            CurrentSelectedRssObj.attr("data-rssurl"),
          dataType: "jsonp",
          success: function (data) {
            refreshRssPosts(data, CurrentSelectedRssObj);
          },
        });
      }
    }
  });
});
$("body").click(function () {
  if (window.parent.$(".bodyBgColorSpectrum").length > 0) {
    window.parent.$(".bodyBgColorSpectrum").spectrum("hide");
    window.parent.$(".fixed-header .dropdown").removeClass("open");
  }
});
var FormFieldLabels = {
  applyBuilderSettingsToPreview: function (elementResource, _forceRefresh) {
    let forceRefresh = _forceRefresh;
    setTimeout(function () {
      let labelsColor = elementResource.attr("data-labelcolor")
        ? elementResource.data("labelcolor")
        : "rgb(0, 0, 0)";
      FormFieldLabels.refreshBuilderSettings(elementResource, forceRefresh);
      window.parent.$(".labelFontSize").trigger("change");
      CurrentSelectedObj.find(".formElementHolder label.spLabelControl ").css(
        "color",
        labelsColor
      );
    }, 100);
  },
  refreshBuilderSettings: function (elementResource, _forceRefresh) {
    let forceRefresh = _forceRefresh;
    let labelsEnabled =
      elementResource.attr("data-showformlabel") == "true" ? true : false;
    let labelsColor = elementResource.attr("data-labelcolor")
      ? elementResource.data("labelcolor")
      : "rgb(0, 0, 0)";
    let labelsSize = elementResource.attr("data-labelfontsize")
      ? elementResource.data("labelfontsize")
      : "16px";
    let controlColor = elementResource.attr("data-selectedcolor")
      ? elementResource.data("selectedcolor")
      : "#3498db";
    let controlTextColor = elementResource.attr("data-choicescolor")
      ? elementResource.data("choicescolor")
      : "rgb(0, 0, 0)";
    let controlTextSize = elementResource.attr("data-choicesfontsize")
      ? elementResource.data("choicesfontsize")
      : "16px";
    window.parent
      .$(".labelFontColor")
      .data("color", labelsColor)
      .val(labelsColor);
    PB_Helpers_Colors.setSpectrum(
      window.parent.$(".labelFontColor"),
      labelsColor,
      Elements_Forms._spectrumFieldsLabelCallback,
      true,
      false
    );
    window.parent
      .$(".formChoicesControls")
      .data("color", controlColor)
      .val(controlColor);
    PB_Helpers_Colors.setSpectrum(
      window.parent.$(".formChoicesControls"),
      controlColor,
      Elements_Forms._spectrumFieldsControlsCallback,
      true,
      false
    );
    window.parent
      .$(".formChoicesFontColor")
      .data("color", controlTextColor)
      .val(controlTextColor);
    PB_Helpers_Colors.setSpectrum(
      window.parent.$(".formChoicesFontColor"),
      controlTextColor,
      Elements_Forms._spectrumFieldsControlsTextCallback,
      true,
      false
    );
    setTimeout(function () {
      FormFieldIcon.applyBuilderSettingsToControlPanel(CurrentSelectedObj);
      window.parent.$(".labelFontSize").trigger("change");
      if (
        CurrentSelectedObj.find(".radioButtonField").length > 0 ||
        CurrentSelectedObj.find(".checkBoxField").length > 0
      ) {
        window.parent.$("#designer-panel .form_choices_controls").show();
        window.parent.$("#designer-panel .form_choices_text").show();
      } else {
        window.parent.$("#designer-panel .form_choices_text").hide();
        window.parent.$("#designer-panel .form_choices_controls").hide();
      }
      window.parent
        .$("#showFormLabels")
        .prop("checked", labelsEnabled)
        .trigger("change", { checked: labelsEnabled });
      window.parent
        .$("select.labelFontSize")
        .val(labelsSize.replace("px", ""))
        .selectpicker("render");
      window.parent
        .$("select.formChoicesFontSize")
        .val(controlTextSize.replace("px", ""))
        .selectpicker("render");
      window.parent
        .$(".labelFontColor")
        .data("color", labelsColor)
        .val(labelsColor);
      PB_Helpers_Colors.setSpectrum(
        window.parent.$(".labelFontColor"),
        labelsColor,
        Elements_Forms._spectrumFieldsLabelCallback,
        true,
        false
      );
      window.parent
        .$(".formChoicesControls")
        .data("color", controlColor)
        .val(controlColor);
      PB_Helpers_Colors.setSpectrum(
        window.parent.$(".formChoicesControls"),
        controlColor,
        Elements_Forms._spectrumFieldsControlsCallback,
        true,
        false
      );
      window.parent
        .$(".formChoicesFontColor")
        .data("color", controlTextColor)
        .val(controlTextColor);
      PB_Helpers_Colors.setSpectrum(
        window.parent.$(".formChoicesFontColor"),
        controlTextColor,
        Elements_Forms._spectrumFieldsControlsTextCallback,
        true,
        false
      );
      if (forceRefresh === true) {
        window.parent
          .$("#designer-panel select.labelFontSize")
          .trigger("change");
        window.parent.$("select.formChoicesFontSize").trigger("change");
        CurrentSelectedObj.find(".custom_styled_choice ").css(
          "color",
          controlTextColor
        );
        CurrentSelectedObj.find(
          ".custom_styled_choice input:checked~.cc_checkmark,.custom_styled_choice input:checked~.rb_checkmark"
        ).css("background-color", controlColor);
        CurrentSelectedObj.find(".custom_styled_choice").attr(
          "data-selectedColor",
          controlColor
        );
      }
    }, 400);
  },
};
var FormFieldEntity = {
  applyBuilderSettingsToControlPanel: function (elementResource) {
    let fieldSize = elementResource.attr("data-fieldsize");
    if (fieldSize == "undefined" || fieldSize == "" || fieldSize == null) {
      fieldSize = "small";
    }
    setTimeout(function () {
      let labelSize = window.parent.$("#formfields .labelFontSize").val();
      window.parent
        .$("#formfields .fieldSizeWrapper .fieldSize")
        .removeClass("active");
      window.parent
        .$("#formfields .fieldSizeWrapper .fieldSize." + fieldSize + "")
        .addClass("active")
        .trigger("click");
      window.parent
        .$("#formfields .labelFontSize")
        .val(labelSize)
        .trigger("change");
    }, 100);
  },
};
var FormFieldIcon = {
  applyBuilderSettingsToControlPanel: function (elementResource) {
    let icons = true;
    let fieldIcons = elementResource.attr("data-fieldicons");
    if (
      fieldIcons == "undefined" ||
      fieldIcons == "" ||
      fieldIcons == null ||
      fieldIcons == "false"
    ) {
      icons = false;
    }
    setTimeout(function () {
      if (icons === true) {
        elementResource
          .find(".formElementHolder .spots-fields-wrapper")
          .each(function () {
            $(this).find(".inner-addon .fa").fadeIn(10);
            $(this)
              .find(".inner-addon input")
              .each(function () {
                $(this).style("padding-left", "", "important");
              });
          });
        window.parent.$("#fieldIcons").prop("checked", true);
      } else {
        elementResource
          .find(".formElementHolder .spots-fields-wrapper")
          .each(function () {
            $(this).find(".inner-addon .fa").fadeOut(10);
            $(this)
              .find(".inner-addon input")
              .each(function () {
                $(this).style("padding-left", "12px", "important");
              });
          });
        window.parent.$("#fieldIcons").prop("checked", false);
      }
    }, 100);
  },
};
function validateEmail(email) {
  var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  return re.test(email);
}
function validatePhone(phone) {
  var re = /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im;
  return re.test(phone);
}
function validateUrl(url) {
  if (
    /^(http|https|ftp):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,15}(:[0-9]{1,15})?(\/.*)?$/i.test(
      url
    )
  ) {
    return true;
  } else {
    return false;
  }
}
var Public_PB = {
  init: function () {
    this.removeTollBox();
    this.fixInlineLinkUrls();
    this.setTextResponsive();
    this.addPluginFunctionality();
    this.addCustomCodeFunctionality();
    this.fixOldElements();
    this.setVideoAutoPlay();
    this.setClickableImages();
    this.initLazyLoad();
    this.initTabsBlockResponsive();
    this.initHeaderToggleMenu();
    this.socialLinkAction();
    this.initGoogleMaps();
    this.initTabSpecialActions();
    setTimeout(function () {
      Public_PB.initRssFieldLinks();
    }, 1000);
  },
  removeTollBox: function () {
    $(".customHtmlElement .elementCustomHtmlHolder").remove();
    $("section").each(function (i, section) {
      var $this = $(section);
      $this
        .removeClass("ui-sortable")
        .removeClass("ui-droppable")
        .removeClass("pulse")
        .removeClass("builderCss");
      $this.find("div.blockRowContainer.empty").remove();
      $this.find(".instructions").closest(".droppableElementArea").remove();
      $this.find(".addInnerRowHolder").remove();
      $this.find(".xxTitle").remove();
      $this.find(".make-captcha-disabled").remove();
      $this.find(".inner-addon.captcha .g-recaptcha").html("");
      $this.find(".section-cp").remove();
      $this.find(".toolbox").remove();
      $this.find(".toolbox-right").remove();
      $this.find(".toolbox-row-col").remove();
      $this.find(".section-title").remove();
      $this.find(".addRowHolder").remove();
      $this.find(".sticky-popover-row").removeClass("sticky-popover-row");
      $this.find(".function-overlay.text-center").remove();
      $this.find("div.updateIconTop").remove();
      $this.find("div.updateIcon").remove();
      $this.find(".toolbox-right-row-col").remove();
      $this.find(".rowColTitle").remove();
      $this.find(".toolbox-right-element").remove();
      $this.find(".innerTabGear.gearTriggerElement").remove();
      $("div, p, span, h1, h2, h3, h4, h5, strong, label, span, a", $this).each(
        function (i, sectionDivs) {
          var $sectionDivs = $(sectionDivs);
          $sectionDivs
            .removeClass("content-editor")
            .removeClass("cke_editable")
            .removeClass("cke_editable_inline")
            .removeClass("cke_contents_ltr");
          if (typeof $sectionDivs.attr("contenteditable") !== "undefined") {
            $sectionDivs.attr("contenteditable", "false");
          }
          $sectionDivs
            .removeClass("edit-row")
            .removeClass("resizeCol")
            .removeClass("edit-shadow");
          if ($sectionDivs.hasClass("img-overlay")) {
            $sectionDivs.remove();
          }
          if ($sectionDivs.hasClass("toolbox-element")) {
            $sectionDivs.remove();
          }
          if ($sectionDivs.hasClass("resizeIcon")) {
            $sectionDivs.remove();
          }
        }
      );
      $("ul.menuContainer li i.fa.fa-cog").remove();
      $("div.vid-overlay").remove();
      $("div.droppableElementArea.ui-droppable div.instructions div.inner")
        .parent()
        .parent()
        .remove();
      $("span, div", $this).removeAttr("tabindex");
    });
  },
  fixInlineLinkUrls: function () {
    $("a[data-cke-saved-href]").each(function (i, element) {
      var $this = $(this);
      var dataLink = $(element).attr("href");
      if (typeof dataLink == "undefined") return;
      if (dataLink.indexOf("show/add_click_to_custom_links") != -1) {
        dataLink = $(element).attr("data-href");
      }
      var linkDetails = [];
      if (dataLink == "" || typeof dataLink == "undefined" || dataLink == "#") {
        return;
      }
      if (dataLink.indexOf("hfpage://") != -1) {
        dataLink = dataLink.replace("hfpage://", "");
        $this.attr("href", siteUrl + "/show-page/" + dataLink);
      }
      if (dataLink == "next-page-positive") {
        $this.attr("href", $("#f-navigator-yes").attr("href"));
      } else if (dataLink == "next-page-negative") {
        $this.attr("href", $("#f-navigator-no").attr("href"));
      }
    });
  },
  setTextResponsive: function () {
    $(window).on("resize", function () {
      Public_PB._makeTextResponsive();
      Public_PB._makeBoxResponsive();
    });
    Public_PB._makeTextResponsive();
    Public_PB._makeBoxResponsive();
  },
  _makeTextResponsive: function () {
    if ($(window).width() < 780) {
      $(".feature-block-7 .ImgGroupIcon.bottom").each(function (i) {
        textBlock = $(this).parent().find(".textContainer");
        $(this).detach();
        $(textBlock).before($(this));
      });
      $("section.instantBlock").each(function (i) {
        if ($(this).find(".text-responsive-column").length > 0) {
          TextBlock = $(this).find(".text-responsive-column");
          $(TextBlock).detach();
          $(this).find(".image-responsive-column").after($(TextBlock));
        }
      });
    } else {
      $(".feature-block-7 .ImgGroupIcon.bottom").each(function (i) {
        textBlock = $(this).parent().find(".textContainer");
        $(this).detach();
        $(textBlock).after($(this));
      });
      $("section.instantBlock").each(function (i) {
        if ($(this).find(".text-responsive-column").length > 0) {
          TextBlock = $(this).find(".text-responsive-column");
          $(TextBlock).detach();
          $(this).find(".image-responsive-column").before($(TextBlock));
        }
      });
    }
  },
  _makeBoxResponsive: function () {
    $("section")
      .find("[data-rowalign]")
      .each(function () {
        SetRowAlign($(this), $(this).attr("data-rowalign"));
      });
  },
  addPluginFunctionality: function () {
    return;
    $(".formElementHolder .spots-phone-number .spots-phonenumberpopup").each(
      function () {
        $(this).intlTelInput({ defaultCountry: $(this).attr("data-iso") });
      }
    );
  },
  addCustomCodeFunctionality: function () {
    $(".elements-control.customHtmlElement").each(function (i, element) {
      var codeType = $(element).data("customelementtype");
      $(element).find(".elementCustomHtmlHolder").remove();
      $(element).find(".elementCustomHtmlCodeHolder").remove();
      $(element).find(".elementWrapper").show();
      if (codeType == "regular") {
        $(element).find(".elementCustomHtmlJsCodeHolder").show();
      } else {
        $(element).find(".elementCustomHtmlEmbedCodeHolder").show();
      }
    });
  },
  setVideoAutoPlay: function () {
    $(".videoPlaceHolder").each(function (i, videoPlaceholder) {
      var videoItem = $(videoPlaceholder).find(".embed-responsive-item");
      if (
        typeof $(videoPlaceholder).data("autoplay") === "undefined" ||
        $(videoPlaceholder).data("autoplay") != true
      ) {
        return true;
      }
      if (
        typeof videoItem.attr("src") !== "undefined" &&
        videoItem.is(":visible")
      ) {
        videoItem.attr(
          "src",
          videoItem.attr("src").replace("autoplay=0", "autoplay=1")
        );
      }
    });
  },
  fixOldElements: function () {
    $(".brandingElement .logo-image img").each(function () {
      if ($(this).attr("style") == undefined) {
        $(this).css("width", "30px");
      }
    });
  },
  setClickableImages: function () {
    $("img").each(function () {
      if (
        $(this).attr("data-imglink") !== undefined &&
        $(this).attr("data-imglink") != ""
      ) {
        $(this).css("cursor", "pointer");
        $(this).on("click", function () {
          var url = $(this).attr("data-imglink");
          window.open(url, "_blank");
        });
      }
    });
  },
  initGoogleMaps: function () {
    var map_script_exits = false;
    var scripts = document.getElementsByTagName("script");
    for (var i = 0; i < scripts.length; i++) {
      if (scripts[i].src) {
        var script_src = scripts[i].src;
        var pattern = /(maps\.googleapis\.com\/maps\/api\/js)+?/gm;
        if (pattern.test(script_src)) {
          console.log("script included");
          map_script_exits = true;
        }
      }
    }
    if (map_script_exits) {
      Public_PB.setGoogleMaps();
    } else {
      let script = document.createElement("script");
      script.setAttribute(
        "src",
        "https://maps.googleapis.com/maps/api/js?key=" + google_map_api
      );
      script.onload = function () {
        Public_PB.setGoogleMaps();
      };
      document.body.appendChild(script);
    }
  },
  setGoogleMaps: function () {
    $(".mapElement").each(function (i) {
      CurrentSelectedObj = $(this);
      if ($(CurrentSelectedObj).find("iframe.mapFrame").length == 0) {
        if (CurrentSelectedObj.attr("data-maptype") !== undefined) {
          if (CurrentSelectedObj.attr("data-maptype") == "address") {
            var zoom = CurrentSelectedObj.attr("data-zoom");
            var mapcompname = CurrentSelectedObj.attr("data-compname");
            var mapAddress = CurrentSelectedObj.attr("data-address");
            var mapCity = CurrentSelectedObj.attr("data-city");
            var map = new google.maps.Map(
              CurrentSelectedObj.find(".map").get(0),
              { zoom: parseInt(zoom) }
            );
            var geocoder = new google.maps.Geocoder();
            geocoder.geocode(
              { address: mapcompname + " " + mapAddress + " " + mapCity },
              function (results, status) {
                if (status == google.maps.GeocoderStatus.OK) {
                  new google.maps.Marker({
                    position: results[0].geometry.location,
                    map: map,
                  });
                  map.setCenter(results[0].geometry.location);
                }
              }
            );
          } else if (CurrentSelectedObj.attr("data-maptype") == "lat") {
            var lat = CurrentSelectedObj.attr("data-lat");
            var lon = CurrentSelectedObj.attr("data-lon");
            var zoom = CurrentSelectedObj.attr("data-zoom");
            var map = new google.maps.Map(
              CurrentSelectedObj.find(".map").get(0),
              {
                center: { lat: parseFloat(lat), lng: parseFloat(lon) },
                zoom: parseInt(zoom),
              }
            );
            var latlng = new google.maps.LatLng(
              parseFloat(lat),
              parseFloat(lon)
            );
            new google.maps.Marker({ position: latlng, map: map });
          }
        } else {
          InitMapElement(CurrentSelectedObj);
        }
      }
    });
    function InitMapElement(currentElm) {
      if ($(currentElm).find("iframe.mapFrame").length == 0) {
        setTimeout(function () {
          var map = new google.maps.Map($(currentElm).find(".map").get(0), {
            zoom: 18,
          });
          var geocoder = new google.maps.Geocoder();
          geocoder.geocode(
            { address: "Pizza Hut Express 12 E 125th St New York" },
            function (results, status) {
              if (status == google.maps.GeocoderStatus.OK) {
                new google.maps.Marker({
                  position: results[0].geometry.location,
                  map: map,
                });
                map.setCenter(results[0].geometry.location);
              }
            }
          );
        }, 1000);
      }
    }
  },
  initLazyLoad: function () {
    window.lazySizesConfig = window.lazySizesConfig || {};
    window.lazySizesConfig.lazyClass = "lazyload-public";
  },
  initTabsBlockResponsive: function () {
    $("section").each(function (i, section) {
      var $this = $(section);
      if ($this.find(".tabs-element").length > 0) {
        generateNewIdsForTabs($this);
        makeTabsResponsive($this);
      }
    });
  },
  initHeaderToggleMenu: function () {
    $(document).on(
      "click",
      '#header-block-1 button[data-toggle="collapse"]',
      function () {
        if (
          !$(
            "#header-block-1 .nav-element.navbar-collapse.header-navbar-collapse"
          ).hasClass("in")
        ) {
          if ($("#header-block-1 .closeSideMenu").length == 0) {
            $(
              "#header-block-1 .nav-element.navbar-collapse.header-navbar-collapse .header-menu-wrapper"
            ).before(
              '<a href="#" class="closeSideMenu navbar-toggle collapsed" data-toggle="collapse" data-target=".header-navbar-collapse"><?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"width="10px" height="15px" viewBox="0 0 357 357" style="enable-background:new 0 0 357 357;" xml:space="preserve"><g><g id="close"><polygon points="357,35.7 321.3,0 178.5,142.8 35.7,0 0,35.7 142.8,178.5 0,321.3 35.7,357 178.5,214.2 321.3,357 357,321.3 214.2,178.5"/></g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g></svg></a>'
            );
          }
          $("#header-block-1 .closeSideMenu svg").css(
            "fill",
            $("#header-block-1 .header-menu-wrapper .menuContainer").css(
              "color"
            )
          );
          if (
            $("#header-block-1 > .cover-overlay").css("background-color") !=
            "rgba(0, 0, 0, 0)"
          ) {
            $(
              "#header-block-1 .nav-element.navbar-collapse.header-navbar-collapse"
            ).css(
              "background-color",
              $("#header-block-1 > .cover-overlay").css("background-color")
            );
          }
        }
      }
    );
    $(document).on("click", "#header-block-1 .menuContainer a", function () {
      if ($(window).width() <= 600) {
        $('#header-block-1 button[data-toggle="collapse"]').trigger("click");
      }
    });
    window.onscroll = function () {
      Public_PB.scrollFunction();
    };
  },
  scrollFunction: function () {
    myScrollTopButton = document.getElementById("myScrollTopButton");
    if (typeof myScrollTopButton != "undefined" && myScrollTopButton != null) {
      if (
        document.body.scrollTop > 50 ||
        document.documentElement.scrollTop > 50
      ) {
        myScrollTopButton.style.display = "block";
      } else {
        myScrollTopButton.style.display = "none";
      }
    } else {
      $("body").append(
        '<button id="myScrollTopButton" title="Go to top" style="display:none;"><i class="fa fa-angle-up"></i></button>'
      );
      myScrollTopButton = document.getElementById("myScrollTopButton");
      $(document).on("click", "#myScrollTopButton", function () {
        Public_PB.topFunction();
      });
    }
  },
  topFunction: function () {
    document.body.scrollTop = 0;
    document.documentElement.scrollTop = 0;
  },
  socialLinkAction: function () {
    $(document).on("click", ".SocialWrapper ul .socialLink a", function (e) {
      e.preventDefault();
      if ($(this).attr("href") != "" && $(this).attr("href") != "#") {
        window.open($(this).attr("href"), "_blank");
      }
    });
  },
  initTabSpecialActions: function () {
    var ActivetabId = Public_PB.getUrlParameter("tabId");
    if (ActivetabId) {
      if (ActivetabId != "") {
        $('.tabs-element a[href="#' + ActivetabId + '"]').trigger("click");
      }
    }
  },
  getUrlParameter: function (sParam) {
    var sPageURL = window.location.search.substring(1),
      sURLVariables = sPageURL.split("&"),
      sParameterName,
      i;
    for (i = 0; i < sURLVariables.length; i++) {
      sParameterName = sURLVariables[i].split("=");
      if (sParameterName[0] === sParam) {
        return sParameterName[1] === undefined
          ? true
          : decodeURIComponent(sParameterName[1]);
      }
    }
  },
  initRssFieldLinks: function () {
    $(".post-main-container .post-container .blog-text-container").each(
      function (i, blogItem) {
        let blogItemResource = $(blogItem);
        let titleResource = blogItemResource.find("a.title-desc-link");
        let readMoreResource = blogItemResource.find("a.post-button");
        let titleResourceUrl = titleResource.attr("data-button-url");
        let readMoreResourceUrl = readMoreResource.attr("data-button-url");
        let readMoreUrl = "";
        if (typeof titleResourceUrl !== "undefined" && readMoreUrl != "") {
          readMoreUrl = titleResourceUrl;
        } else if (
          typeof readMoreResourceUrl !== "undefined" &&
          readMoreResourceUrl != ""
        ) {
          readMoreUrl = titleResourceUrl;
        }
        if (readMoreUrl != "") {
          titleResource.attr("href", readMoreUrl).attr("target", "_blank");
          readMoreResource.attr("href", readMoreUrl).attr("target", "_blank");
        }
      }
    );
  },
};
$(document).ready(function () {
  Public_PB.init();
});
var current_url = window.location.href;
var regex = /\/\.bSectionClass[0-9]+/i;
var m = null;
while ((m = regex.exec(current_url)) !== null) {
  if (m.index === regex.lastIndex) {
    regex.lastIndex++;
  }
  if (m.length && m[0]) {
    var match = m[0];
    current_url = current_url.replace(match, "");
    match = match.replace("/.", "#");
    window.location.href = current_url + match;
  }
}
function SetRowAlign(element, alignment) {
  var mybodyWidth = "";
  var isHyperBlock = false;
  var marginNeed = 0;
  if (element.closest("section").hasClass("instantBlock")) {
    mybodyWidth = element.closest("section").width();
    isHyperBlock = false;
  } else {
    mybodyWidth = element.closest(".blockRowContainer").width();
    isHyperBlock = true;
  }
  if (alignment == "left") {
    if (mybodyWidth > 1170) {
      marginNeed = (mybodyWidth - 1170) / 2;
      element.css("margin-left", marginNeed + "px");
      element.css("margin-right", "auto");
    } else {
      element.css("margin-right", "auto");
      if ($(window).width() <= 991) {
        if (isHyperBlock) {
          element.css("margin-left", "2.5%");
        } else {
          element.css("margin-left", "0");
        }
      } else {
        element.css("margin-left", "2.5%");
      }
    }
  } else if (alignment == "right") {
    if (mybodyWidth > 1170) {
      marginNeed = (mybodyWidth - 1170) / 2;
      element.css("margin-right", marginNeed + "px");
      element.css("margin-left", "auto");
    } else {
      element.css("margin-left", "auto");
      if ($(window).width() <= 991) {
        if (isHyperBlock) {
          element.css("margin-right", "2.5%");
        } else {
          element.css("margin-right", "0");
        }
      } else {
        element.css("margin-right", "2.5%");
      }
    }
  } else {
    element.css("margin-right", "auto");
    element.css("margin-left", "auto");
  }
}
parallaxtb();
parallaxbt();
function parallaxtb() {
  $("section.parallaxtb").each(function () {
    var currentSection = $(this);
    var sectionHeight = currentSection.height();
    $(window).scroll(function () {
      if (currentSection.hasClass("parallaxtb")) {
        var yPos = ($(window).scrollTop() - currentSection.offset().top) / 2;
        var coords = "50% " + yPos + "px";
        currentSection.css({ backgroundPosition: coords });
      }
    });
  });
}
function parallaxbt() {
  $("section.parallaxbt").each(function () {
    var currentSection = $(this);
    var sectionHeight = currentSection.height();
    $(window).scroll(function () {
      var yPos = -(($(window).scrollTop() - currentSection.offset().top) / 8);
      var coords = "50% " + yPos + "px";
      currentSection.css({ backgroundPosition: coords });
    });
  });
}
const CUSTOMFIELD_AlphaNumeric = 1;
const CUSTOMFIELD_DropDown = 2;
const CUSTOMFIELD_Date = 3;
const CUSTOMFIELD_Numeric = 4;
const CUSTOMFIELD_Paragraph = 5;
const CUSTOMFIELD_URL = 6;
const CUSTOMFIELD_Email = 7;
const CUSTOMFIELD_Phone = 8;
const CUSTOMFIELD_CheckBoxes = 9;
const CUSTOMFIELD_Radio = 10;
const CUSTOMFIELD_DatePicker = 11;
var Public_PB_Forms = {
  selectedFormButton: "",
  formSettings: false,
  formSettingsId: false,
  canRedirect: true,
  init: function () {
    if (typeof pageBuilderData !== "undefined") {
      this.CustomFields.getFieldsList();
      this.CustomFields.initAutoValidation();
    }
    this.initSubmitButton();
    this.initCustomLink();
    this.initInlineForm();
  },
  CustomFields: {
    list: [],
    getFieldsList: function () {
      $.ajax({
        type: "GET",
        crossDomain: true,
        dataType: "json",
        async: false,
        url:
          siteUrl +
          "contacts/get-custom-fields/" +
          pageBuilderData.id +
          "/" +
          businessId,
        cache: false,
        success: function (response) {
          if (response.status == "success") {
            Public_PB_Forms.CustomFields.list = response.fieldData;
          }
        },
      });
    },
    initAutoValidation: function () {
      $(document).on("keydown", 'input[type="number"]', function (e) {
        if (
          (e.keyCode >= 48 && e.keyCode <= 57) ||
          (e.keyCode >= 96 && e.keyCode <= 105) ||
          e.keyCode == 190 ||
          e.keyCode == 8 ||
          e.keyCode == 46
        ) {
        } else {
          e.preventDefault();
        }
      });
    },
  },
  initSubmitButton: function () {
    $("a.btn-link-holder").click(function (e) {
      let win;
      let hyperlinkAttrUrl = $(this).attr("href");
      let hyperlinkAttrTarget = $(this).attr("target");
      let hyperlinkUrl =
        typeof hyperlinkAttrUrl == "string" && hyperlinkAttrUrl !== ""
          ? hyperlinkAttrUrl
          : false;
      let hyperlinkTarget =
        typeof hyperlinkAttrTarget == "string" && hyperlinkAttrTarget !== ""
          ? hyperlinkAttrTarget
          : "_self";
      e.preventDefault();
      if (hyperlinkUrl) {
        win = window.open(hyperlinkUrl, hyperlinkTarget);
        win.focus();
      } else {
        console.log("ERROR: Blog missing hyperlink attributes");
      }
      return false;
    });
    $("#popup-form-modal .buttonSubmitPopup button").click(function () {
      return;
      let formResource = $("#button-form");
      var formFields = [];
      var firstNameFieldEnable = false;
      var lastNameFieldEnable = false;
      var foundError = false;
      var hasGtwGrIntegration = false;
      if ($(this).attr("disabled") == "disabled") {
        return;
      }
      Public_PB_Forms.selectedFormButton = $(this);
      $("#popup-form-modal")
        .find(".spots-fields-wrapper div.inner-addon")
        .each(function (i, _field) {
          let $this = $(this);
          let _requiredInfo = $this.find("input").attr("required");
          let fieldName = "";
          let required = false;
          let fieldValue = "";
          let fieldArrayValues = [];
          let customFieldId = 0;
          if (!$this.is(":visible")) {
            return;
          }
          if ($this.hasClass("spots-field-name2")) {
            if (firstNameFieldEnable == true && lastNameFieldEnable == true) {
              fieldName = "full_name";
            } else if (
              firstNameFieldEnable == true &&
              lastNameFieldEnable == false
            ) {
              fieldName = "first_name";
            } else if (
              firstNameFieldEnable == false &&
              lastNameFieldEnable == true
            ) {
              fieldName = "last_name";
            } else {
              fieldName = "full_name";
            }
          } else if ($this.hasClass("spots-field-email2")) {
            fieldName = "email";
          } else if ($this.hasClass("sms-spots-check")) {
            fieldName = "phone";
          } else if ($this.hasClass("spots-phone-number2")) {
            fieldName = "phone";
          } else if ($this.hasClass("spots-sms-checkboxwrapper")) {
            fieldName = "sms";
          } else if ($this.hasClass("textField")) {
            fieldName = "sms";
          }
          if ($this.find("input").attr("type") == "checkbox") {
            fieldValue = $this.find("input").is(":checked") ? 1 : 0;
          } else {
            fieldValue = $this.find("input").val();
          }
          if ($this.hasClass("custom-field")) {
            $.each(Public_PB_Forms.CustomFields.list, function (
              i,
              customFieldItem
            ) {
              let fieldType = parseInt(customFieldItem.type);
              if (customFieldItem.id == $this.data("id")) {
                fieldName = customFieldItem.name;
                customFieldId = customFieldItem.id;
                if (fieldType == CUSTOMFIELD_DropDown) {
                  fieldValue = $this.find("select").val();
                  _requiredInfo =
                    typeof $this.find("select").attr("required") !== "undefined"
                      ? $this.find("select").attr("required")
                      : false;
                } else if (fieldType == CUSTOMFIELD_CheckBoxes) {
                  $this
                    .find('input[type="checkbox"]:checked')
                    .each(function (i, inputItem) {
                      fieldArrayValues.push($(inputItem).val());
                    });
                  fieldValue = fieldArrayValues.join(", ");
                  _requiredInfo =
                    $this.parent().find("label .required").length == 0
                      ? false
                      : true;
                } else if (fieldType == CUSTOMFIELD_Radio) {
                  fieldValue =
                    typeof $this.find('input[type="radio"]:checked').val() !==
                    "undefined"
                      ? $this.find('input[type="radio"]:checked').val()
                      : "";
                  _requiredInfo =
                    $this.parent().find("label .required").length == 0
                      ? false
                      : true;
                } else if (fieldType == CUSTOMFIELD_Date) {
                  if (
                    $this
                      .find("select.monthSelectList option:selected")
                      .val() != "" &&
                    $this.find("select.daySelectList").val() != ""
                  ) {
                    fieldValue =
                      $this
                        .find("select.monthSelectList option:selected")
                        .text() +
                      " " +
                      $this.find("select.daySelectList").val();
                  } else {
                    fieldValue = "";
                  }
                  _requiredInfo = $this
                    .find("select.monthSelectList")
                    .attr("required");
                } else if (fieldType == CUSTOMFIELD_Paragraph) {
                  fieldValue = $this.find("textarea").val();
                  _requiredInfo =
                    typeof $this.find("textarea").attr("required") !==
                    "undefined"
                      ? $this.find("textarea").attr("required")
                      : false;
                }
              }
            });
          }
          if (typeof _requiredInfo !== "undefined" && _requiredInfo !== false) {
            required = true;
          }
          formFields.push({
            name: fieldName,
            required: required,
            value: fieldValue,
            customFieldId: customFieldId,
          });
        });
      formResource.validate();
      if (!formResource.valid()) {
        return;
      }
      Public_PB_Forms.selectedFormButton
        .attr("data-text", $(this).html())
        .html("processing...")
        .attr("disabled", "disabled");
      Public_PB_Forms.saveContact(formFields);
      Public_PB_Forms.addClickToButtonsForms(Public_PB_Forms.formSettingsId);
    });
    $(
      "div.formElement.elements-control div.button.submitBtn, div.formElement.elements-control button.submitBtn, div.formElement div.submitBtn"
    ).click(function () {
      return;
      let formResource;
      var formFields = [];
      var firstNameFieldEnable = false;
      var lastNameFieldEnable = false;
      var foundError = false;
      var foundError = false;
      var hasGtwGrIntegration = false;
      var parent = $(this).closest("div.elements-control").data("parent");
      var _formSettings = "";
      if (
        $(this)
          .closest("div.droppableElementArea")
          .hasClass("signinFormElement")
      ) {
        return;
      }
      if (typeof parent !== "undefined" && parent != "0") {
        _formSettings = $('div.formElement[data-name="' + parent + '"]')
          .find(".buttonModalsSettingsHolder")
          .html();
        formResource = $('div.formElement[data-name="' + parent + '"]').find(
          "form"
        );
      } else {
        _formSettings = $(this)
          .closest("div.elements-control")
          .find(".buttonModalsSettingsHolder")
          .html();
        formResource = $(this).closest("div.elements-control").find("form");
      }
      if ($(this).attr("disabled") == "disabled") {
        return;
      }
      if (typeof _formSettings === "undefined" || _formSettings == "") {
        console.log("ERROR: missing inline form settings!!");
        return;
      }
      Public_PB_Forms.formSettings = jQuery.parseJSON(
        _formSettings.replace('"false"', "'false'")
      );
      Public_PB_Forms.formSettingsId = $(this)
        .closest("div.elements-control")
        .find(".buttonModalsSettingsHolder")
        .attr("data-id");
      if (
        typeof Public_PB_Forms.formSettings.integrations != "undefined" &&
        Public_PB_Forms.formSettings.automation_enable &&
        (Public_PB_Forms.formSettings.integrations.integration_type ==
          "gotowebinar" ||
          Public_PB_Forms.formSettings.integrations.integration_type ==
            "infusionsoft")
      ) {
        hasGtwGrIntegration = true;
      }
      if (typeof Public_PB_Forms.formSettings.fields !== "undefined") {
        $.each(Public_PB_Forms.formSettings.fields, function (i, field) {
          if (field.name == "first_name" && field.visible == 1) {
            firstNameFieldEnable = true;
          }
          if (field.name == "last_name" && field.visible == 1) {
            lastNameFieldEnable = true;
          }
        });
      } else {
        $.each(Public_PB_Forms.formSettings.optin_type.fields, function (
          i,
          field
        ) {
          if (field.name == "first_name" && field.visible == 1) {
            firstNameFieldEnable = true;
          }
          if (field.name == "last_name" && field.visible == 1) {
            lastNameFieldEnable = true;
          }
        });
      }
      if (hasGtwGrIntegration) {
        firstNameFieldEnable = true;
        lastNameFieldEnable = true;
      }
      Public_PB_Forms.selectedFormButton = $(this);
      if ($(this).hasClass("btnControls")) {
      }
      $(this)
        .closest("div.elements-control")
        .find(".spots-fields-wrapper div.inner-addon")
        .each(function (i, _field) {
          let $this = $(this);
          let _requiredInfo = $this.find("input").attr("required");
          let fieldName = "";
          let required = false;
          let fieldValue = "";
          let fieldArrayValues = [];
          let customFieldId = 0;
          if (!$this.is(":visible")) {
            return;
          }
          if ($this.hasClass("spots-field-name2")) {
            if (firstNameFieldEnable == true && lastNameFieldEnable == true) {
              fieldName = "full_name";
            } else if (
              firstNameFieldEnable == true &&
              lastNameFieldEnable == false
            ) {
              fieldName = "first_name";
            } else if (
              firstNameFieldEnable == false &&
              lastNameFieldEnable == true
            ) {
              fieldName = "last_name";
            } else {
              fieldName = "full_name";
            }
          } else if ($this.hasClass("spots-field-email2")) {
            fieldName = "email";
          } else if ($this.hasClass("sms-spots-check")) {
            fieldName = "phone";
          } else if ($this.hasClass("spots-phone-number")) {
            fieldName = "phone";
          } else if ($this.hasClass("spots-sms-checkboxwrapper")) {
            fieldName = "sms";
          } else if ($this.hasClass("textField")) {
            fieldName = "sms";
          }
          if ($this.find("input").attr("type") == "checkbox") {
            fieldValue = $this.find("input").is(":checked") ? 1 : 0;
          } else {
            fieldValue = $this.find("input").val();
          }
          if ($this.hasClass("custom-field")) {
            $.each(Public_PB_Forms.CustomFields.list, function (
              i,
              customFieldItem
            ) {
              let fieldType = parseInt(customFieldItem.type);
              if (customFieldItem.id == $this.data("id")) {
                fieldName = customFieldItem.name;
                customFieldId = customFieldItem.id;
                if (fieldType == CUSTOMFIELD_DropDown) {
                  fieldValue = $this.find("select").val();
                  _requiredInfo =
                    typeof $this.find("select").attr("required") !== "undefined"
                      ? $this.find("select").attr("required")
                      : false;
                } else if (fieldType == CUSTOMFIELD_CheckBoxes) {
                  $this
                    .find('input[type="checkbox"]:checked')
                    .each(function (i, inputItem) {
                      fieldArrayValues.push($(inputItem).val());
                    });
                  fieldValue = fieldArrayValues.join(", ");
                  _requiredInfo =
                    $this.parent().find("label .required").length == 0
                      ? false
                      : true;
                } else if (fieldType == CUSTOMFIELD_Radio) {
                  fieldValue =
                    typeof $this.find('input[type="radio"]:checked').val() !==
                    "undefined"
                      ? $this.find('input[type="radio"]:checked').val()
                      : "";
                  _requiredInfo =
                    $this.parent().find("label .required").length == 0
                      ? false
                      : true;
                } else if (fieldType == CUSTOMFIELD_Date) {
                  if (
                    $this
                      .find("select.monthSelectList option:selected")
                      .val() != "" &&
                    $this.find("select.daySelectList").val() != ""
                  ) {
                    fieldValue =
                      $this
                        .find("select.monthSelectList option:selected")
                        .text() +
                      " " +
                      $this.find("select.daySelectList").val();
                  } else {
                    fieldValue = "";
                  }
                  _requiredInfo = $this
                    .find("select.monthSelectList")
                    .attr("required");
                } else if (fieldType == CUSTOMFIELD_Paragraph) {
                  fieldValue = $this.find("textarea").val();
                  _requiredInfo =
                    typeof $this.find("textarea").attr("required") !==
                    "undefined"
                      ? $this.find("textarea").attr("required")
                      : false;
                }
              }
            });
          }
          if (typeof _requiredInfo !== undefined && _requiredInfo !== false) {
            required = true;
          }
          formFields.push({
            name: fieldName,
            required: required,
            value: fieldValue,
            customFieldId: customFieldId,
          });
        });
      formResource.validate();
      if (!formResource.valid()) {
        return;
      }
      Public_PB_Forms.selectedFormButton
        .attr("data-text", $(this).find("p").html())
        .find("p")
        .html("processing...")
        .attr("disabled", "disabled");
      Public_PB_Forms.saveContact(formFields);
      Public_PB_Forms.addClickToButtonsForms(Public_PB_Forms.formSettingsId);
    });
  },
  initInlineForm: function () {},
  initCustomLink: function () {
    $(document).on("click", "a[data-element-id]", function (e) {
      e.preventDefault();
      var element_id = $(this).attr("data-element-id");
      var href =
        typeof $(this).attr("data-href") != "undefined"
          ? $(this).attr("data-href")
          : $(this).attr("href");
      Public_PB_Forms.addClickToCustomLink(element_id, $(this));
    });
  },
  showModalForm: function () {
    var fields = Public_PB_Forms.formSettings.optin_type.fields;
    var design = Public_PB_Forms.formSettings.optin_type.design;
    let labelsVisible = Public_PB_Forms.formSettings.optin_type.showLabels
      ? Public_PB_Forms.formSettings.optin_type.showLabels
      : 0;
    let customFields =
      typeof Public_PB_Forms.formSettings.optin_type.customFields !==
      "undefined"
        ? Public_PB_Forms.formSettings.optin_type.customFields
        : [];
    let sortedFields =
      typeof Public_PB_Forms.formSettings.optin_type.sortedFields !==
      "undefined"
        ? Public_PB_Forms.formSettings.optin_type.sortedFields
        : [];
    var firstNameVisible = 0;
    var lastNameVisible = 0;
    var firstNameRequired = 0;
    var lastNameRequired = 0;
    var emailVisible = 0;
    var emailRequired = 0;
    var mobilePhoneVisible = 0;
    var mobilePhoneRequired = 0;
    var smsPermissionVisible = 0;
    var captcha = 0;
    var gdpr_optin_approval = 0;
    var namePlaceholder = "Enter Your Full Name";
    var emailPlaceholder = "Enter Your Email";
    var mobilePhonePlaceholder = "Enter Your Mobile Phone";
    Public_PB_Forms.resetModalForm();
    $.each(fields, function (i, field) {
      if (field.name == "first_name") {
        firstNameVisible = field.visible;
        firstNameRequired = field.required;
        namePlaceholder = field.placeholder;
      } else if (field.name == "last_name") {
        lastNameVisible = field.visible;
        lastNameRequired = field.required;
        namePlaceholder = field.placeholder;
      } else if (field.name == "email") {
        emailVisible = field.visible;
        emailRequired = field.required;
        emailPlaceholder = field.placeholder;
      } else if (field.name == "mobile_phone") {
        mobilePhoneVisible = field.visible;
        mobilePhoneRequired = field.required;
        smsPermissionVisible = field.additional.sms_permission;
        mobilePhonePlaceholder = field.placeholder;
      } else if (field.name == "captcha") {
        captcha = field.visible;
      } else if (field.name == "gdpr_optin_approval") {
        gdpr_optin_approval = field.additional.gdpr_optin_approval;
      }
    });
    if (firstNameVisible == 1 && lastNameVisible == 1) {
      $("#popup-form-modal .spots-field-name").show();
      $('#popup-form-modal .spots-field-name input[type="text"]').attr(
        "placeholder",
        namePlaceholder
      );
      if (firstNameRequired == 1 || lastNameRequired == 1) {
        $('#popup-form-modal .spots-field-name input[type="text"]').attr(
          "required",
          "required"
        );
        $("#popup-form-modal .spots-field-name span.required").show();
      } else {
        $('#popup-form-modal .spots-field-name input[type="text"]').attr(
          "required",
          false
        );
        $("#popup-form-modal .spots-field-name span.required").hide();
      }
    }
    if (firstNameVisible == 1 && lastNameVisible == 0) {
      $("#popup-form-modal .spots-field-name").show();
      $('#popup-form-modal .spots-field-name input[type="text"]').attr(
        "placeholder",
        namePlaceholder
      );
      if (firstNameRequired == 1) {
        $('#popup-form-modal .spots-field-name input[type="text"]').attr(
          "required",
          "required"
        );
        $("#popup-form-modal .spots-field-name span.required").show();
      } else {
        $('#popup-form-modal .spots-field-name input[type="text"]').attr(
          "required",
          false
        );
        $("#popup-form-modal .spots-field-name span.required").hide();
      }
    }
    if (firstNameVisible == 0 && lastNameVisible == 1) {
      $("#popup-form-modal .spots-field-name").show();
      $('#popup-form-modal .spots-field-name input[type="text"]').attr(
        "placeholder",
        namePlaceholder
      );
      if (lastNameRequired == 1) {
        $('#popup-form-modal .spots-field-name input[type="text"]').attr(
          "required",
          "required"
        );
        $("#popup-form-modal .spots-field-name span.required").show();
      } else {
        $('#popup-form-modal .spots-field-name input[type="text"]').attr(
          "required",
          false
        );
        $("#popup-form-modal .spots-field-name span.required").hide();
      }
    }
    if (emailVisible == 1) {
      $("#popup-form-modal .spots-field-email").show();
      $('#popup-form-modal .spots-field-email input[type="text"]').attr(
        "placeholder",
        emailPlaceholder
      );
      if (emailRequired == 1) {
        $('#popup-form-modal .spots-field-email input[type="text"]').attr(
          "required",
          "required"
        );
        $("#popup-form-modal .spots-field-email span.required").show();
      } else {
        $('#popup-form-modal .spots-field-email input[type="text"]').attr(
          "required",
          false
        );
        $("#popup-form-modal .spots-field-email span.required").hide();
      }
    }
    if (mobilePhoneVisible == 1) {
      $("#popup-form-modal .spots-phone-number").show();
      $('#popup-form-modal .spots-phone-number input[type="text"]').attr(
        "placeholder",
        mobilePhonePlaceholder
      );
      if (mobilePhoneRequired == 1) {
        $('#popup-form-modal .spots-phone-number input[type="text"]').attr(
          "required",
          "required"
        );
        $("#popup-form-modal .spots-phone-number span.required").show();
      } else {
        $('#popup-form-modal .spots-phone-number input[type="text"]').attr(
          "required",
          false
        );
        $("#popup-form-modal .spots-phone-number span.required").hide();
      }
    } else {
      smsPermissionVisible = 0;
    }
    if (smsPermissionVisible == 1) {
      $("#popup-form-modal .spots-sms-checkboxwrapper").show();
    }
    Public_PB_Forms.addModalCustomFieldsInView(customFields);
    Public_PB_Forms.reorderFieldsInModal(sortedFields);
    $("#popup-form-modal").modal("show");
  },
  reorderFieldsInModal: function (sortableFields) {
    let fieldsToIgnore = ["captcha", "gdpr_optin_approval"];
    let fieldWrapper = $(
      "#popup-form-modal .spots-fields-wrapper .spots-for-custom-field"
    );
    let detachedFieldsHolder = [];
    if (sortableFields.length == 0) {
      return;
    }
    $.each(sortableFields, function (sortableFieldIndex, sortableField) {
      let currentField;
      let detachedField;
      let fieldIdName = sortableField.name;
      if (fieldIdName == "first_name" || fieldIdName == "last_name") {
        fieldIdName = "spots-field-name";
      }
      if (fieldIdName == "mobile_phone") {
        fieldIdName = "spots-phone-number";
      }
      if (fieldIdName == "email") {
        fieldIdName = "spots-field-email";
      }
      if ($.inArray(sortableField.name, fieldsToIgnore) !== -1) {
        return;
      }
      currentField = $(
        '#popup-form-modal .spots-fields-wrapper div.form-group[data-id="' +
          fieldIdName +
          '"]'
      );
      detachedField = currentField.detach();
      detachedFieldsHolder.push(detachedField);
    });
    $.each(detachedFieldsHolder, function (i, detachedField) {
      $(detachedField).appendTo(fieldWrapper);
    });
  },
  addModalCustomFieldsInView: function (customFields) {},
  display: {
    Builder: {
      fieldDetails: {},
      customField: {},
      alphaNumericPreview: function () {
        let fieldDetails = Public_PB_Forms.display.Builder.fieldDetails;
        let fieldLabel =
          typeof fieldDetails.label !== "undefined"
            ? fieldDetails.label
            : fieldDetails.name;
        return `<div class="form-group ${fieldDetails.id}_input"data-id="${fieldDetails.id}"><label class="label-control spLabelControl ${fieldDetails.id}_input">${fieldLabel}</label><div class="inner-addon left-addon ${fieldDetails.id} custom-field textField"data-id="${fieldDetails.id}"><i class="fa fa-flag"aria-hidden="true"></i><input type="text"class="form-control custom-padding"placeholder="${fieldDetails.placeholder}"></div><div class="clearfix"></div></div>`;
      },
      numberPreview: function () {
        let fieldDetails = Public_PB_Forms.display.Builder.fieldDetails;
        let fieldLabel =
          typeof fieldDetails.label !== "undefined"
            ? fieldDetails.label
            : fieldDetails.name;
        return `<div class="form-group ${fieldDetails.id}_input"data-id="${fieldDetails.id}"edit-hover="${fieldDetails.id}"><label class="label-control spLabelControl ${fieldDetails.id}_input">${fieldLabel}</label><div class="inner-addon left-addon ${fieldDetails.id} numberField custom-field"data-id="${fieldDetails.id}"><i class="fa fa-flag"aria-hidden="true"></i><input type="number"class="form-control custom-padding"placeholder="${fieldDetails.placeholder}"></div><div class="clearfix"></div></div>`;
      },
      textareaPreview: function () {
        let fieldDetails = Public_PB_Forms.display.Builder.fieldDetails;
        let fieldLabel =
          typeof fieldDetails.label !== "undefined"
            ? fieldDetails.label
            : fieldDetails.name;
        return `<div class="form-group ${fieldDetails.id}_input"data-id="${fieldDetails.id}"><label class="label-control spLabelControl ${fieldDetails.id}_input">${fieldLabel}</label><div class="inner-addon left-addon ${fieldDetails.id} custom-field paragraphField"data-id="${fieldDetails.id}"><i class="fa fa-flag"aria-hidden="true"></i><textarea rows="3"style="resize: none; height:auto !important;line-height:30px;"class="form-control custom-padding"placeholder="${fieldDetails.placeholder}"></textarea></div><div class="clearfix"></div></div>`;
      },
      datePickerPreview: function () {
        let fieldDetails = Public_PB_Forms.display.Builder.fieldDetails;
        let fieldLabel =
          typeof fieldDetails.label !== "undefined"
            ? fieldDetails.label
            : fieldDetails.name;
        return `<div class="form-group ${fieldDetails.id}_input"data-id="${fieldDetails.id}"><label class="label-control spLabelControl ${fieldDetails.id}_input">${fieldLabel}</label><div class="inner-addon left-addon ${fieldDetails.id} custom-field dateTextField datePickerTextField"data-id="${fieldDetails.id}"><i class="fa fa-calendar"aria-hidden="true"></i><input type="text"class="form-control custom-padding"placeholder="${fieldDetails.placeholder}"></div><div class="clearfix"></div></div>`;
      },
      dropDownPreview: function () {
        let fieldDetails = Public_PB_Forms.display.Builder.fieldDetails;
        let fieldLabel =
          typeof fieldDetails.label !== "undefined"
            ? fieldDetails.label
            : fieldDetails.name;
        let options = $.parseJSON(fieldDetails.options);
        let dropDownOptions =
          typeof options.dropDown === "string"
            ? options.dropDown.split(/\n/)
            : options.dropDown;
        let selectOptionFiltered = [];
        let template;
        for (let o = 0; o < dropDownOptions.length; o++) {
          let option = dropDownOptions[o];
          if (option != "") {
            selectOptionFiltered.push(option);
          }
        }
        template = `<div class="form-group ${fieldDetails.id}_input"data-id="${fieldDetails.id}"edit-hover="${fieldDetails.id}"><label class="label-control spLabelControl ${fieldDetails.id}_input">${fieldLabel}</label><div class="inner-addon left-addon ${fieldDetails.id} dropdownField custom-field"data-id="${fieldDetails.id}"><i class="fa fa-flag"aria-hidden="true"></i><select data-width="100%"class="selectField form-control padding-left-5"><option value="">${fieldDetails.placeholder}</option>`;
        for (let i = 0; i < selectOptionFiltered.length; i++) {
          template += `<option value="${selectOptionFiltered[i]}">${selectOptionFiltered[i]}</option>`;
        }
        template += `</select></div><div class="clearfix"></div></div>`;
        return template;
      },
      datePreview: function () {
        let fieldDetails = Public_PB_Forms.display.Builder.fieldDetails;
        let fieldLabel =
          typeof fieldDetails.label !== "undefined"
            ? fieldDetails.label
            : fieldDetails.name;
        let placeholderDate = $.parseJSON(fieldDetails.placeholder_date);
        let placeholderMonth = placeholderDate.month;
        let placeholderDay = placeholderDate.day;
        let monthList = $("select.monthSelectList").clone();
        let dayList = $("select.daySelectList").clone();
        let template;
        template = `<div class="form-group ${fieldDetails.id}_input"data-id="${fieldDetails.id}"edit-hover="${fieldDetails.id}"><label class="label-control spLabelControl ${fieldDetails.id}_input">${fieldLabel}</label><div class="inner-addon left-addon ${fieldDetails.id} form-group-lg ui-sortable-handle dateField custom-field"data-id="${fieldDetails.id}"><div class="row"><label class="col-xs-2 dateLabel"><i class="fa fa-calendar"></i>${placeholderMonth}</label><div class="col-xs-4">${monthList[0].outerHTML}</div><label class="col-xs-2 dateLabel"><i class="fa fa-calendar"></i>${placeholderDay}</label><div class="col-xs-4">${dayList[0].outerHTML}</div></div></div><div class="clearfix"></div></div>`;
        return template;
      },
      urlPreview: function () {
        let fieldDetails = Public_PB_Forms.display.Builder.fieldDetails;
        let fieldLabel =
          typeof fieldDetails.label !== "undefined"
            ? fieldDetails.label
            : fieldDetails.name;
        return `<div class="form-group ${fieldDetails.id}_input"data-id="${fieldDetails.id}"edit-hover="${fieldDetails.id}"><label class="label-control spLabelControl ${fieldDetails.id}_input">${fieldLabel}</label><div class="inner-addon left-addon ${fieldDetails.id} custom-field textField"data-id="${fieldDetails.id}"><i class="fa fa-link"aria-hidden="true"></i><input type="url"class="form-control custom-padding"placeholder="${fieldDetails.placeholder}"></div><div class="clearfix"></div></div>`;
      },
      emailPreview: function () {
        let fieldDetails = Public_PB_Forms.display.Builder.fieldDetails;
        let fieldLabel =
          typeof fieldDetails.label !== "undefined"
            ? fieldDetails.label
            : fieldDetails.name;
        return `<div class="form-group ${fieldDetails.id}_input"data-id="${fieldDetails.id}"edit-hover="${fieldDetails.id}"><label class="label-control spLabelControl ${fieldDetails.id}_input">${fieldLabel}</label><div class="inner-addon left-addon ${fieldDetails.id} custom-field emailTextField"data-id="${fieldDetails.id}"><i class="fa fa-envelope"aria-hidden="true"></i><input type="email"class="form-control custom-padding"placeholder="${fieldDetails.placeholder}"></div><div class="clearfix"></div></div>`;
      },
      phonePreview: function () {
        let fieldDetails = Public_PB_Forms.display.Builder.fieldDetails;
        let fieldLabel =
          typeof fieldDetails.label !== "undefined"
            ? fieldDetails.label
            : fieldDetails.name;
        return `<div class="form-group ${fieldDetails.id}_input"data-id="${fieldDetails.id}"edit-hover="${fieldDetails.id}"><label class="label-control spLabelControl ${fieldDetails.id}_input">${fieldLabel}</label><div class="inner-addon left-addon phoneTextField ${fieldDetails.id} custom-field textField"data-id="${fieldDetails.id}"><i class="fa fa-mobile"aria-hidden="true"></i><div class="intl-tel-input"><input type="text"class="form-control custom-padding"placeholder="${fieldDetails.placeholder}"></div></div><div class="clearfix"></div></div>`;
      },
      checkBoxesPreview: function () {
        let fieldDetails = Public_PB_Forms.display.Builder.fieldDetails;
        let fieldLabel =
          typeof fieldDetails.label !== "undefined"
            ? fieldDetails.label
            : fieldDetails.name;
        let options = $.parseJSON(fieldDetails.options);
        let dropDownOptions = options.dropDown;
        let template;
        template = `<div class="form-group ${fieldDetails.id}_input checkBoxField"data-id="${fieldDetails.id}"edit-hover="${fieldDetails.id}"><label class="label-control spLabelControl ${fieldDetails.id}_input">${fieldLabel}</label><div class="inner-addon left-addon ${fieldDetails.id} checkBoxField custom-field"data-id="${fieldDetails.id}">`;
        for (let i = 0; i < dropDownOptions.length; i++) {
          template += `<div class="checkbox_item"><label class="custom_styled_choice cc_container"><span>${dropDownOptions[i]}</span><input name="values_${fieldDetails.id}"type="checkbox"value="${dropDownOptions[i]}"/><span class="cc_checkmark"></span></label></div>`;
        }
        template += `</div><div class="clearfix"></div></div>`;
        return template;
      },
      radioButtonsPreview: function () {
        let fieldDetails = Public_PB_Forms.display.Builder.fieldDetails;
        let fieldLabel =
          typeof fieldDetails.label !== "undefined"
            ? fieldDetails.label
            : fieldDetails.name;
        let options = $.parseJSON(fieldDetails.options);
        let dropDownOptions = options.dropDown;
        let template;
        template = `<div class="form-group ${fieldDetails.id}_input radioButtonField"data-id="${fieldDetails.id}"edit-hover="${fieldDetails.id}"><label class="label-control spLabelControl ${fieldDetails.id}_input">${fieldLabel}</label><div class="inner-addon left-addon ${fieldDetails.id} radioButtonField custom-field"data-id="${fieldDetails.id}">`;
        for (let i = 0; i < dropDownOptions.length; i++) {
          template += `<div class="radioButton_item"><label class="custom_styled_choice rb_container"><span>${dropDownOptions[i]}</span><input name="values_${fieldDetails.id}"type="radio"value="${dropDownOptions[i]}"/><span class="rb_checkmark"></span></label></div>`;
        }
        template += `</div><div class="clearfix"></div></div>`;
        return template;
      },
    },
  },
  resetModalForm: function () {
    $("#popup-form-modal .popupTitle").html("");
    $("#popup-form-modal .popupSubTitle").html("");
    $("#popup-form-modal .spamText").html("");
    $("#popup-form-modal .bookingBtnText").html("");
    $("#popup-form-modal .SMSLabelText").html("");
    $("#popup-form-modal .GDPRLabelText").html("");
    $("#popup-form-modal .spots-field-name").hide();
    $("#popup-form-modal .spots-field-email").hide();
    $("#popup-form-modal .spots-phone-number").hide();
    $("#popup-form-modal .spots-sms-checkboxwrapper").hide();
    $('#popup-form-modal input[type="text"]').val("");
    $.each(
      $("#popup-form-modal div.inner-addon.custom-field").parent(),
      function (i, element) {
        if (typeof $(element).data("id") !== "undefined") {
          $(element).remove();
        }
      }
    );
  },
  saveContact: function ($fields) {
    let ajaxData = { rawFields: $fields };
    $.each($fields, function (i, field) {
      ajaxData[field.name] = field.value;
    });
    ajaxData.action_type = "optin";
    ajaxData.formSettingsId = Public_PB_Forms.formSettingsId;
    ajaxData.optin_occurred = "";
    if (Public_PB_Forms.formSettings && Public_PB_Forms.formSettings.name) {
      ajaxData.optin_occurred = Public_PB_Forms.formSettings.name;
    }
    if (!pageBuilderData.id) {
      return false;
    }
    $.ajax({
      type: "POST",
      crossDomain: true,
      dataType: "json",
      url: siteUrl + "contacts/save/" + pageBuilderData.id + "/" + testMode,
      data: ajaxData,
      cache: false,
      success: function (data) {
        Public_PB_Forms.selectedFormButton.attr("disabled", false);
        if (Public_PB_Forms.selectedFormButton.find("p").length == 1) {
          Public_PB_Forms.selectedFormButton
            .find("p")
            .html(Public_PB_Forms.selectedFormButton.attr("data-text"));
        } else {
          Public_PB_Forms.selectedFormButton.html(
            Public_PB_Forms.selectedFormButton.attr("data-text")
          );
        }
        if (
          Public_PB_Forms.selectedFormButton.closest("#popup-form-modal")
            .length == 1
        ) {
          $("#popup-form-modal")
            .closest("form")
            .find("input, textarea")
            .val("");
          $("#popup-form-modal").modal("hide");
        } else {
          Public_PB_Forms.selectedFormButton
            .closest(".formElementHolder")
            .find("input, textarea")
            .val("");
        }
        if (data.status == "success") {
          if (
            Public_PB_Forms.selectedFormButton.closest("#popup-form-modal")
              .length == 1
          ) {
            var optin_action_type =
              Public_PB_Forms.formSettings.optin_action_type;
            if (
              typeof optin_action_type == "undefined" ||
              optin_action_type.length == 0
            )
              optin_action_type = 5;
            if (optin_action_type == "1") {
              var target = "_blank";
              if (
                typeof Public_PB_Forms.formSettings.redirect_type.target !==
                "undefined"
              ) {
                if (Public_PB_Forms.formSettings.redirect_type.target == 1) {
                  target = "_self";
                }
              }
              window.open(
                Public_PB_Forms.formSettings.redirect_type.url.replace(
                  /\&amp;/gi,
                  "&"
                ),
                target
              );
            } else if (optin_action_type == "2") {
              window.location.href =
                "mailto:" + Public_PB_Forms.formSettings.click_to_email.value;
            } else if (optin_action_type == "3") {
              window.location.href =
                "tel://" + Public_PB_Forms.formSettings.click_to_call.value;
            } else if (optin_action_type == "4") {
              $([document.documentElement, document.body]).animate(
                {
                  scrollTop: $(
                    'section[data-id="' +
                      Public_PB_Forms.formSettings.jump_to_block.value +
                      '"]'
                  ).offset().top,
                },
                500
              );
            } else if (optin_action_type == "5") {
              if (
                Public_PB_Forms.formSettings.form_redirect_funnel_url != "" &&
                Public_PB_Forms.formSettings.form_redirect_funnel_url !=
                  "next-funnel"
              ) {
                window.location.href =
                  siteUrl +
                  "show-page/" +
                  Public_PB_Forms.formSettings.form_redirect_funnel_url;
              }
            } else {
              showCoreModalMessage(
                "Success",
                "You information was saved successfully"
              );
            }
            if (version == 1) {
              if (
                $("#f-navigator-yes").length == 1 &&
                Public_PB_Forms.canRedirect &&
                $("#f-navigator-yes").attr("href") != "#"
              ) {
                window.location.href = $("#f-navigator-yes").attr("href");
              } else {
                showCoreModalMessage(
                  "Success",
                  "You information was saved successfully"
                );
              }
            }
          } else {
            if (Public_PB_Forms.formSettings.form_redirect_type == 1) {
              Public_PB_Forms.showThankYouPopUp();
            } else if (Public_PB_Forms.formSettings.form_redirect_type == 2) {
              var target = "_blank";
              if (
                typeof Public_PB_Forms.formSettings.redirect_type.target !==
                "undefined"
              ) {
                if (Public_PB_Forms.formSettings.redirect_type.target == 1) {
                  target = "_self";
                }
              }
              return window.open(
                Public_PB_Forms.formSettings.form_redirect_custom_url.replace(
                  /\&amp;/gi,
                  "&"
                ),
                target
              );
            } else if (Public_PB_Forms.formSettings.form_redirect_type == 4) {
              window.location.href =
                "tel://" + Public_PB_Forms.formSettings.click_to_call.value;
            } else if (Public_PB_Forms.formSettings.form_redirect_type == 5) {
              window.location.href =
                "mailto:" + Public_PB_Forms.formSettings.click_to_email.value;
            } else if (Public_PB_Forms.formSettings.form_redirect_type == 3) {
              if (version == 2) {
                if (
                  Public_PB_Forms.formSettings.form_redirect_funnel_url !=
                  "next-funnel"
                )
                  window.location.href =
                    siteUrl +
                    "show-page/" +
                    Public_PB_Forms.formSettings.form_redirect_funnel_url;
              } else {
                if (
                  Public_PB_Forms.formSettings.form_redirect_funnel_url ==
                  "next-page-positive"
                ) {
                  window.location.href = $("#f-navigator-yes").attr("href");
                } else if (
                  Public_PB_Forms.formSettings.form_redirect_funnel_url ==
                  "next-page-negative"
                ) {
                  window.location.href = $("#f-navigator-no").attr("href");
                }
              }
            }
            return;
          }
        } else {
          if (typeof data.message !== "undefined") {
            showCoreModalMessage("error", data.message);
          }
        }
      },
    });
  },
  showThankYouPopUp: function () {
    $("#form-popup-thank-you").modal("show");
    if (
      Public_PB_Forms.formSettings.thank_you &&
      Public_PB_Forms.formSettings.thank_you.popup_options
    ) {
      var settings = Public_PB_Forms.formSettings.thank_you.popup_options;
      $("#form-popup-thank-you .modal-content").css(
        "background-color",
        settings.background_color
      );
      $("#form-popup-thank-you button.ok-button").css(
        "background",
        settings.button_color
      );
      $("#form-popup-thank-you button.ok-button").css("box-shadow", "none");
      $("#form-popup-thank-you button.ok-button").html(
        b64decode(settings.button_text)
      );
      if (settings.button_visible == 0) {
        $("#form-popup-thank-you button.ok-button").hide();
      }
      $("#form-popup-thank-you .title").html(b64decode(settings.headline_text));
      if (settings.headline_visible == 0) {
        $("#form-popup-thank-you .title").hide();
      }
      $("#form-popup-thank-you .details").html(
        b64decode(settings.subeadline_text)
      );
      if (settings.subheadline_visible == 0) {
        $("#form-popup-thank-you .details").hide();
      }
      $("#form-popup-thank-you .icon-image").attr("src", settings.icon_url);
      if (settings.icon_visible == 0) {
        $("#form-popup-thank-you .icon-image").hide();
      }
      $("#form-popup-thank-you").on("hidden.bs.modal", function () {});
    }
  },
  addClickToButtonsForms: function (element_id) {
    $.ajax({
      type: "POST",
      url: siteUrl + "funnels/show/add_click_to_buttons_forms",
      data: { element_id: element_id },
      success: function () {},
    });
  },
  addClickToCustomLink: function (element_id, anchor_element) {
    var target = "_self";
    if (anchor_element.attr("target")) {
      target = anchor_element.attr("target");
    }
    var win = window.open("", target);
    $.ajax({
      type: "POST",
      url: siteUrl + "funnels/show/add_click_to_custom_links",
      data: { element_id: element_id },
      success: function () {
        win.location = anchor_element.attr("href");
        if (target != "_blank") {
          win.opener = null;
          win.blur();
          window.focus();
        }
      },
    });
  },
  initOptinGDPR: function (
    selector,
    gdpr_optin_approval,
    smsPermissionVisible
  ) {
    $(selector).find(".gdprAgreement").hide();
    if (smsPermissionVisible == 0) {
      if (gdpr_optin_approval == "1") {
        var x = new XMLHttpRequest();
        x.open(
          "GET",
          "https://pro.ip-api.com/xml/?key=R5xiO0FwQoC0t9D&fields=timezone",
          true
        );
        x.onreadystatechange = function () {
          if (x.readyState == 4 && x.status == 200) {
            var doc = x.responseXML;
            var Region = doc
              .getElementsByTagName("timezone")[0]
              .firstChild.nodeValue.toString();
            if (Region.toString().toLowerCase().includes("europe")) {
              $(selector).find(".gdprAgreement").show();
            }
          }
        };
        x.send(null);
      } else if (gdpr_optin_approval == "2") {
        $(selector).find(".gdprAgreement").show();
      }
    }
  },
};
$(document).ready(function () {
  $.validator.setDefaults({
    debug: false,
    highlight: function (element) {
      $(element).closest(".form-group").addClass("has-error");
    },
    unhighlight: function (element) {
      $(element).closest(".form-group").removeClass("has-error");
    },
    errorPlacement: function (error, element) {
      if (
        element.parents(".form-group").hasClass("spots-phone-number") ||
        element.parents(".form-group").hasClass("phoneField")
      ) {
        error.insertAfter(element.parents(".form-group").find(".iti").eq(0));
      } else if (
        element.parents(".form-group").hasClass("checkBoxField") ||
        element.parents(".form-group").hasClass("radioButtonField")
      ) {
        element
          .parents(".form-group")
          .find("label.spLabelControl")
          .eq(0)
          .append("<br>")
          .append(error);
      } else error.insertAfter(element);
    },
  });
  jQuery.validator.addMethod(
    "fullname",
    function (value, element) {
      return (
        this.optional(element) ||
        /^[a-zA-Z.'-,]+(?: +[a-zA-Z.'-]+)+$/i.test(value)
      );
    },
    "Please Enter Your Full Name"
  );
  Public_PB_Forms.init();
});
(function ($) {
  $.fn.inputFilter = function (inputFilter) {
    return this.on(
      "input keydown keyup mousedown mouseup select contextmenu drop",
      function () {
        if (inputFilter(this.value)) {
          this.oldValue = this.value;
          this.oldSelectionStart = this.selectionStart;
          this.oldSelectionEnd = this.selectionEnd;
        } else if (this.hasOwnProperty("oldValue")) {
          this.value = this.oldValue;
          this.setSelectionRange(this.oldSelectionStart, this.oldSelectionEnd);
        } else {
          this.value = "";
        }
      }
    );
  };
})(jQuery);
var Public_PB_Menu = {
  init: function () {
    this.initMenuAction();
    this.initLogout();
  },
  initGoToSection: function () {
    if (window.location.hash) {
      var hash = window.location.hash;
      var section = false;
      if (hash.startsWith("#.new")) {
        section = $("section[data-id='" + hash.substring(5) + "']");
      } else if (hash.startsWith("#.")) section = $(hash.substring(1));
      else section = $(hash);
      if (section != false && section.length > 0) {
        $("html, body").animate({ scrollTop: section.offset().top }, 1000);
      }
    }
  },
  initMenuAction: function () {
    $("ul.menuContainer li a").each(function () {
      var $this = $(this);
      var href = $(this).attr("href");
      if (typeof href == "undefined" || href == "" || href == "#") {
        href = $(this).attr("data-href");
      }
      $this.on("click", function (e) {
        e.preventDefault();
        var $this = $(this);
        var linkType = $this.hasClass("scrollingLink") ? "scroll" : "redirect";
        if ($this.attr("data-linkAction") == 3) {
          linkType = "newSection";
          var dataSectionId = $this.attr("data-linksection");
        }
        var href = $(this).attr("href");
        if (typeof href == "undefined" || href == "" || href == "#") {
          href = $(this).attr("data-href");
        }
        if (linkType == "scroll") {
          var sectionClass = href;
          if (sectionClass.startsWith("#."))
            sectionClass = sectionClass.replace("#", "");
          $("html, body").animate(
            { scrollTop: $(sectionClass).offset().top },
            1000
          );
        } else if (linkType == "newSection") {
          if (typeof isPostPage != "undefined" && isPostPage == true) {
            location.href = blogHomePageUrl + "#.new" + dataSectionId;
          } else {
            section = $("section[data-id='" + dataSectionId + "']");
            if (section.length > 0) {
              $("html, body").animate(
                {
                  scrollTop: $(
                    "section[data-id='" + dataSectionId + "']"
                  ).offset().top,
                },
                1000
              );
            }
          }
        } else {
          if (typeof $(this).attr("target") != "undefined") {
            win = window.open(href, $(this).attr("target"));
            win.focus();
          } else window.location.href = href;
        }
      });
    });
  },
  initLogout: function () {
    if (
      typeof funnelType !== "undefined" &&
      funnelType == "membership" &&
      pageType != "login"
    ) {
      $("ul.menuContainer").append(
        '<li class="element active" contenteditable="false"><a style="color:#666" class="menuItem" data-linkaction="3" data-linksection="-1" href="#logout-signform-modal" data-toggle="modal"><div contenteditable="false"> Logout</div></a></li>'
      );
    }
    $('button[data-action="logout"]').click(function () {
      let url = "/contacts/membership-logout/" + funnelId;
      window.location.href = url;
    });
  },
};
$(document).ready(function () {
  Public_PB_Menu.init();
});
window.onload = function () {
  Public_PB_Menu.initGoToSection();
};
var Public_PB_Countdown = {
  countDownDateSelectors: [],
  countDownContInterval: false,
  init: function () {
    this.initDateCountDown();
    this.initEvergreenCountDown();
    this.initValueCounters();
    this.startCountDown();
  },
  initDateCountDown: function () {
    $('.counterElement[data-counttype="date"]').each(function (i, e) {
      var date = $(e).attr("data-date");
      var hours = parseInt($(e).attr("data-hours"));
      var minutes = parseInt($(e).attr("data-min"));
      var ampm = $(e).attr("data-ampm");
      var timeZone = parseInt($(e).attr("data-tz"));
      var wantedTime = "";
      if (typeof date == "undefined" || date == "") {
        return;
      }
      if (ampm == "pm") {
        hours += 12;
      }
      date = date.split("/");
      wantedTime = new Date(
        Date.UTC(
          parseInt(date[2]),
          parseInt(date[0]) - 1,
          parseInt(date[1]),
          hours,
          minutes,
          0
        )
      );
      wantedTime.setHours(wantedTime.getHours() - timeZone);
      Public_PB_Countdown.countDownDateSelectors.push({
        selector: $(e),
        time: wantedTime,
      });
    });
  },
  initEvergreenCountDown: function () {
    $('.counterElement[data-counttype="evergreen"]').each(function (i, e) {
      if ($(e).attr("evergreen-id") === undefined) {
        $(e).attr("evergreen-id", "evergreen" + getRandomNumber());
      }
      var evergreen_id = $(e).attr("evergreen-id");
      if (
        Public_PB_Countdown.getCookie(evergreen_id + "_egCounter") !== "true"
      ) {
        Public_PB_Countdown.setCookie(evergreen_id + "_egCounter", "true", 100);
        var hours = $(e).attr("data-eghours");
        var minutes = $(e).attr("data-egminutes");
        var seconds = $(e).attr("data-egseconds");
        var days = $(e).attr("data-egdays");
        var wantedTime = new Date();
        wantedTime.setDate(wantedTime.getDate() + parseInt(days));
        wantedTime.setHours(wantedTime.getHours() + parseInt(hours));
        wantedTime.setMinutes(wantedTime.getMinutes() + parseInt(minutes));
        wantedTime.setSeconds(wantedTime.getSeconds() + parseInt(seconds));
        Public_PB_Countdown.setCookie(
          evergreen_id + "_egDate",
          wantedTime,
          100
        );
        Public_PB_Countdown.countDownDateSelectors.push({
          selector: $(e),
          time: wantedTime,
        });
      } else if (
        Public_PB_Countdown.getCookie(evergreen_id + "_egCounter") === "true"
      ) {
        Public_PB_Countdown.countDownDateSelectors.push({
          selector: $(e),
          time: Public_PB_Countdown.getCookie(evergreen_id + "_egDate"),
        });
      }
    });
  },
  startCountDown: function () {
    Public_PB_Countdown.countDownContInterval = window.setInterval(function () {
      Public_PB_Countdown._updateCountDownTimer();
    }, 1000);
  },
  _updateCountDownTimer: function () {
    $.each(Public_PB_Countdown.countDownDateSelectors, function (i, selector) {
      var evergreen_id = selector.selector.attr("evergreen-id");
      if (
        Public_PB_Countdown.getCookie(evergreen_id + "_egCounter") !== "true"
      ) {
        var diff = (selector.time - new Date()) / 1000;
      } else {
        wantedTime = new Date(
          Date.parse(Public_PB_Countdown.getCookie(evergreen_id + "_egDate"))
        );
        var diff = (wantedTime - new Date()) / 1000;
      }
      if (diff < 0) diff = 0;
      selector.selector
        .find(".day-value.countdown-element-value")
        .text(Math.floor(diff / 86400));
      diff = diff % 86400;
      selector.selector
        .find(".hour-value.countdown-element-value")
        .text(Math.floor(diff / 3600));
      diff = diff % 3600;
      selector.selector
        .find(".minute-value.countdown-element-value")
        .text(Math.floor(diff / 60));
      diff = diff % 60;
      selector.selector
        .find(".second-value.countdown-element-value")
        .text(Math.floor(diff));
    });
  },
  initValueCounters: function () {
    $("div.elements-control.upCounterElem .numberHolder .number.element").each(
      function (i, e) {
        var dataFrom = $(e).attr("data-from");
        var dataTo = $(e).attr("data-to");
        var dataSpeed = $(e).attr("data-speed");
        var $e = $(e);
        $(e).html(dataFrom);
        setTimeout(function () {
          $e.countTo({
            from: parseInt(dataFrom),
            to: parseInt(dataTo),
            speed: parseInt(dataSpeed) * 2,
            onComplete: function (value) {
              $(this).html(
                Public_PB_Countdown.numberWithCommas($(this).text())
              );
            },
          });
        }, 1000);
      }
    );
  },
  numberWithCommas: function (x) {
    return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  },
  setCookie: function (cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);
    var expires = "expires=" + d.toUTCString();
    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
  },
  getCookie: function (cname) {
    var name = cname + "=";
    var decodedCookie = decodeURIComponent(document.cookie);
    var ca = decodedCookie.split(";");
    for (var i = 0; i < ca.length; i++) {
      var c = ca[i];
      while (c.charAt(0) == " ") {
        c = c.substring(1);
      }
      if (c.indexOf(name) == 0) {
        return c.substring(name.length, c.length);
      }
    }
    return "";
  },
};
$(document).ready(function () {
  Public_PB_Countdown.init();
});
var Public_PB_Footer = {
  footerFormData: false,
  init: function () {
    if ($(".footerFormModalsSettingsHolder").length == 1) {
      try {
        Public_PB_Footer.footerFormData = jQuery.parseJSON(
          b64decode($(".footerFormModalsSettingsHolder").html())
        );
      } catch (e) {
        Public_PB_Footer.footerFormData = jQuery.parseJSON(
          $(".footerFormModalsSettingsHolder").html()
        );
        $(".footerFormModalsSettingsHolder").html(
          b64encode($(".footerFormModalsSettingsHolder").html())
        );
      }
    }
    tos = b64decode(tos);
    if (tos.tos) {
      if (Public_PB_Footer.footerFormData == false) {
        Public_PB_Footer.footerFormData = { tos: "", privacy: "" };
        if (tos.tos.terms_of_service) {
          Public_PB_Footer.footerFormData.tos = b64decode(
            tos.tos.terms_of_service
          );
        }
        if (tos.tos.privacy_policy) {
          Public_PB_Footer.footerFormData.privacy = b64decode(
            tos.tos.privacy_policy
          );
        }
      }
    }
    if ($("span.current-year").length == 1) {
      $("span.current-year").text(new Date().getFullYear());
    } else if ($("span.comp-name").length == 1) {
      var str = $("span.comp-name")[0].nextSibling.data;
      var res = str.replace(/\b(19|20)\d{2}\b/gi, new Date().getFullYear());
      res = res.replace("&Acirc;", "");
      res = res.replace("Â", "");
      $("span.comp-name")[0].nextSibling.data = res;
      if ($("span.comp-name")[0].previousSibling) {
        var str2 = $("span.comp-name")[0].previousSibling.data;
        var res2 = str2.replace(/\b(19|20)\d{2}\b/gi, new Date().getFullYear());
        res2 = res2.replace("&Acirc;", "");
        res2 = res2.replace("Â", "");
        res2 = res2.replace("Ã‚", "");
        $("span.comp-name")[0].previousSibling.data = res2;
      }
    }
    if ($(".footer-text p").length == 1) {
      var str = $(".footer-text p").html();
      var res = str.replace(/Ã‚Â/gm, "");
      $(".footer-text p").html(res);
    }
    this.initModals();
  },
  initModals: function () {
    $("a.footer-tos").on("click", function () {
      if (Public_PB_Footer.footerFormData == false) return;
      $("#footer-tos-modal .modal-body .content").html(
        b64decode(Public_PB_Footer.footerFormData.tos)
      );
      $("#footer-tos-modal").modal("show");
    });
    $("a.footer-privacy").on("click", function () {
      if (Public_PB_Footer.footerFormData == false) return;
      $("#footer-privacy-modal .modal-body .content").html(
        b64decode(Public_PB_Footer.footerFormData.privacy)
      );
      $("#footer-privacy-modal").modal("show");
    });
  },
};
$(document).ready(function () {
  Public_PB_Footer.init();
});
var orderSettings = "";
var Public_PB_Order = {
  orderFormSettings: false,
  orderFormSettingsId: false,
  init: function () {
    this.getOrderFormSettings();
    this.initItemInfo();
    this.initOrderButton();
    this.initProfitBumpAction();
    if (orderSettings.gateway == "stripe") {
      this.initOrderButtonStripe();
      Stripe_Client.init();
    } else if (orderSettings.gateway == "authorize") {
      this.initOrderButtonAuthorize();
    } else if (orderSettings.gateway == "paypal") {
      this.initOrderButtonPayPal();
    } else if (orderSettings.gateway == "infusionsoft") {
      this.initOrderButtonInfusionSoft();
    }
    if (findGetParameter("show-order-thank-you") == 1) {
      Public_PB_Order.showThankYouPopUp();
    }
  },
  initOrderButtonStripe: function () {
    var payment_form = $(
      '<form action="/" method="post" id="payment-form" class="contactForm"><div class="form-row"><div id="card-element"></div><div id="card-errors" role="alert"></div></div><button class="hide" id="strip-submit-btn">Submit Payment</button> </form>'
    );
    $(".orderFormElement #of-ccard-title").parent().find(".form-group").hide();
    $(".orderFormElement #of-ccard-title").after(payment_form);
  },
  initOrderButtonInfusionSoft: function () {},
  initOrderButtonPayPal: function () {
    $(".orderFormElement #of-ccard-title").parent().find(".form-group").hide();
    $(".orderFormElement #of-ccard-title").hide();
  },
  initOrderButtonAuthorize: function () {},
  showThankYouPopUp: function () {
    var settings = Public_PB_Order.orderFormSettings.thank_you.popup_options;
    $("#form-popup-thank-you").modal("show");
    $("#form-popup-thank-you .modal-content").css(
      "background-color",
      settings.background_color
    );
    $("#form-popup-thank-you button.ok-button").css(
      "background",
      settings.button_color
    );
    $("#form-popup-thank-you button.ok-button").css("box-shadow", "none");
    $("#form-popup-thank-you button.ok-button").html(
      atob(settings.button_text)
    );
    if (settings.button_visible == 0) {
      $("#form-popup-thank-you button.ok-button").hide();
    }
    $("#form-popup-thank-you .title").html(atob(settings.headline_text));
    if (settings.headline_visible == 0) {
      $("#form-popup-thank-you .title").hide();
    }
    $("#form-popup-thank-you .details").html(atob(settings.subeadline_text));
    if (settings.subheadline_visible == 0) {
      $("#form-popup-thank-you .details").hide();
    }
    $("#form-popup-thank-you .icon-image").attr("src", settings.icon_url);
    if (settings.icon_visible == 0) {
      $("#form-popup-thank-you .icon-image").hide();
    }
    $("#form-popup-thank-you").on("hidden.bs.modal", function () {});
  },
  getOrderFormSettings: function () {
    if (pageBuilderData.id) {
      $.ajax({
        type: "POST",
        url: "/funnels/order/get-settings/" + pageBuilderData.id,
        cache: false,
        dataType: "json",
        crossDomain: true,
        data: [],
        async: false,
        success: function (data) {
          orderSettings = data.message;
        },
      });
    }
    if ($(".orderFormElement").length > 0) {
      _formSettings = $(".orderFormElement").find(
        ".buttonModalsSettingsHolder"
      );
      if (_formSettings.length > 0) {
        Public_PB_Order.orderFormSettings = jQuery.parseJSON(
          _formSettings.html()
        );
        Public_PB_Order.orderFormSettingsId = _formSettings.attr("data-id");
        var smsPermissionVisible = 0;
        var gdpr_optin_approval = 0;
        $.each(
          Public_PB_Order.orderFormSettings.order_form_settings.containers,
          function (i, container) {
            $.each(container.fields, function (i, field) {
              if (field["id"] == "of-phone-number") {
                if (field.additional && field.additional.sms_permission) {
                  smsPermissionVisible = field.additional.sms_permission;
                }
                if (field.visible == false) {
                  smsPermissionVisible = 0;
                }
              }
              if (field["id"] == "of-gdpr-optin-approval") {
                if (field.additional && field.additional.gdpr_optin_approval) {
                  gdpr_optin_approval = field.additional.gdpr_optin_approval;
                }
              }
            });
          }
        );
        Public_PB_Order.initOptinGDPR(
          gdpr_optin_approval,
          smsPermissionVisible
        );
      }
    }
  },
  initOrderButton: function () {
    $(".orderFormElement .submitBtn").on("click", function () {
      if ($(this).attr("disabled") == "disabled") return;
      if (isPreview == "true") return;
      var error = false;
      var hasGtwGrIntegration = false;
      if (
        typeof Public_PB_Order.orderFormSettings.integrations != "undefined" &&
        Public_PB_Order.orderFormSettings.automation_enable &&
        (Public_PB_Order.orderFormSettings.integrations.integration_type ==
          "gotowebinar" ||
          Public_PB_Order.orderFormSettings.integrations.integration_type ==
            "infusionsoft")
      ) {
        hasGtwGrIntegration = true;
      }
      var contactInfo = Public_PB_Order._collectContactData();
      if (Public_PB_Order.orderFormSettings == false)
        error = "Order Form setting is missing!";
      else if (contactInfo.name == "") error = "Name is empty!";
      else if (contactInfo.email == "") error = "Email is empty!";
      else if (!validateEmail(contactInfo.email)) error = "Email is invalid!";
      else {
        $.each(
          Public_PB_Order.orderFormSettings.order_form_settings.containers,
          function (i, container) {
            $.each(container.fields, function (i, field) {
              if (
                field["setting"] == true &&
                field["visible"] == true &&
                field["require"] == true
              ) {
                if (field["id"] == "of-phone-number")
                  if (contactInfo.phone == "") {
                    error = "Phone Number is empty!";
                    return;
                  }
              }
            });
          }
        );
      }
      if (error == false) {
        if (
          $("#of-ccard-number input:visible").length == 1 &&
          $("#of-ccard-number input").val() == ""
        ) {
          error = "Credit Card is empty";
        } else if (
          $("#of-ccard-cvc input:visible").length == 1 &&
          $("#of-ccard-cvc input").val() == ""
        ) {
          error = "CVC is empty";
        } else if (
          $("#of-ccard-exmonth:visible").length == 1 &&
          $("#of-ccard-exmonth").val() == "-1"
        ) {
          error = "Expiry Month is empty";
        } else if (
          $("#of-ccard-exyear:visible").length == 1 &&
          $("#of-ccard-exyear").val() == "-1"
        ) {
          error = "Expiry Year is empty";
        }
      }
      if (error == false) {
        Public_PB_Order._setOrderButtonDisabled();
        if (orderSettings.gateway == "stripe") {
          $("#strip-submit-btn").trigger("click");
        } else if (orderSettings.gateway == "authorize") {
          Public_PB_Order.sentAuthorizeOrder();
        } else if (orderSettings.gateway == "paypal") {
          Public_PB_Order.sentPayPalOrder();
        } else if (orderSettings.gateway == "infusionsoft") {
          Public_PB_Order.sentInfusionSoftOrder();
        }
      } else showCoreModalErrorMessage(error);
    });
  },
  initProfitBumpAction: function () {
    $(".otoUpsell-chk").change(function () {
      if (
        $(this).is(":checked") &&
        typeof orderSettings.bump_product != "undefined" &&
        orderSettings.bump_product != null
      ) {
        $(".orderFormElement #order-summary-wrapper .value").html(
          orderSettings.currencySign +
            (
              parseFloat(orderSettings.product.price) +
              parseFloat(orderSettings.bump_product.price)
            ).toFixed(2)
        );
      } else {
        $(".orderFormElement #order-summary-wrapper .value").html(
          orderSettings.currencySign +
            parseFloat(orderSettings.product.price).toFixed(2)
        );
      }
    });
  },
  initItemInfo: function () {
    if (isPreview == "true") return;
    $(".orderFormElement #order-summary-wrapper .lbl").html(
      orderSettings.product.name
    );
    $(".orderFormElement #order-summary-wrapper .value").html(
      orderSettings.currencySign +
        parseFloat(orderSettings.product.price).toFixed(2)
    );
  },
  stripeTokenHandler: function (result) {
    let bump_product = "none";
    if (
      $(".otoUpsell-chk").is(":checked") &&
      typeof orderSettings.bump_product != "undefined" &&
      orderSettings.bump_product != null
    )
      bump_product = orderSettings.bump_product;
    var ajaxData = {
      test_mode: testMode,
      product: orderSettings.product,
      gateway_result: result,
      contact: Public_PB_Order._collectContactData(),
      id: pageBuilderData.id,
      bump_product: bump_product,
      formSettingsId: Public_PB_Order.orderFormSettingsId,
    };
    if ($("#shipping-information-wrapper:visible").length > 0) {
      ajaxData["shipping_info"] = Public_PB_Order._collectShippingInfo();
    }
    $.ajax({
      type: "POST",
      url: siteUrl + "funnels/order/stripe",
      cache: false,
      dataType: "json",
      crossDomain: true,
      data: ajaxData,
      success: function (data) {
        if (data.status == "error") {
          showCoreModalErrorMessage(data.message);
          Public_PB_Order._removeOrderButtonDisabled();
        } else if (data.status == "success") {
          Public_PB_Order._removeOrderButtonDisabled();
          Public_PB_Order.addClickToButtonsForms(
            Public_PB_Order.orderFormSettingsId
          );
          if (Public_PB_Order.orderFormSettings == false) return;
          if (Public_PB_Order.orderFormSettings.action_type == "1")
            Public_PB_Order.showThankYouPopUp();
          if (Public_PB_Order.orderFormSettings.action_type == "2") {
            window.location.href =
              Public_PB_Order.orderFormSettings.form_redirect_custom_url;
          } else if (
            Public_PB_Order.orderFormSettings.form_redirect_type == 4
          ) {
            window.location.href =
              "tel://" + Public_PB_Order.orderFormSettings.click_to_call.value;
          } else if (
            Public_PB_Order.orderFormSettings.form_redirect_type == 5
          ) {
            window.location.href =
              "mailto:" +
              Public_PB_Order.orderFormSettings.click_to_email.value;
          } else if (
            Public_PB_Order.orderFormSettings.form_redirect_type == 3
          ) {
            if (
              Public_PB_Order.orderFormSettings.form_redirect_funnel_url !=
              "next-funnel"
            )
              window.location.href =
                siteUrl +
                "show-page/" +
                Public_PB_Order.orderFormSettings.form_redirect_funnel_url;
          }
        } else {
          Public_PB_Order._removeOrderButtonDisabled();
        }
      },
    });
  },
  _collectContactData: function () {
    var contactInfo = {
      name: $("#of-full-name input").val(),
      email: $("#of-field-email input").val(),
      phone: $("#of-phone-number input").val(),
      last_action: "order",
    };
    return contactInfo;
  },
  _collectShippingInfo: function () {
    var shipping_info = {
      name: $("#of-full-name input").val(),
      address: {
        line1: $("#of-shipping-address input").val(),
        city: $("#of-shipping-city input").val(),
        state: $("#of-shipping-state input").val(),
        country: $("#of-shipping-country").val(),
        postal_code: $("#of-shipping-zipcode input").val(),
      },
    };
    return shipping_info;
  },
  _setOrderButtonDisabled: function () {
    $(".orderFormElement .submitBtn")
      .addClass("disabled")
      .attr("disabled", "disabled");
  },
  _removeOrderButtonDisabled: function () {
    $(".orderFormElement .submitBtn")
      .removeClass("disabled")
      .attr("disabled", false);
  },
  addClickToButtonsForms: function (element_id) {
    $.ajax({
      type: "POST",
      url: siteUrl + "funnels/show/add_click_to_buttons_forms",
      data: { element_id: element_id },
      success: function () {},
    });
  },
  sentAuthorizeOrder: function () {
    var ajaxData = {
      test_mode: testMode,
      product: orderSettings.product,
      contact: Public_PB_Order._collectContactData(),
      id: pageBuilderData.id,
      card: {
        number: $("#of-ccard-number input").val(),
        cvc: $("#of-ccard-cvc input").val(),
        month: $("#of-ccard-exmonth").val(),
        year: $("#of-ccard-exyear").val(),
      },
      formSettingsId: Public_PB_Order.orderFormSettingsId,
    };
    $.ajax({
      type: "POST",
      url: siteUrl + "funnels/order/authorize",
      cache: false,
      dataType: "json",
      crossDomain: true,
      data: ajaxData,
      success: function (data) {
        if (data.status == "error") {
          showCoreModalErrorMessage(data.message);
          Public_PB_Order._removeOrderButtonDisabled();
        } else if (data.status == "success") {
          Public_PB_Order.addClickToButtonsForms(
            Public_PB_Order.orderFormSettingsId
          );
          if (Public_PB_Order.orderFormSettings == false) return;
          if (Public_PB_Order.orderFormSettings.action_type == "1")
            Public_PB_Order.showThankYouPopUp();
          if (Public_PB_Order.orderFormSettings.action_type == "2") {
            window.location.href =
              Public_PB_Order.orderFormSettings.form_redirect_custom_url;
          } else if (Public_PB_Order.orderFormSettings.action_type == "3") {
            window.location.href =
              siteUrl +
              "show-page/" +
              Public_PB_Order.orderFormSettings.form_redirect_funnel_url;
          }
        } else {
          Public_PB_Order._removeOrderButtonDisabled();
        }
      },
    });
  },
  sentPayPalOrder: function () {
    let bump_product = "none";
    if (
      $(".otoUpsell-chk").is(":checked") &&
      typeof orderSettings.bump_product != "undefined" &&
      orderSettings.bump_product != null
    )
      bump_product = orderSettings.bump_product;
    var ajaxData = {
      test_mode: testMode,
      product: orderSettings.product,
      bump_product: bump_product,
      contact: Public_PB_Order._collectContactData(),
      id: pageBuilderData.id,
      page_url:
        document.location.protocol +
        "//" +
        document.location.hostname +
        document.location.pathname,
      next_page_url: "#",
      formSettingsId: Public_PB_Order.orderFormSettingsId,
    };
    if ($("#shipping-information-wrapper:visible").length > 0) {
      ajaxData["shipping_info"] = Public_PB_Order._collectShippingInfo();
    }
    if (Public_PB_Order.orderFormSettings.action_type == "1") {
      ajaxData.next_page_url =
        document.location.protocol +
        "//" +
        document.location.hostname +
        document.location.pathname +
        "?show-order-thank-you=1";
    } else if (Public_PB_Order.orderFormSettings.action_type == "2") {
      ajaxData.next_page_url =
        Public_PB_Order.orderFormSettings.form_redirect_custom_url;
    } else if (Public_PB_Order.orderFormSettings.action_type == 4) {
      ajaxData.next_page_url =
        "tel://" + Public_PB_Order.orderFormSettings.click_to_call.value;
    } else if (Public_PB_Order.orderFormSettings.action_type == 5) {
      ajaxData.next_page_url =
        "mailto:" + Public_PB_Order.orderFormSettings.click_to_email.value;
    } else if (Public_PB_Order.orderFormSettings.form_redirect_type == 3) {
      if (
        Public_PB_Order.orderFormSettings.form_redirect_funnel_url !=
        "next-funnel"
      )
        ajaxData.next_page_url =
          siteUrl +
          "show-page/" +
          Public_PB_Order.orderFormSettings.form_redirect_funnel_url;
    }
    $.ajax({
      type: "POST",
      url: siteUrl + "funnels/order/paypal-redirect",
      cache: false,
      dataType: "json",
      crossDomain: true,
      data: ajaxData,
      success: function (data) {
        if (data.status == "error") {
          showCoreModalErrorMessage(data.message);
          Public_PB_Order._removeOrderButtonDisabled();
        } else if (data.status == "success") {
          window.location.href = data.redirect;
        } else {
          console.log(data);
          Public_PB_Order._removeOrderButtonDisabled();
        }
      },
    });
  },
  sentInfusionSoftOrder: function () {
    var ajaxData = {
      test_mode: testMode,
      product: orderSettings.product,
      contact: Public_PB_Order._collectContactData(),
      id: pageBuilderData.id,
      card: {
        number: $("#of-ccard-number input").val(),
        cvc: $("#of-ccard-cvc input").val(),
        month: $("#of-ccard-exmonth").val(),
        year: $("#of-ccard-exyear").val(),
      },
      formSettingsId: Public_PB_Order.orderFormSettingsId,
    };
    $.ajax({
      type: "POST",
      url: siteUrl + "funnels/order/infusionsoft",
      cache: false,
      dataType: "json",
      crossDomain: true,
      data: ajaxData,
      success: function (data) {
        if (data.status == "error") {
          showCoreModalErrorMessage(data.message);
          Public_PB_Order._removeOrderButtonDisabled();
        } else if (data.status == "success") {
          Public_PB_Order.addClickToButtonsForms(
            Public_PB_Order.orderFormSettingsId
          );
          if (Public_PB_Order.orderFormSettings == false) return;
          if (Public_PB_Order.orderFormSettings.action_type == "1")
            Public_PB_Order.showThankYouPopUp();
          if (Public_PB_Order.orderFormSettings.action_type == "2") {
            window.location.href =
              Public_PB_Order.orderFormSettings.form_redirect_custom_url;
          } else if (Public_PB_Order.orderFormSettings.action_type == "3") {
            window.location.href =
              siteUrl +
              "show-page/" +
              Public_PB_Order.orderFormSettings.form_redirect_funnel_url;
          }
        } else {
          Public_PB_Order._removeOrderButtonDisabled();
        }
      },
    });
  },
  initOptinGDPR: function (gdpr_optin_approval, smsPermissionVisible) {
    $(".orderFormElement").find(".gdprAgreement").hide();
    if (smsPermissionVisible == 0) {
      if (gdpr_optin_approval == "1") {
        var x = new XMLHttpRequest();
        x.open(
          "GET",
          "https://pro.ip-api.com/xml/?key=R5xiO0FwQoC0t9D&fields=timezone",
          true
        );
        x.onreadystatechange = function () {
          if (x.readyState == 4 && x.status == 200) {
            var doc = x.responseXML;
            var Region = doc
              .getElementsByTagName("timezone")[0]
              .firstChild.nodeValue.toString();
            if (Region.toString().toLowerCase().includes("europe")) {
              $(".orderFormElement").find(".gdprAgreement").show();
            }
          }
        };
        x.send(null);
      } else if (gdpr_optin_approval == "2") {
        $(".orderFormElement").find(".gdprAgreement").show();
      }
    }
  },
};
$(document).ready(function () {
  if ($(".orderFormElement").length > 0) Public_PB_Order.init();
});
var Stripe_Client = {
  stripeClient: false,
  stripeCard: false,
  formHolder: false,
  style: {
    base: {
      color: "#32325d",
      lineHeight: "18px",
      fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
      fontSmoothing: "antialiased",
      fontSize: "16px",
      "::placeholder": { color: "#aab7c4" },
    },
    invalid: { color: "#fa755a", iconColor: "#fa755a" },
  },
  init: function () {
    Stripe_Client.formHolder = document.getElementById("payment-form");
    try {
      Stripe_Client.stripeClient = Stripe(orderSettings.settings.api_key);
      Stripe_Client.setCard();
      Stripe_Client.setFormHandler();
    } catch (err) {
      showCoreModalErrorMessage("Please finish your order form setup.");
    }
  },
  setFormHandler: function () {
    Stripe_Client.formHolder.addEventListener("submit", function (event) {
      event.preventDefault();
      Stripe_Client.stripeClient
        .createToken(Stripe_Client.stripeCard)
        .then(function (result) {
          var errorElement = document.getElementById("card-errors");
          if (result.error) {
            errorElement.textContent = result.error.message;
            Public_PB_Order._removeOrderButtonDisabled();
          } else if (!result.token) {
            errorElement.textContent = "Invalid token";
            Public_PB_Order._removeOrderButtonDisabled();
          } else {
            Public_PB_Order.stripeTokenHandler(result.token);
          }
        });
    });
  },
  setCard: function () {
    var elements = Stripe_Client.stripeClient.elements();
    Stripe_Client.stripeCard = elements.create("card", {
      style: Stripe_Client.style,
    });
    Stripe_Client.stripeCard.mount("#card-element");
    Stripe_Client.stripeCard.addEventListener("change", function (event) {
      var displayError = document.getElementById("card-errors");
      if (event.error) {
        displayError.textContent = event.error.message;
      } else {
        displayError.textContent = "";
      }
    });
  },
};
!(function ($) {
  "use strict";
  var TabCollapse = function (el, options) {
    this.options = options;
    this.$tabs = $(el);
    this._accordionVisible = false;
    this._initAccordion();
    this._checkStateOnResize();
    var that = this;
    setTimeout(function () {
      that.checkState();
    }, 0);
  };
  TabCollapse.DEFAULTS = {
    accordionClass: "visible-xs",
    tabsClass: "hidden-xs",
    accordionTemplate: function (heading, groupId, parentId, active) {
      return (
        '<div class="panel panel-default">' +
        '   <div class="panel-heading">' +
        '      <h4 class="panel-title">' +
        "      </h4>" +
        "   </div>" +
        '   <div id="' +
        groupId +
        '" class="panel-collapse collapse ' +
        (active ? "in" : "") +
        '">' +
        '       <div class="panel-body js-tabcollapse-panel-body">' +
        "       </div>" +
        "   </div>" +
        "</div>"
      );
    },
  };
  TabCollapse.prototype.checkState = function () {
    if (this.$tabs.is(":visible") && this._accordionVisible) {
      this.showTabs();
      this._accordionVisible = false;
    } else if (this.$accordion.is(":visible") && !this._accordionVisible) {
      this.showAccordion();
      this._accordionVisible = true;
    }
  };
  TabCollapse.prototype.showTabs = function () {
    var view = this;
    this.$tabs.trigger($.Event("show-tabs.bs.tabcollapse"));
    var $panelHeadings = this.$accordion
      .find(".js-tabcollapse-panel-heading")
      .detach();
    $panelHeadings.each(function () {
      var $panelHeading = $(this),
        $parentLi = $panelHeading.data("bs.tabcollapse.parentLi");
      var $oldHeading = view._panelHeadingToTabHeading($panelHeading);
      $parentLi.removeClass("active");
      if (
        $parentLi.parent().hasClass("dropdown-menu") &&
        !$parentLi.siblings("li").hasClass("active")
      ) {
        $parentLi.parent().parent().removeClass("active");
      }
      if (!$oldHeading.hasClass("collapsed")) {
        $parentLi.addClass("active");
        if ($parentLi.parent().hasClass("dropdown-menu")) {
          $parentLi.parent().parent().addClass("active");
        }
      } else {
        $oldHeading.removeClass("collapsed");
      }
      $parentLi.append($panelHeading);
    });
    if (!$("li").hasClass("active")) {
      $("li").first().addClass("active");
    }
    var $panelBodies = this.$accordion.find(".js-tabcollapse-panel-body");
    $panelBodies.each(function () {
      var $panelBody = $(this),
        $tabPane = $panelBody.data("bs.tabcollapse.tabpane");
      $tabPane.append($panelBody.contents().detach());
    });
    this.$accordion.html("");
    if (this.options.updateLinks) {
      var $tabContents = this.getTabContentElement();
      $tabContents
        .find('[data-toggle-was="tab"], [data-toggle-was="pill"]')
        .each(function () {
          var $el = $(this);
          var href = $el.attr("href").replace(/-collapse$/g, "");
          $el.attr({
            "data-toggle": $el.attr("data-toggle-was"),
            "data-toggle-was": "",
            "data-parent": "",
            href: href,
          });
        });
    }
    this.$tabs.trigger($.Event("shown-tabs.bs.tabcollapse"));
  };
  TabCollapse.prototype.getTabContentElement = function () {
    var $tabContents = $(this.options.tabContentSelector);
    if ($tabContents.length === 0) {
      $tabContents = this.$tabs.siblings(".tab-content");
    }
    return $tabContents;
  };
  TabCollapse.prototype.showAccordion = function () {
    this.$tabs.trigger($.Event("show-accordion.bs.tabcollapse"));
    var $headings = this.$tabs.find(
        'li:not(.dropdown) [data-toggle="tab"], li:not(.dropdown) [data-toggle="pill"]'
      ),
      view = this;
    $headings.each(function () {
      var $heading = $(this),
        $parentLi = $heading.parent();
      $heading.data("bs.tabcollapse.parentLi", $parentLi);
      view.$accordion.append(
        view._createAccordionGroup(
          view.$accordion.attr("id"),
          $heading.detach()
        )
      );
    });
    if (this.options.updateLinks) {
      var parentId = this.$accordion.attr("id");
      var $selector = this.$accordion.find(".js-tabcollapse-panel-body");
      $selector
        .find('[data-toggle="tab"], [data-toggle="pill"]')
        .each(function () {
          var $el = $(this);
          var href = $el.attr("href") + "-collapse";
          $el.attr({
            "data-toggle-was": $el.attr("data-toggle"),
            "data-toggle": "collapse",
            "data-parent": "#" + parentId,
            href: href,
          });
        });
    }
    this.$tabs.trigger($.Event("shown-accordion.bs.tabcollapse"));
  };
  TabCollapse.prototype._panelHeadingToTabHeading = function ($heading) {
    var href = $heading.attr("href").replace(/-collapse$/g, "");
    $heading.attr({ "data-toggle": "tab", href: href, "data-parent": "" });
    return $heading;
  };
  TabCollapse.prototype._tabHeadingToPanelHeading = function (
    $heading,
    groupId,
    parentId,
    active
  ) {
    $heading.addClass(
      "js-tabcollapse-panel-heading " + (active ? "" : "collapsed")
    );
    $heading.attr({
      "data-toggle": "collapse",
      "data-parent": "#" + parentId,
      href: "#" + groupId,
    });
    return $heading;
  };
  TabCollapse.prototype._checkStateOnResize = function () {
    var view = this;
    $(window).resize(function () {
      clearTimeout(view._resizeTimeout);
      view._resizeTimeout = setTimeout(function () {
        view.checkState();
      }, 100);
    });
  };
  TabCollapse.prototype._initAccordion = function () {
    var randomString = function () {
      var result = "",
        possible =
          "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
      for (var i = 0; i < 5; i++) {
        result += possible.charAt(Math.floor(Math.random() * possible.length));
      }
      return result;
    };
    var srcId = this.$tabs.attr("id"),
      accordionId = (srcId ? srcId : randomString()) + "-accordion";
    this.$accordion = $(
      '<div class="panel-group ' +
        this.options.accordionClass +
        '" id="' +
        accordionId +
        '"></div>'
    );
    this.$tabs.after(this.$accordion);
    this.$tabs.addClass(this.options.tabsClass);
    this.getTabContentElement().addClass(this.options.tabsClass);
  };
  TabCollapse.prototype._createAccordionGroup = function (parentId, $heading) {
    var tabSelector = $heading.attr("data-target"),
      active = $heading.data("bs.tabcollapse.parentLi").is(".active");
    if (!tabSelector) {
      tabSelector = $heading.attr("href");
      tabSelector = tabSelector && tabSelector.replace(/.*(?=#[^\s]*$)/, "");
    }
    var $tabPane = $(tabSelector),
      groupId = $tabPane.attr("id") + "-collapse",
      $panel = $(
        this.options.accordionTemplate($heading, groupId, parentId, active)
      );
    $panel
      .find(".panel-heading > .panel-title")
      .append(
        this._tabHeadingToPanelHeading($heading, groupId, parentId, active)
      );
    $panel
      .find(".panel-body")
      .append($tabPane.contents().detach())
      .data("bs.tabcollapse.tabpane", $tabPane);
    return $panel;
  };
  $.fn.tabCollapse = function (option) {
    return this.each(function () {
      var $this = $(this);
      var data = $this.data("bs.tabcollapse");
      var options = $.extend(
        {},
        TabCollapse.DEFAULTS,
        $this.data(),
        typeof option === "object" && option
      );
      if (!data) $this.data("bs.tabcollapse", new TabCollapse(this, options));
    });
  };
  $.fn.tabCollapse.Constructor = TabCollapse;
})(window.jQuery);
var closePopUp = function () {
  var popupWindow = document.getElementById("cookies-popup");
  popupWindow.style.display = "none";
};
var IUnderStandFunc = function () {
  closePopUp();
  document.cookie = "NotFirstTime=YES";
};
var x = new XMLHttpRequest();
x.open(
  "GET",
  "https://pro.ip-api.com/xml/?key=R5xiO0FwQoC0t9D&fields=timezone",
  true
);
x.onreadystatechange = function () {
  if (x.readyState == 4 && x.status == 200) {
    var doc = x.responseXML;
    var Region = doc
      .getElementsByTagName("timezone")[0]
      .firstChild.nodeValue.toString();
    var cookieValue = document.cookie.replace(
      /(?:(?:^|.*;\s*)NotFirstTime\s*\=\s*([^;]*).*$)|^.*$/,
      "$1"
    );
    if (cookieValue != "YES") {
      if (Region.toString().toLowerCase().includes("europe")) {
        var link;
        var element;
        var t = setTimeout(openPopUp, 2000);
        function openPopUp(url) {
          link = url;
          element = document.getElementById("cookies-popup");
          element.style.display = "block";
        }
        var block_to_insert;
        block_to_insert = document.createElement("div");
        block_to_insert.innerHTML =
          '<div id="cookies-popup" style="display:none;" class="cookies-main-container"> <i class="close-circle fa fa-times" onclick="closePopUp()"></i> <div class="upper-side"> <img src="https://assets.localgeniussite.com/webmaster-assets/cookies-popup/cookie-icon.png"/> <p class="upper-title">Its Always Better With Cookies :)</p> </div> <div class="body-side"> <p class="paragraph bold">We use cookies to improve your experience on this site.</p> <p class="paragraph">You agree by clicking <b>"I Understand"</b> or viewing our site after you have received this cookie notification.</p> </div> <div class="down-side"> <a href="javascript:void(0);" class="understand-btn" onclick="IUnderStandFunc()">I understand</a> <a href="javascript:void(0)" onClick="showLearnMore()" class="learn-btn">learn more</a> </div> </div>';
        document.body.appendChild(block_to_insert);
        block_to_insert = document.createElement("div");
        block_to_insert.innerHTML =
          '<div id="gdpr-myModal" style="display:none;" class="gdpr-modal"><div class="gdpr-modal-content"><div class="gdpr-header"><p>PRIVACY POLICY</p></div><div class="gdpr-content"><p><i>Last Revised May 25, 2018</i></p><p class="p-align-right"><b>PRIVACY POLICY</b></p><div><p><b>Introduction</b></p><p>The creator of this website is the data controller and we are responsible for your personal data (referred to as "we", "us" or "our" in this notice) through your use of this Site.</p><p>For the purposes of our Policy, when we refer to "you" we mean any past, current or prospective customer, including a visitor to this Site. </p><p>You grant us permissions outlined in this notice by clicking on "I agree" or by continuing use of this site after receiving this notification.</p><p>If you need to contact us about this Policy, please refer to the business contact information found in the Terms linked at the bottom of the Site.</p><p>This Policy does not cover any other data collection or processing. In the future, the data that you (and potentially any customers) will be governed by a separate agreement.</p><p>By providing us with your data, you warrant to us that you are over 13 years of age.</p></div><div><p><b>Data Collection.</b></p><div><p>We may collect from you the following data:</p><ul><li>First Name and Last Name</li><li>Email Address</li><li>Preferred Phone Number</li><li>Business Name</li><li>Postal Address</li><li>Marketing and Communication Preference</li><li>Technical Data including Cookies and Usage Data</li></ul></div></div><div><p><b>Use of Data.</b></p><div><p>We may use your data to: </p><ul><li>Reply to your request for specific materials or resources,</li><li>Reply to inquiries about products or services,</li><li>Contact you with relevant information including newsletters,</li><li>Contact you marketing and/or promotional offers,</li><li>Contact you with other information that may be of interest to you,</li><li>Contact you with special offers,</li><li>Contact you to participate in relevant surveys,</li><li>Obtain feedback about the quality of service,</li><li>Effectively administer and protect the Site.</li></ul></div></div><div><p><b>Grounds of Processing.</b></p><div><p>Under General Data Protection Data Regulations, we have lawful grounds of processing your personal data because of your consent or our legitimate interests in responding to:</p><ul><li>Your general inquiry,</li><li>Your inquiry about products or services,</li><li>Your request for specific materials or resources.</li></ul><p>We do not collect any Sensitive Data; including details about your race, ethnicity, religious or philosophical beliefs, sexual orientation, political beliefs, health, criminal history.</p><p>Our lawful ground of processing your personal data to send you marketing communications is either your consent or our legitimate interest.</p></div></div><div><p><b>Data Collection.</b></p><div><p>We primarily collect your data by the data you provide to us (Example - Providing Name and Email on this Site or sending an email to the business details found in the Terms). By using our Site, we may automatically collect certain data by using cookies and similar technologies. </p><p>We may use third parties located outside the EU such as Google search, Facebook advertising network, providers of technical services and fraud detection agencies.Marketing Communication.</p></div></div><div><p><b>Communication.</b></p><div><p>Under the Privacy and Electronic Communications Regulations, we may only send you email or text marketing communications if you made a purchase or asked for information from us without having opted out. If you are a limited company, we may still email you without consent. However, you can opt out at any time.</p><p>To unsubscribe or opt out of any communication, please contact us using the business details in the Terms at the bottom of this Site.</p></div></div><div><p><b>Disclosures.</b></p><div><p>Personal data may have to be shared with the following parties:</p><ul><li>Administrative service providers.</li><li>Technical service providers.</li><li>Professional service providers including lawyers & accountants.</li><li>Government bodies.</li><li>Third parties that may acquire or transfer parts or entirety of our business assets.</li></ul><p>All parties with whom we disclose personal data to will be required to adhere to the law.</p></div></div><div><p><b>International Transfer.</b></p><div><p>We may share your personal data with companies outside of the European Economic Area (EAA).</p><p>As such, we are subject to the General Data Protection Regulations (GDPR) that protect your personal data. We will ensure the proper safeguards are in place whenever your personal data is transferred outside the EAA.</p></div></div><div><p><b>Security.</b></p><div><p>Reasonable security measures have been put in place to prevent loss, alteration, accidental disclosures. Only employees and authorized partners will have access to your personal data in order to process it as instructed. All your personal data is expected to be kept confidential.</p><p>If a data breach occurs, we have procedures in place that includes notifying you and any regulation body if we are legally required to.</p></div></div><div><p><b>Cookies.</b></p><div><p>As a data subject, you may set any browser to refuse all cookies or notify you of a cookie sent. If you do not accept any cookies, you may experience issues with this Site.</p></div></div><div><p><b>Information Storage. </b></p><div><p>We will retain your personal data for the length of time required for the purpose it was collected.  As we process your personal data, we ensure it will be treated in accordance with this Privacy Notice.</p></div></div><div><p><b>Links to Other Sites. </b></p><div><p>Our Site may contain links to other sites that are not operated by us. If you click on a third-party link, you will be directed to that third party\'s site. We strongly advise you to review the Privacy Policy of every site you visit. We have no control over and assume no responsibility for the content, privacy policies or practices of any third-party sites or services.</p></div></div><div><p><b>Your Rights.  </b></p><div><p>If you are a resident of the EEA, you have certain personal data protection rights regarding the right to request access, correction, deletion, restriction, transfer, object to processing data, data portability and (where lawful) withdraw consent.</p><p>Please contact the business information in the Terms to make any of the above requests.  Note, we may ask you to verify your identify before acting on any request.</p><p>If you are dissatisfied with how we collect and process your data, we ask that you please contact us first so we can do our best to resolve. However, you have the right to complain to the Information Commission\'s Office (ICO) or your local data protection authority.</p></div></div></div><div class="gdpr-footer"><button type="button" onClick="OptOutHandler()" class="gdpr-btn-close gray">Decline</button><button type="button" onClick="CloseLearnMore()" class="gdpr-btn-close">I Accept</button></div></div></div>';
        document.body.appendChild(block_to_insert);
      }
    }
  }
};
x.send(null);
var btn = document.getElementById("gdpr-myBtn");
var span = document.getElementsByClassName("gdpr-close")[0];
var closeBtn = document.getElementsByClassName("gdpr-btn-close")[0];
var showLearnMore = function () {
  var cookie_privacy_policy = "";
  if (tos.tos && tos.tos.cookie_privacy_policy) {
    cookie_privacy_policy = tos.tos.cookie_privacy_policy;
    $("#gdpr-myModal").find(".gdpr-content").html(cookie_privacy_policy);
  }
  var modal = document.getElementById("gdpr-myModal");
  modal.style.display = "block";
};
var CloseLearnMore = function () {
  var modal = document.getElementById("gdpr-myModal");
  modal.style.display = "none";
  IUnderStandFunc();
};
var OptOutHandler = function () {
  CloseLearnMore();
  document.cookie = "preventCookieCreation=true";
};
window.onclick = function (event) {
  var modal = document.getElementById("gdpr-myModal");
  if (event.target == modal) {
    modal.style.display = "none";
  }
};
$(".imgGalleryElement .outerImageContainer").click(function (e) {
  e.preventDefault();
  $(".imgGalleryElement .outerImageContainer").removeClass("selected");
  const scrollY = document.documentElement.style.getPropertyValue("--scroll-y");
  const body = document.body;
  body.style.position = "fixed";
  body.style.width = "100%";
  body.style.top = `-${scrollY}`;
  $(".imag-gallery-viewer-container").css("visibility", "visible");
  $(".imag-gallery-viewer-container").css("opacity", "1");
  $(this).addClass("selected");
  imgSrc =
    $(this).find(".elementImageHolder >img").attr("data-originalImage") ===
    undefined
      ? $(this).find(".elementImageHolder >img").attr("src")
      : $(this).find(".elementImageHolder >img").attr("data-originalImage");
  $(".imag-gallery-viewer-container  .gallery-viewer-img-container img").attr(
    "src",
    imgSrc
  );
  $(".imag-gallery-viewer-container .gallery-viewer-img-title").html(
    $(this).find(".elementImageHolder .img-title").html()
  );
  $(".imag-gallery-viewer-container .gallery-viewer-img-text").html(
    $(this).find(".elementImageHolder .img-text").html()
  );
  $(".imag-gallery-viewer-container .gallery-viewer-img-link").html(
    $(this).attr("data-link")
  );
  $(".imag-gallery-viewer-container .gallery-viewer-img-link").attr(
    "href",
    $(this).attr("data-link")
  );
});
$(".imag-gallery-viewer-container .gallery-viewer-close-btn").click(
  function () {
    const body = document.body;
    const scrollY = body.style.top;
    body.style.position = "";
    body.style.top = "";
    window.scrollTo(0, parseInt(scrollY || "0") * -1);
    $(".imag-gallery-viewer-container").css("visibility", "hidden");
    $(".imag-gallery-viewer-container").css("opacity", "0");
  }
);
window.addEventListener("scroll", () => {
  document.documentElement.style.setProperty(
    "--scroll-y",
    `${window.scrollY}px`
  );
});
$(".imag-gallery-viewer-container .left.gallery-viewe-control").click(
  function () {
    ShowPreviousImage();
  }
);
$(".imag-gallery-viewer-container .right.gallery-viewe-control").click(
  function () {
    ShowNextImage();
  }
);
function ShowNextImage() {
  currentImage = $(".imgGalleryElement .outerImageContainer.selected");
  nextImage = currentImage.next(".outerImageContainer");
  if (nextImage.length > 0) {
    currentImage.removeClass("selected");
    nextImage.addClass("selected");
    imgLink = "";
    if (nextImage.attr("data-link") != undefined) {
      imgLink = nextImage.attr("data-link");
    }
    imgSrc = nextImage
      .find(".elementImageHolder >img")
      .attr("data-originalImage");
    if (imgSrc === undefined) {
      imgSrc =
        nextImage.find(".elementImageHolder >img").attr("src") === undefined
          ? nextImage.find(".elementImageHolder >img").attr("data-src")
          : nextImage.find(".elementImageHolder >img").attr("src");
    }
    $(
      ".imag-gallery-viewer-container  .gallery-viewer-img-container img"
    ).fadeTo("fast", 0.33, function () {
      $(
        ".imag-gallery-viewer-container  .gallery-viewer-img-container img"
      ).attr("src", imgSrc);
      $(
        ".imag-gallery-viewer-container  .gallery-viewer-img-container img"
      ).fadeTo("fast", 1);
    });
    $(".imag-gallery-viewer-container .gallery-viewer-img-title").html(
      nextImage.find(".elementImageHolder .img-title").html()
    );
    $(".imag-gallery-viewer-container .gallery-viewer-img-text").html(
      nextImage.find(".elementImageHolder .img-text").html()
    );
    $(".imag-gallery-viewer-container .gallery-viewer-img-link").html(imgLink);
    $(".imag-gallery-viewer-container .gallery-viewer-img-link").attr(
      "href",
      imgLink
    );
  }
}
function ShowPreviousImage() {
  currentImage = $(".imgGalleryElement .outerImageContainer.selected");
  prevImage = currentImage.prev(".outerImageContainer");
  if (prevImage.length > 0) {
    currentImage.removeClass("selected");
    prevImage.addClass("selected");
    imgLink = "";
    if (prevImage.attr("data-link") != undefined) {
      imgLink = prevImage.attr("data-link");
    }
    imgSrc = prevImage
      .find(".elementImageHolder >img")
      .attr("data-originalImage");
    if (imgSrc === undefined) {
      imgSrc =
        prevImage.find(".elementImageHolder >img").attr("src") === undefined
          ? prevImage.find(".elementImageHolder >img").attr("data-src")
          : prevImage.find(".elementImageHolder >img").attr("src");
    }
    $(
      ".imag-gallery-viewer-container  .gallery-viewer-img-container img"
    ).fadeTo("fast", 0.33, function () {
      $(
        ".imag-gallery-viewer-container  .gallery-viewer-img-container img"
      ).attr("src", imgSrc);
      $(
        ".imag-gallery-viewer-container  .gallery-viewer-img-container img"
      ).fadeTo("fast", 1);
    });
    $(".imag-gallery-viewer-container .gallery-viewer-img-title").html(
      prevImage.find(".elementImageHolder .img-title").html()
    );
    $(".imag-gallery-viewer-container .gallery-viewer-img-text").html(
      prevImage.find(".elementImageHolder .img-text").html()
    );
    $(".imag-gallery-viewer-container .gallery-viewer-img-link").html(imgLink);
    $(".imag-gallery-viewer-container .gallery-viewer-img-link").attr(
      "href",
      imgLink
    );
  }
}
$(document).ready(function () {
  $(".imgGalleryElement").each(function () {
    myGallery = $(this);
    myGallery.find(".elementWrapper .outerImageContainer:hidden").length > 0
      ? myGallery.find(".gallery-more-btn").show()
      : myGallery.find(".gallery-more-btn").hide();
  });
});
$(document).on("click", ".imgGalleryElement .gallery-more-btn", function () {
  myGallery = $(this).closest(".imgGalleryElement");
  colsCount = parseInt($(myGallery).attr("data-imageColumns"));
  myGallery.find(".outerImageContainer:hidden").each(function (i) {
    if (i + 1 <= colsCount * 2) {
      $(this).show();
    }
  });
  myGallery.find(".elementWrapper .outerImageContainer:hidden").length > 0
    ? myGallery.find(".gallery-more-btn").show()
    : myGallery.find(".gallery-more-btn").hide();
});
