if (typeof ppData === "undefined") { (function () { function a(a) { for (var b, d = document.cookie.split(";"), e = 0; e < d.length; e++) { for (b = d[e]; " " == b.charAt(0);) b = b.substring(1, b.length); if (0 == b.indexOf(a)) return cookie = b.substring(a.length, b.length), parseInt(cookie) || 0 } return 0 } function b(a, b) { var c = new Date, d = new Date(c.getTime() + 3600000); document.cookie = a + b + ";expires=" + d.toGMTString() + ";path=/;" } for (var c, d = function () { }, e = ["assert", "clear", "count", "debug", "dir", "dirxml", "error", "exception", "group", "groupCollapsed", "groupEnd", "info", "log", "markTimeline", "profile", "profileEnd", "table", "time", "timeEnd", "timeStamp", "trace", "warn"], f = e.length, g = window.console = window.console || {}; f--;) c = e[f], g[c] || (g[c] = d); var h = !1, i = "scapp_now=", j = "scapp_next=", k = a(i), l = a(j); if ("undefined" == typeof SCAPPinit ? h = !0 : SCAPPinit.initial ? k && l && k <= l ? (h = !1, 100 > l ? b(j, l + 1) : (b(j, 2), b(i, 1))) : (h = !0, l && k ? b(j, l + 1) : (b(j, 2), b(i, 1))) : (SCAPPinit.initial = !0, k && l && k < l ? (h = !0, b(i, l)) : k && l && "undefined" != typeof SCAPPLive ? h = !0 : h = !1), h) { function a() { SCAPPApi.sacppfancybox(window, document, jQuerySCAPP, void 0), SCAPPApi.scappPlugin(jQuerySCAPP), SCAPPApi.scappCountdown(jQuerySCAPP), jQuerySCAPP(document).ready(function () { m("//cdnjs.cloudflare.com/ajax/libs/json2/20130526/json2.min.js", function () { }), p(jQuerySCAPP) }) } g.log("da loaded"), !function () { var method; Object.keys || (Object.keys = function (e) { var t = []; for (var o in e) e.hasOwnProperty(o) && t.push(o); return t }); for (var noop = function () { }, methods = ["assert", "clear", "count", "debug", "dir", "dirxml", "error", "exception", "group", "groupCollapsed", "groupEnd", "info", "log", "markTimeline", "profile", "profileEnd", "table", "time", "timeEnd", "timeStamp", "trace", "warn"], length = methods.length, console = window.console = window.console || {}, mb; length--;) method = methods[length], console[method] || (console[method] = noop); function scapphandleMouseleave(e) { "undefined" != typeof jQuerySCAPP && SCAPPApi.callbackOnLeave(jQuerySCAPP) } function isMoblieBrowser() { var e, t = !1; try { e = navigator.userAgent || navigator.vendor || window.opera, (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0, 4))) && (t = !0) } catch (e) { console.log(e) } return t } function isTablet() { var e = isMoblieBrowser(); return e || (e = "ontouchstart" in document.documentElement), e } document.documentElement.addEventListener ? document.documentElement.addEventListener("mouseleave", scapphandleMouseleave) : document.documentElement.attachEvent("mouseleave", scapphandleMouseleave); try { isTablet() && (window.onblur = function () { scapphandleMouseleave(void 0) }) } catch (e) { console.log(e) } "undefined" == typeof LZString && (LZString = { _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", _f: String.fromCharCode, compressToBase64: function (e) { if (null == e) return ""; var t, o, i, n, a, r, s, p = "", c = 0; for (e = LZString.compress(e); c < 2 * e.length;) c % 2 == 0 ? (t = e.charCodeAt(c / 2) >> 8, o = 255 & e.charCodeAt(c / 2), i = c / 2 + 1 < e.length ? e.charCodeAt(c / 2 + 1) >> 8 : NaN) : (t = 255 & e.charCodeAt((c - 1) / 2), (c + 1) / 2 < e.length ? (o = e.charCodeAt((c + 1) / 2) >> 8, i = 255 & e.charCodeAt((c + 1) / 2)) : o = i = NaN), c += 3, n = t >> 2, a = (3 & t) << 4 | o >> 4, r = (15 & o) << 2 | i >> 6, s = 63 & i, isNaN(o) ? r = s = 64 : isNaN(i) && (s = 64), p = p + LZString._keyStr.charAt(n) + LZString._keyStr.charAt(a) + LZString._keyStr.charAt(r) + LZString._keyStr.charAt(s); return p }, decompressFromBase64: function (e) { if (null == e) return ""; var t, o, i, n, a, r, s, p = "", c = 0, l = 0, u = LZString._f; for (e = e.replace(/[^A-Za-z0-9\+\/\=]/g, ""); l < e.length;) o = LZString._keyStr.indexOf(e.charAt(l++)) << 2 | (a = LZString._keyStr.indexOf(e.charAt(l++))) >> 4, i = (15 & a) << 4 | (r = LZString._keyStr.indexOf(e.charAt(l++))) >> 2, n = (3 & r) << 6 | (s = LZString._keyStr.indexOf(e.charAt(l++))), c % 2 == 0 ? (t = o << 8, 64 != r && (p += u(t | i)), 64 != s && (t = n << 8)) : (p += u(t | o), 64 != r && (t = i << 8), 64 != s && (p += u(t | n))), c += 3; return LZString.decompress(p) }, compressToUTF16: function (e) { if (null == e) return ""; var t, o, i, n = "", a = 0, r = LZString._f; for (e = LZString.compress(e), t = 0; t < e.length; t++) switch (o = e.charCodeAt(t), a++) { case 0: n += r(32 + (o >> 1)), i = (1 & o) << 14; break; case 1: n += r(i + (o >> 2) + 32), i = (3 & o) << 13; break; case 2: n += r(i + (o >> 3) + 32), i = (7 & o) << 12; break; case 3: n += r(i + (o >> 4) + 32), i = (15 & o) << 11; break; case 4: n += r(i + (o >> 5) + 32), i = (31 & o) << 10; break; case 5: n += r(i + (o >> 6) + 32), i = (63 & o) << 9; break; case 6: n += r(i + (o >> 7) + 32), i = (127 & o) << 8; break; case 7: n += r(i + (o >> 8) + 32), i = (255 & o) << 7; break; case 8: n += r(i + (o >> 9) + 32), i = (511 & o) << 6; break; case 9: n += r(i + (o >> 10) + 32), i = (1023 & o) << 5; break; case 10: n += r(i + (o >> 11) + 32), i = (2047 & o) << 4; break; case 11: n += r(i + (o >> 12) + 32), i = (4095 & o) << 3; break; case 12: n += r(i + (o >> 13) + 32), i = (8191 & o) << 2; break; case 13: n += r(i + (o >> 14) + 32), i = (16383 & o) << 1; break; case 14: n += r(i + (o >> 15) + 32, 32 + (32767 & o)), a = 0 } return n + r(i + 32) }, decompressFromUTF16: function (e) { if (null == e) return ""; for (var t, o, i = "", n = 0, a = 0, r = LZString._f; a < e.length;) { switch (o = e.charCodeAt(a) - 32, n++) { case 0: t = o << 1; break; case 1: i += r(t | o >> 14), t = (16383 & o) << 2; break; case 2: i += r(t | o >> 13), t = (8191 & o) << 3; break; case 3: i += r(t | o >> 12), t = (4095 & o) << 4; break; case 4: i += r(t | o >> 11), t = (2047 & o) << 5; break; case 5: i += r(t | o >> 10), t = (1023 & o) << 6; break; case 6: i += r(t | o >> 9), t = (511 & o) << 7; break; case 7: i += r(t | o >> 8), t = (255 & o) << 8; break; case 8: i += r(t | o >> 7), t = (127 & o) << 9; break; case 9: i += r(t | o >> 6), t = (63 & o) << 10; break; case 10: i += r(t | o >> 5), t = (31 & o) << 11; break; case 11: i += r(t | o >> 4), t = (15 & o) << 12; break; case 12: i += r(t | o >> 3), t = (7 & o) << 13; break; case 13: i += r(t | o >> 2), t = (3 & o) << 14; break; case 14: i += r(t | o >> 1), t = (1 & o) << 15; break; case 15: i += r(t | o), n = 0 } a++ } return LZString.decompress(i) }, compressToUint8Array: function (e) { for (var t = LZString.compress(e), o = new Uint8Array(2 * t.length), i = 0, n = t.length; i < n; i++) { var a = t.charCodeAt(i); o[2 * i] = a >>> 8, o[2 * i + 1] = a % 256 } return o }, decompressFromUint8Array: function (e) { if (null == e) return LZString.decompress(e); for (var t = new Array(e.length / 2), o = 0, i = t.length; o < i; o++) t[o] = 256 * e[2 * o] + e[2 * o + 1]; return LZString.decompress(String.fromCharCode.apply(null, t)) }, compressToEncodedURIComponent: function (e) { return LZString.compressToBase64(e).replace(/=/g, "$").replace(/\//g, "-") }, decompressFromEncodedURIComponent: function (e) { return e && (e = e.replace(/$/g, "=").replace(/-/g, "/")), LZString.decompressFromBase64(e) }, compress: function (e) { if (null == e) return ""; var t, o, i, n = {}, a = {}, r = "", s = "", p = "", c = 2, l = 3, u = 2, d = "", h = 0, f = 0, g = LZString._f; for (i = 0; i < e.length; i += 1) if (r = e.charAt(i), Object.prototype.hasOwnProperty.call(n, r) || (n[r] = l++, a[r] = !0), s = p + r, Object.prototype.hasOwnProperty.call(n, s)) p = s; else { if (Object.prototype.hasOwnProperty.call(a, p)) { if (p.charCodeAt(0) < 256) { for (t = 0; t < u; t++) h <<= 1, 15 == f ? (f = 0, d += g(h), h = 0) : f++; for (o = p.charCodeAt(0), t = 0; t < 8; t++) h = h << 1 | 1 & o, 15 == f ? (f = 0, d += g(h), h = 0) : f++, o >>= 1 } else { for (o = 1, t = 0; t < u; t++) h = h << 1 | o, 15 == f ? (f = 0, d += g(h), h = 0) : f++, o = 0; for (o = p.charCodeAt(0), t = 0; t < 16; t++) h = h << 1 | 1 & o, 15 == f ? (f = 0, d += g(h), h = 0) : f++, o >>= 1 } 0 == --c && (c = Math.pow(2, u), u++), delete a[p] } else for (o = n[p], t = 0; t < u; t++) h = h << 1 | 1 & o, 15 == f ? (f = 0, d += g(h), h = 0) : f++, o >>= 1; 0 == --c && (c = Math.pow(2, u), u++), n[s] = l++, p = String(r) } if ("" !== p) { if (Object.prototype.hasOwnProperty.call(a, p)) { if (p.charCodeAt(0) < 256) { for (t = 0; t < u; t++) h <<= 1, 15 == f ? (f = 0, d += g(h), h = 0) : f++; for (o = p.charCodeAt(0), t = 0; t < 8; t++) h = h << 1 | 1 & o, 15 == f ? (f = 0, d += g(h), h = 0) : f++, o >>= 1 } else { for (o = 1, t = 0; t < u; t++) h = h << 1 | o, 15 == f ? (f = 0, d += g(h), h = 0) : f++, o = 0; for (o = p.charCodeAt(0), t = 0; t < 16; t++) h = h << 1 | 1 & o, 15 == f ? (f = 0, d += g(h), h = 0) : f++, o >>= 1 } 0 == --c && (c = Math.pow(2, u), u++), delete a[p] } else for (o = n[p], t = 0; t < u; t++) h = h << 1 | 1 & o, 15 == f ? (f = 0, d += g(h), h = 0) : f++, o >>= 1; 0 == --c && (c = Math.pow(2, u), u++) } for (o = 2, t = 0; t < u; t++) h = h << 1 | 1 & o, 15 == f ? (f = 0, d += g(h), h = 0) : f++, o >>= 1; for (; ;) { if (h <<= 1, 15 == f) { d += g(h); break } f++ } return d }, decompress: function (e) { if (null == e) return ""; if ("" == e) return null; var t, o, i, n, a, r, s, p = [], c = 4, l = 4, u = 3, d = "", h = "", f = LZString._f, g = {string: e, val: e.charCodeAt(0), position: 32768, index: 1}; for (t = 0; t < 3; t += 1) p[t] = t; for (i = 0, a = Math.pow(2, 2), r = 1; r != a;) n = g.val & g.position, g.position >>= 1, 0 == g.position && (g.position = 32768, g.val = g.string.charCodeAt(g.index++)), i |= (0 < n ? 1 : 0) * r, r <<= 1; switch (i) { case 0: for (i = 0, a = Math.pow(2, 8), r = 1; r != a;) n = g.val & g.position, g.position >>= 1, 0 == g.position && (g.position = 32768, g.val = g.string.charCodeAt(g.index++)), i |= (0 < n ? 1 : 0) * r, r <<= 1; s = f(i); break; case 1: for (i = 0, a = Math.pow(2, 16), r = 1; r != a;) n = g.val & g.position, g.position >>= 1, 0 == g.position && (g.position = 32768, g.val = g.string.charCodeAt(g.index++)), i |= (0 < n ? 1 : 0) * r, r <<= 1; s = f(i); break; case 2: return "" } for (o = h = p[3] = s; ;) { if (g.index > g.string.length) return ""; for (i = 0, a = Math.pow(2, u), r = 1; r != a;) n = g.val & g.position, g.position >>= 1, 0 == g.position && (g.position = 32768, g.val = g.string.charCodeAt(g.index++)), i |= (0 < n ? 1 : 0) * r, r <<= 1; switch (s = i) { case 0: for (i = 0, a = Math.pow(2, 8), r = 1; r != a;) n = g.val & g.position, g.position >>= 1, 0 == g.position && (g.position = 32768, g.val = g.string.charCodeAt(g.index++)), i |= (0 < n ? 1 : 0) * r, r <<= 1; p[l++] = f(i), s = l - 1, c--; break; case 1: for (i = 0, a = Math.pow(2, 16), r = 1; r != a;) n = g.val & g.position, g.position >>= 1, 0 == g.position && (g.position = 32768, g.val = g.string.charCodeAt(g.index++)), i |= (0 < n ? 1 : 0) * r, r <<= 1; p[l++] = f(i), s = l - 1, c--; break; case 2: return h } if (0 == c && (c = Math.pow(2, u), u++), p[s]) d = p[s]; else { if (s !== l) return null; d = o + o.charAt(0) } h += d, p[l++] = o + d.charAt(0), o = d, 0 == --c && (c = Math.pow(2, u), u++) } } }), "undefined" != typeof module && null != module && (module.exports = LZString), "undefined" == typeof SCABase64 && (SCABase64 = { _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", encode: function (e) { var t, o, i, n, a, r, s, p = "", c = 0; for (e = SCABase64._utf8_encode(e); c < e.length;) n = (t = e.charCodeAt(c++)) >> 2, a = (3 & t) << 4 | (o = e.charCodeAt(c++)) >> 4, r = (15 & o) << 2 | (i = e.charCodeAt(c++)) >> 6, s = 63 & i, isNaN(o) ? r = s = 64 : isNaN(i) && (s = 64), p = p + this._keyStr.charAt(n) + this._keyStr.charAt(a) + this._keyStr.charAt(r) + this._keyStr.charAt(s); return p }, decode: function (e) { var t, o, i, n, a, r, s = "", p = 0; for (e = e.replace(/[^A-Za-z0-9\+\/\=]/g, ""); p < e.length;) t = this._keyStr.indexOf(e.charAt(p++)) << 2 | (n = this._keyStr.indexOf(e.charAt(p++))) >> 4, o = (15 & n) << 4 | (a = this._keyStr.indexOf(e.charAt(p++))) >> 2, i = (3 & a) << 6 | (r = this._keyStr.indexOf(e.charAt(p++))), s += String.fromCharCode(t), 64 != a && (s += String.fromCharCode(o)), 64 != r && (s += String.fromCharCode(i)); return s = SCABase64._utf8_decode(s) }, _utf8_encode: function (e) { e = e.replace(/\r\n/g, "\n"); for (var t = "", o = 0; o < e.length; o++) { var i = e.charCodeAt(o); i < 128 ? t += String.fromCharCode(i) : (127 < i && i < 2048 ? t += String.fromCharCode(i >> 6 | 192) : (t += String.fromCharCode(i >> 12 | 224), t += String.fromCharCode(i >> 6 & 63 | 128)), t += String.fromCharCode(63 & i | 128)) } return t }, _utf8_decode: function (e) { for (var t = "", o = 0, i = c1 = c2 = 0; o < e.length;) (i = e.charCodeAt(o)) < 128 ? (t += String.fromCharCode(i), o++) : 191 < i && i < 224 ? (c2 = e.charCodeAt(o + 1), t += String.fromCharCode((31 & i) << 6 | 63 & c2), o += 2) : (c2 = e.charCodeAt(o + 1), c3 = e.charCodeAt(o + 2), t += String.fromCharCode((15 & i) << 12 | (63 & c2) << 6 | 63 & c3), o += 3); return t } }), mb = !1, window.JQClass = function () { }, JQClass.classes = {}, JQClass.extend = function e(t) { var n = this.prototype; mb = !0; var o = new this; for (var i in mb = !1, t) o[i] = "function" == typeof t[i] && "function" == typeof n[i] ? function (o, i) { return function () { var e = this._super; this._super = function (e) { return n[o].apply(this, e || []) }; var t = i.apply(this, arguments); return this._super = e, t } }(i, t[i]) : t[i]; function a() { !mb && this._init && this._init.apply(this, arguments) } return ((a.prototype = o).constructor = a).extend = e, a }, "undefined" == typeof SCAPPApi && (SCAPPApi = { sacppfancybox: function (n, o, j, d) { "use strict"; var a = j("html"), r = j(n), c = j(o), E = j.scappfancybox = function () { E.open.apply(this, arguments) }, s = navigator.userAgent.match(/msie/i), p = null, l = o.createTouch !== d, h = function (e) { return e && e.hasOwnProperty && e instanceof j }, f = function (e) { return e && "string" === j.type(e) }, F = function (e) { return f(e) && 0 < e.indexOf("%") }, q = function (e, t) { var o = parseInt(e, 10) || 0; return t && F(e) && (o = E.getViewport()[t] / 100 * o), Math.ceil(o) }, Q = function (e, t) { return q(e, t) + "px" }; j.extend(E, { version: "2.1.5", defaults: { padding: 0, margin: 18, width: 800, height: 600, minWidth: 100, minHeight: 100, maxWidth: 9999, maxHeight: 9999, pixelRatio: 1, autoSize: !0, autoHeight: !1, autoWidth: !1, autoResize: !0, autoCenter: !l, fitToView: !0, aspectRatio: !1, topRatio: .5, leftRatio: .5, scrolling: "auto", wrapCSS: "", arrows: !0, closeBtn: !0, closeClick: !1, nextClick: !1, mouseWheel: !0, autoPlay: !1, playSpeed: 3e3, preload: 3, modal: !1, loop: !0, ajax: {dataType: "html", headers: {"X-fancyBox": !0}}, iframe: {scrolling: "auto", preload: !0}, swf: {wmode: "transparent", allowfullscreen: "true", allowscriptaccess: "always"}, keys: { next: {13: "left", 34: "up", 39: "left", 40: "up"}, prev: {8: "right", 33: "down", 37: "right", 38: "down"}, close: [27], play: [32], toggle: [70] }, direction: {next: "left", prev: "right"}, scrollOutside: !0, index: 0, type: null, href: null, content: null, title: null, tpl: { wrap: '
', image: '', iframe: '", error: '

The requested content cannot be loaded.
Please try again later.

', closeBtn: '', next: '', prev: '' }, openEffect: "fade", openSpeed: 250, openEasing: "swing", openOpacity: !0, openMethod: "zoomIn", closeEffect: "fade", closeSpeed: 250, closeEasing: "swing", closeOpacity: !0, closeMethod: "zoomOut", nextEffect: "elastic", nextSpeed: 250, nextEasing: "swing", nextMethod: "changeIn", prevEffect: "elastic", prevSpeed: 250, prevEasing: "swing", prevMethod: "changeOut", helpers: {overlay: !0, title: !0}, onCancel: j.noop, beforeLoad: j.noop, afterLoad: j.noop, beforeShow: j.noop, afterShow: j.noop, beforeChange: j.noop, beforeClose: j.noop, afterClose: j.noop }, group: {}, opts: {}, previous: null, coming: null, current: null, isActive: !1, isOpen: !1, isOpened: !1, wrap: null, skin: null, outer: null, inner: null, player: {timer: null, isActive: !1}, ajaxLoad: null, imgPreload: null, transitions: {}, helpers: {}, open: function (l, u) { if (l && (j.isPlainObject(u) || (u = {}), !1 !== E.close(!0))) return j.isArray(l) || (l = h(l) ? j(l).get() : [l]), j.each(l, function (e, t) { var o, i, n, a, r, s, p, c = {}; "object" === j.type(t) && (t.nodeType && (t = j(t)), h(t) ? (c = { href: t.data("scappfancybox-href") || t.attr("href"), title: t.data("scappfancybox-title") || t.attr("title"), isDom: !0, element: t }, j.metadata && j.extend(!0, c, t.metadata())) : c = t), o = u.href || c.href || (f(t) ? t : null), i = u.title !== d ? u.title : c.title || "", !(a = (n = u.content || c.content) ? "html" : u.type || c.type) && c.isDom && ((a = t.data("scappfancybox-type")) || (a = (r = t.prop("class").match(/scappfancybox\.(\w+)/)) ? r[1] : null)), f(o) && (a || (E.isImage(o) ? a = "image" : E.isSWF(o) ? a = "swf" : "#" === o.charAt(0) ? a = "inline" : f(t) && (a = "html", n = t)), "ajax" === a && (o = (s = o.split(/\s+/, 2)).shift(), p = s.shift())), n || ("inline" === a ? o ? n = j(f(o) ? o.replace(/.*(?=#[^\s]+$)/, "") : o) : c.isDom && (n = t) : "html" === a ? n = o : a || o || !c.isDom || (a = "inline", n = t)), j.extend(c, { href: o, type: a, content: n, title: i, selector: p }), l[e] = c }), E.opts = j.extend(!0, {}, E.defaults, u), u.keys !== d && (E.opts.keys = !!u.keys && j.extend({}, E.defaults.keys, u.keys)), E.group = l, E._start(E.opts.index) }, cancel: function () { var e = E.coming; e && !1 !== E.trigger("onCancel") && (E.hideLoading(), E.ajaxLoad && E.ajaxLoad.abort(), E.ajaxLoad = null, E.imgPreload && (E.imgPreload.onload = E.imgPreload.onerror = null), e.wrap && e.wrap.stop(!0, !0).trigger("onReset").remove(), E.coming = null, E.current || E._afterZoomOut(e)) }, close: function (e) { E.cancel(), !1 !== E.trigger("beforeClose") && (E.unbindEvents(), E.isActive && (E.isOpen && !0 !== e ? (E.isOpen = E.isOpened = !1, E.isClosing = !0, j(".scappfancybox-item, .scappfancybox-nav").remove(), E.wrap.stop(!0, !0).removeClass("scappfancybox-opened"), E.transitions[E.current.closeMethod]()) : (j(".scappfancybox-wrap").stop(!0).trigger("onReset").remove(), E._afterZoomOut()))) }, play: function (e) { var t = function () { clearTimeout(E.player.timer) }, o = function () { t(), E.current && E.player.isActive && (E.player.timer = setTimeout(E.next, E.current.playSpeed)) }, i = function () { t(), c.unbind(".player"), E.player.isActive = !1, E.trigger("onPlayEnd") }; !0 === e || !E.player.isActive && !1 !== e ? E.current && (E.current.loop || E.current.index < E.group.length - 1) && (E.player.isActive = !0, c.bind({ "onCancel.player beforeClose.player": i, "onUpdate.player": o, "beforeLoad.player": t }), o(), E.trigger("onPlayStart")) : i() }, next: function (e) { var t = E.current; t && (f(e) || (e = t.direction.next), E.jumpto(t.index + 1, e, "next")) }, prev: function (e) { var t = E.current; t && (f(e) || (e = t.direction.prev), E.jumpto(t.index - 1, e, "prev")) }, jumpto: function (e, t, o) { var i = E.current; i && (e = q(e), E.direction = t || i.direction[e >= i.index ? "next" : "prev"], E.router = o || "jumpto", i.loop && (e < 0 && (e = i.group.length + e % i.group.length), e %= i.group.length), i.group[e] !== d && (E.cancel(), E._start(e))) }, reposition: function (e, t) { var o, i = E.current, n = i ? i.wrap : null; n && (o = E._getPosition(t), e && "scroll" === e.type ? (delete o.position, n.stop(!0, !0).animate(o, 200)) : (n.css(o), i.pos = j.extend({}, i.dim, o))) }, update: function (t) { var o = t && t.type, i = !o || "orientationchange" === o; i && (clearTimeout(p), p = null), E.isOpen && !p && (p = setTimeout(function () { var e = E.current; e && !E.isClosing && (E.wrap.removeClass("scappfancybox-tmp"), (i || "load" === o || "resize" === o && e.autoResize) && E._setDimension(), "scroll" === o && e.canShrink || E.reposition(t), E.trigger("onUpdate"), p = null) }, i && !l ? 0 : 300)) }, toggle: function (e) { E.isOpen && (E.current.fitToView = "boolean" === j.type(e) ? e : !E.current.fitToView, l && (E.wrap.removeAttr("style").addClass("scappfancybox-tmp"), E.trigger("onUpdate")), E.update()) }, hideLoading: function () { c.unbind(".loading"), j("#scappfancybox-loading").remove() }, showLoading: function () { var e, t; E.hideLoading(), e = j('
').click(E.cancel).appendTo("body"), c.bind("keydown.loading", function (e) { 27 === (e.which || e.keyCode) && (e.preventDefault(), E.cancel()) }), E.defaults.fixed || (t = E.getViewport(), e.css({ position: "absolute", top: .5 * t.h + t.y, left: .5 * t.w + t.x })) }, getViewport: function () { var e = E.current && E.current.locked || !1, t = {x: r.scrollLeft(), y: r.scrollTop()}; return t.h = e ? (t.w = e[0].clientWidth, e[0].clientHeight) : (t.w = l && n.innerWidth ? n.innerWidth : r.width(), l || n.innerHeight ? n.innerHeight : r.height()), t }, unbindEvents: function () { E.wrap && h(E.wrap) && E.wrap.unbind(".fb"), c.unbind(".fb"), r.unbind(".fb") }, bindEvents: function () { var t, p = E.current; p && (r.bind("orientationchange.fb" + (l ? "" : " resize.fb") + (p.autoCenter && !p.locked ? " scroll.fb" : ""), E.update), (t = p.keys) && c.bind("keydown.fb", function (o) { var i = o.which || o.keyCode, e = o.target || o.srcElement; if (27 === i && E.coming) return !1; o.ctrlKey || o.altKey || o.shiftKey || o.metaKey || e && (e.type || j(e).is("[contenteditable]")) || j.each(t, function (e, t) { return 1 < p.group.length && t[i] !== d ? (E[e](t[i]), o.preventDefault(), !1) : -1 < j.inArray(i, t) ? (E[e](), o.preventDefault(), !1) : void 0 }) }), j.fn.mousewheel && p.mouseWheel && E.wrap.bind("mousewheel.fb", function (e, t, o, i) { for (var n, a = e.target || null, r = j(a), s = !1; r.length && !(s || r.is(".scappfancybox-skin") || r.is(".scappfancybox-wrap"));) s = (n = r[0]) && !(n.style.overflow && "hidden" === n.style.overflow) && (n.clientWidth && n.scrollWidth > n.clientWidth || n.clientHeight && n.scrollHeight > n.clientHeight), r = j(r).parent(); 0 === t || s || 1 < E.group.length && !p.canShrink && (0 < i || 0 < o ? E.prev(0 < i ? "down" : "left") : (i < 0 || o < 0) && E.next(i < 0 ? "up" : "right"), e.preventDefault()) })) }, trigger: function (o, e) { var t, i = e || E.coming || E.current; if (i) { if (j.isFunction(i[o]) && (t = i[o].apply(i, Array.prototype.slice.call(arguments, 1))), !1 === t) return !1; i.helpers && j.each(i.helpers, function (e, t) { t && E.helpers[e] && j.isFunction(E.helpers[e][o]) && E.helpers[e][o](j.extend(!0, {}, E.helpers[e].defaults, t), i) }), c.trigger(o) } }, isImage: function (e) { return f(e) && e.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i) }, isSWF: function (e) { return f(e) && e.match(/\.(swf)((\?|#).*)?$/i) }, _start: function (e) { var t, o, i, n, a, r = {}; if (e = q(e), !(t = E.group[e] || null)) return !1; if (n = (r = j.extend(!0, {}, E.opts, t)).margin, a = r.padding, "number" === j.type(n) && (r.margin = [n, n, n, n]), "number" === j.type(a) && (r.padding = [a, a, a, a]), r.modal && j.extend(!0, r, { closeBtn: !1, closeClick: !1, nextClick: !1, arrows: !1, mouseWheel: !1, keys: null, helpers: {overlay: {closeClick: !1}} }), r.autoSize && (r.autoWidth = r.autoHeight = !0), "auto" === r.width && (r.autoWidth = !0), "auto" === r.height && (r.autoHeight = !0), r.group = E.group, r.index = e, E.coming = r, !1 !== E.trigger("beforeLoad")) { if (i = r.type, o = r.href, !i) return E.coming = null, !(!E.current || !E.router || "jumpto" === E.router) && (E.current.index = e, E[E.router](E.direction)); if (E.isActive = !0, "image" !== i && "swf" !== i || (r.autoHeight = r.autoWidth = !1, r.scrolling = "visible"), "image" === i && (r.aspectRatio = !0), "iframe" === i && l && (r.scrolling = "scroll"), r.wrap = j(r.tpl.wrap).addClass("scappfancybox-" + (l ? "mobile" : "desktop") + " scappfancybox-type-" + i + " scappfancybox-tmp " + r.wrapCSS).appendTo(r.parent || "body"), j.extend(r, { skin: j(".scappfancybox-skin", r.wrap), outer: j(".scappfancybox-outer", r.wrap), inner: j(".scappfancybox-inner", r.wrap) }), j.each(["Top", "Right", "Bottom", "Left"], function (e, t) { r.skin.css("padding" + t, Q(r.padding[e])) }), E.trigger("onReady"), "inline" === i || "html" === i) { if (!r.content || !r.content.length) return E._error("content") } else if (!o) return E._error("href"); "image" === i ? E._loadImage() : "ajax" === i ? E._loadAjax() : "iframe" === i ? E._loadIframe() : E._afterLoad() } else E.coming = null }, _error: function (e) { j.extend(E.coming, { type: "html", autoWidth: !0, autoHeight: !0, minWidth: 0, minHeight: 0, scrolling: "no", hasError: e, content: E.coming.tpl.error }), E._afterLoad() }, _loadImage: function () { var e = E.imgPreload = new Image; e.onload = function () { this.onload = this.onerror = null, E.coming.width = this.width / E.opts.pixelRatio, E.coming.height = this.height / E.opts.pixelRatio, E._afterLoad() }, e.onerror = function () { this.onload = this.onerror = null, E._error("image") }, e.src = E.coming.href, !0 !== e.complete && E.showLoading() }, _loadAjax: function () { var o = E.coming; E.showLoading(), E.ajaxLoad = j.ajax(j.extend({}, o.ajax, { url: o.href, error: function (e, t) { E.coming && "abort" !== t ? E._error("ajax", e) : E.hideLoading() }, success: function (e, t) { "success" === t && (o.content = e, E._afterLoad()) } })) }, _loadIframe: function () { var e = E.coming, t = j(e.tpl.iframe.replace(/\{rnd\}/g, (new Date).getTime())).attr("scrolling", l ? "auto" : e.iframe.scrolling).attr("src", e.href); j(e.wrap).bind("onReset", function () { try { j(this).find("iframe").hide().attr("src", "//about:blank").end().empty() } catch (e) { } }), e.iframe.preload && (E.showLoading(), t.one("load", function () { j(this).data("ready", 1), l || j(this).bind("load.fb", E.update), j(this).parents(".scappfancybox-wrap").width("100%").removeClass("scappfancybox-tmp").show(), E._afterLoad() })), e.content = t.appendTo(e.inner), e.iframe.preload || E._afterLoad() }, _preloadImages: function () { var e, t, o = E.group, i = E.current, n = o.length, a = i.preload ? Math.min(i.preload, n - 1) : 0; for (t = 1; t <= a; t += 1) "image" === (e = o[(i.index + t) % n]).type && e.href && ((new Image).src = e.href) }, _afterLoad: function () { var e, o, t, i, n, a, r = E.coming, s = E.current, p = "scappfancybox-placeholder"; if (E.hideLoading(), r && !1 !== E.isActive) { if (!1 === E.trigger("afterLoad", r, s)) return r.wrap.stop(!0).trigger("onReset").remove(), void (E.coming = null); switch (s && (E.trigger("beforeChange", s), s.wrap.stop(!0).removeClass("scappfancybox-opened").find(".scappfancybox-item, .scappfancybox-nav").remove()), E.unbindEvents(), o = (e = r).content, t = r.type, i = r.scrolling, j.extend(E, { wrap: e.wrap, skin: e.skin, outer: e.outer, inner: e.inner, current: e, previous: s }), n = e.href, t) { case"inline": case"ajax": case"html": e.selector ? o = j("
").html(o).find(e.selector) : h(o) && (o.data(p) || o.data(p, j('
').insertAfter(o).hide()), o = o.show().detach(), e.wrap.bind("onReset", function () { j(this).find(o).length && o.hide().replaceAll(o.data(p)).data(p, !1) })); break; case"image": o = e.tpl.image.replace("{href}", n); break; case"swf": o = '', a = "", j.each(e.swf, function (e, t) { o += '', a += " " + e + '="' + t + '"' }), o += '" } h(o) && o.parent().is(e.inner) || e.inner.append(o), E.trigger("beforeShow"), e.inner.css("overflow", "yes" === i ? "scroll" : "no" === i ? "hidden" : i), E._setDimension(), E.reposition(), E.isOpen = !1, E.coming = null, E.bindEvents(), E.isOpened ? s.prevMethod && E.transitions[s.prevMethod]() : j(".scappfancybox-wrap").not(e.wrap).stop(!0).trigger("onReset").remove(), E.transitions[E.isOpened ? e.nextMethod : e.openMethod](), E._preloadImages() } }, _setDimension: function () { var e, t, o, i, n, a, r, s, p, c, l, u, d, h, f, g, m, _ = E.getViewport(), v = 0, P = E.wrap, y = E.skin, w = E.inner, b = E.current, A = b.width, C = b.height, S = b.minWidth, x = b.minHeight, k = b.maxWidth, M = b.maxHeight, T = b.scrolling, D = b.scrollOutside ? b.scrollbarWidth : 0, O = b.margin, L = q(O[1] + O[3]), I = q(O[0] + O[2]); if (P.add(y).add(w).width("auto").height("auto").removeClass("scappfancybox-tmp"), n = L + (o = q(y.outerWidth(!0) - y.width())), a = I + (i = q(y.outerHeight(!0) - y.height())), r = F(A) ? (_.w - n) * q(A) / 100 : A, s = F(C) ? (_.h - a) * q(C) / 100 : C, "iframe" === b.type) { if (g = b.content, b.autoHeight && 1 === g.data("ready")) try { g[0].contentWindow.document.location && (w.width(r).height(9999), m = g.contents().find("body"), D && m.css("overflow-x", "hidden"), s = m.outerHeight(!0)) } catch (e) { } } else (b.autoWidth || b.autoHeight) && (w.addClass("scappfancybox-tmp"), b.autoWidth || w.width(r), b.autoHeight || w.height(s), b.autoWidth && (r = w.width()), b.autoHeight && (s = w.height()), w.removeClass("scappfancybox-tmp")); if (A = q(r), C = q(s), l = r / s, S = q(F(S) ? q(S, "w") - n : S), k = q(F(k) ? q(k, "w") - n : k), x = q(F(x) ? q(x, "h") - a : x), p = k, c = M = q(F(M) ? q(M, "h") - a : M), b.fitToView && (k = Math.min(_.w - n, k), M = Math.min(_.h - a, M)), h = _.w - L, f = _.h - I, b.aspectRatio ? (k < A && (C = q((A = k) / l)), M < C && (A = q((C = M) * l)), A < S && (C = q((A = S) / l)), C < x && (A = q((C = x) * l))) : (A = Math.max(S, Math.min(A, k)), b.autoHeight && "iframe" !== b.type && (w.width(A), C = w.height()), C = Math.max(x, Math.min(C, M))), b.fitToView) if (w.width(A).height(C), P.width(A + o), u = P.width(), d = P.height(), b.aspectRatio) for (; (h < u || f < d) && S < A && x < C && !(19 < v++);) C = Math.max(x, Math.min(M, C - 10)), (A = q(C * l)) < S && (C = q((A = S) / l)), k < A && (C = q((A = k) / l)), w.width(A).height(C), P.width(A + o), u = P.width(), d = P.height(); else A = Math.max(S, Math.min(A, A - (u - h))), C = Math.max(x, Math.min(C, C - (d - f))); D && "auto" === T && C < s && A + o + D < h && (A += D), w.width(A).height(C), P.width(A + o), u = P.width(), d = P.height(), e = (h < u || f < d) && S < A && x < C, t = b.aspectRatio ? A < p && C < c && A < r && C < s : (A < p || C < c) && (A < r || C < s), j.extend(b, { dim: { width: Q(u), height: Q(d) }, origWidth: r, origHeight: s, canShrink: e, canExpand: t, wPadding: o, hPadding: i, wrapSpace: d - y.outerHeight(!0), skinSpace: y.height() - C }), !g && b.autoHeight && x < C && C < M && !t && w.height("auto") }, _getPosition: function (e) { var t = E.current, o = E.getViewport(), i = t.margin, n = E.wrap.width() + i[1] + i[3], a = E.wrap.height() + i[0] + i[2], r = {position: "absolute", top: i[0], left: i[3]}; return t.autoCenter && t.fixed && !e && a <= o.h && n <= o.w ? r.position = "fixed" : t.locked || (r.top += o.y, r.left += o.x), r.top = Q(Math.max(r.top, r.top + (o.h - a) * t.topRatio)), r.left = Q(Math.max(r.left, r.left + (o.w - n) * t.leftRatio)), r }, _afterZoomIn: function () { var t = E.current; t && (E.isOpen = E.isOpened = !0, E.wrap.css("overflow", "visible").addClass("scappfancybox-opened"), E.update(), (t.closeClick || t.nextClick && 1 < E.group.length) && E.inner.css("cursor", "pointer").bind("click.fb", function (e) { j(e.target).is("a") || j(e.target).parent().is("a") || (e.preventDefault(), E[t.closeClick ? "close" : "next"]()) }), t.closeBtn && j(t.tpl.closeBtn).appendTo(E.skin).bind("click.fb", function (e) { e.preventDefault(), E.close() }), t.arrows && 1 < E.group.length && ((t.loop || 0 < t.index) && (j(t.tpl.prev).appendTo(E.outer).bind("click.fb", E.prev), E.outer.hover(function () { j(".scappfancybox-nav span").css("visibility", "visible") }, function () { j(".scappfancybox-nav span").css("visibility", "hidden") })), (t.loop || t.index < E.group.length - 1) && (j(t.tpl.next).appendTo(E.outer).bind("click.fb", E.next), E.outer.hover(function () { j(".scappfancybox-nav span").css("visibility", "visible") }, function () { j(".scappfancybox-nav span").css("visibility", "hidden") }))), E.trigger("afterShow"), t.loop || t.index !== t.group.length - 1 ? E.opts.autoPlay && !E.player.isActive && (E.opts.autoPlay = !1, E.play()) : E.play(!1)) }, _afterZoomOut: function (e) { e = e || E.current, j(".scappfancybox-wrap").trigger("onReset").remove(), j.extend(E, { group: {}, opts: {}, router: !1, current: null, isActive: !1, isOpened: !1, isOpen: !1, isClosing: !1, wrap: null, skin: null, outer: null, inner: null }), E.trigger("afterClose", e) } }), E.transitions = { resizeIn: function () { var e = E.previous, t = E.current, o = e.wrap.stop(!0).position(), i = j.extend({opacity: 1}, t.pos); o.width = e.wrap.width(), o.height = e.wrap.height(), e.wrap.stop(!0).trigger("onReset").remove(), delete i.position, t.inner.hide(), t.wrap.css(o).animate(i, { duration: t.nextSpeed, easing: t.nextEasing, step: E.transitions.step, complete: function () { E._afterZoomIn(), t.inner.fadeIn("fast") } }) }, getOrigPosition: function () { var e = E.current, t = e.element, o = e.orig, i = {}, n = 50, a = 50, r = e.hPadding, s = e.wPadding, p = E.getViewport(); return !o && e.isDom && t.is(":visible") && ((o = t.find("img:first")).length || (o = t)), h(o) ? (i = o.offset(), o.is("img") && (n = o.outerWidth(), a = o.outerHeight())) : (i.top = p.y + (p.h - a) * e.topRatio, i.left = p.x + (p.w - n) * e.leftRatio), ("fixed" === E.wrap.css("position") || e.locked) && (i.top -= p.y, i.left -= p.x), i = { top: Q(i.top - r * e.topRatio), left: Q(i.left - s * e.leftRatio), width: Q(n + s), height: Q(a + r) } }, step: function (e, t) { var o, i, n = t.prop, a = E.current, r = a.wrapSpace, s = a.skinSpace; "width" !== n && "height" !== n || (o = t.end === t.start ? 1 : (e - t.start) / (t.end - t.start), E.isClosing && (o = 1 - o), i = e - ("width" === n ? a.wPadding : a.hPadding), E.skin[n](q("width" === n ? i : i - r * o)), E.inner[n](q("width" === n ? i : i - r * o - s * o))) }, zoomIn: function () { var e = E.current, t = e.pos, o = e.openEffect, i = "elastic" === o, n = j.extend({opacity: 1}, t); delete n.position, i ? (t = this.getOrigPosition(), e.openOpacity && (t.opacity = .1)) : "fade" === o && (t.opacity = .1), E.wrap.css(t).animate(n, { duration: "none" === o ? 0 : e.openSpeed, easing: e.openEasing, step: i ? this.step : null, complete: E._afterZoomIn }) }, zoomOut: function () { var e = E.current, t = e.closeEffect, o = "elastic" === t, i = {opacity: .1}; o && (i = this.getOrigPosition(), e.closeOpacity && (i.opacity = .1)), E.wrap.animate(i, { duration: "none" === t ? 0 : e.closeSpeed, easing: e.closeEasing, step: o ? this.step : null, complete: E._afterZoomOut }) }, changeIn: function () { var e, t = E.current, o = t.nextEffect, i = t.pos, n = {opacity: 1}, a = E.direction; i.opacity = .1, "elastic" === o && (n[e = "down" === a || "up" === a ? "top" : "left"] = "down" === a || "right" === a ? (i[e] = Q(q(i[e]) - 200), "+=200px") : (i[e] = Q(q(i[e]) + 200), "-=200px")), "none" === o ? E._afterZoomIn() : E.wrap.css(i).animate(n, { duration: t.nextSpeed, easing: t.nextEasing, complete: E._afterZoomIn }) }, changeOut: function () { var e = E.previous, t = e.prevEffect, o = {opacity: .1}, i = E.direction; "elastic" === t && (o["down" === i || "up" === i ? "top" : "left"] = ("up" === i || "left" === i ? "-" : "+") + "=200px"), e.wrap.animate(o, { duration: "none" === t ? 0 : e.prevSpeed, easing: e.prevEasing, complete: function () { j(this).trigger("onReset").remove() } }) } }, E.helpers.overlay = { defaults: {closeClick: !0, speedOut: 200, showEarly: !0, css: {}, locked: !l, fixed: !0}, overlay: null, fixed: !1, el: j("html"), create: function (e) { e = j.extend({}, this.defaults, e), this.overlay && this.close(), this.overlay = j('
').appendTo(E.coming ? E.coming.parent : e.parent), this.fixed = !1, e.fixed && E.defaults.fixed && (this.overlay.addClass("scappfancybox-overlay-fixed"), this.fixed = !0) }, open: function (e) { var t = this; e = j.extend({}, this.defaults, e), this.overlay ? this.overlay.unbind(".overlay").width("auto").height("auto") : this.create(e), this.fixed || (r.bind("resize.overlay", j.proxy(this.update, this)), this.update()), e.closeClick && this.overlay.bind("click.overlay", function (e) { if (j(e.target).hasClass("scappfancybox-overlay")) return E.isActive ? E.close() : t.close(), !1 }), this.overlay.css(e.css).show(), j(".scappfancybox-overlay").show(), setTimeout(function () { j(".scappfancybox-overlay").show() }, 1e3) }, close: function () { var e, t; r.unbind("resize.overlay"), this.el.hasClass("scappfancybox-lock") && (j(".scappfancybox-margin").removeClass("scappfancybox-margin"), e = r.scrollTop(), t = r.scrollLeft(), this.el.removeClass("scappfancybox-lock"), r.scrollTop(e).scrollLeft(t)), j(".scappfancybox-overlay").remove().hide(), j.extend(this, { overlay: null, fixed: !1 }) }, update: function () { var e, t = "100%"; this.overlay.width(t).height("100%"), s ? (e = Math.max(o.documentElement.offsetWidth, o.body.offsetWidth), c.width() > e && (t = c.width())) : c.width() > r.width() && (t = c.width()), this.overlay.width(t).height(c.height()) }, onReady: function (e, t) { var o = this.overlay; j(".scappfancybox-overlay").stop(!0, !0), o || this.create(e), e.locked && this.fixed && t.fixed && (o || (this.margin = c.height() > r.height() && j("html").css("margin-right").replace("px", "")), t.locked = this.overlay.append(t.wrap), t.fixed = !1), !0 === e.showEarly && this.beforeShow.apply(this, arguments) }, beforeShow: function (e, t) { var o, i; t.locked && (!1 !== this.margin && (j("*").filter(function () { return "fixed" === j(this).css("position") && !j(this).hasClass("scappfancybox-overlay") && !j(this).hasClass("scappfancybox-wrap") }).addClass("scappfancybox-margin"), this.el.addClass("scappfancybox-margin")), o = r.scrollTop(), i = r.scrollLeft(), this.el.addClass("scappfancybox-lock"), r.scrollTop(o).scrollLeft(i)), this.open(e) }, onUpdate: function () { this.fixed || this.update() }, afterClose: function (e) { this.overlay && !E.coming && this.overlay.fadeOut(e.speedOut, j.proxy(this.close, this)) } }, E.helpers.title = { defaults: {type: "float", position: "bottom"}, beforeShow: function (e) { var t, o, i = E.current, n = i.title, a = e.type; if (j.isFunction(n) && (n = n.call(i.element, i)), f(n) && "" !== j.trim(n)) { switch (t = j('
' + n + "
"), a) { case"inside": o = E.skin; break; case"outside": o = E.wrap; break; case"over": o = E.inner; break; default: o = E.skin, t.appendTo("body"), s && t.width(t.width()), t.wrapInner(''), E.current.margin[2] += Math.abs(q(t.css("margin-bottom"))) } t["top" === e.position ? "prependTo" : "appendTo"](o) } } }, j.fn.scappfancybox = function (a) { var r, s = j(this), p = this.selector || "", e = function (e) { var t, o, i = j(this).blur(), n = r; e.ctrlKey || e.altKey || e.shiftKey || e.metaKey || i.is(".scappfancybox-wrap") || (t = a.groupAttr || "data-scappfancybox-group", (o = i.attr(t)) || (t = "rel", o = i.get(0)[t]), o && "" !== o && "nofollow" !== o && (n = (i = (i = p.length ? j(p) : s).filter("[" + t + '="' + o + '"]')).index(this)), a.index = n, !1 !== E.open(i, a) && e.preventDefault()) }; return r = (a = a || {}).index || 0, p && !1 !== a.live ? c.undelegate(p, "click.fb-start").delegate(p + ":not('.scappfancybox-item, .scappfancybox-nav')", "click.fb-start", e) : s.unbind("click.fb-start").bind("click.fb-start", e), this.filter("[data-scappfancybox-start=1]").trigger("click"), this }, c.ready(function () { var e, t, o, i; j.scrollbarWidth === d && (j.scrollbarWidth = function () { var e = j('
').appendTo("body"), t = e.children(), o = t.innerWidth() - t.height(99).innerWidth(); return e.remove(), o }), j.support.fixedPosition === d && (j.support.fixedPosition = (o = j('
').appendTo("body"), i = 20 === o[0].offsetTop || 15 === o[0].offsetTop, o.remove(), i)), j.extend(E.defaults, { scrollbarWidth: j.scrollbarWidth(), fixed: j.support.fixedPosition, parent: j("body") }), e = j(n).width(), a.addClass("scappfancybox-lock-test"), t = j(n).width(), a.removeClass("scappfancybox-lock-test"), j("").appendTo("head") }) }, scappPlugin: function scappPlugin($) { function camelCase(e) { return e.replace(/-([a-z])/g, function (e, t) { return t.toUpperCase() }) } JQClass.classes.JQPlugin = JQClass.extend({ name: "plugin", defaultOptions: {}, regionalOptions: {}, _getters: [], _getMarker: function () { return "is-" + this.name }, _init: function () { $.extend(this.defaultOptions, this.regionalOptions && this.regionalOptions[""] || {}); var o = camelCase(this.name); $[o] = this, $.fn[o] = function (e) { var t = Array.prototype.slice.call(arguments, 1); return $[o]._isNotChained(e, t) ? $[o][e].apply($[o], [this[0]].concat(t)) : this.each(function () { if ("string" == typeof e) { if ("_" === e[0] || !$[o][e]) throw "Unknown method: " + e; $[o][e].apply($[o], [this].concat(t)) } else $[o]._attach(this, e) }) } }, setDefaults: function (e) { $.extend(this.defaultOptions, e || {}) }, _isNotChained: function (e, t) { return "option" === e && (0 === t.length || 1 === t.length && "string" == typeof t[0]) || -1 < $.inArray(e, this._getters) }, _attach: function (e, t) { if (!(e = $(e)).hasClass(this._getMarker())) { e.addClass(this._getMarker()), t = $.extend({}, this.defaultOptions, this._getMetadata(e), t || {}); var o = $.extend({name: this.name, elem: e, options: t}, this._instSettings(e, t)); e.data(this.name, o), this._postAttach(e, o), this.option(e, t) } }, _instSettings: function (e, t) { return {} }, _postAttach: function (e, t) { }, _getMetadata: function (elem) { try { var data = elem.data(this.name.toLowerCase()) || ""; for (var name in data = data.replace(/'/g, '"'), data = data.replace(/([a-zA-Z0-9]+):/g, function (e, t, o) { var i = data.substring(0, o).match(/"/g); return i && i.length % 2 != 0 ? t + ":" : '"' + t + '":' }), data = $.parseJSON("{" + data + "}"), data) { var value = data[name]; "string" == typeof value && value.match(/^new Date\((.*)\)$/) && (data[name] = eval(value)) } return data } catch (e) { return {} } }, _getInst: function (e) { return $(e).data(this.name) || {} }, option: function (e, t, o) { var i = (e = $(e)).data(this.name); if (!t || "string" == typeof t && null == o) return (n = (i || {}).options) && t ? n[t] : n; if (e.hasClass(this._getMarker())) { var n = t || {}; "string" == typeof t && ((n = {})[t] = o), this._optionsChanged(e, i, n), $.extend(i.options, n) } }, _optionsChanged: function (e, t, o) { }, destroy: function (e) { (e = $(e)).hasClass(this._getMarker()) && (this._preDestroy(e, this._getInst(e)), e.removeData(this.name).removeClass(this._getMarker())) }, _preDestroy: function (e, t) { } }), $.JQPlugin = { createPlugin: function (e, t) { "object" == typeof e && (t = e, e = "JQPlugin"), e = camelCase(e); var o = camelCase(t.name); JQClass.classes[o] = JQClass.classes[e].extend(t), new JQClass.classes[o] } } }, scappCountdown: function (g) { var e = "countdown"; g.JQPlugin.createPlugin({ name: "scacountdown", defaultOptions: { until: null, since: null, timezone: null, serverSync: null, format: "dHMS", layout: "", compact: !1, padZeroes: !1, significant: 0, description: "", expiryUrl: "", expiryText: "", alwaysExpire: !1, onExpiry: null, onTick: null, tickInterval: 1 }, regionalOptions: { "": { labels: ["Years", "Months", "Weeks", "Days", "Hours", "Minutes", "Seconds"], labels1: ["Year", "Month", "Week", "Day", "Hour", "Minute", "Second"], compactLabels: ["y", "m", "w", "d"], whichLabels: null, digits: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], timeSeparator: ":", isRTL: !1 } }, _getters: ["getTimes"], _rtlClass: e + "-rtl", _sectionClass: e + "-section", _amountClass: e + "-amount", _periodClass: e + "-period", _rowClass: e + "-row", _holdingClass: e + "-holding", _showClass: e + "-show", _descrClass: e + "-descr", _timerElems: [], _init: function () { var i = this; this._super(), this._serverSyncs = []; var n = "function" == typeof Date.now ? Date.now : function () { return (new Date).getTime() }, a = window.performance && "function" == typeof window.performance.now; var r = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || null, s = 0; !r || g.noRequestAnimationFrame ? (g.noRequestAnimationFrame = null, setInterval(function () { i._updateElems() }, 980)) : (s = window.animationStartTime || window.webkitAnimationStartTime || window.mozAnimationStartTime || window.oAnimationStartTime || window.msAnimationStartTime || n(), r(function e(t) { var o = t < 1e12 ? a ? performance.now() + performance.timing.navigationStart : n() : t || n(); 1e3 <= o - s && (i._updateElems(), s = o), r(e) })) }, UTCDate: function (e, t, o, i, n, a, r, s) { "object" == typeof t && t.constructor == Date && (s = t.getMilliseconds(), r = t.getSeconds(), a = t.getMinutes(), n = t.getHours(), i = t.getDate(), o = t.getMonth(), t = t.getFullYear()); var p = new Date; return p.setUTCFullYear(t), p.setUTCDate(1), p.setUTCMonth(o || 0), p.setUTCDate(i || 1), p.setUTCHours(n || 0), p.setUTCMinutes((a || 0) - (Math.abs(e) < 30 ? 60 * e : e)), p.setUTCSeconds(r || 0), p.setUTCMilliseconds(s || 0), p }, periodsToSeconds: function (e) { return 31557600 * e[0] + 2629800 * e[1] + 604800 * e[2] + 86400 * e[3] + 3600 * e[4] + 60 * e[5] + e[6] }, _instSettings: function (e, t) { return {_periods: [0, 0, 0, 0, 0, 0, 0]} }, _addElem: function (e) { this._hasElem(e) || this._timerElems.push(e) }, _hasElem: function (e) { return -1 < g.inArray(e, this._timerElems) }, _removeElem: function (t) { this._timerElems = g.map(this._timerElems, function (e) { return e == t ? null : e }) }, _updateElems: function () { for (var e = this._timerElems.length - 1; 0 <= e; e--) this._updateCountdown(this._timerElems[e]) }, _optionsChanged: function (e, t, o) { o.layout && (o.layout = o.layout.replace(/</g, "<").replace(/>/g, ">")), this._resetExtraLabels(t.options, o); var i = t.options.timezone != o.timezone; g.extend(t.options, o), this._adjustSettings(e, t, null != o.until || null != o.since || i); var n = new Date; (t._since && t._since < n || t._until && t._until > n) && this._addElem(e[0]), this._updateCountdown(e, t) }, _updateCountdown: function (e, t) { try { if (e = e.jquery ? e : g(e), !(t = t || this._getInst(e))) return; if (e.html(this._generateHTML(t)).toggleClass(this._rtlClass, t.options.isRTL), g.isFunction(t.options.onTick)) { var o = "lap" != t._hold ? t._periods : this._calculatePeriods(t, t._show, t.options.significant, new Date); 1 != t.options.tickInterval && this.periodsToSeconds(o) % t.options.tickInterval != 0 || t.options.onTick.apply(e[0], [o]) } if ("pause" != t._hold && (t._since ? t._now.getTime() < t._since.getTime() : t._now.getTime() >= t._until.getTime()) && !t._expiring) { if (t._expiring = !0, this._hasElem(e[0]) || t.options.alwaysExpire) { if (this._removeElem(e[0]), g.isFunction(t.options.onExpiry) && t.options.onExpiry.apply(e[0], []), t.options.expiryText) { var i = t.options.layout; t.options.layout = t.options.expiryText, this._updateCountdown(e[0], t), t.options.layout = i } t.options.expiryUrl && (window.location = t.options.expiryUrl) } t._expiring = !1 } else "pause" == t._hold && this._removeElem(e[0]) } catch (e) { } }, _resetExtraLabels: function (e, t) { for (var o in t) o.match(/[Ll]abels[02-9]|compactLabels1/) && (e[o] = t[o]); for (var o in e) o.match(/[Ll]abels[02-9]|compactLabels1/) && void 0 === t[o] && (e[o] = null) }, _adjustSettings: function (e, t, o) { for (var i, n = 0, a = null, r = 0; r < this._serverSyncs.length; r++) if (this._serverSyncs[r][0] == t.options.serverSync) { a = this._serverSyncs[r][1]; break } if (null != a) n = t.options.serverSync ? a : 0, i = new Date; else { var s = g.isFunction(t.options.serverSync) ? t.options.serverSync.apply(e[0], []) : null; i = new Date, n = s ? i.getTime() - s.getTime() : 0, this._serverSyncs.push([t.options.serverSync, n]) } var p = t.options.timezone; p = null == p ? -i.getTimezoneOffset() : p, (o || !o && null == t._until && null == t._since) && (t._since = t.options.since, null != t._since && (t._since = this.UTCDate(p, this._determineTime(t._since, null)), t._since && n && t._since.setMilliseconds(t._since.getMilliseconds() + n)), t._until = this.UTCDate(p, this._determineTime(t.options.until, i)), n && t._until.setMilliseconds(t._until.getMilliseconds() + n)), t._show = this._determineShow(t) }, _preDestroy: function (e, t) { this._removeElem(e[0]), e.empty() }, pause: function (e) { this._hold(e, "pause") }, lap: function (e) { this._hold(e, "lap") }, resume: function (e) { this._hold(e, null) }, toggle: function (e) { this[(g.data(e, this.name) || {})._hold ? "resume" : "pause"](e) }, toggleLap: function (e) { this[(g.data(e, this.name) || {})._hold ? "resume" : "lap"](e) }, _hold: function (e, t) { var o = g.data(e, this.name); if (o) { if ("pause" == o._hold && !t) { o._periods = o._savePeriods; var i = o._since ? "-" : "+"; o[o._since ? "_since" : "_until"] = this._determineTime(i + o._periods[0] + "y" + i + o._periods[1] + "o" + i + o._periods[2] + "w" + i + o._periods[3] + "d" + i + o._periods[4] + "h" + i + o._periods[5] + "m" + i + o._periods[6] + "s"), this._addElem(e) } o._hold = t, o._savePeriods = "pause" == t ? o._periods : null, g.data(e, this.name, o), this._updateCountdown(e, o) } }, getTimes: function (e) { var t = g.data(e, this.name); return t ? "pause" == t._hold ? t._savePeriods : t._hold ? this._calculatePeriods(t, t._show, t.options.significant, new Date) : t._periods : null }, _determineTime: function (e, t) { var o, i, l = this, n = null == e ? t : "string" == typeof e ? function (e) { e = e.toLowerCase(); for (var t = new Date, o = t.getFullYear(), i = t.getMonth(), n = t.getDate(), a = t.getHours(), r = t.getMinutes(), s = t.getSeconds(), p = /([+-]?[0-9]+)\s*(s|m|h|d|w|o|y)?/g, c = p.exec(e); c;) { switch (c[2] || "s") { case"s": s += parseInt(c[1], 10); break; case"m": r += parseInt(c[1], 10); break; case"h": a += parseInt(c[1], 10); break; case"d": n += parseInt(c[1], 10); break; case"w": n += 7 * parseInt(c[1], 10); break; case"o": i += parseInt(c[1], 10), n = Math.min(n, l._getDaysInMonth(o, i)); break; case"y": o += parseInt(c[1], 10), n = Math.min(n, l._getDaysInMonth(o, i)) } c = p.exec(e) } return new Date(o, i, n, a, r, s, 0) }(e) : "number" == typeof e ? (o = e, (i = new Date).setTime(i.getTime() + 1e3 * o), i) : e; return n && n.setMilliseconds(0), n }, _getDaysInMonth: function (e, t) { return 32 - new Date(e, t, 32).getDate() }, _normalLabels: function (e) { return e }, _generateHTML: function (o) { var i = this; o._periods = o._hold ? o._periods : this._calculatePeriods(o, o._show, o.options.significant, new Date); for (var e = !1, t = 0, n = o.options.significant, a = g.extend({}, o._show), r = 0; r <= 6; r++) e |= "?" == o._show[r] && 0 < o._periods[r], a[r] = "?" != o._show[r] || e ? o._show[r] : null, t += a[r] ? 1 : 0, n -= 0 < o._periods[r] ? 1 : 0; var s = [!1, !1, !1, !1, !1, !1, !1]; for (r = 6; 0 <= r; r--) o._show[r] && (o._periods[r] ? s[r] = !0 : (s[r] = 0 < n, n--)); var p = o.options.compact ? o.options.compactLabels : o.options.labels, c = o.options.whichLabels || this._normalLabels, l = function (e) { var t = o.options["compactLabels" + c(o._periods[e])]; return a[e] ? i._translateDigits(o, o._periods[e]) + (t ? t[e] : p[e]) + " " : "" }, u = o.options.padZeroes ? 2 : 1, d = function (e) { var t = o.options["labels" + c(o._periods[e])]; return !o.options.significant && a[e] || o.options.significant && s[e] ? '' + i._minDigits(o, o._periods[e], u) + '' + (t ? t[e] : p[e]) + "" : "" }; return o.options.layout ? this._buildLayout(o, a, o.options.layout, o.options.compact, o.options.significant, s) : (o.options.compact ? '' + l(0) + l(1) + l(2) + l(3) + (a[4] ? this._minDigits(o, o._periods[4], 2) : "") + (a[5] ? (a[4] ? o.options.timeSeparator : "") + this._minDigits(o, o._periods[5], 2) : "") + (a[6] ? (a[4] || a[5] ? o.options.timeSeparator : "") + this._minDigits(o, o._periods[6], 2) : "") : '' + d(0) + d(1) + d(2) + d(3) + d(4) + d(5) + d(6)) + "" + (o.options.description ? '' + o.options.description + "" : "") }, _buildLayout: function (o, e, t, i, n, a) { for (var r = o.options[i ? "compactLabels" : "labels"], s = o.options.whichLabels || this._normalLabels, p = function (e) { return (o.options[(i ? "compactLabels" : "labels") + s(o._periods[e])] || r)[e] }, c = function (e, t) { return o.options.digits[Math.floor(e / t) % 10] }, l = { desc: o.options.description, sep: o.options.timeSeparator, yl: p(0), yn: this._minDigits(o, o._periods[0], 1), ynn: this._minDigits(o, o._periods[0], 2), ynnn: this._minDigits(o, o._periods[0], 3), y1: c(o._periods[0], 1), y10: c(o._periods[0], 10), y100: c(o._periods[0], 100), y1000: c(o._periods[0], 1e3), ol: p(1), on: this._minDigits(o, o._periods[1], 1), onn: this._minDigits(o, o._periods[1], 2), onnn: this._minDigits(o, o._periods[1], 3), o1: c(o._periods[1], 1), o10: c(o._periods[1], 10), o100: c(o._periods[1], 100), o1000: c(o._periods[1], 1e3), wl: p(2), wn: this._minDigits(o, o._periods[2], 1), wnn: this._minDigits(o, o._periods[2], 2), wnnn: this._minDigits(o, o._periods[2], 3), w1: c(o._periods[2], 1), w10: c(o._periods[2], 10), w100: c(o._periods[2], 100), w1000: c(o._periods[2], 1e3), dl: p(3), dn: this._minDigits(o, o._periods[3], 1), dnn: this._minDigits(o, o._periods[3], 2), dnnn: this._minDigits(o, o._periods[3], 3), d1: c(o._periods[3], 1), d10: c(o._periods[3], 10), d100: c(o._periods[3], 100), d1000: c(o._periods[3], 1e3), hl: p(4), hn: this._minDigits(o, o._periods[4], 1), hnn: this._minDigits(o, o._periods[4], 2), hnnn: this._minDigits(o, o._periods[4], 3), h1: c(o._periods[4], 1), h10: c(o._periods[4], 10), h100: c(o._periods[4], 100), h1000: c(o._periods[4], 1e3), ml: p(5), mn: this._minDigits(o, o._periods[5], 1), mnn: this._minDigits(o, o._periods[5], 2), mnnn: this._minDigits(o, o._periods[5], 3), m1: c(o._periods[5], 1), m10: c(o._periods[5], 10), m100: c(o._periods[5], 100), m1000: c(o._periods[5], 1e3), sl: p(6), sn: this._minDigits(o, o._periods[6], 1), snn: this._minDigits(o, o._periods[6], 2), snnn: this._minDigits(o, o._periods[6], 3), s1: c(o._periods[6], 1), s10: c(o._periods[6], 10), s100: c(o._periods[6], 100), s1000: c(o._periods[6], 1e3) }, u = t, d = 0; d <= 6; d++) { var h = "yowdhms".charAt(d), f = new RegExp("\\{" + h + "<\\}([\\s\\S]*)\\{" + h + ">\\}", "g"); u = u.replace(f, !n && e[d] || n && a[d] ? "$1" : "") } return g.each(l, function (e, t) { var o = new RegExp("\\{" + e + "\\}", "g"); u = u.replace(o, t) }), u }, _minDigits: function (e, t, o) { return (t = "" + t).length >= o ? this._translateDigits(e, t) : (t = "0000000000" + t, this._translateDigits(e, t.substr(t.length - o))) }, _translateDigits: function (t, e) { return ("" + e).replace(/[0-9]/g, function (e) { return t.options.digits[e] }) }, _determineShow: function (e) { var t = e.options.format, o = []; return o[0] = t.match("y") ? "?" : t.match("Y") ? "!" : null, o[1] = t.match("o") ? "?" : t.match("O") ? "!" : null, o[2] = t.match("w") ? "?" : t.match("W") ? "!" : null, o[3] = t.match("d") ? "?" : t.match("D") ? "!" : null, o[4] = t.match("h") ? "?" : t.match("H") ? "!" : null, o[5] = t.match("m") ? "?" : t.match("M") ? "!" : null, o[6] = t.match("s") ? "?" : t.match("S") ? "!" : null, o }, _calculatePeriods: function (e, o, t, i) { e._now = i, e._now.setMilliseconds(0); var n = new Date(e._now.getTime()); e._since ? i.getTime() < e._since.getTime() ? e._now = i = n : i = e._since : (n.setTime(e._until.getTime()), i.getTime() > e._until.getTime() && (e._now = i = n)); var a = [0, 0, 0, 0, 0, 0, 0]; if (o[0] || o[1]) { var r = this._getDaysInMonth(i.getFullYear(), i.getMonth()), s = this._getDaysInMonth(n.getFullYear(), n.getMonth()), p = n.getDate() == i.getDate() || n.getDate() >= Math.min(r, s) && i.getDate() >= Math.min(r, s), c = function (e) { return 60 * (60 * e.getHours() + e.getMinutes()) + e.getSeconds() }, l = Math.max(0, 12 * (n.getFullYear() - i.getFullYear()) + n.getMonth() - i.getMonth() + (n.getDate() < i.getDate() && !p || p && c(n) < c(i) ? -1 : 0)); a[0] = o[0] ? Math.floor(l / 12) : 0, a[1] = o[1] ? l - 12 * a[0] : 0; var u = (i = new Date(i.getTime())).getDate() == r, d = this._getDaysInMonth(i.getFullYear() + a[0], i.getMonth() + a[1]); i.getDate() > d && i.setDate(d), i.setFullYear(i.getFullYear() + a[0]), i.setMonth(i.getMonth() + a[1]), u && i.setDate(d) } var h = Math.floor((n.getTime() - i.getTime()) / 1e3), f = function (e, t) { a[e] = o[e] ? Math.floor(h / t) : 0, h -= a[e] * t }; if (f(2, 604800), f(3, 86400), f(4, 3600), f(5, 60), f(6, 1), 0 < h && !e._since) for (var g = [1, 12, 4.3482, 7, 24, 60, 60], m = 6, _ = 1, v = 6; 0 <= v; v--) o[v] && (a[m] >= _ && (a[m] = 0, h = 1), 0 < h && (a[v]++, h = 0, m = v, _ = 1)), _ *= g[v]; if (t) for (v = 0; v <= 6; v++) t && a[v] ? t-- : t || (a[v] = 0); return a } }) }, isHomePage: function () { return "/" == window.location.pathname }, isProductPage: function () { return -1 != window.location.pathname.indexOf("/products/") }, isCategoryPage: function () { return -1 != window.location.pathname.indexOf("/collections/") }, isBlogPage: function () { return -1 != window.location.pathname.indexOf("/blogs/") }, isPagePage: function () { return -1 != window.location.pathname.indexOf("/pages/") }, isCartPage: function () { return "/cart" == window.location.pathname }, _open: "open", _leave: "leave", _ppbntclicked: !1, callbackOnLeave: function (e) { for (var t in SCAPPApi.initWhenHandlerFor(e, SCAPPApi._leave), SCAPP.leave_queue) SCAPP.leave_queue[t] = !0; 1 < Object.keys(SCAPP.leave_queue).length ? SCAPPApi.showAllPopups(e, SCAPP.leave_queue) : SCAPPApi.closeCallback(e, SCAPP.leave_queue), SCAPPApi.activateDiscountOrder(SCAPP.popups, !1) }, showByCustomer: function (e, t) { try { if ("specific_tags" == t.who) { if (SCAPPShop.customer && SCAPPShop.customer.tags && t.who_specific) { var o = t.who_specific.split(","); for (var i in o) { var n = e.trim(o[i]); if (0 < n.length && -1 != e.inArray(n, SCAPPShop.customer.tags)) return !0 } } return !1 } } catch (e) { console.log(e) } return !0 }, onAjaxComplete: function (e, t, o) { if (-1 != o.url.indexOf("/cart/") && (console.log("shopify cart event:" + o.url), $.ajax({ dataType: "json", url: "/cart.json", async: !1, success: function (e) { SCAPP.current_cart = e, SCAPPApi.activateDiscountOrder(SCAPP.popups, !1) } }), o.data)) { var i = new RegExp("id=[0-9]*&*").exec(o.data); if (!i) return; o.data = i[0].replace("&", ""); var n = o.data.split("="); if (1 < n.length) { for (var a = n[1], r = SCAPP.filter.open, s = [], p = [], c = 0; c < r.length; ++c) { var l = parseInt(r[c]); if (!SCAPPApi.popupIsExpire(jQuerySCAPP, SCAPP.popups[l])) if (SCAPP.filter.cart_nonempty && -1 != $.inArray(l, SCAPP.filter.cart_nonempty)) s[l] = !0, SCAPP.open_queue[l] = !0; else { var u = SCAPP.popups[l]; if (-1 != $.trim(u.cart_variants).indexOf(a)) return p[l] = !0, SCAPP.open_queue[l] = !0, SCAPPApi.showPromotionTab(jQuerySCAPP, p), SCAPPApi._ppbntclicked = !0, SCAPPApi.closeCallback(jQuerySCAPP, p), void (SCAPPApi._ppbntclicked = !1) } } SCAPPApi.showPromotionTab(jQuerySCAPP, s), 1 < Object.keys(s).length ? SCAPPApi.showAllPopups(jQuerySCAPP, s) : SCAPPApi.closeCallback(jQuerySCAPP, s) } } }, showPromotionTab: function (e, t) { if (t) for (var o in t) { var i = SCAPP.popups[o]; if (SCAPPApi.showByCustomer(e, SCAPP.popups[o]) && (i.ppbnt_status && (!isMoblieBrowser() || "on" != SCAPP.popups[o].disable_mobile))) { 0 == e("#scapp-ppbnt").length && (i.ppbnt_template && "gift" == i.ppbnt_template ? e("body").eq(0).append('') : i.ppbnt_template && "normal" == i.ppbnt_template ? e("body").eq(0).append('') : e("body").eq(0).append('')), e("#scapp-ppbnt").click(function () { SCAPPApi.callbackOnPPBntClicked(e) }), i.ppbnt_bgcolor && e("#scapp-ppbnt").css("background-color", i.ppbnt_bgcolor), i.ppbnt_position_css && e("#scapp-ppbnt").css(JSON.parse(i.ppbnt_position_css)), i.ppbnt_text && e("#scapp-ppbnt-text").html(i.ppbnt_text), i.ppbnt_text_color && e("#scapp-ppbnt-text").css("color", i.ppbnt_text_color); break } } }, callbackOnOpen: function (e) { e.ajax({ dataType: "json", url: "/cart.json", async: !1, success: function (e) { SCAPP.current_cart = e } }), SCAPPApi.removeExpiredPopFromLocalStogare(), SCAPPApi.initWhenHandlerFor(e, SCAPPApi._open), 1 < Object.keys(SCAPP.open_queue).length ? SCAPPApi.showAllPopups(e, SCAPP.open_queue) : SCAPPApi.closeCallback(e, SCAPP.open_queue), SCAPPApi.activateDiscountOrder(SCAPP.popups, !1), SCAPPApi.showPromotionTab(jQuerySCAPP, SCAPP.open_queue), e(document).ajaxComplete(SCAPPApi.onAjaxComplete), setTimeout(function () { "undefined" != typeof SCAShopify && void 0 !== SCAShopify.jQuery && SCAShopify.jQuery(document).ajaxComplete(SCAPPApi.onAjaxComplete) }, 3e3) }, callbackOnPPBntClicked: function (e) { var t = SCAPP.open_queue; if (t) for (var o in t) { SCAPP.popups[o].ppbnt_status && (t[o] = !0) } SCAPPApi._ppbntclicked = !0; try { 1 < Object.keys(SCAPP.open_queue).length ? SCAPPApi.showAllPopups(e, SCAPP.open_queue, !1) : SCAPPApi.closeCallback(e, SCAPP.open_queue, !1) } catch (e) { console.log("callbackOnPPBntClicked error : "), console.log(e) } SCAPPApi._ppbntclicked = !1 }, scappShowPopup: function (o, i, e, t) { if (0 == o(".scappfancybox-overlay").length) { var n = LZString.decompressFromBase64(i.popup_content); if (o.scappfancybox.open({ content: n, beforeShow: function () { if (i.background_image && "" != i.background_image) { o.scappfancybox.showLoading(); var e = new Image, t = i.background_image.replace("https", "http"); e.onload = function () { o.scappfancybox.hideLoading() }, e.onerror = function () { o.scappfancybox.hideLoading() }, e.src = t } }, afterShow: function () { SCAPPApi.initPersistenceCounter(); var e = new Date; if (e = new Date(parseInt(i.end_time + "000")), o("#defaultCountdown").scacountdown({until: e}), o("#year").text(e.getFullYear()), "automatic" == i.popup_close) { var t = parseInt(i.close_delay, 10) || 0; 0 < t && setTimeout(function () { o.scappfancybox.close() }, 1e3 * t) } SCAPPApi.scappHeightForMobile(), SCAPPApi.showProductOption(o) }, scrolling: "no", padding: 0, openEffect: "none", openSpeed: 0, padding: 0, helpers: {overlay: {locked: !1}}, afterClose: function () { setTimeout(function () { e(o, t) }, 1e3) } }), "onetime" == i.frequency && i.cookie_expire && !SCAPPApi._ppbntclicked) { var a = SCAPPApi.readCookie(), r = new Date; r = r.getTime(); var s = parseFloat(i.cookie_expire, 10) || 0, p = Math.round(r + 60 * s * 60 * 1e3); a[parseInt(i.popup_id)] = p, a.expires ? p > a.expires && (a.expires = p) : a.expires = p, SCAPPApi.writeCookie(a) } } }, popupIsExpire: function (e, t) { if (!t.end_time || t.end_time && "" == t.end_time) return !1; var o = new Date, i = new Date(parseInt(t.end_time + "000")), n = o; return t.start_time && "" != t.start_time && (n = new Date(parseInt(t.start_time + "000"))), !(o < i && n <= o) }, addToPopupQueue: function (e, t) { t[e] = !0 }, removeFromPopupQueue: function (e, t) { delete t[e] }, cartAction: function (e, t, o, i) { var n = SCAPP.popups[o]; if ("cart" == n.popup_where) if (0 < t.item_count) if (SCAPP.filter.cart_nonempty && -1 != e.inArray(o, SCAPP.filter.cart_nonempty)) SCAPPApi.addToPopupQueue(o, i); else for (var a in t.items) { var r = t.items[a]; if (-1 != e.trim(n.cart_variants).indexOf(r.id)) return void SCAPPApi.addToPopupQueue(o, i); if (-1 != e.trim(n.cart_product).indexOf(r.sku)) return void SCAPPApi.addToPopupQueue(o, i) } else SCAPP.filter.cart_empty && -1 != e.inArray(o, SCAPP.filter.cart_empty) && SCAPPApi.addToPopupQueue(o, i) }, initWhenHandlerFor: function (t, e) { var o; if (SCAPPApi.initPersistenceCounter(), e == SCAPPApi._open) SCAPP.open_queue ? o = SCAPP.open_queue : (o = {}, SCAPP.open_queue = o), e = SCAPP.filter.open; else { if (e != SCAPPApi._leave) return; SCAPP.leave_queue ? o = SCAPP.leave_queue : (o = {}, SCAPP.leave_queue = o), e = SCAPP.filter.leave } if (e && 0 < e.length && t.isEmptyObject(o)) for (var i = 0; i < e.length; ++i) { var n = parseInt(e[i]); if (!SCAPPApi.popupIsExpire(t, SCAPP.popups[n])) if (SCAPP.filter.all && -1 != t.inArray(n, SCAPP.filter.all)) SCAPPApi.addToPopupQueue(n, o); else { if (SCAPPApi.isHomePage() && SCAPP.filter.home && -1 != t.inArray(n, SCAPP.filter.home) && SCAPPApi.addToPopupQueue(n, o), SCAPPApi.isProductPage() && SCAPP.filter.product && -1 != t.inArray(n, SCAPP.filter.product) && SCAPPApi.addToPopupQueue(n, o), SCAPPApi.isCategoryPage() && SCAPP.filter.category && -1 != t.inArray(n, SCAPP.filter.category) && SCAPPApi.addToPopupQueue(n, o), SCAPPApi.isBlogPage() && SCAPP.filter.blog && -1 != t.inArray(n, SCAPP.filter.blog) && SCAPPApi.addToPopupQueue(n, o), SCAPPApi.isPagePage() && SCAPP.filter.page && -1 != t.inArray(n, SCAPP.filter.page)) SCAPPApi.addToPopupQueue(n, o); else if (SCAPPApi.isCartPage()) SCAPP.current_cart ? SCAPPApi.cartAction(t, SCAPP.current_cart, n, o) : t.ajax({ dataType: "json", url: "/cart.json", async: !1, success: function (e) { SCAPP.current_cart = e, SCAPPApi.cartAction(t, SCAPP.current_cart, n, o) } }); else if (SCAPP.filter.specific && -1 != t.inArray(n, SCAPP.filter.specific)) { s = (s = (s = window.location.host + window.location.pathname).split("#")[0]).split("?")[0]; var a = SCAPP.popups[n].where_specific_url; for (var r in a = a.split("|")) { -1 < (p = a[r]).indexOf("://") && (p = p.split("://")[1]), p = (p = p.split("#")[0]).split("?")[0], SCAPPApi.stringIsSame(p, s) && SCAPPApi.addToPopupQueue(n, o) } } if (SCAPP.filter.remove && -1 != t.inArray(n, SCAPP.filter.remove)) { var s; s = (s = (s = window.location.host + window.location.pathname).split("#")[0]).split("?")[0]; a = SCAPP.popups[n].where_remove_url; for (var r in a = a.split("|")) { var p; -1 < (p = a[r]).indexOf("://") && (p = p.split("://")[1]), p = (p = p.split("#")[0]).split("?")[0], SCAPPApi.stringIsSame(p, s) && SCAPPApi.removeFromPopupQueue(n, o) } } } } }, stringIsSame: function (e, t) { if (!e || !t) return !1; if (e = e.trim(), t = t.trim(), e.length != t.length) return !1; var o = e.length < t.length ? e.length : t.length; if (3 < Math.abs(e.length - t.length)) return !1; return e.substring(0, o) == t.substring(0, o) }, closeCallback: function e(t, o, i) { if (o) { var n = SCAPPApi.readCookie(), a = new Date; for (var r in a = a.getTime(), o) if (SCAPPApi.showByCustomer(t, SCAPP.popups[r]) && o[r] && (!isMoblieBrowser() || "on" != SCAPP.popups[r].disable_mobile)) { o[r] = !1; var s = SCAPP.popups[r]; if ((i = void 0 === i || i) && s.musttab) return; SCAPPApi.addShowedPopup(r); var p = n[r], c = a; if (s.timestamp && (c = 1e3 * s.timestamp), p && "onetime" == s.frequency && s.cookie_expire) { var l = parseFloat(s.cookie_expire, 10) || 0; p < Math.round(c + 60 * l * 60 * 1e3) && (p = void 0, delete n[r]) } else p = void 0, delete n[r]; if (!p || p < a || SCAPPApi._ppbntclicked) return p && !SCAPPApi._ppbntclicked && delete n[r], SCAPP.popups[r].popup_after && !SCAPPApi._ppbntclicked ? void setTimeout(function () { SCAPPApi.scappShowPopup(jQuerySCAPP, SCAPP.popups[r], e, o) }, 1e3 * SCAPP.popups[r].popup_after) : void SCAPPApi.scappShowPopup(t, SCAPP.popups[r], e, o) } } }, showAllPopups: function (e, t, o) { if (t) { var i = SCAPPApi.readCookie(), n = new Date; n = n.getTime(); var a = [], r = []; for (var s in t) if (SCAPPApi.showByCustomer(e, SCAPP.popups[s]) && t[s] && (!isMoblieBrowser() || "on" != SCAPP.popups[s].disable_mobile)) { t[s] = !1; var p = SCAPP.popups[s]; if ((o = void 0 === o || o) && p.musttab) continue; r.push(p), SCAPPApi.addShowedPopup(s); var c = i[s], l = 1e3 * s; if (p.timestamp && (l = 1e3 * p.timestamp), c && "onetime" == p.frequency && p.cookie_expire) { var u = parseFloat(p.cookie_expire, 10) || 0; c < Math.round(l + 60 * u * 60 * 1e3) && (c = void 0, delete i[s]) } else c = void 0, delete i[s]; if (!c || c < n || SCAPPApi._ppbntclicked) { if (c && !SCAPPApi._ppbntclicked && delete i[s], SCAPP.popups[s].popup_after && !SCAPPApi._ppbntclicked && SCAPP.popups[s].popup_after && !SCAPPApi._ppbntclicked) { setTimeout(function (e) { SCAPPApi.scappShowPopup(jQuerySCAPP, SCAPP.popups[e], SCAPPApi.closeCallback, t) }.bind(this, s), 1e3 * SCAPP.popups[s].popup_after); continue } var d = {}; d.content = LZString.decompressFromBase64(p.popup_content) + '
' + p.popup_id + "
", a.push(d) } } SCAPPApi.scappShowFancyPopups(e, a) } else ; }, addShowedPopup: function (e) { var t = ""; localStorage.sca_showedpoup ? (t = localStorage.sca_showedpoup, SCAPPApi.isShowedPopup(e) || (t = localStorage.sca_showedpoup.concat(e + ","))) : t = e + ",", localStorage.setItem("sca_showedpoup", t) }, isShowedPopup: function (e) { return !(!localStorage.sca_showedpoup || -1 == localStorage.sca_showedpoup.indexOf(e)) }, cartContainVariantid: function (e) { for (var t in SCAPP.current_cart.items) { if (SCAPP.current_cart.items[t].product_id == e) return !0 } return !1 }, removeExpiredPopFromLocalStogare: function () { var e = ""; if (localStorage.sca_showedpoup) { var t = localStorage.sca_showedpoup.split(","); for (var o in t) { popup_id = parseInt(t[o]); var i = SCAPP.popups[popup_id]; i && !SCAPPApi.popupIsExpire(null, i) && (e += popup_id + ",") } localStorage.setItem("sca_showedpoup", e) } }, gotoCheckout: function (e) { var t = $(".scapp-coupon-code").data(); sessionStorage.sca_currentCoupon = "secomapp_temp_coupon", e != t.checkout_url && (e = t.checkout_url), e || (e = "/checkout"), document.location = e }, activateDiscountOrder: function (e, t) { var o = -1, i = "", n = "", a = 1e3, r = 1e3, s = 1e3; for (var p in e) { var c = e[p]; if (!SCAPPApi.popupIsExpire(null, c) && SCAPPApi.isShowedPopup(p)) { if (c.scapp_is_coupon && "yes" == c.scapp_is_coupon && c.scapp_coupon_checkout && "#" != c.scapp_coupon_checkout) { var l = c.popup_priority ? c.popup_priority : 1; 0 < SCAPP.current_cart.item_count && l < s && (c.scapp_coupon_checkout, s = l) } if (c.scapp_order_limit && "#" != c.scapp_order_limit && c.scapp_coupon_order && "#" != c.scapp_coupon_order) { var u = 100 * parseFloat(c.scapp_order_limit); l = c.popup_priority ? c.popup_priority : 1; SCAPP.current_cart.total_price >= u && l < a ? (a = l, o = u, i = c.scapp_coupon_order) : SCAPP.current_cart.total_price >= u && a == l && o < u && (o = u, i = c.scapp_coupon_order) } if (c.scapp_variant_id && "#" != c.scapp_variant_id && c.scapp_coupon_product && "#" != c.scapp_coupon_product && c.scapp_product_id && "#" != c.scapp_product_id) { var d = c.popup_priority ? c.popup_priority : 1; SCAPPApi.cartContainVariantid(c.scapp_product_id) && d < r && (r = d, n = c.scapp_coupon_product) } } } a < r ? s < a ? SCAPPApi.doActivateDiscount("") : SCAPPApi.doActivateDiscount(i) : s < r ? SCAPPApi.doActivateDiscount("") : SCAPPApi.doActivateDiscount(n) }, doActivateDiscount: function (e) { if (e && $("form").has("button[name='checkout'], input[name='checkout']") && -1 != location.href.indexOf("/cart") && $("form").has("button[name='checkout'], input[name='checkout']").append(''), "undefined" != typeof Storage && "undefined" != typeof SCAPP && SCAPP.current_cart && 0 < SCAPP.current_cart.item_count) if (void 0 === sessionStorage.sca_currentCoupon && sessionStorage.setItem("sca_currentCoupon", ""), sessionStorage.sca_currentCoupon === e && localStorage.sca_currentToken === SCAPP.current_cart.token) ; else { var t = !1, o = new Date; if (o = o.getTime(), localStorage.lastLoaded) if (sessionStorage.sca_currentCoupon && sessionStorage.sca_currentCoupon != e || sessionStorage.sca_currentCoupon || e) t = !0; else 15e3 < o - parseInt(localStorage.lastLoaded) && (t = !0); else t = !0; if (t) { sessionStorage.setItem("sca_currentCoupon", e), localStorage.setItem("sca_currentToken", SCAPP.current_cart.token), localStorage.setItem("lastLoaded", o); var i = encodeURI("/checkout?discount=" + e); $("body").prepend('') } else console.log("stop load coupon multi time. ") } }, addProductDiscount: function (e, t) { var o = $(".scapp-coupon-code").data(); if (o && o.variantid && o.variantid != e && (e = o.variantid), $("#scapp-product-selected").val() && (e = $("#scapp-product-selected").val()), e && "#" != e) return document.location = "/cart/add/" + e, !1 }, scappHeightForMobile: function () { try { if (isMoblieBrowser()) { var e = $(".scapp-promobox").attr("datawidth"), t = $(".scapp-promobox").attr("dataheight"), o = $(".scapp-promobox").height(); e = parseInt(e) || 0, t = parseInt(t) || 0, o = parseInt(o) || 0, 0 < e && 0 < t && 0 < o < 100 && (nheight = t / e * 300, nheight > o && $(".scapp-promobox").attr("style", $(".scapp-promobox").attr("style") + "; height: " + nheight + "px !important")) } } catch (e) { } }, removeUnavailOption: function (c, e) { var l = l || {}; l.arrayIncludes = function (e, t) { for (var o = 0; o < e.length; o++) if (e[o] == t) return !0; return !1 }, l.uniq = function (e) { for (var t = [], o = 0; o < e.length; o++) l.arrayIncludes(t, e[o]) || t.push(e[o]); return t }, l.optionsMap = {}, l.updateOptionsInSelector = function (e) { var t = "#scapp-variant-options "; switch (e) { case 0: var o = "root", i = jQuery(t + ".single-option-selector:eq(0)"); break; case 1: o = jQuery(t + ".single-option-selector:eq(0)").val(), i = jQuery(t + ".single-option-selector:eq(1)"); break; case 2: o = jQuery(t + ".single-option-selector:eq(0)").val(); o += " / " + jQuery(t + ".single-option-selector:eq(1)").val(); i = jQuery(t + ".single-option-selector:eq(2)") } var n = i.val(); i.empty(); for (var a = l.optionsMap[o], r = 0; r < a.length; r++) { var s = a[r], p = jQuery("").val(s).html(s); i.append(p) } jQuery(t + '.swatch[data-option-index="' + e + '"] .swatch-element').each(function () { -1 !== jQuery.inArray(c(this).attr("data-value"), a) ? c(this).removeClass("soldout").show().find(":radio").removeAttr("disabled", "disabled").removeAttr("checked") : c(this).addClass("soldout").hide().find(":radio").removeAttr("checked").attr("disabled", "disabled") }), -1 !== jQuery.inArray(n, a) && i.val(n), i.trigger("change") }, l.linkOptionSelectors = function (e) { var t = "#scapp-variant-options "; l.optionsMap.root = []; for (var o = 0; o < e.variants.length; o++) { var i = e.variants[o]; if (i.available) { if (l.optionsMap.root = l.optionsMap.root || [], l.optionsMap.root.push(i.option1), l.optionsMap.root = l.uniq(l.optionsMap.root), 1 < e.options.length) { var n = i.option1; l.optionsMap[n] = l.optionsMap[n] || [], l.optionsMap[n].push(i.option2), l.optionsMap[n] = l.uniq(l.optionsMap[n]) } if (3 === e.options.length) { n = i.option1 + " / " + i.option2; l.optionsMap[n] = l.optionsMap[n] || [], l.optionsMap[n].push(i.option3), l.optionsMap[n] = l.uniq(l.optionsMap[n]) } } } l.updateOptionsInSelector(0), 1 < e.options.length && l.updateOptionsInSelector(1), 3 === e.options.length && l.updateOptionsInSelector(2), jQuery(t + ".single-option-selector:eq(0)").change(function () { return l.updateOptionsInSelector(1), 3 === e.options.length && l.updateOptionsInSelector(2), !0 }), jQuery(t + ".single-option-selector:eq(1)").change(function () { return 3 === e.options.length && l.updateOptionsInSelector(2), !0 }) }, l.linkOptionSelectors(e) }, showProductOption: function (t) { try { 0 < t("#scapp-variant-options").length && 0 < t(".scapp-coupon-code").length && t(".scapp-coupon-code").data().handle && (t("#scapp-variant-options .selector-wrapper").remove(), t.ajax({ dataType: "json", url: "/products/" + t(".scapp-coupon-code").data().handle + ".js", contentType: "application/json; charset=utf-8", success: function (e) { var o = []; t.each(e.options, function (e, t) { o[e] = t.name }), e.options = o; try { e = function (e) { for (var t = [], o = -1, i = 0, n = e.options.length; i < n; i++) if ("BuyXDiscount" == e.options[i]) { o = i + 1; break } if (-1 == o) return e; 1 < e.options.length ? e.options.splice(o - 1, 1) : e.options[0] = "Title", o = "option" + o, e.available = !1; for (var a = 0, r = e.variants.length; a < r; a++) "Default" == e.variants[a][o] && (e.variants[a][o] = "", t.push(e.variants[a]), e.available = e.available || e.variants[a].available); return e.variants = t, e }(e = function (e) { if (e) { String.prototype.endsWith || Object.defineProperty(String.prototype, "endsWith", { value: function (e, t) { var o = this.toString(); (void 0 === t || t > o.length) && (t = o.length), t -= e.length; var i = o.indexOf(e, t); return -1 !== i && i === t } }); for (var t = function (e) { for (var t in e) if (e.hasOwnProperty(t)) return !1; return !0 }, o = e.price, i = e.price_max, n = e.price_min, a = e.compare_at_price, r = e.compare_at_price_max, s = e.compare_at_price_min, p = 0; p < e.variants.length; p++) { var c = e.variants[p], l = null !== c.option3 ? c.option3 : null !== c.option2 ? c.option2 : c.option1; "undefined" != typeof SECOMAPP && void 0 !== SECOMAPP.gifts_list_avai && !t(SECOMAPP.gifts_list_avai) && void 0 !== SECOMAPP.gifts_list_avai[c.id] || l.endsWith("(Freegifts)") || l.endsWith("% off)") ? (e.variants.splice(p, 1), p -= 1) : (i >= c.price && (i = c.price, o = c.price), n <= c.price && (n = c.price), c.compare_at_price && (r >= c.compare_at_price && (r = c.compare_at_price, a = c.compare_at_price), s <= c.compare_at_price && (s = c.compare_at_price)), 1 == c.available && (e.available = !0)) } e.price = o, e.price_max = n, e.price_min = i, e.compare_at_price = a, e.compare_at_price_max = s, e.compare_at_price_min = r, e.price_varies = i < n, e.compare_at_price_varies = r < s } return e }(e)) } catch (e) { console.log(e) } new Shopify.OptionSelectors("scapp-product-selected", { product: e, onVariantSelected: function () { } }), SCAPPApi.removeUnavailOption(t, e), 1 == e.variants.length && -1 < e.variants[0].title.indexOf("Default") || t("#scapp-variant-options").show() } })) } catch (e) { console.log(e) } }, scappShowFancyPopups: function (p, e) { 0 == p(".scappfancybox-overlay").length && p.scappfancybox.open(e, { afterShow: function () { var e = parseInt(p("#scapp-popupid").text(), 10) || 0; if (0 < e && SCAPP.popups[e]) { if (popup = SCAPP.popups[e], popup.background_image && "" != popup.background_image) { p.scappfancybox.showLoading(); var t = new Image, o = popup.background_image.replace("https", "http"); t.onload = function () { p.scappfancybox.hideLoading() }, t.onerror = function () { p.scappfancybox.hideLoading() }, t.src = o } SCAPPApi.initPersistenceCounter(); var i = new Date; if (i = new Date(parseInt(popup.end_time + "000")), p("#defaultCountdown").scacountdown({until: i}), p("#year").text(i.getFullYear()), "onetime" == popup.frequency && popup.cookie_expire) { var n = SCAPPApi.readCookie(), a = new Date; a = a.getTime(); var r = parseFloat(popup.cookie_expire, 10) || 0, s = Math.round(a + 60 * r * 60 * 1e3); n.expires ? s > n.expires && (n.expires = s) : n.expires = s, n[e] || (n[parseInt(popup.popup_id)] = s, SCAPPApi.writeCookie(n)) } } SCAPPApi.scappHeightForMobile(), SCAPPApi.showProductOption(p) }, scrolling: "no", padding: 0, openEffect: "none", openSpeed: 0, padding: 0, loop: !1, nextMethod: "resizeIn", nextSpeed: 250, prevMethod: !1, helpers: {overlay: {locked: !1}} }) }, writeCookie: function (e) { SCAPPApi.filterCookies(e); var t = new Date(e.expires).toGMTString(); e = LZString.compressToBase64(JSON.stringify(e)); document.cookie = "sca_pp=" + e + ";expires=" + t + ";path=/;" }, readCookie: function () { if (SCAPP.cookies) return SCAPP.cookies; SCAPP.cookies = {}; for (var e = null, t = "sca_pp=", o = document.cookie.split(";"), i = 0; i < o.length; i++) { for (var n = o[i]; " " == n.charAt(0);) n = n.substring(1, n.length); if (0 == n.indexOf(t)) { e = n.substring(t.length, n.length); break } } return e && (SCAPP.cookies = JSON.parse(LZString.decompressFromBase64(e))), SCAPP.cookies }, filterCookies: function (e) { var t = new Date; for (var o in t = t.getTime(), e) ("expires" != o && !SCAPP.popups[o] || e[o] < t) && delete e[o] }, initPersistenceCounter: function () { try { var e = []; for (popup_id in SCAPP.popups) { var t = SCAPP.popups[popup_id]; if (t.persistence_counter && "on" == t.persistence_counter) { var o = sessionStorage.getItem("sca_" + popup_id), i = (new Date).getTime() / 1e3, n = Math.round(i + 60 * t.persistence_value); o && i < (o = 0 | parseInt(o)) && (n = o), SCAPP.popups[popup_id].end_time = Math.round(n), e.push(popup_id), sessionStorage.setItem("sca_" + popup_id, SCAPP.popups[popup_id].end_time) } } } catch (e) { console.log(e) } } }) }(); var m = function (a, b) { var c = document.createElement("script"); c.type = "text/javascript", c.readyState ? c.onreadystatechange = function () { ("loaded" == c.readyState || "complete" == c.readyState) && (c.onreadystatechange = null, b()) } : c.onload = function () { b() }, c.src = a, document.getElementsByTagName("head")[0].appendChild(c) }, n = function (a, b) { if ("js" == b) { var c = document.createElement("script"); c.setAttribute("type", "text/javascript"), c.setAttribute("src", a) } else if ("css" == b) { var c = document.createElement("link"); c.setAttribute("rel", "stylesheet"), c.setAttribute("type", "text/css"), c.setAttribute("href", a) } "undefined" != typeof c && document.getElementsByTagName("head")[0].appendChild(c) }; n("////fonts.googleapis.com/css?family=Josefin+Sans|Open+Sans+Condensed:300|Roboto+Slab|Lobster|Lora|Indie+Flower|Muli|Shadows+Into+Light|Maven+Pro|Pacifico|Dancing+Script|Gloria+Hallelujah|Lobster+Two", "css"); var o = function () { var a = SCAPP.popups; for (var b in a) { var c = a[b]; if (c.background_image && "" != c.background_image) { var d = c.background_image.replace("https", "http"); new Image().src = d } } }, p = function (a) { o(), SCAPPApi.callbackOnOpen(a) }, q = function (a, b) { try { var c = a.split("."), d = b.split("."), e = 1e8 * parseInt(c[0]) + 1e6 * parseInt(c[1]) + 1e4 * parseInt(c[2]), f = 1e8 * parseInt(d[0]) + 1e6 * parseInt(d[1]) + 1e4 * parseInt(d[2]); return e > f ? 1 : e < f ? -1 : 0 } catch (a) { g.log(a) } return 1 }; "undefined" == typeof jQuery || 0 < q("1.7.0", jQuery.fn.jquery) ? m("//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js", function () { g.log("finished load jquery.."), jQuerySCAPP = jQuery.noConflict(!0), a() }) : (g.log("use shop's jquery.."), jQuerySCAPP = jQuery, a()) } })(); console.log("squirai popup v1") } else { window.PPSQUIRAI = []; window.PTSQUIRAI = {}; window.FUNCSQUIRAI = {}; window.SPSQUIRAI = {}; window.SPSQUIRAI.CUSTOM_EVENTS = { SP_RENDER_POPUP: "sp_render_popup:success", SP_CLOSE_POPUP: "sp_close_popup" } try { window.PPSQUIRAI = ppData?.popups ?? []; window.PTSQUIRAI = JSON.parse(ppData?.tabs ?? "{}"); } catch (e) { console.error("Cannot convert data popup"); } let indexPopupShow = 0; const isVisible = "sca-is-visible-pu"; //window fetch const {fetch: ppFetch} = window; window.fetch = async (...args) => { let responseFetch = await ppFetch(...args); if ( typeof args[0] == 'string' && ( args[0].includes("/cart/add.js") || args[0].includes("/cart/change.js") || args[0].startsWith("/cart/update.js") || args[0].includes("/cart/add") || args[0].includes("/cart/change") ) ) { await checkConditionAfterFilter(true); } return responseFetch; }; const renderEvent = () => { document.querySelector(".sca-p-popup-tab-click").addEventListener("click", async () => { indexPopupShow = 0; await whenPopupShow(); }); document.querySelector("#squirai-tab-close-button").addEventListener("click", (e) => { if (e.target === document.querySelector("#squirai-tab-close-button")) { sessionStorage.setItem("SQUIRAIEnableTabButton", "0"); document.querySelector("#sca-p-popup-tab").style.display = "none"; } }); document.querySelector("#sca-p-popup-main-popup-container").addEventListener("click", (e) => { if (e.target === document.querySelector("#sca-p-popup-main-popup-container")) { clearTimeout(window.timeClosePopup); document.querySelector("#sca-p-popup-main-popup-container.sca-p-popup-main-container.sca-modal-pu.sca-is-visible-pu").classList.remove(isVisible); const popupModal = document.querySelector("#sca-p-popup-modal") if (popupModal.querySelectorAll('iframe').length > 0) { popupModal.querySelectorAll('iframe').forEach(iframe => iframe.remove()); } } }); document.addEventListener("keyup", (e) => { if (e.key === "Escape" && document.querySelector("#sca-p-popup-main-popup-container.sca-p-popup-main-container.sca-modal-pu.sca-is-visible-pu")) { clearTimeout(window.timeClosePopup); document.querySelector("#sca-p-popup-main-popup-container.sca-p-popup-main-container.sca-modal-pu.sca-is-visible-pu").classList.remove(isVisible); const popupModal = document.querySelector("#sca-p-popup-modal") if (popupModal.querySelectorAll('iframe').length > 0) { popupModal.querySelectorAll('iframe').forEach(iframe => iframe.remove()); } } }); document.querySelector("#sca-p-popup-main-popup-container").addEventListener("click", (e) => { if (PPSQUIRAI.length > 1) { if (e.target === document.querySelector("#sca-p-popup-main-popup-container")) { clearTimeout(window.timeClosePopup); indexPopupShow++; if (indexPopupShow < PPSQUIRAI.length) { renderPopup(PPSQUIRAI[indexPopupShow]); } } } }); }; const addItemToCart = async (popupRender) => { try { if (popupRender?.popup_design?.data_design?.list_product_selected?.length > 0) { const variantId = popupRender?.popup_design?.data_design?.list_product_selected[0]?.variants[0]?.id?.split("/")?.reverse()[0]; let formData = { items: [{ id: variantId, quantity: 1, },], }; await fetch("/cart/add.js", { method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify(formData), }).then((response) => { return response.json(); }).catch((error) => { console.error("Error:", error); }); const ObjectUrl = new URL(window.location.href); const redirect = popupRender?.popup_design?.data_design?.redirect_after_add === null || popupRender?.popup_design?.data_design?.redirect_after_add === "" ? "/cart" : popupRender?.popup_design?.data_design?.redirect_after_add; const urlNew = `${ObjectUrl.origin}/discount/${popupRender?.popup_design?.data_design?.discount_code}?redirect=${redirect}`; location.replace(urlNew); } } catch (e) { console.log(e) } }; const handleButtonHover = (button, defaultColor, hoverColor) => { button.addEventListener('mouseenter', () => { button.style.backgroundColor = `${hoverColor}` }) button.addEventListener('mouseleave', () => { button.style.backgroundColor = `${defaultColor}` }) } const handlePromotionTab = (arrPopupPassToShow) => { if (document.querySelector("#sca-p-popup-tab")) { if (arrPopupPassToShow?.length === 0 || !PTSQUIRAI?.status || sessionStorage.getItem("SQUIRAIEnableTabButton") === "0") { document.querySelector("#sca-p-popup-tab").style.display = "none"; } else { document.querySelector("#sca-p-popup-tab").style.display = "block"; let button = document.querySelector("#sca-p-popup-tab .sca-p-popup-warp-btn"); let textButton = document.querySelector("#sca-p-popup-text"); if (PTSQUIRAI?.tab_position === "bottom_center") { button.style.left = "50%"; button.style.transform = "translate(-50%, 0)"; } else if (PTSQUIRAI?.tab_position === "bottom_left") { button.style.left = "1%"; } else if (PTSQUIRAI?.tab_position === "middle_left") { button.style.left = "0"; button.style.bottom = "55%"; button.style.transform = "rotate(90deg)"; button.style.transformOrigin = "left bottom" } else if (PTSQUIRAI?.tab_position === "middle_right") { button.style.right = "0"; button.style.bottom = "60%"; button.style.transform = "rotate(270deg)"; button.style.transformOrigin = "right bottom" } else { button.style.right = "1%"; } button.style.backgroundColor = PTSQUIRAI?.background_color; textButton.style.color = PTSQUIRAI?.tab_text_color; textButton.innerHTML = PTSQUIRAI?.tab_title; } } }; let countFailed = 0; const handleCountDown = (distance, popupRender) => { const second = 1000, minute = second * 60, hour = minute * 60, day = hour * 24; //do something later when date is reached if (distance <= 0) { document.querySelector("#sca-p-popup-main-popup-container").click(); window.PPSQUIRAI = PPSQUIRAI.filter((pp) => pp.id !== popupRender.id); if (PPSQUIRAI?.length === 0 || !PTSQUIRAI?.status) { document.querySelector("#sca-p-popup-tab").style.display = "none"; } clearInterval(window.countDownInterval); } try { document.getElementById("days").innerText = Math.floor(distance / day).toString(); document.getElementById("hours").innerText = Math.floor((distance % day) / hour).toString(); document.getElementById("minutes").innerText = Math.floor((distance % hour) / minute).toString(); document.getElementById("seconds").innerText = Math.floor((distance % minute) / second).toString(); } catch (e) { console.log("Failed to handleCountDown") countFailed++; if (countFailed === 100) clearInterval(window.countDownInterval); } }; const countDownByEndTime = (popupRender) => { const countDown = new Date(popupRender.popup_design.data_design.end_by_date).getTime(); window.countDownInterval = setInterval(function () { const now = new Date().getTime(); handleCountDown(countDown - now, popupRender); }); }; const countDownByTimeSetting = (popupRender) => { const countDown = new Date().getTime() + popupRender.popup_design.data_design.time_countdown * 60000; const value = { timeToEnd: countDown, timeCountDown: popupRender.popup_design.data_design.time_countdown, }; if (localStorage.getItem(`SQUIRAICountDown${popupRender.id}`) === null) { localStorage.setItem(`SQUIRAICountDown${popupRender.id}`, JSON.stringify(value)); } else if (popupRender.popup_design.data_design.time_countdown !== JSON.parse(localStorage.getItem(`SQUIRAICountDown${popupRender.id}`)).timeCountDown) { localStorage.setItem(`SQUIRAICountDown${popupRender.id}`, JSON.stringify(value)); } window.countDownInterval = setInterval(function () { const now = new Date().getTime(); handleCountDown(JSON.parse(localStorage.getItem(`SQUIRAICountDown${popupRender.id}`)).timeToEnd - now, popupRender); }); }; const displayPopup = (promotionPopup, popupRender) => { try { if (indexPopupShow === 0) { handleDisplayPopup(promotionPopup, popupRender); } else { setTimeout(() => { handleDisplayPopup(promotionPopup, popupRender); }, 250); } } catch (e) { console.error("some thing wrong with render popup action", e); } } const renderPopup = (popupRender) => { let promotionPopup = document.querySelector("#sca-p-popup-modal"); if (promotionPopup) { displayPopup(promotionPopup, popupRender); } }; const renderPopupAuto = (popupRender) => { const timeShowAgain = popupRender.when_popup_show.time_show_again * 3600000; const lastShownTime = parseInt(sessionStorage.getItem(`SQUIRAILastTimeShown${popupRender.id}`)); let promotionPopup = document.querySelector("#sca-p-popup-modal"); if (promotionPopup && (Date.now() - lastShownTime >= timeShowAgain || sessionStorage.getItem(`SQUIRAILastTimeShown${popupRender.id}`) === null)) { displayPopup(promotionPopup, popupRender); } else { indexPopupShow++ if (indexPopupShow < PPSQUIRAI.length) { renderPopupAuto(PPSQUIRAI[indexPopupShow]); } } }; const handleDisplayPopup = (promotionPopup, popupRender) => { clearInterval(window.countDownInterval); promotionPopup.innerHTML = popupRender.popup_design.code_html; // + ((ppData?.hidden_brandmark ?? false) // ? "" // :
Powered by SmartPopup
); sessionStorage.setItem(`SQUIRAILastTimeShown${popupRender.id}`, Date.now()); if (popupRender.popup_design.data_design.show_countdown) { if (popupRender.popup_design.data_design.type_countdown === "end_time_setting") { countDownByEndTime(popupRender); } else if (popupRender.popup_design.data_design.type_countdown === "time_setting") { countDownByTimeSetting(popupRender); } } document.querySelector("#sca-p-popup-main-popup-container.sca-p-popup-main-container.sca-modal-pu").classList.add(isVisible); //button for old template popup if (document.querySelector(".sqrai-button")) { const sqraiButton = document.querySelector(".sqrai-button"); handleButtonHover(sqraiButton, popupRender.popup_design.data_design.button_color, popupRender.popup_design.data_design.button_hover_color) } if (document.querySelector("#sqrai-button-add-to-cart")) { const squiraiButton = document.querySelector("#sqrai-button-add-to-cart"); handleButtonHover(squiraiButton, popupRender.popup_design.data_design.button_color, popupRender.popup_design.data_design.button_hover_color) document.querySelector("#sqrai-button-add-to-cart").addEventListener("click", (e) => { addItemToCart(popupRender); document.querySelector("#sca-p-popup-main-popup-container.sca-p-popup-main-container.sca-modal-pu.sca-is-visible-pu")?.classList.remove(isVisible); }); } //button for new template popup if (document.querySelector("#squirai-button")) { const squiraiButton = document.querySelector("#squirai-button"); handleButtonHover(squiraiButton, popupRender.popup_design.data_design.button_color, popupRender.popup_design.data_design.button_hover_color) } if (document.querySelector("#squirai-button-add-to-cart")) { const squiraiButton = document.querySelector("#squirai-button-add-to-cart"); handleButtonHover(squiraiButton, popupRender.popup_design.data_design.button_color, popupRender.popup_design.data_design.button_hover_color) document.querySelector("#squirai-button-add-to-cart").addEventListener("click", (e) => { addItemToCart(popupRender); clearInterval(window.countDownInterval); document.querySelector("#sca-p-popup-main-popup-container.sca-p-popup-main-container.sca-modal-pu.sca-is-visible-pu")?.classList.remove(isVisible); }); } if (document.querySelector("#squirai-close-button")) { document.querySelector("#squirai-close-button").addEventListener("click", (e) => { const popupModal = document.querySelector("#sca-p-popup-modal") if (popupModal.querySelectorAll('iframe').length > 0) { popupModal.querySelectorAll('iframe').forEach(iframe => iframe.remove()); } document.querySelector("#sca-p-popup-main-popup-container.sca-p-popup-main-container.sca-modal-pu.sca-is-visible-pu")?.classList.remove(isVisible); if (PPSQUIRAI.length > 1) { clearTimeout(window.timeClosePopup); indexPopupShow++; if (indexPopupShow < PPSQUIRAI.length) { renderPopup(PPSQUIRAI[indexPopupShow]); } } document.dispatchEvent(new CustomEvent(SPSQUIRAI.CUSTOM_EVENTS.SP_CLOSE_POPUP, { detail: { data: popupRender } })) }); } //when popup close if (popupRender.when_popup_close.type === "auto_close") { window.timeClosePopup = setTimeout(() => { document.querySelector("#sca-p-popup-main-popup-container").click(); }, popupRender.when_popup_close.time_to_close * 1000); } else { clearTimeout(window.timeClosePopup); } document.dispatchEvent(new CustomEvent(SPSQUIRAI.CUSTOM_EVENTS.SP_RENDER_POPUP, { detail: { data: popupRender } })) } function handleAutoShowPopupAgain() { if (PPSQUIRAI) { const now = Date.now(); PPSQUIRAI?.forEach((popupRender) => { if (sessionStorage.getItem(`SQUIRAILastTimeShown${popupRender.id}`) !== null && popupRender.when_popup_show.time_show_again !== 0) { const timeShowAgain = popupRender.when_popup_show.time_show_again * 3600000; const lastShownTime = parseInt(sessionStorage.getItem(`SQUIRAILastTimeShown${popupRender.id}`)); if (now - lastShownTime >= timeShowAgain) { let promotionPopup = document.querySelector("#sca-p-popup-modal"); handleDisplayPopup(promotionPopup, popupRender); } } }) requestAnimationFrame(handleAutoShowPopupAgain); } } const empty = (data) => { if (data === 0) { return true; } if (typeof data == "number" || typeof data == "boolean") { return false; } if (typeof data == "undefined" || data === null) { return true; } if (typeof data.length != "undefined") { return data.length === 0; } let count = 0; for (let i in data) { if (data.hasOwnProperty(i)) { count++; } } return count === 0; }; const checkValidTimeOffer = (start, end) => { if (start) { const now = new Date(); const timeZone = now.getTimezoneOffset(); const timeStamp = now.getTime(); const startTime = new Date(start.replaceAll("-", "/")).getTime() - timeZone * 60 * 1000; if (end) { const endTime = new Date(end.replaceAll("-", "/")).getTime() - timeZone * 60 * 1000; return timeStamp >= startTime && timeStamp <= endTime; } else { return timeStamp >= startTime; } } return false; }; let mobileCheck = () => { let check = false; (function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera); return check; }; let checkConditionPopup = (popup) => { let checkWhoCanSeePopup = true; let checkWherePopupShow = true; // who can see popup if (popup.who_can_see_popup.type === "specific_customers") { let checkExistCustomerTags = popup.who_can_see_popup.customer_tags.filter((eachCustomerTag) => SQUIRAI.customer_tags?.tags?.includes(eachCustomerTag)); checkWhoCanSeePopup = !(checkExistCustomerTags.length === 0); } // where popup show if (popup.where_popup_show.type_page !== "all_page") { let wherePopupShow = popup.where_popup_show; let currentLocation = location.pathname; if (currentLocation === "/") { currentLocation = "home"; } else if (currentLocation.startsWith("/products")) { currentLocation = "products"; } else if (currentLocation.startsWith("/collections")) { currentLocation = "collections"; } else if (currentLocation.startsWith("/cart")) { currentLocation = "cart"; } else if (currentLocation.startsWith("/search")) { currentLocation = "search"; } else if (currentLocation.startsWith("/blog")) { currentLocation = "blog"; } else if (currentLocation.startsWith("/page")) { currentLocation = "page"; } checkWherePopupShow = wherePopupShow.specific_pages.includes(currentLocation); if (wherePopupShow.specific_urls.length !== 0) { if (wherePopupShow.include_specific_urls) { checkWherePopupShow = checkWherePopupShow || wherePopupShow.specific_urls.includes(location.href); } else { checkWherePopupShow = checkWherePopupShow && !wherePopupShow.specific_urls.includes(location.href); } } } return checkWhoCanSeePopup && checkWherePopupShow; }; let checkCartConditionPopup = async (popup) => { let cartCondition = popup.when_popup_show.cart_condition; if (cartCondition.status) { let cartData = await ppFetch("/cart.js").then((data) => { return data.json(); }); let quantityCartItems = cartData.item_count; let totalPriceCart = cartData.total_price / 100; let arrCartProductId = cartData.items?.map((item) => item.product_id); arrCartProductId = arrCartProductId.map(String); const checkSatisfiedArrProduct = cartCondition.product_id?.length === 0 ? true : cartCondition.product_id?.some((eachProductId) => arrCartProductId.includes(eachProductId)) ?? false; const checkSatisfiedQuantityCartItems = cartCondition?.min_quantity_to_show === 0 ? true : quantityCartItems >= cartCondition.min_quantity_to_show; const checkSatisfiedTotalPriceCart = cartCondition?.min_order_total === 0 ? true : totalPriceCart >= cartCondition.min_order_total; return (checkSatisfiedTotalPriceCart && checkSatisfiedQuantityCartItems && checkSatisfiedArrProduct); } return true; }; const filterPopupByPriority = (arrPopupShow) => { arrPopupShow?.sort(function (beforeVal, afterVal) { return beforeVal.priority - afterVal.priority; }); return arrPopupShow; }; const whenPopupShow = async (arrPopupShow, isTryToLeave = false) => { let checkIsCallFromButton = false; if (empty(arrPopupShow)) { arrPopupShow = await filterAllPopups(); checkIsCallFromButton = true; } let checkExistDomPopup = document.querySelector("#sca-p-popup-modal").textContent; if (checkExistDomPopup) { document.querySelector("#sca-p-popup-modal").replaceChildren(); } window.PPSQUIRAI = filterPopupByPriority(arrPopupShow); //when popup show.delay_before_show const firstPopupNoTimeShowAgain = findFirst(PPSQUIRAI, function (popup) { return popup.when_popup_show.time_show_again === 0; }) let delayBeforeShowPopup = 0; if (!isTryToLeave) { delayBeforeShowPopup = firstPopupNoTimeShowAgain ? firstPopupNoTimeShowAgain?.when_popup_show?.delay_before_show : PPSQUIRAI[0].when_popup_show.delay_before_show } try { if (checkIsCallFromButton) { renderPopup(PPSQUIRAI[indexPopupShow]); } else { setTimeout(() => { if (indexPopupShow < PPSQUIRAI.length) { renderPopupAuto(PPSQUIRAI[indexPopupShow]); } }, delayBeforeShowPopup * 1000); } } catch (e) { console.log("some thing wrong with general condition function", e); } }; const findFirst = (array, condition) => { for (let i = 0; i < array.length; i++) { if (condition(array[i])) { return array[i]; } } return false; } let filterAllPopups = async () => { try { // filter by time and status window.PPSQUIRAI = PPSQUIRAI.filter((eachPopup) => { return (checkValidTimeOffer(eachPopup.start_time, eachPopup.end_time) && eachPopup.status); }); // filter by time count down PPSQUIRAI.forEach((eachPopup) => { if (localStorage.getItem(`SQUIRAICountDown${eachPopup.id}`) !== null && JSON.parse(localStorage.getItem(`SQUIRAICountDown${eachPopup.id}`)).timeToEnd < new Date().getTime()) { window.PPSQUIRAI = PPSQUIRAI.filter((pp) => pp.id !== eachPopup.id); } }); // filter by detect device is mobile if (mobileCheck()) { window.PPSQUIRAI = PPSQUIRAI.filter((eachPopup) => eachPopup.show_on_mobile); } //logic to get satisfied each popup let arrSatisfiedPopups = []; for (const eachPopup of PPSQUIRAI) { let checkCanShowPopup = checkConditionPopup(eachPopup); let checkCartCondition = await checkCartConditionPopup(eachPopup); if (checkCanShowPopup && checkCartCondition) { arrSatisfiedPopups.push(eachPopup); } } return arrSatisfiedPopups; } catch (e) { console.log("some thing went wrong with filter popups", e); } }; let checkConditionAfterFilter = (isRunByCartCondition) => { try { filterAllPopups().then(async (arrPopupPassToShow) => { let popupWithTryToLeave = []; arrPopupPassToShow = arrPopupPassToShow?.filter((popup) => { let isLeavePage = popup.when_popup_show.type === "leave_page"; if (isLeavePage) { popupWithTryToLeave.push(popup) } if (!empty(isRunByCartCondition)) { return popup.when_popup_show.cart_condition.status === true && !isLeavePage } return !isLeavePage }) if (popupWithTryToLeave.length > 0) { document.addEventListener('mouseleave', async function (event) { if (!event.toElement && !event.relatedTarget) { await whenPopupShow(popupWithTryToLeave, true) } }); } handlePromotionTab(arrPopupPassToShow) if (!empty(arrPopupPassToShow)) { await whenPopupShow(arrPopupPassToShow) } console.log("Promotion popup check has no popups to show") }); } catch (e) { console.log("something went wrong with check condition cart function", e); } }; const startHere = () => { indexPopupShow = 0; renderEvent(); checkConditionAfterFilter(); document.dispatchEvent(new CustomEvent("squiraiCustomFunction")) }; startHere(); handleAutoShowPopupAgain(); window.FUNCSQUIRAI.reRunLogicApp = () => { startHere(); handleAutoShowPopupAgain(); } window.FUNCSQUIRAI.reRenderPopup = async () => { indexPopupShow = 0; await whenPopupShow(); } }