PageSourceSearch

https://www.statefairpark.org/js/functions.js?sv=8.6.3

js statefairpark.org collected 2026-09-26 04:03:06 UTC 149,256 bytes, 4,588 lines download raw bytes

1/// <asp:ScriptReference Path="~/js/jquery-1.7.2.min.js" />
2/// <asp:ScriptReference Path="~/js/jquery-ui-1.8.20.custom.min.js" />
3
4// -------------------------------------------------
5
6jQuery.htmlPrefilter = function( html ) {
7	return html;
8};
9
10if (window.jQuery && parseFloat($.fn.jquery) < 3.7) {
11
12    (function ($) {
13        if (!$ || !$.extend) return;
14
15        const originalExtend = $.extend;
16
17        $.extend = function (...args) {
18            args.forEach(arg => sanitize(arg));
19            return originalExtend.apply(this, args);
20        };
21
22        function sanitize(obj, visited = new WeakSet(), depth = 0) {
23            if (!obj || typeof obj !== "object") return;
24            if (!$.isPlainObject(obj)) return; // covers DOM nodes, window, jQuery objects etc.
25            if (visited.has(obj)) return;
26            if (depth > 10) return;
27
28            visited.add(obj);
29
30            try {
31                delete obj.__proto__;
32                delete obj.constructor;
33                delete obj.prototype;
34            } catch (e) {
35                return;
36            }
37
38            for (const key of Object.keys(obj)) {
39                try {
40                    sanitize(obj[key], visited, depth + 1);
41                } catch (e) {
42                    continue;
43                }
44            }
45        }
46    })(window.jQuery);
47
48}
49
50(function (jQuery) {
51    "use strict";
52    if (!jQuery || !jQuery.ajaxPrefilter) {
53        return;
54    }
55    jQuery.ajaxPrefilter(function (s) {
56        if (s.crossDomain && s.contents) {
57            s.contents.script = false;
58        }
59    });
60})(window.jQuery || window.$);
61
62
63// END -------------------------------------------------
64
65/*
66Namespacing
67*/
68//http://addyosmani.com/blog/essential-js-namespacing/
69function extend(destination, source) {
70    var toString = Object.prototype.toString,
71        objTest = toString.call({});
72    for (var property in source) {
73        if (source[property] && objTest == toString.call(source[property])) {
74            destination[property] = destination[property] || {};
75            extend(destination[property], source[property]);
76        } else {
77            destination[property] = source[property];
78        }
79    }
80    return destination;
81};
82
83var saffire = saffire || {};
84
85extend(saffire, {
86    utils: {
87
88        getWidgetData: function(opts) {
89          return new Promise(function(resolve, reject) {
90            $.ajax({
91              type: "POST",
92              url: opts.scriptPath,
93              data: "{'widgetModuleItemID':" + opts.currentWidgetModuleItemID + "}",
94              contentType: opts.contentType,
95              dataType: opts.dataType,
96              success: function(data) {
97                resolve(data.d)
98              },
99              error: function(data) {
100                console.log('Sponsor Widget failed to load', '\n' + 'Status: ' + data.status + ' ' + data.statusText, '\n' + data.responseText);
101                reject(data.responseText);
102              }
103            });
104          });
105        }
106
107    }
108});
109
110/*********************************
111Global Variables
112**********************************/
113
114var windowTopValue = 5;  // value used for "sticky headers" - can be redeclared in local ascx files ... re-evaluate if still needed
115var isIE = /*@cc_on!@*/false || !!document.documentMode;
116
117/*********************************
118General Functions
119**********************************/
120
121/**
122 Function to add numbers (ints and floats) and keep 2 decimals
123 The + forces a number to be returned since toFixed returns a string
124**/
125function AddNumbers(num1, num2) {
126    return +(num1 + num2).toFixed(2)
127}
128
129
130// "IE not supported" Banner & IE body class
131(function () {
132  if (isIE) {
133    var $body = $('body');
134    var ieBannerHTML = '\
135      <div id="ie-banner" class="ie-banner">\
136        <div>\
137          <span class="ie-banner__title">\
138          <img src="/images/icon-exclamation-orange.png" alt="warning">\
139          Whoops! Looks like you are using an outdated browser. <br>You might experience display issues.</span>\
140          <p>We recommend viewing this site with one of the following browsers:</p>\
141          <div class="ie-banner__browsers">\
142            <a href="https://www.google.com/chrome/" class="ie-banner__browsers__ch" target="_blank">\
143              <img src="/images/logo-gchrome.svg" alt="Google Chrome">\
144              <span>Google Chrome</span>\
145            </a>\
146            <a href="https://www.mozilla.org/en-US/firefox/new/" class="ie-banner__browsers__ff" target="_blank">\
147              <img src="/images/logo-mfirefox.svg" alt="Mozilla Firefox">\
148              <span>Mozilla Firefox</span>\
149            </a>\
150            <a href="https://www.microsoft.com/en-us/edge/" class="ie-banner__browsers__ed" target="_blank">\
151              <img src="/images/logo-msedge.svg" alt="Microsoft Edge">\
152              <span>Microsoft Edge</span>\
153            </a>\
154          </div>\
155        </div>\
156      </div>\
157    ';
158    $body.prepend(ieBannerHTML);
159    $body.addClass('browser-ie');
160    console.log('Whoops! Looks like you are using an outdated browser. You might experience display issues.');
161  } else {
162    return false;
163  }
164})();  
165// -----
166
167function toggleEventPane() {
168  const $body = $('body');
169  const $col1 = $('.eventCol1');
170  const $toggle = $('#calendarMobileToggle');
171
172  if ($body.hasClass('saffireMobileSize')) {
173    const isOpen = $col1.hasClass('calendarControlsOpen');
174
175    if (isOpen) {
176      // Closing
177      $(document).off('keydown.togglePane');
178
179      $('#scroll-panel-current-category').removeAttr('inert');
180      $toggle.prependTo('.eventCol2')
181        .removeAttr('aria-label')
182        .attr('aria-expanded', 'false')
183        .addClass('button');
184
185      $col1.removeClass('calendarControlsOpen').removeAttr('role aria-modal');
186      $col1.find('.clickEventUpload').removeClass("button");
187      $body.removeClass('calendarControlsCurrentlyOpen');
188      $('#businessListing .eventCol1 .planner-link').css("font-size", "0");
189      $toggle.focus();
190
191    } else {
192      // Opening
193      $('#scroll-panel-current-category').attr('inert', '');
194      $col1.attr({ 'role': 'dialog', 'aria-modal': 'true' })
195        .addClass('calendarControlsOpen')
196        .scrollTop(0);
197
198      $col1.find('.clickEventUpload').addClass("button");
199      $body.addClass('calendarControlsCurrentlyOpen');
200      $('.eventCol2 #calendarMobileToggle').removeClass('button');
201      $('#businessListing .eventCol1 .planner-link').css("font-size", "inherit");
202
203      $toggle.prependTo($col1)
204        .attr({ 'aria-label': 'Close Filters', 'aria-expanded': 'true' })
205        .focus();
206
207      // Focus handling
208      $(document).on('keydown.togglePane', function(e) {
209        // Handle Escape Key
210        if (e.key === 'Escape') {
211          toggleEventPane(); 
212          return;
213        }
214
215        // Handle Tab Key
216        if (e.key === 'Tab') {
217          const $focusable = $col1.find('.planner-link, input.filter-checkbox, .create-event-button a')
218                                  .filter(':visible');
219          
220          const $first = $toggle;
221          const $last = $focusable.last();
222
223          if (e.shiftKey && document.activeElement === $first[0]) {
224            e.preventDefault();
225            $last.focus();
226          } else if (!e.shiftKey && document.activeElement === $last[0]) {
227            e.preventDefault();
228            $first.focus();
229          }
230        }
231      });
232    }
233  }
234}
235
236function openSinglePlayer(singleSong, songTitle) {
237    singleSong = escape(singleSong);
238    songTitle = escape(songTitle);
239    window.open(SITEBASEURL + 'MusicPlayer.aspx?sf=' + singleSong + '&sfn=' + songTitle, 'null', 'width=480,height=160,toolbar=no,scrollbars=no,location=no,resizable=no');
240};
241
242function processCartTimers() {
243
244    for (ce = 0; ce < cartExpirations.length; ce++) {
245
246        var cartExpiration = cartExpirations[ce];
247        var secondsLeft = cartExpiration.secondsLeft - parseInt((new Date().getTime() - pageLoadedDate) / 1000);
248        var elements = $('.cartTimer_' + cartExpiration.cartItemID.toString());
249
250        for (cee = 0; cee < elements.length; cee++) {
251            var element = $(elements[cee]);
252            var cartTimer = element.find('.cartCountDown')
253            var cartNonExpiredMessage = element.find('.cartNonExpiredMessage')
254            var cartExpiredMessage = element.find('.cartExpiredMessage')
255
256            cartTimer.html(secondsToTime(secondsLeft));
257
258            if (secondsLeft > 0) {
259                cartNonExpiredMessage.css('display', 'block');
260                cartExpiredMessage.css('display', 'none');
261            } else {
262                cartNonExpiredMessage.css('display', 'none');
263                cartExpiredMessage.css('display', 'block');
264            }
265
266            element.css('visibility', 'visible');
267        }
268
269        if (secondsLeft <= 0 && cartExpiration.showNotifications && !cartExpiration.notificationShown) {
270            cartExpiration.notificationShown = true;
271            openInvalidCartItemsModal();
272        }
273
274    }
275
276}
277
278function openInvalidCartItemsModal() {
279
280    OpenModal('modal', SITEBASEURL + 'modalucLoader.aspx?controlPath=~/Core/Checkout/CheckoutInvalidCart.ascx', '450', '400', { 'OnClosePostBack': true, 'OnCloseTargetID': 'cartUpdated', 'Parent': window, 'ScrollFrame': true })
281}
282
283function ShowMessage() {
284    OpenModal('modal', '', '400px', '200px', { 'Parent': window, 'dialogID': 'messageModal' });
285}
286
287function updateClonedSubmit() {
288    var keywords = $('.clonedSearchBox .searchBoxInput input').val();
289    search(keywords);
290}
291
292function searchByInputID(id) {
293    var keywords = $('#' + id).val();
294    search(keywords);
295}
296
297function search(keywords) {
298    if (keywords != '') {
299        window.location = SITEBASEURL + 'search.aspx?q=' + keywords;
300    }
301}
302
303String.prototype.format = function () {
304    var args = arguments;
305    return this.replace(/\{\{|\}\}|\{(\d+)\}/g, function (m, n) {
306        if (m == "{{") { return "{"; }
307        if (m == "}}") { return "}"; }
308        return args[n];
309    });
310};
311
312String.prototype.toInteger = function () {
313    if ($.isNumeric(this)) {
314        return parseInt(this);
315    }
316
317    return 0;
318}
319
320Number.prototype.toInteger = function () {
321    return this;
322}
323
324Number.prototype.formatMoney = function (c) {
325    var n = this,
326        c = isNaN(c = Math.abs(c)) ? 2 : c,
327        d = ".",
328        t = ",",
329        s = n < 0 ? "-" : "",
330        i = String(parseInt(n = Math.abs(Number(n) || 0).toFixed(c))),
331        j = (j = i.length) > 3 ? j % 3 : 0;
332    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
333};
334
335Number.prototype.pad = function (size) {
336    var s = String(this);
337    while (s.length < (size || 2)) { s = "0" + s; }
338    return s;
339}
340
341Number.prototype.roundToDecimal = function (decimals) {
342    return parseFloat(this.toFixed(decimals))
343}
344
345// IE Polyfill for Number.isInteger
346if (isIE) {
347  Number.isInteger = Number.isInteger || function(value) {
348    return typeof value === 'number' && 
349      isFinite(value) && 
350      Math.floor(value) === value;
351  };
352}
353
354function rgb2hex(rgb) {
355    if(rgb != '' && rgb != undefined) {
356        rgb = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))?\)$/);
357        function hex(x) {
358            return ("0" + parseInt(x).toString(16)).slice(-2);
359        }
360        return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
361    }
362    return '';
363}
364
365function redirect(page) {
366    window.location.href = page
367}
368
369function OpenWindow(page, params) {
370    open_window(page, params)
371}
372
373function open_window(page, params) {
374    window.open(page, "popup", params)
375}
376
377function getWindowTop() {
378
379    var topWindow = window
380    var withinDomain = true;
381
382    while (topWindow != window.top && withinDomain) {
383
384        try{
385            var parentWindowLocation = topWindow.parent.location.host.toLowerCase();
386
387            topWindow = topWindow.parent
388        }
389        catch(err){
390            withinDomain = false;
391        }
392
393    }
394  
395    return topWindow
396
397}
398
399function isInCrossDomainIframe() {
400
401    var topWindow = window
402    var withinDomain = true;
403
404    while (topWindow != window.top && withinDomain) {
405
406        try{
407            var parentWindowLocation = topWindow.parent.location.host.toLowerCase();
408
409            topWindow = topWindow.parent
410        }
411        catch(err){
412            withinDomain = false;
413        }
414
415    }
416
417    return !withinDomain
418
419}
420
421function resizeIframe(obj) {
422    obj.style.height = 0;
423    obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
424}
425
426function IsNumeric(sText) {
427    var ValidChars = "0123456789.";
428    var IsNumber = true;
429    var Char;
430
431    for (i = 0; i < sText.length && IsNumber == true; i++) {
432        Char = sText.charAt(i);
433        if (ValidChars.indexOf(Char) == -1) {
434            IsNumber = false;
435        }
436    }
437    return IsNumber;
438}
439
440function secondsToTime(seconds) {
441
442    if (seconds < 0) {
443        seconds = 0;
444    }
445
446    var minutes = parseInt(seconds / 60);
447    seconds = seconds - (minutes * 60);
448
449    var hours = parseInt(minutes / 60);
450    minutes = minutes - (hours * 60);
451
452    var times = [];
453
454    if (hours) {
455        times.push(hours.pad(2).toString());
456    }
457    times.push(minutes.pad(2).toString());
458    times.push(seconds.pad(2).toString());
459
460    return times.join(":")
461
462}
463
464function guid() {
465    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
466        var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
467        return v.toString(16);
468    });
469}
470
471function stringIsNullOrEmpty(text) {
472    if (text == undefined) {
473        return true;
474    }
475    else if (text.trim() == '') {
476        return true;
477    }
478
479    return false
480}
481
482function stopBubbling(e) {
483
484    if (!e)
485        e = window.event;
486
487    if (e.stopPropagation)
488        e.stopPropagation();
489
490    if (e.preventDefault)
491        e.preventDefault();
492
493    e.cancelBubble = true;
494    e.cancel = true;
495    e.returnValue = false;
496    return false;
497
498}
499
500function DefaultButton(btnID, e) {
501    default_button(btnID, e);
502}
503
504function default_button(btnID, e) {
505    var btn = document.getElementById(btnID);
506
507    if (document.all) {
508        var code = null;
509        code = (e.keyCode ? e.keyCode : e.which);
510        if (code == 13 || code == 10) {
511            stopBubbling(e);
512            btn.click();
513        }
514    } else if (document.getElementById || document.layers) {
515
516        if (e.which == 13 || e.which == 10) {
517
518            if (btn && btn.tagName == 'A') {
519                if (btn.onclick) {
520                    result = btn.onclick;
521                }
522
523                if (typeof (result) == 'undefined') {
524                    eval(btn.getAttribute('href'));
525                }
526                else {
527                    stopBubbling(e)
528                    $('.textbox').blur();
529                    result();
530                }
531
532            } else if (btn && btn.click) {
533
534                stopBubbling(e)
535                btn.click();
536
537            } else if (btn && btn.onclick) {
538
539                var temp = eval(btn.onclick);
540                if (temp) {
541                    stopBubbling(e);
542                    temp(e);
543                }
544
545            }
546        }
547    }
548}
549
550escapeRegularExpression = function (text) {
551    return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
552}
553
554/*********************************
555Google Translate
556**********************************/
557
558function googleTranslateElementInit() {
559    new google.translate.TranslateElement({
560        pageLanguage: 'en',
561        autoDisplay: false,
562        includedLanguages: 'en,tl,fr,de,id,pl,pt,ru,es,th,ko',
563        layout: google.translate.TranslateElement.InlineLayout.SIMPLE
564    }, 'google_translate_element');
565}
566
567/*********************************
568Google Analytics
569**********************************/
570
571function sendGA4PurchaseEvent(data, aggregate, targetID) {
572
573    var gItems = [];
574
575    for (var i = 0; i < data.items.length; i++) {
576
577        var item = data.items[i];
578
579        var gItem = {
580            item_id: item.id,
581            item_name: item.name,
582            affiliation: aggregate ? ORGANIZATIONNAME : '',
583            currency: data.currency,
584            item_category: item.category,
585            item_category2: item.subcategory,
586            price: item.pricePer,
587            quantity: item.quantity
588        }
589
590        gItems.push(gItem);
591    }
592
593    gtag("event", "purchase", {
594        send_to: targetID,
595        transaction_id: aggregate ? '{0}_{1}'.format(data.id, RID) : data.id,
596        affiliation: aggregate ? ORGANIZATIONNAME : '',
597        value: data.total,
598        currency: data.currency,
599        coupon: data.discountApplied,
600        items: gItems
601    });
602}
603
604/***Email Signup****/
605
606var emailSignupInitialText;
607var emailSignupTbx;
608
609function EmailSignup(tbxID, initialText, listName, mobile, e) {
610    var tbx = $get(tbxID);
611
612    if (tbx) {
613
614        emailSignupInitialText = initialText;
615        emailSignupTbx = tbx;
616
617        if (tbx.value == '' || tbx.value == initialText) {
618            setTimeout('alert(\'Invalid Email Address\');', 100);
619        } else {
620            if (mobile) {
621                saffire.web.services.general.emailSignup(tbx.value, listName, EmailSignupSuccessMobile, EmailSignupError);
622            } else {
623                saffire.web.services.general.emailSignup(tbx.value, listName, EmailSignupSuccess, EmailSignupError);
624            }
625
626        }
627    } else {
628        setTimeout('alert(\'Invalid Email Address\');', 100);
629    }
630}
631
632function EmailSignupSuccess(result) {
633    if (result.result == 1) {
634        emailSignupTbx.value = emailSignupInitialText;
635
636        OpenModal('modal', SITEBASEURL +'I_thanks.aspx?e=' + result.message, '510px', '140px', 'no')
637    } else {
638        alert(result.message)
639    }
640}
641
642function EmailSignupSuccessMobile(result) {
643    if (result.result == 1) {
644        var redirectPage = 'I_thanks.aspx?e=' + result.message
645        emailSignupTbx.value = emailSignupInitialText;
646
647        window.location = redirectPage;
648    } else {
649        alert(result.message)
650    }
651}
652
653function EmailSignupError(result) {
654    if (result.message == null) {
655        alert('There was an error processing your submission.  Please try again shortly.')
656    } else {
657        alert(result.message);
658    }
659}
660
661
662function Search(initialText, tbx) {
663    if (tbx) {
664        var Query = tbx.value;
665
666        if (Query == '' || Query == initialText) {
667            setTimeout('alert(\'Invalid Search Criteria\');', 100)
668        } else {
669            redirect(SITEBASEURL + 'search.aspx?q=' + escape(Query));
670        }
671    }
672}
673
674function crossBrowserOuterHTML(node) {
675    return node.outerHTML || new XMLSerializer().serializeToString(node);
676}
677
678function getURLRewriteParameterFromDate(parameterDate) {
679
680    var year = parameterDate.getFullYear().toString();
681    var month = (parameterDate.getMonth() + 1).toString();
682    var day = parameterDate.getDate().toString();
683
684    if (month.length == 1) {
685        month = "0" + month;
686    }
687
688    if (day.length == 1) {
689        day = "0" + day;
690    }
691
692    return month + day + year;
693}
694
695/***Update Signup****/
696
697var updateSignupInitialText;
698var updateSignupTbx;
699
700
701function UpdateSignup(tbxID, initialText, listName, mobile, textSupported, e) {
702    var tbx = $get(tbxID);
703
704    if (tbx) {
705
706        var errorMsg = 'Invalid Email Address'
707
708        if (textSupported) {
709            errorMsg = 'Invalid Email Address or Phone Number'
710        }
711
712        updateSignupInitialText = initialText;
713        updateSignupTbx = tbx;
714
715        if (tbx.value == '' || tbx.value == initialText) {
716            setTimeout('alert(\'' + errorMsg + '\');', 100);
717        } else {
718
719            var isEmail = (tbx.value.indexOf("@") > 0)
720
721            if (isEmail || textSupported == false) {
722                if (mobile) {
723
724                } else {
725                    var leadEventID =  guid();
726                    saffire.web.services.general.emailSignup(tbx.value, listName, EmailSignupSuccess, EmailSignupError, leadEventID);
727
728                    if (window.top.FB_CONFIG && window.top.fbq) {
729                        window.top.fbq('track', 'Lead', null, { eventID: leadEventID });
730                    }
731                }
732            }
733            else {
734
735                var phoneNumber = tbx.value.replace(/-/gi, "").replace(/\(/gi, "").replace(/\)/gi, "").replace(/ /gi, "")
736
737                if (IsNumeric(phoneNumber) && phoneNumber.length == 10) {
738
739                    window.top.OpenModal('modal', SITEBASEURL + 'modalUCLoader.aspx?controlPath=~/Events/General/TextSignup.ascx&pn=' + tbx.value + '&list=' + listName, '510px', '246px', 'no')
740
741                    updateSignupTbx.value = updateSignupInitialText;
742
743                }
744                else {
745                    setTimeout('alert(\'Invalid phone number\');', 100);
746                }
747            }
748
749
750
751        }
752    } else {
753        setTimeout('alert(\'' + errorMsg + '\');', 100);
754    }
755}
756
757function EmailSignupSuccess(result) {
758
759    var isInTopWindow = window.location.href === window.top.location.href;
760
761    switch (result.result) {
762        case 1:
763            //No extra email fields
764            updateSignupTbx.value = updateSignupInitialText;
765
766            var url = SITEBASEURL + 'I_thanks.aspx?e=' + result.message;
767
768            if (isInTopWindow) {
769                window.top.OpenModal('modal', url, '510px', '140px', 'no');
770            } else {
771                window.location.href = url;
772            }
773
774            break;
775        case 2:
776            //Needs more info
777
778            var url = SITEBASEURL + 'modalUCLoader.aspx?controlPath=~/Core/Content/EmailSignupFields.ascx&em=' + updateSignupTbx.value + '&list=' + result.message;
779
780            if (isInTopWindow) {
781                window.top.OpenModal('modal', url, '510px', '300px', { 'ScrollFrame': true });
782            } else {
783                window.location.href = url;
784            }
785
786
787            updateSignupTbx.value = updateSignupInitialText;
788
789            break;
790        default:
791            alert(result.message)
792    }
793
794}
795
796function EmailSignupSuccessMobile(result) {
797    if (result.result == 1) {
798        var redirectPage = 'I_thanks.aspx?e=' + result.message
799        emailSignupTbx.value = emailSignupInitialText;
800
801        window.location = redirectPage;
802    } else {
803        alert(result.message)
804    }
805}
806
807function EmailSignupError(result) {
808    if (result.message == null) {
809        alert('There was an error processing your submission.  Please try again shortly.')
810    } else {
811        alert(result.message);
812    }
813}
814
815/***Search***/
816
817function Search(initialText, tbx) {
818    if (tbx) {
819        var Query = tbx.value;
820
821        if (Query == '' || Query == initialText) {
822            setTimeout('alert(\'Invalid Search Criteria\');', 100)
823        } else {
824            redirect(SITEBASEURL + 'search.aspx?q=' + escape(Query));
825        }
826    }
827}
828
829function crossBrowserOuterHTML(node) {
830    return node.outerHTML || new XMLSerializer().serializeToString(node);
831}
832
833/***IMAGE CACHING FUNCTIONS***/
834function MM_swapImgRestore() { //v3.0
835
836    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
837}
838
839function MM_preloadImages() { //v3.0
840    var d = document; if (d.images) {
841        if (!d.MM_p) d.MM_p = new Array();
842        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
843            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; }
844    }
845}
846
847function MM_findObj(n, d) { //v4.01
848    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
849        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
850    }
851    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
852    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
853    if (!x && d.getElementById) x = d.getElementById(n); return x;
854}
855
856function MM_swapImage() { //v3.0
857    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
858        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
859}
860/***/
861/**MODAL MANAGEMENT**/
862
863CurrentModalDialogs = [];
864
865$OpenModalAutoHide = function ($element, settings) {
866
867    var effectiveSettings = {
868        modal: false,
869        autoHide: true,
870        resizable: false,
871        draggable: false,
872        element: $element
873    }
874
875    effectiveSettings = $.extend(effectiveSettings, settings);
876
877    $OpenModal(effectiveSettings);
878
879}
880
881$OpenModal = function (settings) {
882
883    var effectiveSettings = {
884        modal: true,
885        autoOpen: true,
886        closeOnEscape: true,
887        draggable: true,
888        resizable: false,
889        forceFitInContainer: false,
890        width: settings.width,
891        height: settings.height,
892        buttons: [],
893        open: OpenDialogHandler, /*DONT CHANGE, CALLBACKS SHOULD BE HANDLED THROUGH customCallbacks PROPERTY*/
894        close: CloseDialogHandler, /*DONT CHANGE, CALLBACKS SHOULD BE HANDLED THROUGH customCallbacks PROPERTY*/
895        closeText: '&nbsp;',
896        //custom settings (not part of jquery ui dialog defaults, but used in our implementation)
897        dialogID: '',
898        element: null,
899        iframe: {
900            url: null,
901            scrolling: 'no'
902        },
903        customCallbacks: {
904            open: function() {
905              var thisModal = $('#dynamicModal iframe');
906              thisModal.attr('tabindex','0');
907              thisModal.load(function(){ 
908                thisModal.contents().find('body').append('<a href="javascript:void(0)" class="modalTopJump" aria-label="jump to top of modal"></a>');
909                $(".ui-dialog-titlebar a.modalCloseButton").attr('tabindex','0');
910                var focusable = $("#dynamicModal iframe").contents().find('a.button');
911                var closeButton = $(".modalClose a.modalCloseButton");
912                var lastFocusable = focusable.last();
913                if (focusable.length < 0) {
914                  thisModal.contents().find('body').append('<a href="javascript:void(0)" class="modalTopJump"></a>');
915                  thisModal.contents().find('#eventEntryModal').append('<a href="javascript:void(0)" class="modalTopJump" aria-label="jump to top of modal"></a>');
916                  lastFocusable = thisModal.contents().find('.modalTopJump');
917                }
918                thisModal.contents().find('input:not([type="hidden"]), select, textarea').first().focus();
919                lastFocusable = thisModal.contents().find('.modalTopJump');
920                lastFocusable.keydown(function(e) {
921                  if (e.which === 9) {
922                    e.preventDefault();
923                    closeButton.focus();
924                  }
925                });
926                thisModal.contents().find('.modalTopJump').on('keydown', function(e) {
927                  if (e.which === 13) {
928                    e.preventDefault();
929                    closeButton.focus();
930                  }
931                });
932            });
933            },
934            close: null
935        },
936        postback: {
937            parent: null,
938            enabled: false,
939            targetID: null,
940            eventArgs: null
941        },
942        isDynamic: false,
943        autoHide: false,
944        autoHideDelay: 1000,
945    };
946
947    if (settings) {
948
949        //handle legacy settings
950        if (settings.OnCloseCallbackFunction && typeof settings.OnCloseCallbackFunction === 'function') {
951            effectiveSettings.customCallbacks.close = settings.OnCloseCallbackFunction;
952        }
953        effectiveSettings.postback.enabled = !!settings.OnClosePostBack;
954        effectiveSettings.postback.targetID = settings.OnCloseTargetID;
955        effectiveSettings.postback.eventArgs = settings.OnCloseEventArg;
956        effectiveSettings.postback.parent = settings.Parent;
957        if (effectiveSettings.ScrollFrame) effectiveSettings.iframe.scrolling = 'auto';
958
959        effectiveSettings = $.extend(effectiveSettings, settings);
960
961    }
962
963    if (window.top != window.self) {
964        //effectiveSettings = $.extend(effectiveSettings, {position: {my: 'top', at: 'top', of: 'window'}});
965    }
966
967    var $element;
968    if (effectiveSettings.element == null) {
969
970        if (effectiveSettings.dialogID != '') {
971            $element = $('#' + effectiveSettings.dialogID);
972        }
973
974        if ($element == null) {
975            if (window.top != window.self) {
976                var rand = Math.floor(Math.random() * (5 - 1) + 1);
977                effectiveSettings = $.extend(effectiveSettings, {position: {my: "center",  at: "center", of: window.parent.$("body"), within: window.parent.$("body")}});
978                $element = $("<div id='dynamicModal"+rand+"' class='modal nested'></div>");
979                effectiveSettings.dialogID = 'dynamicModal' + rand;
980                window.parent.$('body').append($element);
981            } else {
982                $element = $("<div id='dynamicModal' class='modal'></div>");
983                effectiveSettings.dialogID = 'dynamicModal';
984            }
985            settings.isDynamic = true;
986        }
987
988    }
989
990    var dialogID = effectiveSettings.dialogID;
991
992    //set innerHtml of target (if a url is provided)
993    if (effectiveSettings.iframe.url) {
994        $element.append('<iframe src="' + effectiveSettings.iframe.url + '" width="100%" height="100%" onload="keyboardFix(this)" scrolling="auto" frameborder="0"></iframe>');
995    }
996
997    //adjust for padding
998    effectiveSettings.height = parseInt(effectiveSettings.height) + 85
999    effectiveSettings.width = parseInt(effectiveSettings.width) + 20
1000
1001    //create title bar contents
1002    var modalCloseButtonClass;
1003    if(isResponsive){
1004        modalCloseButtonClass= "modalCloseButton button";
1005    } else {
1006        modalCloseButtonClass= "modalCloseButton";
1007    }
1008    $modalCloseContainer = $("<div class='modalClose' style='width:100%;text-align: right;'></div>");
1009    $modalCloseButton = $("<a aria-label='Close' role='button' class='"+modalCloseButtonClass+"' href='javascript:void(0)'></a>");
1010    $modalCloseButton.on('click', function () { $HideModal($element) });
1011    $modalCloseContainer.append($modalCloseButton);
1012
1013    //open the dialog
1014    console.log(effectiveSettings)
1015    $element.dialog(effectiveSettings).prev('.ui-dialog-titlebar').append($modalCloseContainer);
1016
1017    //add to list of open dialogs
1018    var index = CurrentModalDialogs.indexOf(dialogID);
1019    if (index === -1) {
1020        CurrentModalDialogs.push(dialogID);
1021    }
1022
1023    if (effectiveSettings.autoHide) {
1024        setTimeout(function () {
1025            $HideModal($element);
1026        }, effectiveSettings.autoHideDelay);
1027    }
1028
1029    $modalCloseButton.blur();
1030
1031    return false;
1032
1033}
1034
1035OpenModal = function (dialogID, url, width, height, settings) {
1036
1037    if (width.indexOf('px') > -1) {
1038        width = width.replace('px', '');
1039    }
1040
1041    if (height.indexOf('px') > -1) {
1042        height = height.replace('px', '');
1043    }
1044
1045    var effectiveSettings = {
1046        iframe: {
1047            url: url
1048        },
1049        width: width,
1050        height: height
1051    }
1052
1053    effectiveSettings = $.extend(effectiveSettings, settings);
1054
1055    return $OpenModal(effectiveSettings);
1056
1057}
1058
1059OpenDialogHandler = function (event, ui) {
1060    window.parent.$('body').addClass('hideBackToTop');
1061    var callbacks = $(this).dialog('option', 'customCallbacks');
1062    var dialogID = $(this).attr('id');
1063
1064    //handle callback(s)
1065    if (callbacks.open) {
1066        var args = {
1067            event: event,
1068            element: this
1069        }
1070        callbacks.open(args);
1071    }
1072
1073    //$(this).css('overflow', 'hidden');
1074
1075    var forceFitInContainer = $(this).dialog('option', 'forceFitInContainer');
1076
1077    if (forceFitInContainer) {
1078
1079        var $this = $(this);
1080        var $window = $(window);
1081
1082        if ($this.width() > $window.width()) {
1083            $this.width($window.width());
1084        }
1085
1086        if ($this.height() > $window.height()) {
1087            $this.height($window.height());
1088        }
1089
1090    }
1091
1092}
1093
1094keyboardFix = function(target) {
1095    if (Modernizr.touch == true) {
1096        var isIOS = /(iPad|iPhone|iPod)/g.test(navigator.userAgent);
1097        if (isIOS) {
1098            var $target = $(target);
1099            var $txtFields = $target.contents().find("input[type=text], textarea");
1100            $txtFields.on('focus', function(e){
1101                window.parent.scroll(0,0);
1102                window.parent.$('.ui-dialog').css({position:'absolute'});
1103            })
1104            $txtFields.on('blur', function(e){
1105                window.parent.$('.ui-dialog').css({position:'fixed'});
1106            })
1107        }
1108    }
1109}
1110
1111CloseDialogHandler = function (event, ui) {
1112
1113    window.parent.$('body').removeClass('hideBackToTop');
1114
1115    var callbacks = $(this).dialog('option', 'customCallbacks');
1116    var postback = $(this).dialog('option', 'postback');
1117    var hideSettings = $(this).dialog('option', 'hideSettings');
1118    var isDynamic = $(this).dialog('option', 'isDynamic');
1119    var dialogID = $(this).attr('id');
1120    var eventArgs = null;
1121    var userContext = $(this).dialog('option', 'UserContext');
1122
1123    if (hideSettings) {
1124        eventArgs = hideSettings.EventArgs;
1125        if (hideSettings.AddOnCloseDoPostBack && postback) {
1126            postback.enabled = true;
1127        }
1128    }
1129
1130    //remove from open dialogs list
1131    var index = CurrentModalDialogs.indexOf(dialogID);
1132    if (index !== -1) {
1133        CurrentModalDialogs.splice(index, 1);
1134    }
1135
1136    //handle callback(s)
1137    if (callbacks.close) {
1138        var args = {
1139            event: event,
1140            element: this,
1141            eventTargetID: null,
1142            eventArgs: eventArgs,
1143            userContext: userContext,
1144        }
1145        callbacks.close(args);
1146    }
1147
1148    //handle postbacks
1149    if (postback && postback.enabled) {
1150        var evtArgs = postback.eventArgs;
1151        var doPostback = true;
1152        if (hideSettings) {
1153            if (typeof hideSettings.EventArgs != 'undefined') {
1154                evtArgs = hideSettings.EventArgs;
1155            } else if (!evtArgs) {
1156                evtArgs = '';
1157            }
1158            if (hideSettings.CancelOnCloseDoPostBack && !hideSettings.AddOnCloseDoPostBack) {
1159                doPostback = false;
1160            }
1161        }
1162        //do the postback
1163        if (doPostback) {
1164            if (postback.parent) {
1165                postback.parent.UpdatePage(postback.targetID, evtArgs);
1166            } else {
1167                UpdatePage(postback.targetID, evtArgs);
1168            }
1169        }
1170    }
1171
1172    if (isDynamic) {
1173        $(this).dialog("destroy");
1174        $(this).remove();
1175    }
1176}
1177
1178$HideModal = function ($element) {
1179    $element.dialog('close');
1180    $element.remove();
1181}
1182
1183HideModal = function (hideSettings) {
1184
1185    if (hideSettings && hideSettings.dialogID) {
1186        //close a specific dialog
1187
1188        $('#' + hideSettings.dialogID).dialog('option', 'hideSettings', hideSettings);
1189        $('#' + hideSettings.dialogID).dialog("close");
1190
1191    } else {
1192        //close all dialogs
1193
1194        var selectors = '';
1195        for (var x = 0, len = CurrentModalDialogs.length; x < len; x++) {
1196            if (selectors != '') {
1197                selectors += ',';
1198            }
1199            selectors += '#{0}'.format(CurrentModalDialogs[x]);
1200        }
1201
1202        if (selectors != '') {
1203            $(selectors).dialog('option', 'hideSettings', hideSettings);
1204            $(selectors).dialog("close");
1205            $(selectors).remove();
1206
1207        }
1208
1209    }
1210
1211}
1212
1213OpenModalParams = function () {
1214    this.OnClosePostBack = false;
1215    this.OnCloseTargetID = '';
1216    this.OnCloseArgument = '';
1217    this.UserContext = null;
1218    this.OnCloseCallbackFunction = '';
1219    this.Parent = null;
1220    this.ScrollFrame = false;
1221}
1222
1223HideModalParams = function () {
1224    this.EventArgs;
1225    this.CancelOnCloseDoPostBack = false;
1226    this.AddOnCloseDoPostBack = false;
1227}
1228
1229/***/
1230/**Window MANAGEMENT**/
1231
1232var CurrentWindow;
1233var CurrentWindowOnCloseDoPostBack = false;
1234var CurrentWindowOnCloseTargetID = '';
1235var CurrentWindowOnCloseEventArg = '';
1236
1237function OpenWindowModal(url, width, height, OpenWindowParams) {
1238
1239    if (OpenWindowParams) {
1240        CurrentWindowOnCloseDoPostBack = OpenWindowParams.OnClosePostBack;
1241        CurrentWindowOnCloseTargetID = OpenWindowParams.OnCloseTargetID;
1242        CurrentWindowOnCloseEventArg = OpenWindowParams.OnCloseEventArg;
1243        if (OpenWindowParams.ScrollFrame && OpenWindowParams.ScrollFrame == true) {
1244            OpenWindowParams.ScrollFrame = '1';
1245        }
1246        else {
1247            OpenWindowParams.ScrollFrame = '0';
1248        }
1249    }
1250
1251    if (CurrentWindowOnCloseDoPostBack) {
1252        url = url + '&OnCloseDoPostBack=true';
1253    }
1254
1255    if (CurrentWindowOnCloseTargetID) {
1256        url = url + '&OnCloseTargetID=' + CurrentWindowOnCloseTargetID;
1257    }
1258
1259    if (CurrentWindowOnCloseEventArg) {
1260        url = url + '&OnCloseEventArg=' + CurrentWindowOnCloseEventArg;
1261    }
1262
1263    var CurrentWindowOptions = 'width=' + width + ',height=' + height + ',directories=no,location=no,menubar=no,resizable=no,scrollbars=' + OpenWindowParams.ScrollFrame + ',status=0, toolbar = no';
1264
1265    CurrentWindow = window.open(url, 'window', CurrentWindowOptions);
1266
1267    var scrolling = 'NO';
1268
1269    return true;
1270
1271}
1272
1273function OpenWindowParams() {
1274    var OnClosePostBack = false;
1275    var OnCloseTargetID = '';
1276    var OnCloseCallbackFunction = '';
1277    var ScrollFrame = false;
1278}
1279
1280function HideWindow(HideWindowParams) {
1281
1282    var m = CurrentWindow;
1283
1284    if (m) {
1285
1286        m.close();
1287
1288        var _EventArgs = m.CurrentWindowOnCloseEventArg;
1289        if (HideWindowParams) {
1290
1291            if (HideWindowParams.EventArgs != undefined) {
1292                _EventArgs = HideWindowParams.EventArgs;
1293            } else {
1294                if (_EventArgs == '' || _EventArgs == undefined) {
1295                    _EventArgs = '';
1296                }
1297            }
1298
1299            if (HideWindowParams.CancelOnCloseDoPostBack) {
1300                m.CurrentWindowOnCloseDoPostBack = false;
1301            }
1302        }
1303
1304        if (m.CurrentWindowOnCloseDoPostBack) {
1305            UpdatePage(m.CurrentWindowOnCloseTargetID, _EventArgs);
1306        }
1307
1308        CurrentWindow = null;
1309        CurrentWindowOnCloseDoPostBack = false;
1310        CurrentWindowOnCloseTargetID = '';
1311
1312        //Fix bug in ie9 that continues to process the page after this script runs.
1313        window.onerror = function () { return true; };
1314
1315    }
1316}
1317
1318function HideWindowParams() {
1319    var EventArgs;
1320    var CancelOnCloseDoPostBack = false;
1321}
1322
1323function WindowOnCloseCallbackParams() {
1324    var EventTargetID = '';
1325    var EventArgs = '';
1326}
1327
1328/*End Window Management*/
1329
1330function getQueryStringValueByName(name) {
1331    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
1332    var regexS = "[\\?&]" + name + "=([^&#]*)";
1333    var regex = new RegExp(regexS);
1334    var results = regex.exec(window.location.search);
1335    if (results == null)
1336        return "";
1337    else
1338        return decodeURIComponent(results[1].replace(/\+/g, " "));
1339}
1340
1341/***PopupControlExtender***/
1342
1343function ShowQuickDialog(behaviorID, params) {
1344    var pce = $find(behaviorID);
1345    if (pce) {
1346        if (params) {
1347            pce._popupBehavior.set_parentElementID(params.targetElementID);
1348            pce.set_OffsetX(params.offSetX);
1349            pce.set_OffsetY(params.offSetY);
1350        }
1351
1352        pce.showPopup();
1353    }
1354}
1355
1356function HideQuickDialog(behaviorID) {
1357    var pce = $find(behaviorID);
1358    if (pce) {
1359        pce.hidePopup();
1360    }
1361}
1362
1363function ShowQuickDialogParams() {
1364    offSetX = 0;
1365    offSetY = 0;
1366    targetElementID = '';
1367}
1368
1369/***/
1370
1371function UpdatePage(target, args) {
1372    setTimeout('__doPostBack(\'' + target + '\', \'' + args + '\')', 100)
1373}
1374
1375function ChangePaginationPageSize(ddlID, baseURL) {
1376    var ddl = $get(ddlID);
1377
1378    if (baseURL.indexOf('?') == -1) {
1379        baseURL += "?"
1380    } else {
1381        baseURL += "&"
1382    }
1383
1384    redirect(baseURL + 'cp=1&ps=' + ddl[ddl.selectedIndex].value);
1385}
1386
1387function GetFlashMovie(movieName) {
1388    if (navigator.appName.indexOf("Microsoft") != -1) {
1389        return window[movieName]
1390    } else {
1391        return document[movieName]
1392    }
1393}
1394
1395function ClearDefaultText(tbx, defaultText) {
1396
1397    if (tbx) {
1398        if (tbx.value == defaultText) {
1399            tbx.value = '';
1400        }
1401    }
1402}
1403
1404
1405
1406
1407/***********************************************
1408* Textarea Maxlength script- � Dynamic Drive (www.dynamicdrive.com)
1409* This notice must stay intact for legal use.
1410* Visit http://www.dynamicdrive.com/ for full source code
1411***********************************************/
1412
1413function ismaxlength(obj, maxLength) {
1414    var mlength = obj.getAttribute ? parseInt(maxLength) : ""
1415    if (obj.getAttribute && obj.value.length > mlength)
1416        obj.value = obj.value.substring(0, mlength)
1417}
1418
1419/***********************************************
1420* Found at http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/msg/f2234ba565b8effa?dmode=source&output=gplain
1421***********************************************/
1422
1423function SetUniqueRadioButton(nameregex, current) {
1424    re = new RegExp(nameregex);
1425    for (i = 0; i < document.forms[0].elements.length; i++) {
1426        elm = document.forms[0].elements[i]
1427        if (elm.type == 'radio') {
1428            if (re.test(elm.name)) {
1429                elm.checked = false;
1430            }
1431        }
1432    }
1433    current.checked = true;
1434}
1435
1436
1437/*********************************
1438Fan Pick
1439**********************************/
1440function ShowFanPickSavedDialog() {
1441    var bodyOffsetTop = $(window).scrollTop();
1442    var thanksDialog = $('<div id="myFanPickDialog" class="modalContent border content" Style="border: solid 10px #ffffff; padding: 15px; background-color:#fff; color:#313131;"></div>');
1443    $('body').append(thanksDialog);
1444    thanksDialog.html('<h1>Thanks!</h1>Your Fan Pick Saved');
1445    $(thanksDialog).dialog({
1446        height: 200,
1447        width: 320,
1448        closeText: '',
1449        show: 'blind',
1450        collision: 'fit',
1451        open: function () { setTimeout(function(){$('.ui-dialog[aria-describedby="myFanPickDialog"]').css('display','none');}, 5000); }
1452    });
1453    $(thanksDialog).dialog('open').position({ my: "center", at: "center", of: window.top }).delay(5000).hide('slide');
1454    window.scrollTo(0, bodyOffsetTop); //ie fix for versions 7 and under
1455}
1456function FanPick(sender, entityTypeName, entityID) {
1457    TrackBeAFan();
1458
1459    saffire.web.services.events.saveFanPick(entityTypeName, entityID
1460                                , function (result, context) {
1461                                    if (result && result.result == 1) {
1462
1463                                        var bodyOffsetTop = $(window).scrollTop();
1464                                       	$('.fan a').text('FAN').css('opacity','0.5');
1465
1466                                        window.scrollTo(0, bodyOffsetTop); //ie fix for versions 7 and under
1467
1468                                        sender.onclick = null;
1469
1470                                        saffire.web.services.events.getEventFanPickCount(entityID
1471                                            , function (result, context) {
1472                                                if (result) {
1473                                                    if (result > 0) {
1474                                                        $(context).parent().children().filter("span").text(result + ' Fans')
1475                                                    }
1476                                                }
1477                                            }
1478                                            , function () { }
1479                                            , sender);
1480                                        ShowFanPickSavedDialog();
1481
1482                                    }
1483                                }
1484                                , function (sender, args) { alert(args.message) }
1485                                , sender
1486                                );
1487}
1488
1489/*********************************
1490Business Fan Pick
1491**********************************/
1492function ShowBusinessFanPickSavedDialog() {
1493    var bodyOffsetTop = $(window).scrollTop();
1494    var thanksDialog = $('<div id="myFanPickDialog" class="modalContent border content" Style="border: solid 10px #ffffff; padding: 15px; background-color:#fff; color:#313131;"></div>');
1495    $('body').append(thanksDialog);
1496    thanksDialog.html('<h1>Thanks!</h1>Your Fan Pick Saved');
1497    $(thanksDialog).dialog({
1498        height: 200,
1499        width: 320,
1500        closeText: '',
1501        show: 'blind',
1502        collision: 'fit',
1503        open: function () { setTimeout(function(){$('.ui-dialog[aria-describedby="myFanPickDialog"]').css('display','none');}, 5000); }
1504    });
1505    $(thanksDialog).dialog('open').position({ my: "center", at: "center", of: window.top }).delay(5000).hide('slide');
1506    window.scrollTo(0, bodyOffsetTop); //ie fix for versions 7 and under
1507}
1508function BusinessFanPick(sender, entityTypeName, entityID) {
1509    TrackBeAFan();
1510
1511    saffire.web.services.businesses.saveFanPick(entityTypeName, entityID
1512                                , function (result, context) {
1513                                    if (result && result.result == 1) {
1514
1515                                        var bodyOffsetTop = $(window).scrollTop();
1516                                        $('.fan a').text('FAN').css('opacity', '0.5');
1517
1518                                        window.scrollTo(0, bodyOffsetTop); //ie fix for versions 7 and under
1519
1520                                        sender.onclick = null;
1521
1522                                        saffire.web.services.businesses.getBusinessFanPickCount(entityID
1523                                            , function (result, context) {
1524                                                if (result) {
1525                                                    if (result > 0) {
1526                                                        $(context).parent().children().filter("span").text(result + ' Fans')
1527                                                    }
1528                                                }
1529                                            }
1530                                            , function () { }
1531                                            , sender);
1532                                        ShowBusinessFanPickSavedDialog();
1533
1534                                    }
1535                                }
1536                                , function (sender, args) { alert(args.message) }
1537                                , sender
1538                                );
1539}
1540
1541
1542
1543/*********************************
1544Add To Cart
1545**********************************/
1546
1547$(document).ready(function () {
1548
1549    ConfigureAddToCartButtons();
1550
1551});
1552
1553
1554
1555function ConfigureAddToCartButtons() {
1556
1557    $('.purchaseOptions').on('keypress click', '.buyButton[data-promptpurchasername="false"]', function (e) {
1558
1559      if (e.which === 13 || e.type === 'click') {
1560
1561        $this = $(this);
1562        var itemID = $this.data("itemid");
1563        var $itemContainer = $('.purchaseOptions[data-itemid="' + itemID + '"]');
1564        if ($itemContainer) {
1565
1566            ClearPurchaseOptionMessage($itemContainer);
1567
1568            var purchaser = $('.purchaserName', $itemContainer).val();
1569
1570            var addToCartRequest = { itemID: itemID, options: [], purchaser: purchaser };
1571
1572            var totalQtyAdded = 0;
1573
1574            var freeFormRequired = $this.data('freeformrequired');
1575            var freeFormPrice = 0;
1576
1577            if (freeFormRequired) {
1578                var freeFormPriceInput = $('.freeFormPriceInput', $itemContainer);
1579
1580                if (freeFormPriceInput) {
1581                    if ($.isNumeric(freeFormPriceInput.val())) {
1582
1583                        freeFormPrice = freeFormPriceInput.val();
1584                        addToCartRequest.freeFormPrice = freeFormPrice;
1585
1586                        if (freeFormPrice > 0) {
1587                            totalQtyAdded = 1;
1588                        }
1589
1590                    }
1591                }
1592            }
1593
1594            addToCartRequest.detailURL = window.location.href;
1595
1596            $('.purchaseOption', $itemContainer).each(function (i) {
1597
1598                var $option = $(this);
1599                var productID = $option.data('productid');
1600                var qty = 0;
1601
1602                var ddlQty = $('.dropdown', $option);
1603
1604                if (ddlQty) {
1605                    qty = ddlQty.val();
1606                    if (qty < 0) {
1607                        qty = 0;
1608                    }
1609                }
1610
1611                if (qty > 0) {
1612                    addToCartRequest.options.push({ productID: productID, qty: qty });
1613                    totalQtyAdded = totalQtyAdded + qty;
1614                }
1615
1616                addToCartRequest.subProducts = [];
1617
1618                var $subProductsContainer = $('.subProductsPurchaseOptions', $itemContainer);
1619
1620                $('.subProductPurchaseOption', $subProductsContainer).each(function (i, $item) {
1621
1622                    var $option = $(this);
1623
1624                    var subProduct = { itemID: itemID, productID: $option.data('productid'), options: [] };
1625
1626                    $('.subProductTicketTypePurchaseOption', $item).each(function (i) {
1627                        var $option = $(this);                        
1628                        subProduct.options.push({ productID: $option.data('productid'), quantity: parseInt($option.data('qty')) });
1629                    })
1630
1631                    addToCartRequest.subProducts.push(subProduct);
1632                })
1633            });
1634
1635            if (totalQtyAdded > 0) {
1636                AddItemToCart($this, addToCartRequest);
1637            } else {
1638                if (totalQtyAdded == 0) {
1639
1640                    if (freeFormRequired && freeFormPrice == 0) {
1641                        ShowPurchaseOptionMessage($itemContainer, "Amount is required");
1642                    } else {
1643                        ShowPurchaseOptionMessage($itemContainer, "Quantity is required");
1644                    }
1645
1646                }
1647            }
1648        }
1649      }
1650
1651    });
1652
1653
1654    // true
1655
1656    $('.purchaseOptions').on('keypress click', '.buyButton[data-promptpurchasername="true"]', function (e) {
1657      if (e.which === 13 || e.type === 'click') {
1658        $this = $(this);
1659        var itemID = $this.data("itemid");
1660        var $itemContainer = $('.purchaseOptions[data-itemid="' + itemID + '"]');
1661
1662        ClearPurchaseOptionMessage($itemContainer);
1663
1664        $OpenModal({
1665            width: '350px',
1666            height: '200px',
1667            iframe: { url: '{0}modalucloader.aspx?controlPath=~/Core/Content/I_mapMarkerPurchaserName.ascx'.format(SITEBASEURL) },
1668            customCallbacks: {
1669                close: function (data) {
1670
1671                    $('.purchaserName', $this.parent()).val(data.eventArgs);
1672                    $this.attr('data-promptpurchasername', 'false');
1673                    $this.trigger('click');
1674                }
1675            }
1676
1677        });
1678      }
1679    });
1680
1681
1682
1683}
1684
1685function ShowPurchaseOptionMessage($e, message) {
1686    $e.append("<div class='purchaseOptionMessage' role='status'>{0}</div> ".format(message));
1687}
1688
1689function ClearPurchaseOptionMessage($e) {
1690    $('.purchaseOptionMessage', $e).remove();
1691}
1692
1693
1694var _addToCartCallInProgress = false;
1695function AddItemToCart(sender, options) {
1696    // console.log(sender);
1697    // console.log(options)
1698
1699    if (!_addToCartCallInProgress) {
1700        _addToCartCallInProgress = true;
1701
1702        if (FB_CONFIG) {
1703            options.fbEventID = guid();
1704        }
1705
1706        $.ajax({
1707            url: SITEBASEURL + 'api/cart/additem'
1708            , dataType: 'json'
1709            , contentType: 'application/json; charset=utf-8'
1710            , type: 'POST'
1711            , data:  JSON.stringify(options)
1712        }).done(function(data) {
1713            _addToCartCallInProgress = false;
1714
1715            if (data) {
1716                if (data.IsSuccess) {
1717                	if (FB_CONFIG && typeof fbq === 'function') {
1718                        fbq('track', 'AddToCart', null, { eventID: options.fbEventID });
1719                    }
1720                        
1721                    if (data.RedirectURL) {
1722                      window.top.location.href = data.RedirectURL;
1723                    } else {
1724                        getWindowTop().ShowAddToCartSavedModal(sender, options.addToCartMessage, data, options.inCheckout, true);
1725                        getWindowTop().cartProductUnitCount = data.CartProductUnitCount;
1726                        getWindowTop().UpdateCartIndicator();
1727                    }
1728                } else {
1729                    alert(data.Message);
1730                }
1731            }
1732
1733        }).fail(function(status, error) {
1734            _addToCartCallInProgress = false;
1735
1736        });
1737
1738    } else {
1739        _addToCartCallInProgress = false;
1740        console.log('skipping AddItemToCart because service is busy');
1741    }
1742
1743}
1744
1745function GetPriceTextboxValue(tbxID) {
1746    var priceTextbox = $('#' + tbxID);
1747    var price = 0;
1748    if (priceTextbox.length == 1) {
1749        if (priceTextbox.val() != '') {
1750            price = priceTextbox.val();
1751        }
1752    }
1753    return price;
1754}
1755
1756// function ShowAddToCartSavedDialog(sender, addtocartmessage) {
1757
1758//     if (addtocartmessage === undefined) {
1759//         addtocartmessage = "Added to cart!";
1760//     }
1761
1762//     $('.addtocartsuccessmsg').remove();
1763
1764//     var addToCartMsg = $('<div class="addtocartsuccessmsg subContainer" style="display:inline; visability:hidden; white-space:nowrap;  position:absolute; z-index=100" ></div>');
1765
1766//     var crossDomainTest = isInCrossDomainIframe();
1767//     if (crossDomainTest) {
1768//         addToCartMsg.append('{0}<br/><a href="{1}cart.aspx" tabindex="0" target="_blank">Checkout Now</a>'.format(addtocartmessage, SITEBASEURL));
1769//     } else {
1770//         addToCartMsg.append('{0}<br/><a href="javascript:void(0)" tabindex="0" onclick="window.top.location = \'{1}cart.aspx\'">Checkout Now</a>'.format(addtocartmessage, SITEBASEURL));
1771//     }
1772
1773//     $('body').append(addToCartMsg);
1774
1775//     if (sender) {
1776//         $('.addtocartsuccessmsg:last').show().position({
1777//             of: sender,
1778//             my: "right top",
1779//             at: "right bottom"
1780//         }).css("zIndex", 100).delay(3000).hide('slide');
1781//     }
1782// }
1783
1784function ShowAddToCartSavedModal(sender, addToCartMessage, data, incheckout, isJSCall) {
1785
1786    var scope = angular.element(document.getElementById("cartItemAddedContainer")).scope();
1787
1788    if (scope) {
1789       
1790        scope.sender = sender;
1791        scope.addedCartItem = data;
1792        scope.isRendered = true;
1793
1794        if (incheckout === undefined) {
1795          incheckout = false;
1796        }
1797
1798        if (isJSCall === undefined) {
1799            isJSCall = false;
1800        }
1801
1802        scope.addedCartItem.incheckout = incheckout;
1803
1804        if (addToCartMessage === undefined) {
1805            scope.addToCartMessage = "Added to Cart";
1806        }
1807
1808        if (!incheckout && isJSCall) {
1809            scope.$apply();
1810        }
1811    }    
1812}
1813
1814function getCartItemCountFromCookie() {
1815
1816    //get the cart item count from the cookie if available
1817    var cartItemsCookie = Cookies.get('CartItemDetails2');
1818
1819    if (cartItemsCookie) {
1820
1821        try {
1822            var cookie = JSON.parse(cartItemsCookie)
1823
1824            var itemCount = 0
1825
1826            for (c = 0; c < cookie.length; c++) {
1827                var cartItem = cookie[c];
1828
1829                if (cartItem.Units) {
1830                    for (u = 0; u < cartItem.Units.length; u++) {
1831                        itemCount += cartItem.Units[u].Quantity
1832                    }
1833                }
1834            }
1835
1836            return itemCount;
1837        }
1838        catch (err) {}
1839    }
1840
1841    return undefined;
1842
1843}
1844
1845function UpdateCartIndicator(suppressPopup) {
1846    updateCartProductUnitCountLink();
1847}
1848
1849function updateCartProductUnitCountLink() {
1850
1851    var cookieItemCount = getCartItemCountFromCookie();
1852
1853    if (cookieItemCount != undefined) {
1854        cartProductUnitCount = cookieItemCount;
1855    }
1856
1857    $cartLink = $('.cartMenuLink');
1858
1859    if ($cartLink) {
1860
1861        $cartLink.text(cartProductUnitCountTextFormat.format(cartProductUnitCount))
1862
1863        $cartLink.data('itemcount', cartProductUnitCount)
1864
1865        if (cartProductUnitCount == 0) {
1866            $cartLink.prop('disabled', true)
1867            $cartLink.prop('href', 'javascript:void(0)')
1868            $cartLink.attr('tabindex', '-1');
1869            $cartLink.attr('aria-disabled', 'true');
1870        } else {
1871            $cartLink.prop('disabled', false)
1872            $cartLink.prop('href', SITEBASEURL + 'cart.aspx')
1873            $cartLink.attr('tabindex', '0');
1874            $cartLink.attr('aria-disabled', 'false');            
1875        }
1876    }
1877
1878}
1879
1880/*********************************
1881Planner
1882**********************************/
1883
1884function ConfigurePlannerButtons() {
1885
1886    $('.btn-mypick').each(function () {
1887
1888        var $this = $(this);
1889        var $thisAnchor = $this.children('a:not(.planner-link)');
1890
1891        ConfigurePlannerButton($thisAnchor);
1892
1893    });
1894
1895}
1896
1897function ConfigurePlannerButton($thisAnchor) {
1898
1899    var $senderParent = $thisAnchor.parent();
1900
1901    var plannerName = $thisAnchor.attr('data-plannerName');
1902    var addText = $thisAnchor.attr("data-addText");
1903    var removeText = $thisAnchor.attr("data-removeText");
1904    var entityType = $thisAnchor.attr("data-type");
1905    var entityID = $thisAnchor.attr('data-id');
1906    var isPicked = $thisAnchor.attr('data-isPicked');
1907    var userID = $thisAnchor.attr('data-uID');
1908    var successURL = $thisAnchor.attr('data-successURL');
1909    var cancelURL = $thisAnchor.attr('data-cancelURL');
1910    var $hoverMessage = $thisAnchor.children('.planner-dialog');
1911
1912    if(isMobile){
1913        if (isPicked == 'false') {
1914            $thisAnchor.html(addText.format(plannerName));
1915            $senderParent.addClass('AddToPlanner');
1916            $thisAnchor.attr('title', 'Add to ' + plannerName);
1917        } else {
1918            $thisAnchor.html(removeText.format(plannerName));
1919            $senderParent.removeClass('AddToPlanner');
1920            $thisAnchor.attr('title', 'Remove from ' + plannerName);
1921        }
1922    } else {
1923        if (isPicked == 'false') {
1924            $senderParent.addClass('AddToPlanner');
1925            $hoverMessage.text('+ Add to ' + plannerName);
1926            $thisAnchor.attr('aria-label', 'Add to ' + plannerName);
1927        } else {
1928            $senderParent.removeClass('AddToPlanner');
1929            $hoverMessage.text('- Remove from ' + plannerName);
1930            $thisAnchor.attr('aria-label', 'Remove from ' + plannerName);
1931        }
1932    }
1933
1934    $thisAnchor.off('click');
1935
1936    $thisAnchor.on('click', function () {
1937
1938        if (isPicked == 'false') {
1939            if (!isMobile) {
1940                AddToPlanner($thisAnchor, entityID, entityType, userID);
1941            } else {
1942                AddToPlannerMobile($thisAnchor, entityID, entityType, userID, cancelURL, successURL);
1943            }
1944        } else {
1945            RemoveFromPlanner($thisAnchor, entityID, entityType, userID);
1946        }
1947
1948    });
1949
1950}
1951
1952function RemoveFromPlanner($sender, entityID, entityType, userID, successCallback) {
1953
1954    var confirmed = confirm('Are you sure you want to remove this ' + entityType + '');
1955    if (confirmed) {
1956
1957        PersistRemoveFromPlanner({ 'userID': userID, 'entityID': entityID, 'entityType': entityType, 'sender': $sender });
1958
1959    }
1960
1961}
1962
1963function AddToPlanner(sender, entityID, entityType, userID, successCallback) {
1964    PersistAddToPlanner({ 'userID': userID, 'entityID': entityID, 'entityType': entityType, 'successCallback': successCallback, 'sender': sender });
1965}
1966
1967function AddToPlannerMobile(sender, entityID, entityType, userID, cancelURL, successURL) {
1968    PersistAddToPlanner({ 'userID': userID, 'entityID': entityID, 'entityType': entityType, 'sender': sender});
1969 }
1970
1971function PersistAddToPlanner(data) {
1972
1973    var userID = data.userID;
1974    var entityID = data.entityID;
1975    var entityType = data.entityType;
1976    var $sender = data.sender;
1977
1978    var endpoint = 'AddEvent';
1979    if (entityType == 'business') {
1980        endpoint = 'AddBusiness';
1981    }
1982
1983    $.ajax({
1984        type: "POST",
1985        url: SITEBASEURL + "services/planner.asmx/" + endpoint,
1986        data: "{'id': '" + entityID + "'}",
1987        contentType: "application/json; charset=utf-8",
1988        dataType: "json",
1989        success: function () {
1990            ShowAddedToPlannerDialog($sender, data);
1991            if (window.top.preventDescriptionRemoval != undefined) {
1992                window.top.preventDescriptionRemoval = false;
1993            }
1994        }
1995    });
1996}
1997
1998function ShowAddedToPlannerDialog($sender, data) {
1999
2000    var plannerName = $sender.attr('data-plannerName');
2001    var $dialog = $('<div class="mypickAddedMessage">Added to ' + plannerName + '</div>');
2002    var $senderParent = $sender.parent();
2003
2004    $senderParent.append($dialog);
2005
2006    $dialog.delay(1500).fadeOut(10, function () {
2007
2008        $(this).remove();
2009
2010        $sender.attr('data-isPicked', 'true');
2011
2012        ConfigurePlannerButton($sender);
2013
2014    });
2015
2016}
2017
2018function PersistRemoveFromPlanner(data) {
2019
2020    var userID = data.userID;
2021    var entityID = data.entityID;
2022    var entityType = data.entityType;
2023    var $sender = data.sender;
2024
2025    var endpoint = 'RemoveEvent';
2026    if (entityType == 'business') {
2027        endpoint = 'RemoveBusiness';
2028    }
2029
2030    $.ajax({
2031        type: "POST",
2032        url: SITEBASEURL + "services/planner.asmx/" + endpoint,
2033        data: "{'id': '" + entityID + "', 'userID' : " + userID + "}",
2034        contentType: "application/json; charset=utf-8",
2035        dataType: "json",
2036        success: function () {
2037            $sender.attr('data-isPicked', 'false');
2038            ConfigurePlannerButton($sender);
2039        }
2040    });
2041
2042}
2043
2044/*********************************
2045My Business Pick
2046**********************************/
2047
2048function ShowMyBusinessPickSavedDialog() {
2049    var bodyOffsetTop = $(window).scrollTop();
2050    var thanksDialog;
2051
2052    thanksDialog = $('<div id="myEventPickDialog" class="modalContent border content" Style="border: solid 10px #ffffff; padding: 15px; background-color:#fff; color:#313131;"></div>');
2053    $('body').append(thanksDialog);
2054
2055    thanksDialog.html('<h1>Thanks!</h1>Business added to My Businesses');
2056    $(thanksDialog).dialog({
2057        height: 200,
2058        width: 320,
2059        closeText: '',
2060        show: 'blind',
2061        collision: 'fit',
2062        close: function () { $('#myEventPickDialog').remove() }
2063    });
2064    $(thanksDialog).dialog('open').position({ my: "center", at: "center", of: window.top }).delay(5000).hide('slide');
2065    window.scrollTo(0, bodyOffsetTop); //ie fix for versions 7 and under
2066}
2067
2068function MyBusinessPickRedirect(sender, entityID, userID, CancelURLEncoded, SuccessURLEncoded) {
2069    TrackSaveToMyFavorites();
2070
2071    _currentMyPickSender = sender;
2072
2073    saffire.web.services.users.isAuthenticated(userID, function (result) {
2074
2075        if (result) {
2076
2077            MyBusinessPickSave({ 'userID': userID, 'businessID': entityID, 'sender': sender });
2078
2079        } else {
2080            window.location.href = SITEBASEURL + 'login.aspx' + '?cancelURL=' + CancelURLEncoded + '&successURL=' + SuccessURLEncoded;
2081
2082
2083        }
2084
2085
2086    }, function (result) {
2087        alert("Error communicating with the server");
2088    });
2089
2090}
2091
2092function MyBusinessPick(sender, entityID, userID, onSuccessCallback) {
2093    TrackSaveToMyFavorites();
2094    _currentMyPickSender = sender;
2095    saffire.web.services.users.isAuthenticated(userID, function (result) {
2096
2097        if (result) {
2098            MyBusinessPickSave({ 'userID': userID, 'businessID': entityID, 'successCallback': onSuccessCallback, 'sender': sender })
2099        } else {
2100            window.top.OpenModal('modal', SITEBASEURL + 'i_login.aspx', '650px', '620px', {
2101                'OnClosePostBack': false,
2102                'UserContext': { 'sender': sender, 'businessID': entityID, 'successCallback': onSuccessCallback, 'sender': sender },
2103                'OnCloseCallbackFunction':
2104                    function (userID, context) {
2105
2106                        if (userID > 0) {
2107                            MyBusinessPickSave({ 'businessID': entityID, 'userID': userID, 'successCallback': context.successCallback, 'sender': context.sender });
2108                        }
2109
2110                    }
2111            }
2112            );
2113        }
2114
2115    }, function (result) {
2116        alert("Error communicating with the server");
2117    });
2118
2119}
2120
2121/*******************************
2122Audio Button
2123********************************/
2124
2125var CurrentImgID = '';
2126var CurrentTrack = '';
2127var isPlaying = false;
2128
2129function playSoundClip(track, imgID) {
2130
2131    var player = getSoundClipPlayer();
2132
2133    if (player) {
2134
2135        var isPlayCommand = true;
2136
2137        if (CurrentImgID != '') {
2138            if (CurrentImgID != imgID) {
2139                if (track == CurrentTrack) {
2140                    player.PlayMusic(track);
2141                }
2142                stopSoundClip()
2143            } else {
2144                isPlayCommand = false
2145            }
2146        }
2147
2148
2149        swapAudioClipImg(imgID)
2150        if (isPlayCommand) {
2151            player.PlayMusic(track);
2152            swapAudioClipImg(imgID, true)
2153            CurrentImgID = imgID;
2154            CurrentTrack = track;
2155        } else {
2156            player.PlayMusic(track);
2157            swapAudioClipImg(imgID,false)
2158            CurrentImgID = '';
2159            CurrentTrack = '';
2160        }
2161
2162    }
2163
2164
2165    if (player) {
2166
2167    }
2168
2169    //var isPlayCommand = true;
2170
2171    //if (CurrentImgID != '') {
2172    //    if (CurrentImgID != imgID) {
2173    //        stopSoundClip()
2174    //    } else {
2175    //        isPlayCommand = false
2176    //    }
2177    //}
2178
2179    //var player = getSoundClipPlayer();
2180    //if (player) {
2181    //    player.PlayMusic(track);
2182    //    swapAudioClipImg(imgID)
2183    //    if (isPlayCommand) {
2184    //        CurrentImgID = imgID;
2185    //        CurrentTrack = track;
2186    //    } else {
2187    //        CurrentImgID = '';
2188    //        CurrentTrack = '';
2189    //    }
2190    //}
2191}
2192
2193function stopSoundClip() {
2194    swapAudioClipImg(CurrentImgID,false)
2195    CurrentImgID = '';
2196    CurrentTrack = '';
2197}
2198
2199function getSoundClipPlayer() {
2200    var player = GetFlashMovie('soundClip');
2201    return player
2202}
2203
2204function swapAudioClipImg(imgID,isPlaying) {
2205    var img = $get(imgID);
2206    if (img) {
2207        if (isPlaying) {
2208            img.src = SITEBASEURL + 'images/music_on.gif';
2209        } else {
2210            $('.flashMusicPlayerImage').each(function () {
2211                this.src = SITEBASEURL + 'images/music_off.gif';
2212            });
2213        }
2214    }
2215}
2216
2217
2218/***********************
2219Users Service
2220************************/
2221var userIsAuthenticated = false;
2222function isAuthenticated(uid) {
2223
2224    Saffire.Web.Services.UsersService.IsAuthenticated(uid
2225                    , function (result) {
2226                        userIsAuthenticated = result;
2227                    }
2228                    , function (result) {
2229                        alert("Error communicating with the server")
2230                    })
2231
2232    return userIsAuthenticated;
2233}
2234
2235function updateLoginStatusLink() {
2236
2237    var $loginWrapper = $('.loginstatus-wrapper');
2238    var $loginStatusLink = $('.login-status-link');
2239    var $loginStatusChangeLink = $('.loginstatus-change');
2240
2241    if ($loginWrapper || $loginStatusLink) {
2242
2243        if (isLoggedIn) {
2244            $loginStatusChangeLink.text('Log Out');
2245        } else {
2246            $loginStatusChangeLink.text('Log In');
2247        }
2248
2249        $loginStatusChangeLink.on('click', function () {
2250            saffire.web.services.user.changeLoginStatusAndGetNextStepURL(
2251                function (result) {
2252                    window.location.href = result;
2253                }
2254                , function (result) {
2255                    alert("Error communicating with the server");
2256                })
2257        });
2258
2259    }
2260
2261}
2262
2263function updateMyAccountLink() {
2264
2265    var $myAccountLinkWrapper = $('.myAccountButton-wrapper');
2266    var $myAccountLink = $('.my-account-link');
2267
2268    if ($myAccountLinkWrapper) {
2269
2270        $myAccountLinkWrapper.css('display', isLoggedIn ? 'block' : 'none')
2271        $myAccountLink.prop('href', SITEBASEURL + 'myaccountinfo.aspx')
2272
2273    }
2274
2275    if ( ($myAccountLinkWrapper.length === 0) && $myAccountLink ) {
2276        $myAccountLink.prop('href', SITEBASEURL + 'myaccountinfo.aspx')
2277        if (isLoggedIn) {
2278            $('.my-account-link').each(function(i, item) {
2279                item.style.removeProperty('display');
2280            });
2281        }
2282    }
2283}
2284
2285/*****************************
2286Calendar Service
2287******************************/
2288
2289function ProduceVCalendarFile(entityType, entityID) {
2290
2291    $('<iframe />', {
2292        id: 'vCalFrame'
2293        , src: SITEBASEURL + 'services/calendarFileServer.aspx?entityType=' + entityType + '&id=' + entityID
2294        , style: "width:0px; height:0px; display:none"
2295    }).appendTo('body');
2296
2297}
2298
2299
2300/**photo gallery modal**/
2301
2302(function ($) {
2303
2304    $.fn.dialogPhotoGallery = function (options) {
2305
2306        var $this = this;
2307
2308        var _defaultOptions = {
2309            startID: 0,
2310            action: '',
2311            datasource: null,
2312            width: 400,
2313            height: 400,
2314            collision: 'fit',
2315            position: {my: "top-25%", at: "top-25%", of: window}
2316        }
2317
2318        if (typeof (options) == 'string') {
2319
2320            var action = options;
2321
2322            options = _defaultOptions
2323
2324            if (action == 'show') {
2325                options.action = "show";
2326            } else if (action == 'close') {
2327                options.action = "close";
2328            }
2329
2330        } else {
2331            options = $.extend(_defaultOptions, options);
2332        }
2333
2334
2335
2336        if (options.action == "show") {
2337            show();
2338        } else if (options.action == "close") {
2339            close();
2340        } else {
2341            set_currentID(0);
2342            set_currentIndex(0);
2343            init();
2344        }
2345
2346        function init() {
2347
2348            $this.dialog({
2349                modal: true,
2350                draggable: false,
2351                closeText: '',
2352                autoOpen: false,
2353                width: options.width,
2354                height: options.height,
2355                position: options.position
2356            });
2357
2358
2359            if (get_datasource() == null && options.datasource != null) {
2360                set_datasource(options.datasource);
2361            }
2362
2363            $this.find(".previousButton").bind("click", _showPreviousPhoto);
2364            $this.find(".nextButton").bind("click", _showNextPhoto);
2365            $this.find(".closeButton").bind("click", close);
2366
2367        }
2368
2369        function show() {
2370
2371            _setupDatasource()
2372            if (get_currentID() != options.startID) {
2373                set_currentID(options.startID);
2374                set_currentIndex(_getIDIndex(get_currentID()));
2375            }
2376
2377            if (get_datasource().length > 0) {
2378                _setupPhoto(get_currentIndex())
2379            }
2380
2381            _setupPreviousNextButtons()
2382            $this.dialog("open");
2383            $this.css("display", "block")
2384
2385            $this.trigger("show", { currentPhotoID: get_currentID() })
2386
2387        }
2388
2389        function close() {
2390
2391            $this.dialog("close");
2392            $this.css("display", "none")
2393
2394            $this.trigger("closed")
2395        }
2396
2397        /**Properties**/
2398
2399        function get_datasource() { return $this.data("data") }
2400        function set_datasource(value) { $this.data("data", value) }
2401
2402        function get_currentID() { return $this.data("currentID") }
2403        function set_currentID(value) { $this.data("currentID", value) }
2404
2405        function get_currentIndex() { return $this.data("currentIndex") }
2406        function set_currentIndex(value) { $this.data("currentIndex", value) }
2407
2408        /**PRIVATE MEMBERS**/
2409
2410        function _setupDatasource() {
2411
2412        }
2413
2414        function _setupPhoto(indx) {
2415            var tmp = get_datasource();
2416
2417            var pinitButton = $('.pin-it-button')
2418
2419            if(pinitButton.length == 0){
2420                pinitButton = $('a[class^="PIN_"]')
2421            }
2422
2423            // Pinterest.
2424            pinitButton.attr('href', 'http://pinterest.com/pin/create/button/?url=' + encodeURIComponent(document.URL) + '&media=' + encodeURIComponent(tmp[indx].src.split(' ').join('%20')) + "&description=" + encodeURIComponent(tmp[indx].eventname + " - " + tmp[indx].caption));
2425            if (($('iframe[src^="http://pinit-cdn.pinterest.com/pinit.html"]').length))
2426                $('iframe[src^="http://pinit-cdn.pinterest.com/pinit.html"]').attr('src', 'http://pinit-cdn.pinterest.com/pinit.html?url=' + encodeURIComponent(document.URL) + '&media=' + encodeURIComponent(tmp[indx].src.split(' ').join('%20')) + "&description=" + encodeURIComponent(tmp[indx].eventname + " - " + tmp[indx].caption));
2427            else
2428            $.ajax({ url: location.protocol + '://assets.pinterest.com/js/pinit.js', dataType: '
2428script', cache: true});
2429
2430            var $featImg = $(".featureImage");
2431            $featImg.attr('src', tmp[indx].src);
2432            $featImg.attr('alt', tmp[indx].caption);
2433            $this.find(".caption").html(tmp[indx].caption);
2434
2435            if (tmp[indx].showsocial == 'true') {
2436                $('.shareThisToolbox').show();
2437            } else {
2438                $('.shareThisToolbox').hide();
2439            }
2440
2441            set_currentIndex(indx);
2442            set_currentID(tmp[indx].id);
2443        }
2444
2445        function _showPreviousPhoto() {
2446
2447
2448            var indx = get_currentIndex()
2449
2450            if (indx > 0) {
2451                _setupPhoto(indx - 1);
2452                _setupPreviousNextButtons();
2453                $this.trigger("show", { currentPhotoID: get_currentID() })
2454            }
2455
2456        }
2457
2458        function _showNextPhoto() {
2459
2460            var indx = get_currentIndex()
2461
2462            if (indx < get_datasource().length - 1) {
2463                _setupPhoto(indx + 1);
2464                _setupPreviousNextButtons()
2465                $this.trigger("show", { currentPhotoID: get_currentID() });
2466            }
2467        }
2468
2469        function _getIDIndex(id) {
2470
2471            var tmp = get_datasource()
2472
2473            if (id > 0) {
2474                for (var x = 0; x < tmp.length; x++) {
2475                    if (tmp[x].id == id) {
2476                        return x
2477                    }
2478                }
2479            }
2480            return 0;
2481        }
2482
2483        function _setupPreviousNextButtons() {
2484
2485            var tmp = get_datasource();
2486            var indx = get_currentIndex()
2487
2488
2489            if (indx == 0) {
2490                $this.find(".previousButton").css("display", "none")
2491            } else {
2492                $this.find(".previousButton").css("display", "block")
2493            }
2494
2495            if (indx == tmp.length - 1) {
2496                $this.find(".nextButton").css("display", "none")
2497            } else {
2498                $this.find(".nextButton").css("display", "block")
2499            }
2500        }
2501
2502        function _retrieveDataFromService(serviceMethod) {
2503
2504        }
2505
2506        return this;
2507
2508    };
2509})(jQuery);
2510
2511var addthis_config = {
2512    data_use_cookies_ondomain: false,
2513    data_use_cookies: false
2514};
2515
2516/*Add This*/
2517function initAddThis(gaKey) {
2518    addthis_config.data_ga_property = gaKey;
2519    addthis_config.data_ga_social = true;
2520
2521    if (typeof addthis != "undefined") {
2522        addthis.init();
2523    }
2524}
2525/**media gallery modal**/
2526
2527(function ($) {
2528
2529    $.fn.dialogMediaGallery = function (options) {
2530
2531        var $this = this;
2532
2533        var _defaultOptions = {
2534            startID: 0,
2535            action: '',
2536            datasource: null,
2537            width: 400,
2538            height: 400
2539        }
2540
2541        if (typeof (options) == 'string') {
2542            var action = options;
2543
2544            options = _defaultOptions
2545
2546            if (action == 'show') {
2547                options.action = "show";
2548            } else if (action == 'close') {
2549                options.action = "close";
2550            }
2551
2552        } else {
2553            options = $.extend(_defaultOptions, options);
2554        }
2555
2556
2557        if (options.action == "show") {
2558            show();
2559        } else if (options.action == "close") {
2560            close();
2561        } else {
2562            set_currentID(0);
2563            set_currentIndex(0);
2564            init()
2565        }
2566
2567        function init() {
2568
2569
2570            $this.dialog({
2571                modal: true,
2572                draggable: false,
2573                closeText: '',
2574                autoOpen: false,
2575                width: options.width,
2576                height: options.height
2577            });
2578
2579            if (options.datasource != null) {
2580                set_datasource(options.datasource);
2581            }
2582
2583            $this.find(".previousButton").bind("click", _showPreviousPhoto);
2584            $this.find(".nextButton").bind("click", _showNextPhoto);
2585            $this.find(".closeButton").bind("click", close);
2586
2587        }
2588
2589        function show() {
2590
2591
2592            _setupDatasource();
2593
2594            if (get_currentID() != options.startID) {
2595                set_currentID(options.startID);
2596                set_currentIndex(_getIDIndex(get_currentID()));
2597            }
2598
2599            if (get_datasource().length > 0) {
2600                _setupPhoto(get_currentIndex())
2601            }
2602
2603            _setupPreviousNextButtons()
2604
2605            $this.dialog("open");
2606            $this.css("display", "block")
2607
2608            $this.trigger("show", { currentPhotoID: get_currentID() })
2609
2610        }
2611
2612        function close() {
2613
2614            var $featDiv = $(".featureDiv");
2615
2616            $featDiv.html('');
2617
2618            $this.dialog("close");
2619            $this.css("display", "none")
2620
2621            $this.trigger("closed")
2622        }
2623
2624        /**Properties**/
2625
2626        function get_datasource() { return $this.data("data") }
2627        function set_datasource(value) { $this.data("data", value) }
2628
2629        function get_currentID() { return $this.data("currentID") }
2630        function set_currentID(value) { $this.data("currentID", value) }
2631
2632        function get_currentIndex() { return $this.data("currentIndex") }
2633        function set_currentIndex(value) { $this.data("currentIndex", value) }
2634
2635        /**PRIVATE MEMBERS**/
2636
2637        function _setupDatasource() {
2638
2639        }
2640
2641        function _setupPhoto(indx) {
2642            var tmp = get_datasource();
2643
2644            var $featDiv = $(".featureDiv");
2645
2646            $featDiv.html(tmp[indx].src);
2647            $this.find(".caption").html(tmp[indx].caption);
2648
2649            $this.find('.galleryTitle').html(tmp[indx].title)
2650
2651            set_currentIndex(indx);
2652            set_currentID(tmp[indx].id);
2653
2654            var img = $('.featureDiv').find('img');
2655            var video = $('.featureDiv').find('iframe');
2656
2657            var pinitButton = $('.pin-it-button')
2658
2659            if(pinitButton.length == 0){
2660                pinitButton = $('a[class^="PIN_"]')
2661            }
2662
2663            if (img.length > 0) {
2664
2665                // Pinterest.
2666                if (img.attr('src') != undefined) {
2667                    pinitButton.attr('href', 'http://pinterest.com/pin/create/button/?url=' + encodeURIComponent(document.URL) + '&media=' + encodeURIComponent(img.attr('src').split(' ').join('%20')) + "&description=" + encodeURIComponent(tmp[indx].eventname + " - " + tmp[indx].caption));
2668                    if (($('iframe[src^="http://pinit-cdn.pinterest.com/pinit.html"]').length))
2669                        $('iframe[src^="http://pinit-cdn.pinterest.com/pinit.html"]').attr('src', 'http://pinit-cdn.pinterest.com/pinit.html?url=' + encodeURIComponent(document.URL) + '&media=' + encodeURIComponent(img.attr('src').split(' ').join('%20')) + "&description=" + encodeURIComponent(tmp[indx].eventname + " - " + tmp[indx].caption));
2670                    else
2671                        $.ajax({ url: location.protocol + '//assets.pinterest.com/js/pinit.js', dataType: 'script', cache: true });
2672                }
2673
2674
2675                if (img.attr('share-email') == 'true') {
2676                    $('.emailPhoto').show();
2677                } else {
2678                    $('.emailPhoto').hide();
2679                }
2680
2681                if (img.attr('share-social') == 'true') {
2682                    $('.shareThisToolbox').show();
2683                } else {
2684                    $('.shareThisToolbox').hide();
2685                }
2686
2687                if (img.attr('link-email') != null && img.attr('link-email') != '') {
2688                    $('.linkEmail').attr('href', img.attr('link-email'))
2689                    $('.linkEmail').show();
2690                } else {
2691                    $('.linkEmail').hide();
2692                }
2693
2694                if (img.attr('link-more') != null && img.attr('link-more') != '') {
2695                    $('.linkMore').attr('href', img.attr('link-more'))
2696                    $('.linkMore').show();
2697
2698                    if (img.attr('link-target') != null && img.attr('link-target') != '') {
2699                        $('.linkMore').attr('target', img.attr('link-target'));
2700                    }
2701                    else {
2702                        $('.linkMore').attr('target', '');
2703                    }
2704                } else {
2705                    $('.linkMore').hide();
2706                }
2707
2708            }
2709            else {
2710                //video
2711
2712                if (video.attr('link-email') != null && video.attr('link-email') != '') {
2713                    $('.linkEmail').attr('href', video.attr('link-email'))
2714                    $('.linkEmail').show();
2715                } else {
2716                    $('.linkEmail').hide();
2717                }
2718
2719                if (video.attr('link-more') != null && video.attr('link-more') != '') {
2720                    $('.linkMore').attr('href', video.attr('link-more'))
2721                    $('.linkMore').show();
2722
2723                    if (video.attr('link-target') != null && video.attr('link-target') != '') {
2724                        $('.linkMore').attr('target', video.attr('link-target'));
2725                    }
2726                    else {
2727                        $('.linkMore').attr('target', '');
2728                    }
2729                } else {
2730                    $('.linkMore').hide();
2731                }
2732            }
2733        }
2734
2735        function _showPreviousPhoto() {
2736
2737            var indx = get_currentIndex()
2738
2739            if (indx > 0) {
2740                _setupPhoto(indx - 1);
2741                _setupPreviousNextButtons();
2742                $this.trigger("show", { currentPhotoID: get_currentID() })
2743            }
2744
2745        }
2746
2747        function _showNextPhoto() {
2748
2749            var indx = get_currentIndex()
2750
2751            if (indx < get_datasource().length - 1) {
2752                _setupPhoto(indx + 1);
2753                _setupPreviousNextButtons();
2754
2755                $this.trigger("show", { currentPhotoID: get_currentID() });
2756            }
2757        }
2758
2759        function _getIDIndex(id) {
2760
2761            var tmp = get_datasource()
2762
2763            if (id > 0) {
2764                for (var x = 0; x < tmp.length; x++) {
2765                    if (tmp[x].id == id) {
2766                        return x
2767                    }
2768                }
2769            }
2770            return 0;
2771        }
2772
2773        function _setupPreviousNextButtons() {
2774
2775            var tmp = get_datasource();
2776            var indx = get_currentIndex()
2777
2778
2779            if (indx == 0) {
2780                $this.find(".previousButton").css("display", "none")
2781            } else {
2782                $this.find(".previousButton").css("display", "block")
2783            }
2784
2785            if (indx == tmp.length - 1) {
2786                $this.find(".nextButton").css("display", "none")
2787            } else {
2788                $this.find(".nextButton").css("display", "block")
2789            }
2790        }
2791
2792        function _retrieveDataFromService(serviceMethod) {
2793
2794        }
2795
2796        return this;
2797
2798    };
2799})(jQuery);
2800
2801var youTubeIframeLoading = false;
2802var youTubeIframeAPIReady = false;
2803
2804var loadYoutubeIframeAPI = null;
2805
2806// Youtube API should not be loaded on boxoffice or kiosk pages
2807if (window.location.href && !window.location.href.includes('/boxoffice') && !window.location.href.includes('/kiosk')) {
2808    if (typeof Promise !== "undefined" && Promise.toString().indexOf("[native code]") !== -1) {
2809
2810        loadYoutubeIframeAPI = new Promise(function (resolve, reject) {
2811
2812            if (!youTubeIframeLoading) {
2813                youTubeIframeLoading = true;
2814                var tag = document.createElement('script');
2815                var firstScriptTag = document.getElementsByTagName('script')[0];
2816                tag.src = "https://www.youtube.com/iframe_api";
2817                firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
2818
2819                window.onYouTubeIframeAPIReady = function () {
2820                    resolve();
2821                }
2822            }
2823
2824        })
2825
2826    }
2827}
2828
2829
2830
2831var lightBoxYouTubePlayers = [];
2832
2833function LightBox(data, id, callback) {
2834    var popupID = '#light-box'+ id;
2835    var player = 'player' + id;
2836    this.YTplayer = '';
2837    this.currentIndex = 0;
2838    this.data = data;
2839    this.playerID = id;
2840    // console.log(data)
2841    this.$el = {
2842        player: $(popupID + ' #player' + id),
2843        currentNum: $(popupID + ' .lb-item-count-num'),
2844        closeBtn: $(popupID + ' .close-lightbox'),
2845        lightBox: $(popupID),
2846        leftArrow: $(popupID + ' .gallery-control.arrow-previous'),
2847        rightArrow: $(popupID + ' .gallery-control.arrow-next'),
2848        expandImage: $(popupID + ' .lb-expand-image'),
2849        title: $(popupID + ' .lb-title'),
2850        videoTranscriptURL: $(popupID + ' .lb-transcript-link'),
2851        itemCount: $(popupID + ' .lb-item-count-num'),
2852        maxCount: $(popupID + ' .lb-item-count_max'),
2853        img: $(popupID + ' .lb-image'),
2854        textContainer: $(popupID + ' .lb-text-container'),
2855        caption: $(popupID + ' .lb-caption'),
2856        emailPhotoLink: $(popupID + ' .lb-email-photo'),
2857        externalLink: $(popupID + ' .lb-externalLink'),
2858        socialSharingContainer: $(popupID + ' .lb-social-sharing-container'),
2859        shareSocialContainer: $(popupID + ' .lb-share-social-container'),
2860        shareThisToolbox: $(popupID + ' .shareThisToolbox'),
2861        shareFacebookLink: $(popupID + ' .lb-facebook'),
2862        shareTwitterLink: $(popupID + ' .lb-twitter'),
2863        sharePinterestLink: $(popupID + ' .lb-pinterest'),
2864    }
2865
2866    if (data.length == 1) {
2867        this.$el.lightBox.addClass('single-photo');
2868    }
2869    else {
2870        this.$el.lightBox.removeClass('single-photo');
2871    }
2872
2873    this.resetData = function (data) {
2874        this.currentIndex = 0;
2875        this.data = data;
2876    }
2877
2878    this.bindUIEvents = function () {
2879
2880        var boxObj = this;
2881        this.$el.rightArrow.click(function () {
2882            boxObj.changeView('next');
2883        });
2884        this.$el.leftArrow.on('keypress click', function (e) {
2885          if (e.which === 37 || e.type === 'click') {
2886            boxObj.changeView('last');
2887          }
2888        });
2889        this.$el.closeBtn.click(function () {
2890            boxObj.close();
2891        });
2892
2893        $(document).keydown(function(event) {
2894
2895            switch(event.which) {
2896            case 27:
2897            boxObj.close();
2898            break;
2899
2900            case 37:
2901            boxObj.$el.leftArrow.click();
2902            break;
2903
2904            case 39:
2905            boxObj.$el.rightArrow.click();
2906            break;
2907
2908            default: return; // exit this handler for other keys
2909            }
2910        });
2911    }
2912
2913    this.changeView = function (direction) {
2914
2915        if (direction === 'next') {
2916            if ((this.currentIndex+1) === this.data.length ) {
2917            this.currentIndex = 0;
2918            } else {
2919            this.currentIndex++;
2920            }
2921        } else if (direction === 'last') {
2922            if (this.currentIndex === 0 ) {
2923            this.currentIndex = (this.data.length - 1);
2924            } else {
2925            this.currentIndex--;
2926            }
2927        }
2928
2929        var mediaItem = this.data[this.currentIndex];
2930
2931        var elem = this.$el;
2932        var alternateText = ""
2933        if (mediaItem.alternateText)
2934        {
2935            alternateText = mediaItem.alternateText;
2936        }
2937        //title
2938        if (mediaItem.title) {
2939            elem.title.show();
2940            elem.title.html('<strong>'+mediaItem.title+'</strong>');
2941        }
2942        else {
2943            elem.title.hide();
2944        }
2945
2946
2947        //caption
2948        if (mediaItem.caption) {
2949            elem.caption.show();
2950            elem.caption.html(mediaItem.caption);
2951        }
2952        else {
2953            elem.caption.hide();
2954        }
2955        //transcript
2956        if (mediaItem.videoTranscriptURL) {
2957            elem.videoTranscriptURL.show();
2958            elem.videoTranscriptURL.attr('href', mediaItem.videoTranscriptURL);
2959            elem.videoTranscriptURL.attr('target', '_blank');
2960        }
2961        else {
2962            elem.videoTranscriptURL.hide();
2963        }
2964
2965        //link
2966        if (mediaItem.hasLink) {
2967            if (mediaItem.linkIsEmail) {
2968                elem.externalLink.hide();
2969                elem.emailPhotoLink.show();
2970                elem.emailPhotoLink.prop('href','mailto:' + mediaItem.linkURL)
2971            }
2972            else {
2973                elem.emailPhotoLink.hide();
2974                elem.externalLink.show();
2975                elem.externalLink.prop('href', mediaItem.linkURL)
2976                if (mediaItem.linkOpenInNewWindow) {
2977                    elem.externalLink.prop('target', '_blank');
2978                }
2979                else {
2980                    elem.externalLink.prop('target', '');
2981                }
2982            }
2983        }
2984        else {
2985            elem.emailPhotoLink.hide();
2986            elem.externalLink.hide();
2987        }
2988
2989        //social sharing
2990        if (mediaItem.socialShareURL && mediaItem.img) {
2991            elem.shareSocialContainer.show();
2992
2993            //facebook
2994            elem.shareFacebookLink.attr('addthis:url', mediaItem.socialShareURL);
2995
2996
2997            //twitter
2998            elem.shareTwitterLink.attr('addthis:url', mediaItem.socialShareURL);
2999            elem.shareTwitterLink.attr('addthis:title', mediaItem.title);
3000            elem.shareTwitterLink.attr('addthis:description', mediaItem.caption);
3001            elem.shareTwitterLink.attr('addthis:media', mediaItem.img);
3002
3003            //pinterest
3004            elem.sharePinterestLink.attr('addthis:url', mediaItem.socialShareURL);
3005            elem.sharePinterestLink.attr('addthis:title', mediaItem.title);
3006            elem.sharePinterestLink.attr('addthis:description', mediaItem.caption);
3007            elem.sharePinterestLink.attr('addthis:media', mediaItem.img);
3008
3009            if (window.addthis) {
3010                window.addthis.toolbox('.shareThisToolbox');
3011            }
3012
3013        }
3014        else {
3015            elem.shareSocialContainer.hide();
3016        }
3017
3018
3019
3020        if (mediaItem.video) {
3021            elem.YTiframe.show();
3022            elem.img.hide();
3023            elem.expandImage.hide();
3024            this.YTplayer.loadVideoById(mediaItem.video);
3025        }
3026        else {
3027            if (elem.YTiframe) {
3028                elem.YTiframe.hide();
3029            }
3030            elem.img.show();
3031            elem.expandImage.show();
3032
3033            if (this.YTplayer != "") {
3034                this.YTplayer.pauseVideo();
3035            }
3036
3037            elem.img.prop('alt', alternateText);
3038            elem.img.attr('tabindex', '0');
3039            elem.img.attr('aria-label', alternateText);
3040            elem.img.prop('src', mediaItem.img);
3041
3042        }
3043
3044        this.updateCount();
3045
3046    };
3047
3048
3049    this.close = function() {
3050        $("#body").removeClass('lightbox-showing');
3051        // $(document).unbind('keydown');
3052        this.$el.lightBox.removeClass('show-lightbox');
3053        this.$el.lightBox.attr('tabindex', '-1');
3054        if (this.YTplayer) {
3055            this.YTplayer.pauseVideo();
3056        }
3057    };
3058
3059
3060
3061    this.open = function(uniqueID) {
3062
3063        this.currentIndex = 0;
3064
3065        for (i = 0; i < this.data.length; i++) {
3066            if (this.data[i].uniqueID == uniqueID) {
3067                this.currentIndex = i;
3068            }
3069        }
3070
3071        this.updateCount();
3072        $("#body").addClass('lightbox-showing');
3073        this.$el.lightBox.addClass('show-lightbox');
3074        this.$el.lightBox.attr('tabindex', '0');
3075        this.$el.lightBox.attr('aria-label', 'image lightbox');
3076        this.$el.lightBox.focus();
3077        this.changeView(null);
3078        
3079        // trap tab focus in lightbox
3080        var focusableEls = this.$el.lightBox.find('a:visible, button:visible');
3081        var firstFocusableEl = focusableEls[0];  
3082        var lastFocusableEl = focusableEls[focusableEls.length - 1];
3083        $(lastFocusableEl).keydown(function(e) {
3084          if(e.which == 9) { 
3085            e.preventDefault();          
3086            $(firstFocusableEl).focus();   
3087          }          
3088        });
3089
3090    };
3091
3092    this.updateCount = function() {
3093        this.$el.currentNum.text(this.currentIndex + 1);
3094        this.$el.maxCount.text(this.data.length);
3095    };
3096
3097
3098    //initialize
3099    var hasVideo = false;
3100    this.data.map(function (i) {
3101        if (i.video != undefined && i.video !== '') {
3102            hasVideo = true;
3103        }
3104    });
3105    this.hasVideo = hasVideo;
3106
3107    if (this.hasVideo) {
3108
3109        lightBoxYouTubePlayers.push({
3110            playerID: player,
3111            box: this,
3112            initialized: false,
3113            callback: callback
3114        })
3115
3116        if (loadYoutubeIframeAPI) {
3117
3118            loadYoutubeIframeAPI.then(function () {
3119
3120                $.each(lightBoxYouTubePlayers, function (boxIdx) {
3121                    var box = lightBoxYouTubePlayers[boxIdx]
3122                    if (!box.initialized) {
3123                        box.initialized = true;
3124
3125                        var boxObj = box.box;
3126
3127                        boxObj.bindUIEvents();
3128                        boxObj.YTplayer = new YT.Player(box.playerID, {
3129                            height: '475',
3130                            width: '725',
3131                            videoId: '',
3132                            events: {
3133                                'onReady': function (event) {
3134                                    // console.log(box.playerID);
3135                                    box.callback();
3136                                },
3137                                'onStateChange': function (event) {
3138
3139                                }
3140                            }
3141                        });
3142                        boxObj.$el.YTiframe = $(boxObj.YTplayer.getIframe());
3143                    }
3144                })
3145
3146            });
3147
3148        }
3149
3150    } else {
3151        this.bindUIEvents();
3152        callback();
3153    }
3154}
3155
3156// New media Gallery Light box
3157function showLightBox($elm, e, opts) {
3158        var isUploadButton = e.target.classList.contains('upload-photo');
3159
3160        if (!isUploadButton) {
3161          $('.gallery-container .card.show').removeClass('show');
3162          $lightbox = $elm;
3163          var $arrowPrev = $lightbox.find('.arrow-previous');
3164          var $arrowNext = $lightbox.find('.arrow-next');
3165          var $closeBtn = $lightbox.find('.close-lightbox');
3166          var lbIndexCount = $(".media-container-popup .media-container-popup-header .item-count .item-count-num");
3167          var media = [];
3168          var videos = [];
3169          var index = 0;
3170
3171          if (opts) {
3172            if (opts.startIndex) {
3173              index = opts.startIndex;
3174            }
3175          }
3176
3177          lbIndexCount.html(parseInt(index) + 1);
3178
3179          $lightbox.find('.card').each(function() {
3180            if ($(this).find('iframe').length > 0) {
3181              videos.push($(this).find('iframe')[0]);
3182              $(this).find(".lb-iframe-wrapper").addClass("has-video");
3183            }
3184            media.push($(this));
3185          });
3186
3187          media[index].addClass('show');
3188          $lightbox.addClass('show-lightbox');
3189          $("#body").addClass('lightbox-showing');
3190
3191         
3192
3193          $lightbox.on("swipeleft", function() {
3194            $arrowNext.click();
3195          });
3196          $lightbox.on("swiperight", function() {
3197            $arrowPrev.click();
3198          });
3199
3200
3201          $arrowNext.click(function() {
3202            media[index].removeClass('show');
3203            if (index < (media.length - 1)) {
3204              index++;
3205              lbIndexCount.html(index + 1);
3206              media[index].toggleClass('show');
3207            } else if (index == (media.length - 1)) {
3208              index = 0;
3209              lbIndexCount.html(index + 1);
3210              media[index].toggleClass('show');
3211            }
3212            if (videos.length > 0) {
3213              pauseIframes(videos);
3214            }
3215          });
3216
3217          $arrowPrev.click(function() {
3218            media[index].removeClass('show');
3219            if (index > 0) {
3220              index--;
3221              lbIndexCount.html(index + 1);
3222              media[index].toggleClass('show');
3223            } else if (index == 0) {
3224              index = (media.length - 1);
3225              lbIndexCount.html(index + 1);
3226              media[index].toggleClass('show');
3227            }
3228            if (videos.length > 0) {
3229              pauseIframes(videos);
3230            }
3231          });
3232
3233          $closeBtn.click(function() {
3234            $(document).unbind('keydown');
3235            $lightbox.unbind('swiperight');
3236            $lightbox.unbind('swipeleft');
3237            $arrowNext.unbind('click');
3238            $arrowPrev.unbind('click');
3239            $closeBtn.unbind('click');
3240            $("#body").removeClass('lightbox-showing');
3241
3242            if (videos.length > 0) {
3243              pauseIframes(videos);
3244            }
3245          });
3246
3247          $(document).keydown(function(event) {
3248            switch(event.which) {
3249              case 27:
3250              $closeBtn.click();
3251              break;
3252
3253              case 37:
3254              $arrowPrev.click();
3255              break;
3256
3257              case 39:
3258              $arrowNext.click();
3259              break;
3260
3261              default: return; // exit this handler for other keys
3262            }
3263          });
3264
3265          function configureSocialShare() {
3266
3267            $('.lb-pinterest', $lightbox).each(function(idx) {
3268
3269              var pinitButton = $(this);
3270
3271              var url = pinitButton.attr("data-url");
3272              var mediaImage = pinitButton.attr("data-media");
3273
3274              if (mediaImage == '') {
3275                mediaImage = url;
3276              }
3277
3278              // Pinterest.
3279              pinitButton.attr('href', 'http://pinterest.com/pin/create/button/?url=' + encodeURIComponent(url) + '&media=' + encodeURIComponent(mediaImage) + "&description=" + encodeURIComponent(pinitButton.attr("data-desc")));
3280
3281              if (($('iframe[src^="http://pinit-cdn.pinterest.com/pinit.html"]').length)) {
3282                $('iframe[src^="http://pinit-cdn.pinterest.com/pinit.html"]').attr('src', 'http://pinit-cdn.pinterest.com/pinit.html?url=' + encodeURIComponent(url) + '&media=' + encodeURIComponent(mediaImage) + "&description=" + encodeURIComponent(pinitButton.attr("data-desc")));
3283              } else {
3284                $.ajax({ url: 'https://assets.pinterest.com/js/pinit.js', dataType: '
3284script', cache: true });
3285              }
3286
3287
3288            });
3289
3290          }
3291
3292          configureSocialShare();
3293
3294        }
3295
3296
3297
3298}
3299
3300function pauseIframes(videos) {
3301  for (var i = 0; i < videos.length; i++) {
3302    // console.log(videos[i]);
3303    videos[i].contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
3304  }
3305}
3306
3307
3308function closeLightBox() {
3309  var lightBox = $(".media-container-popup.show-lightbox");
3310  var imageCards = $(".media-container-popup .gallery-container .card");
3311  var lbHeader = $(".media-container-popup .media-container-popup-header");
3312  lightBox.removeClass("lb-fullscreen-img");
3313  lbHeader.removeClass("lb-fullscreen-img");
3314  imageCards.removeClass("lb-fullscreen-img");
3315  $('.media-container-popup.show-lightbox').toggleClass('show-lightbox');
3316  $("#body").removeClass('lightbox-showing');
3317}
3318
3319$('body').on('keydown', function(e) {
3320  if (event.which === 27) { // Escape Key
3321    closeLightBox();
3322  }
3323});
3324
3325function expandLightBoxImage() {
3326  var lightBox = $(".media-container-popup.show-lightbox");
3327  var imageCards = $(".media-container-popup .gallery-container .card");
3328  var lbHeader = $(".media-container-popup .media-container-popup-header");
3329  lightBox.toggleClass("lb-fullscreen-img");
3330  lbHeader.toggleClass("lb-fullscreen-img");
3331  imageCards.toggleClass("lb-fullscreen-img");
3332}
3333
3334/* Copyright (c) 2007 Tom Deater (http://www.tomdeater.com)
3335* Licensed under the MIT License:
3336* http://www.opensource.org/licenses/mit-license.php
3337*/
3338
3339(function ($) {
3340    /**
3341    * attaches a character counter to each textarea element in the jQuery object
3342    * usage: $("#myTextArea").charCounter(max, settings);
3343    */
3344
3345    $.fn.charCounter = function (max, settings,hideTextCounter) {
3346        var counterDisplay = 'block';
3347        if(hideTextCounter){
3348        counterDisplay = 'none';
3349        }
3350
3351        max = max || 100;
3352        settings = $.extend({
3353            container: "<span style='display:" + counterDisplay + "'></span>",
3354            classname: "charcounter",
3355            format: "<span class='tiny'><span class='number'>%1</span>&nbsp;left</span>",
3356            pulse: true,
3357            delay: 0
3358        }, settings);
3359        var p, timeout;
3360
3361        function count(el, container) {
3362            el = $(el);
3363            var lengthWithBreaksDoubled = el.val().replace(/(\n)/gm, '\n\n').length
3364
3365            if (lengthWithBreaksDoubled > max) {
3366
3367                var alphaCount = el.val().replace(/(\n)/gm, '\n\n').length;
3368                var lfCount = (el.val().match(/\n/g) || []).length;
3369
3370                //cut off as much as we can before looping to reduce length
3371                if (lengthWithBreaksDoubled > max + lfCount) {
3372                    el.val(el.val().substring(0, max + lfCount));
3373                }
3374
3375                while (el.val().replace(/(\n)/gm, '\n\n').length > max) {
3376                    el.val(el.val().substring(0, el.val().length - 1));
3377                }
3378
3379                if (settings.pulse && !p) {
3380                    pulse(container, true);
3381                };
3382            };
3383            if (settings.delay > 0) {
3384                if (timeout) {
3385                    window.clearTimeout(timeout);
3386                }
3387                //we need to add a second new line character before we count to simulate the crlf used in other places
3388                timeout = window.setTimeout(function () {
3389                    container.html(settings.format.replace(/%1/, (max - el.val().replace(/(\n)/gm, '\n\n').length)));
3390                }, settings.delay);
3391            } else {
3392                container.html(settings.format.replace(/%1/, (max - el.val().replace(/(\n)/gm, '\n\n').length)));
3393            }
3394        };
3395
3396        function pulse(el, again) {
3397            if (p) {
3398                window.clearTimeout(p);
3399                p = null;
3400            };
3401            el.animate({ opacity: 0.1 }, 100, function () {
3402                $(this).animate({ opacity: 1.0 }, 100);
3403            });
3404            if (again) {
3405                p = window.setTimeout(function () { pulse(el) }, 200);
3406            };
3407        };
3408
3409        return this.each(function () {
3410            var container = (!settings.container.match(/^<.+>$/))
3411				? $(settings.container)
3412				: $(settings.container)
3413					.insertAfter(this)
3414					.addClass(settings.classname);
3415            $(this)
3416				.bind("keydown", function () { count(this, container); })
3417				.bind("keypress", function () { count(this, container); })
3418				.bind("keyup", function () { count(this, container); })
3419				.bind("focus", function () { count(this, container); })
3420				.bind("mouseover", function () { count(this, container); })
3421				.bind("mouseout", function () { count(this, container); })
3422				.bind("paste", function () {
3423				    var me = this;
3424				    setTimeout(function () { count(me, container); }, 10);
3425				});
3426            if (this.addEventListener) {
3427                this.addEventListener('input', function () { count(this, container); }, false);
3428            };
3429            count(this, container);
3430        });
3431    };
3432
3433})(jQuery);
3434
3435/*****************************
3436GA Social Tracking
3437******************************/
3438
3439function TrackBeAFan() {
3440    if (typeof _gaq != "undefined")
3441        _gaq.push(['_trackSocial', 'Saffire', 'Be a Fan']);
3442}
3443
3444function TrackSaveToMyFavorites() {
3445    if (typeof _gaq != "undefined")
3446        _gaq.push(['_trackSocial', 'Saffire', 'Save to my Favorites']);
3447}
3448
3449function TrackUploadPhoto() {
3450    if (typeof _gaq != "undefined")
3451        _gaq.push(['_trackSocial', 'Saffire', 'Upload Photo']);
3452}
3453
3454function TrackForwardToFriend() {
3455    if (typeof _gaq != "undefined")
3456        _gaq.push(['_trackSocial', 'Saffire', 'Forward to Friend']);
3457}
3458
3459function TrackFacebookReferTo() {
3460    if (typeof _gaq != "undefined")
3461        _gaq.push(['_trackSocial', 'facebook', 'Refer To']);
3462}
3463
3464function TrackTwitterReferTo() {
3465    if (typeof _gaq != "undefined")
3466        _gaq.push(['_trackSocial', 'twitter', 'Refer To']);
3467}
3468
3469function TrackInstagramReferTo() {
3470    if (typeof _gaq != "undefined")
3471        _gaq.push(['_trackSocial', 'instagram', 'Refer To']);
3472}
3473
3474function TrackYoutubeReferTo() {
3475    if (typeof _gaq != "undefined")
3476        _gaq.push(['_trackSocial', 'youtube', 'Refer To']);
3477}
3478
3479function TrackPinterestReferTo() {
3480    if (typeof _gaq != "undefined")
3481        _gaq.push(['_trackSocial', 'pinterest', 'Refer To']);
3482}
3483
3484$(document).ready(function(){
3485	$('.expand').each(function(){
3486		$(this).addClass('hasImage');
3487	});
3488	var checkIt = $('.listing .hasImage').length;
3489	if(checkIt>0){
3490		$('.expand').css('width', '60px');
3491	}
3492
3493	$('.nav .items .item.temporaryNudgeRight > a').each(function(){
3494		var pl = $(this).css('padding-left');
3495		var pr = $(this).css('padding-right');
3496		pl = parseInt(pl);
3497		pr = parseInt(pr);
3498		$(this).css({paddingLeft:pl+8+'px', paddingRight:pr-8+'px'});
3499	});
3500
3501	var b = $('.newTixDeals .listing .row').css('background-color');
3502	$('.newTixDeals .listing .row, .newTixDeals .listing .row_alt').hover(function(){$(this).css('background-color', b);});
3503	var c = $('.newTixDeals .listing .item .question a span').css('color');
3504	$('.newTixDeals .listing .item .date, .newTixDeals .listing .item .time, .newTixDeals .listing .item .cost').css({color:c});
3505});
3506
3507//fix for ie 10 image button issue
3508$(function () {
3509    // Patch fractional .x, .y form parameters for IE10.
3510    if (typeof (Sys) !== 'undefined' && Sys.Browser.agent === Sys.Browser.InternetExplorer) {
3511        Sys.WebForms.PageRequestManager.getInstance()._onFormElementActive = function Sys$WebForms$PageRequestManager$_onFormElementActive(element, offsetX, offsetY) {
3512            if (element.disabled) {
3513                return;
3514            }
3515            this._activeElement = element;
3516            this._postBackSettings = this._getPostBackSettings(element, element.name);
3517            if (element.name) {
3518                var tagName = element.tagName.toUpperCase();
3519                if (tagName === 'INPUT') {
3520                    var type = element.type;
3521                    if (type === 'submit') {
3522                        this._additionalInput = encodeURIComponent(element.name) + '=' + encodeURIComponent(element.value);
3523                    }
3524                    else if (type === 'image') {
3525                        this._additionalInput = encodeURIComponent(element.name) + '.x=' + Math.floor(offsetX) + '&' + encodeURIComponent(element.name) + '.y=' + Math.floor(offsetY);
3526                    }
3527                }
3528                else if ((tagName === 'BUTTON') && (element.name.length !== 0) && (element.type === 'submit')) {
3529                    this._additionalInput = encodeURIComponent(element.name) + '=' + encodeURIComponent(element.value);
3530                }
3531            }
3532        };
3533    }
3534});
3535
3536
3537/****************** centers images in their container (image grids) - use for IE8-9 only, in place of css flex **************/
3538function imageGridVerticalCentering(containerClass){
3539	$('.imageGalleryViewItem').each(function(){
3540		var i = $(this).has('img');
3541		if(i){
3542			var containerHeight = $('.'+containerClass).height();
3543			var itemHeight = $('img', this).height();
3544			var margin = (containerHeight-itemHeight)*0.5;
3545			$('img',this).css('margin-top',margin+'px');
3546			$(this).css('text-align','center');
3547		}
3548	});
3549}
3550
3551/***************** insures that images wrap properly regardless of site width or descriptive text (call on window.load) **************/
3552function imageGridLayout(containerClass){
3553    $('.imageGallery').each(function(){
3554        var c = $('.'+containerClass).width();
3555        var img = parseInt($('.imageGalleryViewItem', this).css('width'));
3556        var mL = parseInt($('.imageGalleryViewItem', this).css('margin-left'));
3557        var mR = parseInt($('.imageGalleryViewItem', this).css('margin-right'));
3558        var pL = parseInt($('.imageGalleryViewItem', this).css('padding-left'));
3559        var pR = parseInt($('.imageGalleryViewItem', this).css('padding-right'));
3560        var tot = img+mL+mR+pR+pL;
3561        var n = Math.floor(c/tot);
3562    	var loop = n+1;
3563
3564        //$(this).css({width:n*tot+'px', marginRight:'auto', marginLeft:'auto'})
3565        var i = 1;
3566        $('.imageGalleryViewItem', this).each(function(){
3567            if(i<loop){
3568                i++;
3569            } else {
3570                $(this).css('clear','left');
3571                i = 2;
3572            }
3573        });
3574    });
3575    $('.imageGalleryViewItem').animate({opacity:'1'},750)
3576}
3577
3578/***********Support for indexOf for IE8 or lower***************/
3579
3580if (!Array.prototype.indexOf) {
3581    Array.prototype.indexOf = function (obj, start) {
3582        for (var i = (start || 0), j = this.length; i < j; i++) {
3583            if (this[i] === obj) { return i; }
3584        }
3585        return -1;
3586    }
3587}
3588
3589
3590/********** Opens info panel in mobile view slideshow **************/
3591function showImageGridDescription(el){
3592    var checkClass = $(el).closest('.swiper-slide').hasClass('imageGridShowingDescription');
3593
3594    if(!checkClass){
3595        $(el).closest('.swiper-slide').addClass('imageGridShowingDescription');
3596    } else {
3597        $(el).closest('.swiper-slide').removeClass('imageGridShowingDescription');
3598    }
3599}
3600
3601function setResponsiveSize() {
3602    if (mobileSize && isResponsive) {
3603
3604        var winWidth = $(window).width();
3605
3606        if (winWidth <= mobileSize) {
3607            $('body').addClass('saffireMobileSize');
3608            $('body').removeClass('saffireLargeSize');
3609        } else {
3610            $('body').removeClass('saffireMobileSize');
3611            $('body').addClass('saffireLargeSize');
3612        }
3613    }
3614}
3615
3616/*********************************
3617ASMX Service Functions
3618**********************************/
3619extend(saffire, {
3620    data: {
3621        callAPI: function(endpoint, data, success, error) {
3622
3623            $.ajax({
3624                type: "POST",
3625                url: endpoint,
3626                cache: false,
3627                contentType: "application/json; charset=utf-8",
3628                data: data,
3629                dataType: "json",
3630                success: success,
3631                error: error,
3632                dataFilter: function (originalData) {
3633                    try {
3634                        var data = JSON.parse(originalData);
3635                        if (data.hasOwnProperty('d')) {
3636                            data = data.d;
3637                            return JSON.stringify(data);
3638                        }
3639                        else {
3640                            return originalData;
3641                        }
3642
3643                    }
3644                    catch (err) {
3645                        return originalData;
3646                    }
3647                }
3648            });
3649
3650        }
3651    }
3652});
3653
3654
3655extend(saffire, {
3656    web: {
3657        services: {
3658            general: {
3659
3660                emailSignup: function (email, list, success, error, eventID, context) {
3661
3662                    saffire.data.callAPI(SITEBASEURL + "services/GeneralService.asmx/EmailSignup",
3663                        "{'email': '" + email + "', 'list': '" + list + "', 'eventID': '" + eventID + "'}",
3664                        success, error);
3665
3666                }
3667
3668            }
3669
3670            ,events: {
3671
3672                saveFanPick: function(entityTypeName, entityID, success, error, context) {
3673
3674                    saffire.data.callAPI(SITEBASEURL + "services/EventsService.asmx/SaveFanPick",
3675                        "{'entityTypeName': '" + entityTypeName + "', 'eventID': '" + entityID + "'}",
3676                        success, error);
3677
3678                }
3679                , getEventFanPickCount: function(entityID, success, error, context) {
3680
3681                    saffire.data.callAPI(SITEBASEURL + "services/EventsService.asmx/GetEventFanPickCount",
3682                        "{'eventID': '" + entityID + "'}",
3683                        success, error);
3684
3685                }
3686
3687            }
3688
3689            ,businesses: {
3690
3691                saveFanPick: function(entityTypeName, entityID, success, error, context) {
3692
3693                    saffire.data.callAPI(SITEBASEURL + "services/BusinessesService.asmx/SaveFanPick",
3694                       "{'entityTypeName': '" + entityTypeName + "', 'businessID': '" + entityID + "'}",
3695                       success, error);
3696
3697                }
3698
3699                , getBusinessFanPickCount: function (entityID, success, error, context) {
3700
3701                    saffire.data.callAPI(SITEBASEURL + "services/BusinessesService.asmx/GetBusinessFanPickCount",
3702                        "{'businessID': '" + entityID + "'}",
3703                        success, error);
3704
3705                }
3706
3707            }
3708
3709            ,user: {
3710
3711                isAuthenticated: function(userID, success, error) {
3712
3713                    saffire.data.callAPI(SITEBASEURL + "services/UsersService.asmx/IsAuthenticated",
3714                       "{'uid': '" + userID + "'}",
3715                       success, error);
3716
3717                }
3718
3719                , changeLoginStatusAndGetNextStepURL: function (success, error) {
3720
3721                    saffire.data.callAPI(SITEBASEURL + "services/UsersService.asmx/ChangeLoginStatusAndGetNextStepURL",
3722                        "",
3723                        success, error);
3724
3725                }
3726
3727            }
3728            
3729        }
3730    }
3731
3732});
3733
3734/*********************************
3735Document Events
3736**********************************/
3737
3738setResponsiveSize();
3739
3740$(document).ready(function () {
3741
3742    var skipToContent = $('#skiptocontent');
3743
3744    if (skipToContent.length > 0) {
3745
3746       var isFirstTabClick = false;
3747
3748       document.documentElement.addEventListener('keydown', function (event) {
3749           var code = event.which;
3750           // Show animation only upon Tab or Arrow keys press.
3751           if (code === 9) {
3752
3753               if (!isFirstTabClick) {
3754                   skipToContent.show();                   
3755                   isFirstTabClick = true;
3756               }
3757           }
3758       }, false);
3759      
3760       $('#skiptocontent a').click(function () {
3761          var firstFocusableElem = $('main.content').find(':focusable').first();
3762          firstFocusableElem.focus();
3763       });
3764    }
3765
3766
3767    // Hide/show itemListing Product Details
3768    function showItemListingDetails(el) {
3769      if ( !el.hasClass('show-details') ) {
3770        el.addClass('show-details');
3771        el.find('> a').text('Hide Details');
3772      } else {
3773        el.removeClass('show-details');
3774        el.find('> a').text('View Details');
3775      }
3776    }
3777    $('.listingItem .viewDetails > a,.cartNavItem .viewDetails > a , .cart-product .viewDetails > a ').on('keypress click', function(e) {
3778      var el = $(this).parent();
3779      if (e.which === 13 || e.type === 'click') {
3780        showItemListingDetails(el);
3781      }
3782    });
3783    // -----
3784
3785    // workaround for blogs (headerEmailSignupMode var is missing there)
3786    if (headerEmailSignupMode === undefined) {
3787      var headerEmailSignupMode = 1;
3788    }
3789    // -----
3790
3791    if (isResponsive || headerEmailSignupMode) {
3792
3793        if (headerEmailSignupMode) {
3794            var $emailBtn = $('.header .emailSignup .emailSubmitButton');
3795            if ($emailBtn.length > 0 && $emailBtn.attr("href") != undefined) {
3796                if (!$emailBtn.attr("href").startsWith("http")) {
3797                    $emailBtn.removeAttr('onclick').removeAttr('href', '');
3798                }
3799            }
3800        }
3801
3802        $('.header .emailSignup').attr('tabindex', '0');
3803        $('.header .emailSignup').on('click keydown', function(e){
3804          if (e.type === 'click'|| e.key === "Enter" || e.key === ' ') {
3805            var getWidth = $(window).width();
3806            if (getWidth <= mobileSize || headerEmailSignupMode) {
3807                window.top.OpenModal('modal', SITEBASEURL + 'modalucloader.aspx?controlpath=~/events/content/email.ascx', '600px', '275px', { 'OnClosePostBack': false, 'OnCloseTargetID': 'Reload', 'Parent': window, 'ScrollFrame': false });
3808            }
3809          }
3810        });
3811
3812        if (isResponsive) {
3813
3814            var $searchBox = $('.header .searchBox');
3815            if ($searchBox.length > 0) {
3816
3817                if (!$('#searchBoxClicker').length) {
3818                    $('.header .searchBox').prepend('<div id="searchBoxClicker" tabindex="0" aria-label="toggle search website field" role="button"></div>');
3819                }
3820                $('#searchBoxClicker').click(function () {
3821                    $('.clonedSearchBox').remove();
3822                    var getWidth = $(window).width();
3823                    var isClicked = $(this).hasClass('searchBoxShowing');
3824                    if (getWidth <= mobileSize) {
3825                        $('.header').append('<div class="searchBox clonedSearchBox">' +
3826                            '<div class="searchBoxInput">' +
3827                            '<input type="text" class="textbox search inputFieldTextbox ui-autocomplete-input" placeholder="Search Website" />' +
3828                            '<span role="status" aria-live="polite" class="ui-helper-hidden-accessible"></span>' +
3829                            '</div>' +
3830                            '<div class="searchBoxSubmit">' +
3831                            '<a href="javascript:void(0)" onclick="updateClonedSubmit()" class="button inputFieldSubmit searchSubmitButton" role="button"></a>' +
3832                            '</div>' +
3833                            '<a onclick="document.querySelector(\'.clonedSearchBox\').remove()" class="mobileSearchCloseButton" href="javascript:void(0);">X</a></div>'
3834                        )
3835
3836                        $('.clonedSearchBox #searchBoxClicker').remove();
3837
3838                        $(".clonedSearchBox input").keyup(function (event) {
3839                            if (event.keyCode == 13) {
3840                                $(".clonedSearchBox a.inputFieldSubmit").click();
3841                            }
3842                        });
3843                    }
3844                });
3845
3846                $('.mobile-menu-container .search-container .search-submit-btn').click(function () {
3847                    var curValue = $('.search-container input').val();
3848                    if (curValue != '') {
3849                        window.location = SITEBASEURL + 'search.aspx?q=' + curValue;
3850                    }
3851                });
3852
3853                $('.search-container input').keyup(function (event) {
3854                    if (event.keyCode == 13) {
3855                        $(".mobile-menu-container .search-container .search-submit-btn").click();
3856                    }
3857                });
3858
3859
3860                $('.nav>div.clear:first-of-type').click(function () {
3861                    var checkClicked = $(this).hasClass('navTriggerClicked');
3862                    if (checkClicked) {
3863                        $(this).removeClass('navTriggerClicked');
3864                        $('body').removeClass('mobileNavShowing');
3865                        $('ul').removeClass('navMobileMenuShiftedLeft');
3866                        $('.navMobileMenuShiftedGoBack').css('display', 'none');
3867                    } else {
3868                        $(this).addClass('navTriggerClicked');
3869                        $('body').addClass('mobileNavShowing');
3870                    }
3871                });
3872
3873                $('.nav .groups').before('<span class="navMobileMenuShiftedGoBack" onclick="hideMenuPanel()"></span>');
3874
3875                var i = 0;
3876                $('li[aria-haspopup="true"]').each(function () {
3877                    var getDummyLinkText = $(this).children('a').text();
3878                    $(this).prepend('<span class="navDummyLink">
3878' + getDummyLinkText + '</span>');
3879                    getDummyLinkText = getDummyLinkText.replace('>', '');
3880                    $('ul', this).first().prepend('<li class="item navClonedItem" id="navDummyLink' + i + '"></li>')
3881                    $(this).children('a').text(getDummyLinkText);
3882                    $(this).children('a').clone().appendTo('#navDummyLink' + i);
3883                    i++;
3884                });
3885
3886                $('.nav .items .item.temporaryNudgeRight > .navDummyLink').each(function () {
3887                    var pl = $(this).css('padding-left');
3888                    var pr = $(this).css('padding-right'); // console.log(pl + ' '+ pr)
3889                    pl = parseInt(pl);
3890                    pr = parseInt(pr);
3891                    $(this).css({ paddingLeft: pl + 8 + 'px', paddingRight: pr - 8 + 'px' });
3892                });
3893
3894                $('.navDummyLink').click(function () {
3895                    $(this).closest('li').find('ul').first().addClass('navMobileMenuShiftedLeft');
3896                    $('.navMobileMenuShiftedGoBack').css('display', 'block');
3897                });
3898
3899              }
3900              else {
3901                $('.mobile-menu-container .search-container').remove();
3902              }
3903            
3904            $('#calendarMobileToggle, #eventFilterOptions li').click(function () {
3905                toggleEventPane();
3906            });
3907        }
3908    }
3909});
3910
3911$(window).load(function () {
3912
3913    if ($('.footer').length > 0 ) {
3914        var windowWidth = $(window).width();
3915        if (windowWidth <= mobileSize && isResponsive) {
3916            $('.footer .footerItems1 a').addClass('button');
3917            $('.footer .footerSignIn a').addClass('button');
3918        } else {
3919            $('.footer .footerItems1 a').removeClass('button');
3920            $('.footer .footerSignIn a').removeClass('button');
3921        }
3922    }
3923
3924    $('body').addClass('pageIsLoaded');
3925
3926    var topScrollPos = $(window).scrollTop();
3927
3928    if (topScrollPos > windowTopValue) {
3929        $('body').addClass('saffireWindowScrolled');
3930    } else {
3931        $('body').removeClass('saffireWindowScrolled');
3932    }
3933
3934});
3935
3936$(window).resize(function () {
3937
3938    setResponsiveSize();
3939
3940    if ($('.footer').length > 0) {
3941        var windowWidth = $(window).width();
3942        if (windowWidth <= mobileSize && isResponsive) {
3943            $('.footer .footerItems1 a').addClass('button');
3944            $('.footer .footerSignIn a').addClass('button');
3945        } else {
3946            $('.footer .footerItems1 a').removeClass('button');
3947            $('.footer .footerSignIn a').removeClass('button');
3948        }
3949    }
3950});
3951
3952$(window).scroll(function () {
3953
3954    var topScrollPos = $(window).scrollTop();
3955    if (windowTopValue != undefined && windowTopValue != null) {
3956        if (topScrollPos > windowTopValue) {
3957            $('body').addClass('saffireWindowScrolled');
3958        } else {
3959            $('body').removeClass('saffireWindowScrolled');
3960        }
3961    }
3962});
3963
3964/*********************************
3965Mobile Nav
3966**********************************/
3967
3968$(document).ready(function() {
3969
3970  let $lastNavTrigger;
3971  const $menu = $('.mobile-menu-container');
3972  const $firstFocusableInMobileNav = $menu.find('.close-mobile-menu');  
3973
3974  function getLastFocusableInMobileNav() {
3975      return $menu.find('.mobile-menu-footer-links a').last();
3976  }  
3977
3978  function createMobileNavMenu() {
3979      var navGroups = $('#mainNavigation .groups').first().clone();
3980      var mobileNavPanel = $('.mobile-menu-container .mobile-menu-slider');
3981
3982      $('.mobile-menu-container .mobile-menu-slider .groups').remove();
3983      var navEl = document.createElement('nav');
3984      navEl.setAttribute('id', "mobile-nav");
3985      mobileNavPanel.append(navEl);
3986      
3987      navGroups.find('.navDummyLink').remove();
3988      navGroups.find('.navClonedItem').remove();
3989      
3990      navGroups.find('li[aria-haspopup="true"]').addClass('has-subitems');
3991      navGroups.find('li[aria-haspopup="true"]').append(
3992          '<span class="next-level-btn" role="button" tabindex="0" aria-label="Open submenu">❯</span>'
3993      );
3994      
3995      var backBtnHtml = '<li class="item prev-level-btn" role="button" tabindex="0"><a href="javascript:void(0);" tabindex="-1">❮ &nbsp; Back</a></li>';
3996      navGroups.find('.items').prepend(backBtnHtml);
3997      navGroups.find('.subitems').prepend(backBtnHtml);
3998      
3999      navGroups.addClass('m-groups');
4000      navGroups.find('.group').addClass('m-group');
4001      navGroups.find('.items').addClass('m-items');
4002      navGroups.find('.items > .item').addClass('m-item');
4003      navGroups.find('.subitems').addClass('m-subitems');
4004      navGroups.find('.subitems > .item').addClass('m-subitem');
4005
4006      navGroups.removeClass('groups');
4007      navGroups.find('.group').removeClass('group');
4008      navGroups.find('.items').removeClass('items');
4009      navGroups.find('.item').removeClass('item');
4010      navGroups.find('.subitems').removeClass('subitems');
4011      navGroups.find('.temporaryNudgeRight').removeClass('temporaryNudgeRight');
4012      navGroups.find('a').removeAttr('id');
4013      navGroups.find('a').removeClass('showingNav');
4014      
4015      mobileNavPanel.find('nav').append(navGroups);
4016
4017      // Next nav level
4018      $('.m-group.has-subitems .next-level-btn').click(function() {
4019          $(this).prev('ul').addClass('level-2-showing');
4020          $(this).closest('nav').addClass('show-level-2');
4021          var contHeight = $(this).prev('.level-2-showing').height();
4022          $('.mobile-menu-slider').height(contHeight + 'px');
4023      });
4024      $('.m-item.has-subitems .next-level-btn').click(function() {
4025          $(this).prev('ul').addClass('level-3-showing');
4026          $(this).closest('nav').addClass('show-level-3');
4027          $(this).closest('nav').removeClass('show-level-2');
4028          var contHeight = $(this).prev('.level-3-showing').height();
4029          $('.mobile-menu-slider').height(contHeight + 'px');
4030      });
4031      $('.m-subitem.has-subitems .next-level-btn').click(function() {
4032        $(this).prev('ul').addClass('level-4-showing');
4033        $(this).closest('nav').addClass('show-level-4');
4034        $(this).closest('nav').removeClass('show-level-3');
4035        var contHeight = $(this).prev('.level-4-showing').height();
4036        $('.mobile-menu-slider').height(contHeight + 'px');
4037      });
4038
4039      // Previous nav level
4040      $('.m-group.has-subitems .prev-level-btn').click(function() {
4041          $(this).closest('nav').removeClass('show-level-2');
4042          var contHeight = $('#mobile-nav').height();
4043          var thisParent = $(this).parent('ul');
4044          setTimeout(function () {
4045              thisParent.removeClass('level-2-showing');
4046              $('.mobile-menu-slider').height(contHeight + 'px');
4047          }, 300);
4048      });
4049      $('.m-item.has-subitems .prev-level-btn').click(function() {
4050          $(this).closest('nav').removeClass('show-level-3');
4051          $(this).closest('nav').addClass('show-level-2');
4052          var contHeight = $('.m-items.level-2-showing').height();
4053          var thisParent = $(this).parent('ul');
4054          setTimeout(function () {
4055              thisParent.removeClass('level-3-showing');
4056              $('.mobile-menu-slider').height(contHeight + 'px');
4057          }, 300);
4058      });
4059      $('.m-subitem.has-subitems .prev-level-btn').click(function() {
4060        $(this).closest('nav').removeClass('show-level-4');
4061        $(this).closest('nav').addClass('show-level-3');
4062        var contHeight = $('.m-subitems.level-3-showing').height();
4063        var thisParent = $(this).parent('ul');
4064        setTimeout(function () {
4065            thisParent.removeClass('level-4-showing');
4066            $('.mobile-menu-slider').height(contHeight + 'px');
4067        }, 300);
4068    });
4069
4070
4071    // additional event handling for accessiblity
4072
4073    var $slider = $('.mobile-menu-slider');
4074
4075    // Sets focusability for a specific list level
4076    function setLevelFocus($targetUl, isEnabled) {
4077        var tabVal = isEnabled ? "0" : "-1";
4078        
4079        // Target only direct children
4080        var $items = $targetUl.find('> li > a, > li > .next-level-btn, > li.prev-level-btn');
4081        
4082        $items.attr('tabindex', tabVal);
4083
4084        // Handle the 'Back' button
4085        if (isEnabled) {
4086            $targetUl.find('.prev-level-btn a').attr('tabindex', '-1'); 
4087        }
4088    }
4089
4090    // Mute every link/button inside the slider initially
4091    $slider.find('a, [role="button"], .next-level-btn').attr('tabindex', '-1');
4092    // Enable only for Level 1
4093    setLevelFocus($('.m-groups'), true);
4094
4095    // handler for next level
4096    $(document).on('click', '.next-level-btn', function() {
4097        var $btn = $(this);
4098        var $parentLi = $btn.closest('li');
4099        var $parentLink = $parentLi.find('> a');        
4100        var $currentUl = $btn.closest('ul');
4101        var $targetUl = $btn.prev('ul');
4102
4103        $btn.attr('aria-expanded', 'true');
4104        $parentLink.attr('aria-expanded', 'true');
4105
4106        // Kill focus on current level, enable on next
4107        setLevelFocus($currentUl, false);
4108        setLevelFocus($targetUl, true);
4109
4110        // Focus the Back button of the new level
4111        setTimeout(function() {
4112            $targetUl.find('.prev-level-btn').first().focus();
4113        }, 150);
4114    });
4115
4116    // handler for prev level
4117    $(document).on('click', '.prev-level-btn', function() {
4118        var $btn = $(this);
4119        var $currentUl = $btn.parent('ul');
4120        var $parentLi = $currentUl.closest('li');
4121        var $parentUl = $parentLi.closest('ul');
4122
4123        var $openingBtn = $parentLi.find('.next-level-btn');
4124        var $openingLink = $parentLi.find('> a');  
4125        $openingBtn.attr('aria-expanded', 'false');
4126        $openingLink.attr('aria-expanded', 'false');      
4127
4128        // Kill focus on current, restore to parent level
4129        setLevelFocus($currentUl, false);
4130        setLevelFocus($parentUl, true);
4131
4132        // Return focus to the trigger
4133        setTimeout(function() {
4134            $parentLi.find('> a, .next-level-btn').first().focus();
4135        }, 150);
4136    });    
4137
4138  }
4139
4140  // Hide and show mobile-nav
4141  $('.mobileNavLink, .mobile-nav-toggle').click(function() {
4142      const $menuContainer = $('.mobile-menu-container');
4143      const $wrapper = $('.wrapper');
4144      $('body').toggleClass('mobile-menu-open');
4145      updateMobileNavCart();
4146      createMobileNavMenu();
4147      $lastNavTrigger = $(this);
4148      $lastNavTrigger.attr('aria-expanded', 'true');     
4149
4150      if ($('body').hasClass('mobile-menu-open')) {
4151          $menuContainer.removeAttr('inert');  
4152          $wrapper.attr('inert', '');
4153      } else {
4154          $menuContainer.attr('inert', '');      
4155          $wrapper.removeAttr('inert');      
4156      }
4157      setTimeout(function() {
4158          var $closeBtn = $('.close-mobile-menu');
4159          $closeBtn.focus();
4160      }, 350);     
4161  });
4162
4163  $('.mobile-menu-header .close-mobile-menu').click(function() {
4164      const $menuContainer = $('.mobile-menu-container');    
4165      const $wrapper = $('.wrapper');
4166      $('body').toggleClass('mobile-menu-open');
4167
4168      $menuContainer.attr('inert', '');      
4169      $wrapper.removeAttr('inert');
4170      
4171      setTimeout(function () {
4172          $('#mobile-nav').remove();
4173          if ($lastNavTrigger) {
4174            $lastNavTrigger.attr('aria-expanded', 'false').focus();
4175          }      
4176      }, 300);
4177  });
4178
4179  // Handle Tab on the last element in the mobile menu
4180  $(document).on('keydown', '.mobile-menu-footer-links a:last', function(e) {
4181      if (e.key === 'Tab' && !e.shiftKey) {
4182          e.preventDefault();
4183          $firstFocusableInMobileNav.focus();
4184      }
4185  });
4186
4187  // Handle Shift+Tab on the first element in the mobile menu
4188  $firstFocusableInMobileNav.on('keydown', function(e) {
4189      if (e.key === 'Tab' && e.shiftKey) {
4190          var $lastFocusableInMobileNav = getLastFocusableInMobileNav();
4191          e.preventDefault();
4192          $lastFocusableInMobileNav.focus();
4193      }
4194  });  
4195
4196  // Handle keyboard interactions
4197  $(document).on('keydown', '.mobileNavLink, .mobile-nav-toggle, .close-mobile-menu, .next-level-btn, .prev-level-btn', function(e) {
4198      if (e.key === 'Enter' || e.key === ' ') {
4199          e.preventDefault();
4200          $(this).click(); 
4201      }
4202  });
4203
4204  // Handle Escape key to close nav menu
4205  $(document).on('keydown', function(e) {
4206      if (e.key === 'Escape' && $('body').hasClass('mobile-menu-open')) {
4207          $('.close-mobile-menu').click();
4208      }
4209  });  
4210
4211
4212  // quicklinks functionality -- hide these by default?
4213  var mobileNavSearchContainer = $('.mobile-menu-container .search-container');
4214  var mobileNavEmailContainer = $('.mobile-menu-container .email-signup-container');
4215  var mobileNavCartContainer = $('.mobile-menu-container .mobile-menu-cart');
4216  var mobileNavLoginContainer = $('.mobile-menu-container .mobile-menu-login-links');
4217  var mobileTicketBtn = $('.mobile-menu-container .mobile-menu-ticket-btn');
4218
4219  if ( $('.header .searchBox').length > 0 ) {
4220    mobileNavSearchContainer.show();
4221  } else {
4222    mobileNavSearchContainer.hide();
4223  }
4224
4225  if ( $('.header .emailSignup').length > 0 ) {
4226      mobileNavEmailContainer.find('a').attr('href','/email.aspx');
4227      mobileNavEmailContainer.show();
4228  } else {
4229      mobileNavEmailContainer.hide();
4230  }
4231
4232  if ( $('.header .viewcart').length > 0 ) {
4233      mobileNavCartContainer.find('a').attr('href','/cart.aspx');
4234      mobileNavCartContainer.show();
4235  } else {
4236      mobileNavCartContainer.hide();
4237  }
4238
4239  if ( ($('.loginstatus').length > 0) || ($('.login-status-link').length > 0) ) {
4240    var headerSignOut = $('.loginstatus a').attr('href') || $('.login-status-link').attr('href');
4241    var signIn = $('.mobile-menu-signInBtn');
4242    var signOut = $('.mobile-menu-signOutBtn');
4243    var myAcct = $('.mobile-menu-myAccountBtn');
4244
4245    mobileNavLoginContainer.show();
4246    if ( $('body').hasClass('userLoggedIn') ) {
4247        signIn.hide();
4248        myAcct.attr('href', '/myaccountinfo.aspx');
4249        myAcct.show();
4250        signOut.attr('href', headerSignOut);
4251        signOut.show();
4252    } else {
4253        signIn.attr('href', '/login.aspx');
4254        signIn.show();
4255        myAcct.hide();
4256        signOut.hide();
4257    }
4258  } else {
4259    $('.mobile-menu-login').hide();
4260     mobileNavLoginContainer.hide();
4261  }
4262
4263  if ( $('.ticket').length > 0 ) {
4264    mobileTicketBtn.show();
4265  } else {
4266    mobileTicketBtn.hide();
4267  }
4268
4269
4270});
4271
4272// Update items number in mobile nav cart. - also called in viewcartnav.ascx
4273function updateMobileNavCart() {
4274  var itemsInCart = $('.cartMenuLink').data('itemcount');
4275  var $mobileMenuCartBtn = $('.mobile-menu-cart a');
4276  $('.mobile-menu-container .cart-counter').text(itemsInCart);
4277  if (!itemsInCart) {
4278    $mobileMenuCartBtn.attr({
4279      'tabindex': '-1',
4280      'aria-disabled': 'true'
4281    });
4282  } else {
4283    $mobileMenuCartBtn.attr({
4284      'tabindex': '0',
4285      'aria-disabled': 'false'
4286    });    
4287  }
4288}
4289
4290function valueIsNullOrUndefinedOrEmpty(value) {
4291
4292    if (value == undefined || value == null || value === '') {
4293        return true
4294    }
4295
4296    return false
4297}
4298
4299// Show sign-in link in checkout if loginstatus is present in header
4300// Show sign-in and create account section in checkout confirmation if loginstatus is present in header
4301$(document).ready(function() {
4302  if ( ($('.loginstatus').length > 0) || ($('.login-status-link').length > 0) ) {
4303    if ( $('#checkout').length > 0 ) {
4304      var chkLoginLink = $('.checkout-header__links a').first();
4305      chkLoginLink.next().show();
4306      chkLoginLink.show();
4307    }
4308    if ( $('.checkout-confirmation__section-account').length > 0 ) {
4309      $('.checkout-confirmation__section-account').show();
4310    }
4311  }
4312});
4313
4314function getUrlVars() {
4315    var url = window.location.href;
4316    var vars = {};
4317    var hashes = url.split("?")[1];
4318    var hash = hashes.split('&');
4319
4320    for (var i = 0; i < hash.length; i++) {
4321        params = hash[i].split("=");
4322        vars[params[0]] = params[1];
4323    }
4324    return vars;
4325}
4326
4327function convertDataURIToBinary (dataURI) {
4328    var BASE64_MARKER = ';base64,';
4329
4330    var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
4331    var base64 = dataURI.substring(base64Index);
4332    var raw = window.atob(base64);
4333    var rawLength = raw.length;
4334    var array = new Uint8Array(new ArrayBuffer(rawLength));
4335
4336    for (i = 0; i < rawLength; i++) {
4337        array[i] = raw.charCodeAt(i);
4338    }
4339
4340    return array;
4341}
4342
4343
4344$(document).ready(function() {
4345
4346    function initFeeChangesDialog() {
4347
4348        const showDialog = typeof SHOWPRODUCTFEECHANGESPOPUP !== 'undefined' && SHOWPRODUCTFEECHANGESPOPUP;
4349        const cookieName = 'SA_FEE_CHANGES_NOTICE';
4350        const isDialogSuppressed = typeof Cookies !== 'undefined' && (Cookies.get(cookieName) === 'set' || localStorage.getItem(cookieName) === 'set');
4351        const pageHasTixForSale = () => $('.purchaseOptions[data-producttype]:not([data-producttype="0"]):not([data-producttype="1"])').length > 0;
4352
4353        if (!showDialog || isDialogSuppressed || !pageHasTixForSale()) {
4354            return false;
4355        }
4356
4357        const $feeChangesDialog = $(`
4358          <dialog id="fee-changes-dialog" class="fee-changes-dialog" aria-labelledby="fee-changes-dialog__title">
4359            <div class="fee-changes-dialog__header">
4360                <div id="fee-changes-dialog__close-btn" class="button buttonSmall" tabindex="0" role="button" aria-label="X - Close Dialog">X</div>
4361            </div>
4362            <div class="fee-changes-dialog__content">
4363                <h2 id="fee-changes-dialog__title" class="fee-changes-dialog__title">ALL-IN PRICING</h2>
4364                <p>Ticket prices represent the total cost of the ticket, including fees.</p>
4365            </div>
4366            <div class="fee-changes-dialog__footer">
4367              <div id="fee-changes-dialog__ok-button" class="button" tabindex="0" role="button" aria-label="OK">OK</div>
4368            </div>
4369          </dialog>
4370        `);
4371
4372        function suppressDialog() {
4373            Cookies.set(cookieName, 'set', { expires: 365 });
4374
4375            if (Cookies.get(cookieName) === undefined) {
4376                localStorage.setItem(cookieName, 'set');
4377            }
4378        }
4379
4380        function closeFeeChangesDialog(dialog) {
4381            dialog.close();
4382            $(dialog).remove();
4383            suppressDialog();
4384        }                 
4385
4386        // Append dialog to body
4387        $('#body').append($feeChangesDialog);
4388
4389        const dialogEl = document.getElementById('fee-changes-dialog');  
4390
4391        // Attach event listeners
4392        $(document).on('click keydown', '#fee-changes-dialog__ok-button, #fee-changes-dialog__close-btn', function(e) {
4393            if (e.type === 'click' || e.key === 'Enter' || e.key === ' ') {
4394                e.preventDefault(); 
4395                closeFeeChangesDialog(dialogEl);
4396            }
4397        });
4398
4399        dialogEl.addEventListener('cancel', (e) => {
4400            e.preventDefault(); 
4401            closeFeeChangesDialog(dialogEl);
4402        });                      
4403
4404        // Show the dialog
4405        dialogEl.showModal();
4406        $('#fee-changes-dialog__ok-button').focus();     
4407
4408    };
4409
4410    if (window.location.href && !window.location.href.includes('/boxoffice') && !window.location.href.includes('/kiosk') && !window.location.href.includes('/spark')) {
4411        initFeeChangesDialog();
4412    }
4413
4414});
4415
4416//Fluent
4417
4418function RenderFluentWidget(userOptIn, orderMeta) {
4419
4420    var params = {
4421        orderId: orderMeta.id,
4422        transactionValue: orderMeta.total,
4423        currency: 'USD'
4424    }
4425
4426    if (userOptIn) {
4427
4428        params.email = orderMeta.emailAddress;
4429
4430        if (orderMeta.firstName !== null) {
4431            params.firstname = orderMeta.firstName;
4432        }
4433
4434        if (orderMeta.lastName !== null) {
4435            params.lastname = orderMeta.lastName;
4436        }
4437
4438        if (orderMeta.postalCode !== null) {
4439            params.zip = orderMeta.postalCode;
4440        }
4441
4442        if (orderMeta.city !== null) {
4443            params.city = orderMeta.city;
4444        }
4445
4446        if (orderMeta.state !== null) {
4447            params.state = orderMeta.state;
4448        }
4449
4450        const fc = new FlowContainer({
4451            params: params,
4452        });
4453
4454        fc.show();
4455
4456    }
4457}
4458
4459//STAY22
4460
4461function RenderStay22MapWidget(options) {
4462
4463    // Create iframe
4464    const iframe = document.createElement('iframe');
4465    iframe.width = '100%';
4466    iframe.height = '460';
4467    iframe.style.border = '0';
4468
4469    var baseUrl = 'https://www.stay22.com/embed/gm';
4470    var urlParams = new URLSearchParams();
4471
4472    // Function to add a single param
4473    function addIframeParam(key, value) {
4474        urlParams.append(key, value);
4475        iframe.src = `${baseUrl}?${urlParams.toString()}`;
4476    }
4477
4478    document.getElementById('stay22-frame-container').appendChild(iframe);
4479
4480    addIframeParam('aid', options.affiliateID);
4481    addIframeParam('address', options.address);
4482    addIframeParam('campaign', options.domain);
4483    addIframeParam('campaign', options.campaign);
4484
4485}
4486
4487
4488// Use for setting focus into modals/popups and trapping the focus within
4489function setFocusInModal(modalSelector) {
4490    const modal = $(modalSelector);
4491    const focusableElements = modal.find(
4492        'a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])'
4493    );
4494    const firstFocusableElement = focusableElements.first();
4495    const lastFocusableElement = focusableElements.last();
4496    const firstVisibleInput = focusableElements.filter('input:visible').first();
4497
4498    if (firstVisibleInput.length) {
4499        firstVisibleInput.focus();
4500    } else {
4501        firstFocusableElement.focus();
4502    }
4503
4504    function handleTabKey(e) {
4505        if (e.key === "Tab") {
4506            if (e.shiftKey) {
4507                // Shift + Tab (go to the last element)
4508                if ($(document.activeElement).is(firstFocusableElement)) {
4509                    lastFocusableElement.focus();
4510                    e.preventDefault();
4511                }
4512            } else {
4513                // Tab (go to the first element)
4514                if ($(document.activeElement).is(lastFocusableElement)) {
4515                    firstFocusableElement.focus();
4516                    e.preventDefault();
4517                }
4518            }
4519        }
4520    }
4521
4522    // Add the keydown event listener to trap focus inside the modal
4523    modal.on("keydown", handleTabKey);
4524}
4525
4526
4527// Handle Hover/Focus for popovers, tooltips, etc.
4528function handlePopovers() {
4529    // Toggle visibility of popover content
4530    function toggleVisibility(trigger, content, isVisible) {
4531        if (isVisible) {
4532            trigger.attr('data-popover-open', 'true'); 
4533            trigger.attr('aria-expanded', 'true');
4534            content.attr('aria-hidden', 'false');
4535        } else {
4536            trigger.attr('data-popover-open', 'false');
4537            trigger.attr('aria-expanded', 'false');
4538            content.attr('aria-hidden', 'true');
4539        }
4540    }
4541
4542    // Dismiss popover globally when the Escape key is pressed (if the popover is visible)
4543    function handleEscapeKeyForPopovers(event) {
4544        if (event.key === 'Escape') {
4545            const openPopovers = $('.js-popover[data-popover-open="true"]');
4546
4547            // Close any visible popovers when Escape is pressed
4548            if (openPopovers.length) {
4549                openPopovers.each(function() {
4550                    const popover = $(this);
4551                    const popoverContent = popover.find('.js-popover-content');
4552                    // Check if the focused element is inside the popover
4553                    if (popover.has(document.activeElement).length > 0) {
4554                        // Move the focus back to the trigger
4555                        popover.focus();
4556                    }
4557                    toggleVisibility(popover, popoverContent, false);
4558                });
4559                event.stopImmediatePropagation();
4560            }
4561        }
4562    };    
4563
4564    // Attach delegated event listeners for popovers
4565    
4566    // Show popover when hovering or focusing
4567    $(document).off('mouseenter focusin', '.js-popover') 
4568        .on('mouseenter focusin', '.js-popover', function() {
4569            const popover = $(this);
4570            const popoverContent = popover.find('.js-popover-content');
4571            toggleVisibility(popover, popoverContent, true);
4572        });
4573
4574    // Hide popover when leaving or blur
4575    $(document).off('mouseleave focusout', '.js-popover') 
4576        .on('mouseleave focusout', '.js-popover', function() {
4577            const popover = $(this);
4578            const popoverContent = popover.find('.js-popover-content');
4579            toggleVisibility(popover, popoverContent, false);
4580        });
4581
4582    // Attach delegated event listener for escape key to close popovers
4583    $(document).off('keydown.handlePopoversEscape').on('keydown.handlePopoversEscape', handleEscapeKeyForPopovers);
4584}
4585
4586$(window).load(function() {
4587    handlePopovers();
4588});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.