{ if (!window.vahara) { window.vahara = {}; } var v = window.vahara; v.orbitId = '4'; v.serverUrl = 'https://o4npfwh.vahara.io'; v.remoteSiteUrl = 'https://ccssd.dev.jmak-design.com'; v.projectId = '67659'; v.version = '60'; v.showEditButtons = false; // Locate the api key from the script tag if possible var scriptTags = document.querySelectorAll('script'); for (let i = 0; i < scriptTags.length; i++) { if (scriptTags[i].src.match(/https\:\/\/assets\.vahara\.io.*start.js/)) { const remoteKey = scriptTags[i].getAttribute('data-key'); if (remoteKey) { v.remoteKey = remoteKey; } } } // TODO: Remove this after everybody has moved to the new format of tag var scriptTags = document.getElementsByTagName('script'); for (var i = 0; i < scriptTags.length; i++) { var src = scriptTags[i].getAttribute('src'); if (src && src.includes('rk=')) { var rkValue = src.match(/rk=([^&]+)/); if (rkValue) { v.remoteKey = rkValue[1]; break; } } } v.componentHtml = []; v.editorUseImageLibrary = 1; v.settings = {"editor_use_image_library":"1","new_user_registration_enabled":null,"payments_platform":null,"replicated_site":"0","replicated_site_type":null,"replicated_site_default_url":null,"store_checkout_page":null,"store_dscheckout_page":null,"store_shopping_page":null,"stripe_publishable_key":null,"image_host":"https:\/\/vahara-04.imgix.net","image_host_type":"imgix","image_max_width":"1920","image_quality":"80","auth_must_verify_browser":null,"direct_scale_enabled":null,"brand_color_options":["#212121","#ffffff","#10537f","#ffab48","#c4c4c4","#f3f3f3","#23a8cf","#ff7777","transparent"],"froala_font_options":null,"froala_inline_styles":null,"froala_hide_font_size":"1","froala_hide_fonts":"1","representative_term":null,"default_customer_sponsor_id":null,"email_send_domains":null,"replicated_site_can_select_sponsor":null,"project_styles":[{"vw-p-sm":"Paragraph Small"},{"vw-p-rg":"Paragraph Regular"},{"vw-p-lg":"Paragraph Large"},{"vw-p-xl":"Paragraph XL"},{"vw-h-style-1":"Heading 1 - Sequel 65 Blue"},{"vw-h-style-2":"Heading 2 - Univers Next Pro Yellow"},{"vw-h-style-3":"Heading 3 - Univers Next Pro Blue"},{"vw-h-style-4":"Heading 4 - Univers Next Pro Yellow"},{"vw-p-style-2":"Paragraph Style 2"},{"vw-p-style-3":"Paragraph Style 3"},{"vw-h-style-lg":"Large"},{"vw-h-style-xl":"X Large"},{"vw-h-style-xxl":"XX Large"}],"hide_remote_site_vahara_buttons":null,"google_maps_frontend_api_key":"AIzaSyAjGt7qExElb2agwNtzUqArfUcSk7r2WZA","nexiopay_pubkey":null,"remote_elements_off":"1","captcha_enabled":"0","default_captcha_types":null}; var dropElements = document.getElementsByClassName('vhc-js-widget-drop'); var pageId = null; if (dropElements.length) { pageId = dropElements[0].getAttribute('data-vhc-id'); } parent.postMessage({action: 'vahara-page-loaded', projectId: v.projectId, pageId: pageId, link: window.location.href}, '*'); v.siteLibsLoaded = function (callback) { // If libs have loaded already, call the code now if (v.siteLibsLoadedFlag) { callback(); // If not, launch them when they are loaded } else { window.addEventListener('vaharaSiteLibsLoaded', function (e) { callback(); }); } }; v.loadScript = function (url, callback, appendToHead, discourageDuplicateInserts, disableVersionParam) { var js = document.createElement('script'); js.type = 'text/javascript'; js.async = true; js.src = url; js.id = 'script' + hashString(url); if(typeof disableVersionParam === undefined) disableVersionParam = false; if (!disableVersionParam && v.version) { if (js.src.indexOf('?') > 0) { js.src+= '&v=' + v.version; } else { js.src+= '?v=' + v.version; } } if(typeof appendToHead === undefined) appendToHead = false; if(typeof callback === 'function') { js.addEventListener('load', function (e) { callback(e); }, false); } if(discourageDuplicateInserts === true) { // Check if this script has already been inserted -- if so -- do not insert it again if(document.getElementById(js.id) !== null) { if(typeof callback === 'function') { callback(); } return; } } if(appendToHead === true) { document.getElementsByTagName('head')[0].appendChild(js); } else { document.body.appendChild(js); } }; // Find the script file for the current script // Put trimLevel = -1 to remove the script file name, trimLevel = -2 to remove the directory just above, -3 the directory above that, etc v.getCurrentScriptPath = function(trimLevel) { var script = ''; if (document.currentScript) { script = document.currentScript.src; } else { var scripts = document.getElementsByTagName("script"); script = scripts[scripts.length - 1].src; } scriptParts = script.split('/'); return scriptParts.slice(0, scriptParts.length + trimLevel).join('/'); }; // Load a CSS file v.loadCss = function (url) { var link = document.createElement("link"); link.href = url; link.type = "text/css"; link.rel = "stylesheet"; link.media = "screen,print"; if (v.version) { if (link.href.indexOf('?') > 0) { link.href+= '&v=' + v.version; } else { link.href+= '?v=' + v.version; } } // If IE do this differently if(typeof(Event) === 'function') { document.head.prepend(link); } else { document.head.insertBefore(link, document.head.children[0]); } }; // This callback will be triggered when google maps first loads v.triggerGoogleMapsLoadedEvent = function() { v.googleMapsLoaded = true; v.triggerEvent('vhGoogleMapsLoaded'); } // Load the google map API and Gmap v.loadGoogleMaps = function(callbackFunction) { if (v.googleMapsLoaded) { callbackFunction(); } else { // Load the map script with a callback to googleMapsLoaded v.loadScript('https://maps.googleapis.com/maps/api/js?v=weekly&key='+v.settings.google_maps_frontend_api_key+'&callback=window.vahara.triggerGoogleMapsLoadedEvent', null, false, true, true); v.loadScript('https://cdnjs.cloudflare.com/ajax/libs/gmaps.js/0.4.25/gmaps.min.js', function() { v.googleMapsHelperLoaded = true; }); v.onEvent('vhGoogleMapsLoaded', function() { var loadedInterval = setInterval(function() { if (v.googleMapsHelperLoaded) { setTimeout(function() { callbackFunction(); }, 300); clearInterval(loadedInterval); } }, 20); }); } } v.loadHtml = function (url, callback) { var request = new XMLHttpRequest(); request.onreadystatechange = function() { window.r = request; if(request.readyState === 4) { if(request.status === 200) { // Insert the HTML into the top of the DOM var html = request.responseText; v.insertHtml(html, callback(html)); } } } request.withCredentials = true; // send cookies with HTML requests request.open('GET', url); request.send(null); }; v.insertHtml = function(html, callback) { var newDiv = document.createElement('vhc'); newDiv.innerHTML = html; newDiv.style.display = 'none'; document.body.insertBefore(newDiv, document.body.firstChild); // Find elements with class 'vh-component' and process them var vhComponents = newDiv.querySelectorAll('.vh-component'); vhComponents.forEach(function(element) { var name = element.getAttribute('data-vh-component-label'); v.componentHtml[name] = element.outerHTML; }); // Call the callback if there was one if (callback) { callback(html); } // Remove the temporary element from the DOM newDiv.parentNode.removeChild(newDiv); }; v.insertCss = function(css) { var style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = css; document.getElementsByTagName('head')[0].appendChild(style); }; v.triggerEvent = function(name, data) { let vjWindow = window; var event = null; if(typeof(Event) === 'function') { event = new CustomEvent(name, {detail: data}); } else { event = document.createEvent('Event'); event.detail = data; event.initEvent(name, true, true); } vjWindow.dispatchEvent(event); }; v.onEvent = function(name, callback) { let vjWindow = window; vjWindow.addEventListener(name, function(e) { callback(e.detail); }, false); }; v.setCookie = function(key, value, days, secure, samesite, path) { if(typeof secure === "undefined" || secure === null) secure = ''; secure = secure === true ? 'secure;' : ''; if(typeof samesite === "undefined" || samesite === null) samesite = 'lax'; if(typeof path === "undefined" || path === null) path = '/'; let expires = new Date(); if (days) { expires.setTime(expires.getTime() + (days * 24 * 60 * 60 * 1000)); document.cookie = key + '=' + value + ';expires=' + expires.toUTCString() + ';' + secure + ' SameSite=' + samesite + '; path = ' + path + ';'; } else { document.cookie = key + '=' + value + ';expires=Fri, 30 Dec 9999 23:59:59 GMT;' + secure + ' SameSite=' + samesite + '; path = ' + path + ';'; } }; v.getCookie = function(key) { let keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)'); return keyValue ? keyValue[2] : null; }; v.currencyWithComma = function(input) { var x = (input*1).toFixed(2); var parts = x.toString().split("."); parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); return parts.join("."); }; v.compileTemplate = function(templateClassOrJqueryElement, data) { let el = null; if (typeof templateClassOrJqueryElement === 'string' || templateClassOrJqueryElement instanceof String) { el = document.querySelector(templateClassOrJqueryElement); } else { el = templateClassOrJqueryElement[0]; } if(el !== null) { Handlebars.registerHelper('date', function(input) { return moment(input).format('MMM D, YYYY'); }); Handlebars.registerHelper('dateTime', function(input) { return moment(input).format('MMM D, YYYY - hh:mm a'); }); Handlebars.registerHelper('selectOption', function(value, options) { let selectElement = document.createElement('select'); selectElement.innerHTML = options.fn(this); Array.from(selectElement.options).forEach(function(option) { if (option.value === value) { option.selected = true; } }); return selectElement.innerHTML; }); Handlebars.registerHelper('ifCond', function(v1, v2, options) { if(v1 === v2) { return options.fn(this); } return options.inverse(this); }); Handlebars.registerHelper('ifEqual', function(v1, v2, options) { if(v1 === v2) { return options.fn(this); } return options.inverse(this); }); Handlebars.registerHelper('gtZero', function(input, options) { return (typeof input !== undefined && input !== null && input > 0) ? options.fn(this) : options.inverse(this); }); Handlebars.registerHelper('json_string', function(input) { try { return JSON.stringify(input) } catch (e) { return '{}'; } }); Handlebars.registerHelper('currency', function(input) { return (input*1).toFixed(2); }); Handlebars.registerHelper('urlEncode', function(input) { return (input && typeof input === 'string') ? encodeURI(input) : input; }); Handlebars.registerHelper('grouped_each', function(every, context, options) { var out = "", subcontext = [], i; if (context && context.length > 0) { for (i = 0; i < context.length; i++) { if (i > 0 && i % every === 0) { out += options.fn(subcontext); subcontext = []; } subcontext.push(context[i]); } out += options.fn(subcontext); } return out; }); Handlebars.registerHelper('join_with_space', function(array) { return array.join(' '); }); Handlebars.registerHelper('lower_case', function (input) { return (input && typeof input === 'string') ? input.toLowerCase() : ''; }); Handlebars.registerHelper('upper_case_words', function (input) { return (input && typeof input === 'string') ? input.toLowerCase().replace(/\b[a-z]/g, function(letter) { return letter.toUpperCase(); }) : ''; }); Handlebars.registerHelper('upper_case_first', function (input) { return (input && typeof input === 'string') ? input.substr(0,1).toUpperCase() + input.toLowerCase().substr(1) : ''; }); Handlebars.registerHelper('currency_with_comma', function (input) { return v.currencyWithComma(input); }); Handlebars.registerHelper("math", function(lvalue, operator, rvalue, options) { lvalue = parseFloat(lvalue); rvalue = parseFloat(rvalue); return { "+": lvalue + rvalue, "-": lvalue - rvalue, "*": lvalue * rvalue, "/": lvalue / rvalue, "%": lvalue % rvalue }[operator]; }); Handlebars.registerHelper('in_array', function (array, value, options) { return array.indexOf(value) > -1 ? options.fn(this) : options.inverse(this); }); Handlebars.registerHelper("everyOther", function (index, amount, scope) { if ( ++index % amount) return scope.inverse(this); else return scope.fn(this); }); Handlebars.registerHelper("counter", function (index) { return index + 1; }); Handlebars.registerHelper("title_case", function (str) { return str .replace(/([^A-Z])([A-Z])/g, '$1 $2') // split cameCase .replace(/[_\-]+/g, ' ') // split snake_case and lisp-case .toLowerCase() .replace(/(^\w|\b\w)/g, function(m) { return m.toUpperCase(); }) // title case words .replace(/\s+/g, ' ') // collapse repeated whitespace .replace(/^\s+|\s+$/, ''); // remove leading/trailing whitespace }); Handlebars.registerHelper("makeSlug", function (input) { const a = 'àáäâãåăæąçćčđďèéěėëêęğǵḧìíïîįłḿǹńňñòóöôœøṕŕřßşśšșťțùúüûǘůűūųẃẍÿýźžż·/_,:;' const b = 'aaaaaaaaacccddeeeeeeegghiiiiilmnnnnooooooprrsssssttuuuuuuuuuwxyyzzz------' const p = new RegExp(a.split('').join('|'), 'g') for (var index = 0, l = a.length; index < l; index++) { input = input.replace(new RegExp(a.charAt(index), 'g'), b.charAt(index)); } return input.toString().toLowerCase() .replace(/\s+/g, '-') // Replace spaces with - .replace(/&/g, '-and-') // Replace & with 'and' .replace(/[^\w\-]+/g, '') // Remove all non-word characters .replace(/\-\-+/g, '-') // Replace multiple - with single - .replace(/^-+/, '') // Trim - from start of text .replace(/-+$/, '') // Trim - from end of text .replace(/[0-9]/g, ''); }); Handlebars.registerHelper("add", function (number1, number2, number3, number4, number5, number6) { var total = 0; if (!isNaN(number1)) { total = total + number1; } if (!isNaN(number2)) { total = total + number2; } if (!isNaN(number3)) { total = total + number3; } if (!isNaN(number4)) { total = total + number4; } if (!isNaN(number5)) { total = total + number5; } if (!isNaN(number6)) { total = total + number6; } return total; }); Handlebars.registerHelper("concat", function concatenate (string1, string2, string3, string4, string5, string6) { var outputString = ''; if (string1) { outputString = outputString + string1.toString(); } if (string2) { outputString = outputString + string2.toString(); } if (string3) { outputString = outputString + string3.toString(); } if (string4) { outputString = outputString + string4.toString(); } if (string5) { outputString = outputString + string5.toString(); } if (string6) { outputString = outputString + string6.toString(); } return outputString; }); let template = Handlebars.compile(el.innerHTML); return template(data); } }; v.getVisitorId = function(generateAndSetNew) { if(typeof generateAndSetNew === 'undefined') generateAndSetNew = false; let visitorId = v.getCookie('_vaharaVisitorId'); if(!(new Uuid()).isUuid(visitorId)) generateAndSetNew = true; if(generateAndSetNew) visitorId = null; if(visitorId === null) { visitorId = (new Uuid()).uuid(); v.setCookie('_vaharaVisitorId', visitorId, 30, true, 'None'); } return visitorId; }; function Uuid() { var buf, bufIdx = 0, hexBytes = [], i; var uuid = {}; uuid.BUFFER_SIZE = 512; for (i = 0; i < 256; i++) { hexBytes[i] = (i + 0x100).toString(16).substr(1); } function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min)) + min; }; function randomBytes(n) { var r; if (typeof crypto !== 'undefined') { if ((typeof buf === 'undefined') || ((bufIdx + n) > uuid.BUFFER_SIZE)) { bufIdx = 0; if (crypto.getRandomValues) { buf = new Uint8Array(uuid.BUFFER_SIZE); crypto.getRandomValues(buf); } else if (crypto.randomBytes) { buf = crypto.randomBytes(uuid.BUFFER_SIZE); } else { throw new Error('Non-standard crypto library'); } } return buf.slice(bufIdx, bufIdx += n); } else { r = []; for (i = 0; i < n; i++) { r.push(getRandomInt(0, 255)); } return r; } }; function uuidbin() { var b = randomBytes(16); b[6] = (b[6] & 0x0f) | 0x40; b[8] = (b[8] & 0x3f) | 0x80; return b; }; this.isUuid = function (uuid) { if (typeof uuid === 'string') { return /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(uuid); }} this.uuid = function () { var b = uuidbin(); return hexBytes[b[0]] + hexBytes[b[1]] + hexBytes[b[2]] + hexBytes[b[3]] + '-' + hexBytes[b[4]] + hexBytes[b[5]] + '-' + hexBytes[b[6]] + hexBytes[b[7]] + '-' + hexBytes[b[8]] + hexBytes[b[9]] + '-' + hexBytes[b[10]] + hexBytes[b[11]] + hexBytes[b[12]] + hexBytes[b[13]] + hexBytes[b[14]] + hexBytes[b[15]]; }; } function hashString(str) { var hash = 0; for (var i = 0; i < str.length; i++) { hash = ~~(((hash << 5) - hash) + str.charCodeAt(i)); } return hash; } v.guestUser = false; v.userId = ''; v.userLevel = ''; v.userName = ""; v.userEmail = ""; v.loadScript('https://assets.vahara.io/general/vahara-site-libs.js'); v.optimizeImages = function(callback, target) { // Check if target is a jQuery object and convert it to a regular HTML node if (typeof window.jQuery !== 'undefined') { if (target && (target instanceof Object || target instanceof jQuery)) { target = target[0]; // Get the first element of the jQuery object } } else { if (target && target instanceof Object) { target = target[0]; // Get the first element of the jQuery object } } if (!target) { target = document.body; } var url = null; if (v.settings.image_host_type === 'imgix' || v.settings.image_host_type == 'otfip') { if (!(v.settings.image_max_width > 0)) { v.settings.image_max_width = 1920; } if (!(v.settings.image_quality > 0)) { v.settings.image_quality = 60; } // Identify mages that are from this orbit -- there are two patterns // All orbits should be vahara-oX-public.s3.amazon.com, but orbit #1 has // just o1-public.s3.amazonaws.com, so check for both var pattern = ''; var pattern2 = ''; var pattern3 = ''; if (v.orbitId == 4) { pattern = new RegExp('vahara-0' + v.orbitId + '-public.s3.amazonaws'); pattern2 = new RegExp('0' + v.orbitId + '-public.s3.amazonaws'); pattern3 = new RegExp('vahara-0' + v.orbitId + '-public.s3.[\\w\\-]+.amazonaws'); } else { pattern = new RegExp('vahara-o' + v.orbitId + '-public.s3.amazonaws'); pattern2 = new RegExp('o' + v.orbitId + '-public.s3.amazonaws'); pattern3 = new RegExp('vahara-o' + v.orbitId + '-public.s3.[\\w\\.-]+.amazonaws'); } var images = target.querySelectorAll('img[data-vh-src]'); images.forEach(function (image) { url = image.getAttribute('data-vh-src'); // If the URL is a placeholder, hold off on this one... if (url.match(/^\{\{/)) { return; } // Only optimize the image url if it is an amazon url if (pattern.test(url) || pattern2.test(url) || pattern3.test(url)) { url = url.replace(/^.*?:\/\/.*?\//, v.settings.image_host + '/'); url = url.replace(/\?.*$/, ''); var width = image.getAttribute('data-vh-width'); if (!(width > 0)) { width = image.width * 2; if (width < 1) { // If width is < 1, load the image in, then get the size once the image is loaded // If we already tried, let it go... if (image.getAttribute('data-vh-loading-image')) { image.removeAttribute('data-vh-loading-image'); } else { // If we haven't tried yet, try it image.setAttribute('data-vh-loading-image', 1); setTimeout(function () { image.setAttribute('data-vh-src', image.getAttribute('src')); v.optimizeImages(null, target); }, 2000); } } if (width > v.settings.image_max_width || width < 1) { width = v.settings.image_max_width; } } image.setAttribute('src', url + '?w=' + width + '&auto=compress'); } else { image.setAttribute('src', url); } // Remove the attributes once done with them image.removeAttribute('data-vh-src'); image.removeAttribute('data-vh-width'); }); } else { var images = target.querySelectorAll('img[data-vh-src]'); images.forEach(function (image) { url = image.getAttribute('data-vh-src'); image.setAttribute('src', url); }); } if (callback) { callback(url); } }; v.optimizeImages(function() { v.triggerEvent('vh:images-optimized'); }); v.loadScript(v.serverUrl + '/remote-site/access/edit-functions'); }