PageSourceSearch

https://www.geico.com/public/scripts/design6/global.js

js geico.com collected 2026-09-24 08:32:38 UTC 87,182 bytes, 2,281 lines download raw bytes

1$(document).ready(function() {
2    // create a script DOM node
3    var florida_zipcodes_script = document.createElement("script");
4    // set its src to the provided URL
5    florida_zipcodes_script.src = "/public/scripts/florida-zipcodes.js";
6    // add it to the end of the head section of the page (could change 'head' to 'body' to add it to the end of the body section instead)
7    document.body.appendChild(florida_zipcodes_script);
8
9    let productLogin = {
10        'Business Owners Insurance' : 'manage_business_owners',
11        'Commercial Auto Insurance' : 'manage_commercial_auto',
12        'General Liability Insurance' : 'manage_general_liability',
13        'Professional Liability Insurance' : 'manage_professional_liability',
14        'Workers\' Compensation Insurance' : 'manage_workers_compensation'
15    }
16
17    var $managePrimary = $('#primary-navigation #manage_select').length ? $('#primary-navigation #manage_select') : $('#manage_select');
18    var $manageGds = $('#gds-side-panel-navigation #manage_select');
19
20    if ($('html[data-product]').length && $('html').attr('data-product') in productLogin && $managePrimary.length) {
21        $managePrimary.attr("data-selected", productLogin[$('html').attr('data-product')]);
22    }
23
24    function initManageSelectFromDataSelected($select) {
25        if (!$select.length) {
26            return;
27        }
28        var login_panel = $select.data('selected');
29        var $root = $select.closest('.policy-form');
30
31        switch (login_panel) {
32            //ecams products using the same login form
33            case 'manage_auto':
34            case 'manage_motorcycle':
35            case 'manage_atv':
36            case 'manage_rv':
37                $select.find('.' + login_panel).prop('selected', true);
38                $root.find('#manage_ecams_form').addClass('show').show();
39                break;
40
41            //homeowner product using the same login form
42            case 'manage_homeowners':
43                $select.find('.' + login_panel).prop('selected', true);
44                $root.find('#manage_ecams_form').addClass('show').show();
45                $root.find('#ins_partner').attr('href', '/homeowners-insurance/policyholder/');
46                $root.find('#findPartner').addClass('show').show();
47                break;
48
49            //renter product using the same login form
50            case 'manage_renters':
51                $select.find('.' + login_panel).prop('selected', true);
52                $root.find('#manage_ecams_form').addClass('show').show();
53                $root.find('#ins_partner').attr('href', '/renters-insurance/policyholder/');
54                $root.find('#findPartner').addClass('show').show();
55                break;
56
57            //condo product using the same login form
58            case 'manage_condo':
59                $select.find('.' + login_panel).prop('selected', true);
60                $root.find('#manage_ecams_form').addClass('show').show();
61                $root.find('#ins_partner').attr('href', '/condo-insurance/policyholder/');
62                $root.find('#findPartner').addClass('show').show();
63                break;
64
65            //mobile-home product using the same login form
66            case 'manage_mobile_home':
67                $select.find('.' + login_panel).prop('selected', true);
68                $root.find('#manage_ecams_form').addClass('show').show();
69                $root.find('#ins_partner').attr('href', '/mobile-home-insurance/policyholder/');
70                $root.find('#findPartner').addClass('show').show();
71                break;
72
73            //landlord product using the same login form
74            case 'manage_landlord':
75                $select.find('.' + login_panel).prop('selected', true);
76                $root.find('#manage_ecams_form').addClass('show').show();
77                $root.find('#ins_partner').attr('href', '/landlord-insurance/policyholder/');
78                $root.find('#findPartner').addClass('show').show();
79                break;
80
81            //commercial products using the same login form
82            case 'manage_commercial_auto':
83            case 'manage_rideshare':
84                $select.find('.' + login_panel).prop('selected', true);
85                $root.find('#manage_commercial_form').addClass('show').show();
86                break;
87
88            //everything else
89            default:
90                $select.val(login_panel);
91                $root.find('#' + login_panel).addClass('show').show();
92                break;
93        }
94
95        nav_login_express($select);
96        ins_partners($select);
97    }
98
99    initManageSelectFromDataSelected($managePrimary);
100    initManageSelectFromDataSelected($manageGds);
101
102    $managePrimary.add($manageGds).add('#homepage_manage_select').change(function() {
103        nav_login_express(this);
104        ins_partners(this);
105    });
106
107    ///////////////////////////
108    // Miscellaneous helpers //
109    ///////////////////////////
110
111    $(".search-box").submit(function(e) {
112        e.preventDefault();
113        var term = ( $("input[name='term']", this).val() != undefined ) ? $("input[name='term']", this).val() : $("input.search-input[name='stq']").val();
114        if (language == "es-US") {
115            window.location.href = '/espanol/search/#q=' + term;
116        } else {
117            window.location.href = '/search/#q=' + term;
118        }
119        
120        GDK.navigation.closeAllPanels();
121    });
122
123    // hide/show .toggleContent
124    $(".toggleLink").click(function(e) {
125        e.preventDefault();
126        $(this).next(".toggleContent").slideToggle();
127    });
128
129    // close top fixed banners
130    $('.banner.top .banner_close').click(function(e){
131        $(this).parents('.banner.top').slideUp().removeClass('show');
132    });
133
134    //Reset quote form to first choice and show zip fields (or set to :selected option if one is already selected)
135    if($('#quoteForm select').find('option:selected')) {
136        $('#quoteForm select').find('option:selected').prop('selected', true);  
137    } else {
138        $('#quoteForm select').find('option:first').prop('selected', true);
139        $('#zipBox, #zip').show();
140    }
141
142    if($("#quoteForm").parents("#margin").length > 0) {
143        update_quote_button_text(document.getElementById('insurancetype').value);
144    }
145
146    // modify quote forms on change
147    if ($('#quoteForm').length) {
148        format_quote_form($('#insurancetype'));
149    }
150    $('#insurancetype').change(function() {
151        format_quote_form($(this));
152
153        if($("#quoteForm").parents("#margin").length > 0) {
154            update_quote_button_text(this.value);
155        }
156    });
157
158    // external disclaimer modal for manage & quote links
159    $('.modal-manage-link, .modal-quote-link').click(function() {
160        var company = $(this).data('company');
161        var product = $(this).data('product');
162        var link = $(this).data('link');
163        var modal_id = '#external_disclaimer_manage_modal';
164
165        if($(this).hasClass('modal-quote-link')){
166            modal_id = '#external_disclaimer_quote_modal';
167            $(modal_id).addClass('non-form');
168        }
169
170        $(modal_id + ' .external_company').text(company);
171        $(modal_id + ' .external_product').text(product);
172        $(modal_id + ' .modal-continue').attr('href', link);
173    });
174
175    $('#logInWithMobileApp a').click(function() {
176        $("input[name='userName']").val('');
177        $("input[name='userPassword']").val('');
178        location.href='https://geico.app.link/staticLogInPanelAccessYourPolicy';
179    });
180
181    // initialize geolocation zip fields
182    init_geo_zip();
183
184    // Add Spanish modals to page ZIP forms
185    spanishInternalModal();
186
187    //overwrite DK menu behavior
188    $('#primary-header .lang-toggle').click(function(){
189        window.location.href = $(this).parent().attr('href');
190    });
191
192    //For service, log Adobe Analytics
193    if ($.cookie("geo_info")) {
194        var geo_info_cookie = JSON.parse($.cookie("geo_info"));
195        if (geo_info_cookie['first_name'] != null) {
196            updateDTM('userProfile', 'Policyholder:Edge');
197        }
198    }
199
200    let btnDblClickDisabledOnce = false;
201    // prevent double click on service homepage login button
202    $('#homepage_manageForm, #homepage_manageForm_extra').submit(function(){
203        if(!btnDblClickDisabledOnce){
204            loginForm = $(this);
205            loginForm.find(':button[type=submit]').prop('disabled', true);
206            
207            //remove disabled button state after timeout in case something goes wrong, and don't set to disabled again
208            setTimeout(function(){
209                loginForm.find(':button[type=submit]').prop('disabled', false);
210                btnDblClickDisabledOnce = true;
211            }, 3000);
212        }
213    });
214
215    // Logging Apple store and Google Play link clicks
216    var appleStoreButtons = document.querySelectorAll("a[href^='https://itunes.apple.com/us/app/id331763096'], a[href^='https://apps.apple.com/us/app/id331763096']");
217    var googlePlayButtons = document.querySelectorAll("a[href^='https://play.google.com/store/apps/details?id=com.geico.mobile']");
218    Array.prototype.forEach.call(appleStoreButtons, function (appleStoreLink) {
219        appleStoreLink.addEventListener("click", function (e) {
220            updateDTM('generalAction', 'Static:MobileDownload:Apple');
221        });
222    });
223
224    Array.prototype.forEach.call(googlePlayButtons, function (googlePlayLink) {
225        googlePlayLink.addEventListener("click", function (e) {
226            updateDTM('generalAction', 'Static:MobileDownload:Google');
227        });
228    });
229
230});
231
232//determine which express service links to show for different products in login dropdowns
233function nav_login_express(dropdown) {
234    var $dropdown = $(dropdown);
235    if (!$dropdown.length) {
236        return;
237    }
238    var product = $('option:selected', $dropdown).text();
239    var $select_content;
240
241    if ($dropdown.closest('#primary-panel.service').length > 0) {
242        $select_content = $('.promotions'); //the express links to show/hide is in the .promotions bar
243    } else if ((($dropdown.attr('id')) || '').indexOf('homepage') !== -1) {
244        $select_content = $('#homepage_manage_policy_content');
245    } else {
246        var $scoped = $dropdown.closest('.policy-form').find('#manage_policy_content');
247        $select_content = $scoped.length ? $scoped : $('#manage_policy_content');
248    }
249
250    switch (product) {
251        case 'Auto':
252            if ($select_content.is('.promotions') || product === 'Auto') {
253                $select_content.find('.express_links, .express_links li').removeClass('hide');
254            }
255            else {
256                $select_content.find('.express_links').addClass('hide');
257            }
258            break;
259
260        case 'ATV':
261        case 'Motorcycle':
262            $select_content.find('.express_links').removeClass('hide');
263            $select_content.find('.express_links .vehicle, .express_links .documents').addClass('hide');
264            break;
265
266        default:
267            $select_content.find('.express_links').addClass('hide');
268            break;
269    }
270}
271
272function ins_partners(dropdown) {
273    var $dropdown = $(dropdown);
274    if (!$dropdown.length) {
275        return;
276    }
277    var product = $('option:selected', $dropdown).text();
278    var $select_content;
279
280    if ($dropdown.closest('#primary-panel.service').length > 0) {
281        $select_content = $('#service-links');
282    } else if ((($dropdown.attr('id')) || '').indexOf('homepage') !== -1) {
283        $select_content = $('#homepage_manage_policy_content');
284    } else {
285        var $scoped = $dropdown.closest('.policy-form').find('#manage_policy_content');
286        $select_content = $scoped.length ? $scoped : $('#manage_policy_content');
287    }
288
289    switch (product) {
290        case 'Homeowners':
291            $select_content.find('#ins_partner').attr('href', '/homeowners-insurance/policyholder/');
292            $select_content.find('#insurance_type').html('home');
293            $select_content.find('#findPartner').addClass('show').show();
294
295            break;
296
297        case 'Renters':
298            $select_content.find('#ins_partner').attr('href', '/renters-insurance/policyholder/');
299            $select_content.find('#insurance_type').html('renter');
300            $select_content.find('#findPartner').addClass('show').show();
301
302            break;
303
304        case 'Condo':
305            $select_content.find('#ins_partner').attr('href', '/condo-insurance/policyholder/');
306            $select_content.find('#insurance_type').html('condo');
307            $select_content.find('#findPartner').addClass('show').show();
308
309            break;
310
311        case 'Landlord':
312            $select_content.find('#ins_partner').attr('href', '/landlord-insurance/policyholder/');
313            $select_content.find('#insurance_type').html('landlord');
314            $select_content.find('#findPartner').addClass('show').show();
315
316            break;
317
318        case 'Mobile Home':
319            $select_content.find('#ins_partner').attr('href', '/mobile-home-insurance/policyholder/');
320            $select_content.find('#insurance_type').html('mobile home');
321            $select_content.find('#findPartner').addClass('show').show();
322
323            break;
324
325        default:
326            $select_content.find('#findPartner').removeClass('show');
327            $select_content.find('#findPartner').hide();
328
329            break;
330    }
331}
332
333function init_geo_zip() {
334    // override to hide geolocation by default, this should be done in CSS 
335    // but the design kit is set to always displays icons in IE8
336    $('#geolocation, a.geolocation').hide();
337
338    //if we have our geo location cookie set, update boxes where available
339    if ($.cookie("geo_info")) {
340        geo_info = JSON.parse($.cookie("geo_info"));
341
342        if (geo_info != null) {
343            if (geo_info['zip_code'] != null) {
344                geo_zip_success(geo_info['zip_code']);
345                $('.location .geo-info').html(geo_info['state'] + ' ' + geo_info['zip_code']);
346            }
347        }
348    }
349
350    // Show geolocation if available
351    if (navigator.geolocation && $('#geolocation, a.geolocation, .form-field.geozip').length) {
352        //load geolocation.js and do whatever is needed
353        $.ajax({
354            async: true,
355            cache: true,
356            url: "/public/scripts/geolocation.js",
357            success: function() {
358                $('#geolocation, a.geolocation').show();
359                $('#geolocation, a.geolocation').click(function() {
360                    get_geo_data('zip');
361                });
362                $(".geozip").each(function(i) {
363                    var id = 'geozip' + i;
364
365                    zip_placeholder = 'ZIP Code';
366                    zip_input = $(this).find('.zip-code-input');
367
368                    if(zip_input.attr('placeholder') !== undefined){
369                        zip_placeholder = zip_input.attr('placeholder');
370                    }
371
372                    window[id] = new GDK.ZipCode({
373                        content: $(this)[0],
374                        geolocation: true,
375                        callBackForGeolocation: (function () {
376                            get_geo_data('zip');
377                        }),
378                        callBackOnZipChange: (function() {
379                            $('.zip-code-geo-icon').removeClass("active");
380                        }),
381                        inputPlaceHolder: zip_placeholder,
382                    });
383                });
384            }
385        });
386    }
387}
388
389// populate geolocation zip
390function geo_zip_success(zip) {
391    $('#zip, .zip-code-input, input[placeholder="ZIP Code"]').val(zip);
392    $('.zip-code-geo-icon').addClass("active");
393}
394
395function set_geo_cookie(user_state, user_zip) {
396
397    // do some basic validation on the returned zip and state
398    if(user_state.length == 2 && user_zip.length == 5) {
399        user_source = "user_cookie";
400
401        var geo_info = { state: user_state, zip_code: user_zip, source: user_source };
402        if ($.cookie("geo_info")) {
403            var geo_info_cookie = JSON.parse($.cookie("geo_info"));
404            if (geo_info_cookie['first_name'] != null && geo_info_cookie['hpecams'] != null) {
405                geo_info = { state: user_state, zip_code: user_zip, first_name: geo_info_cookie['first_name'], source: user_source, hpecams: geo_info_cookie['hpecams'] };
406            }
407            else if (geo_info_cookie['first_name'] != null) {
408                geo_info = { state: user_state, zip_code: user_zip, first_name: geo_info_cookie['first_name'], source: user_source };
409            }
410            else if (geo_info_cookie['hpecams'] != null) {
411                geo_info = { state: user_state, zip_code: user_zip, source: user_source, hpecams: geo_info_cookie['hpecams'] };
412            }
413        }
414        date = new Date();
415        date.setTime(date.getTime()+(30*24*60*60*1000));
416
417        var geo_info_string = encodeURIComponent(JSON.stringify(geo_info));
418
419        var url = location.hostname.split('.');
420        var subdomain = url.shift();
421        var domain = url.join('.');
422
423        if (domain == '') {
424            domain = window.location.hostname;
425        } else {
426            domain = '.' + domain;
427        }
428
429        document.cookie = "geo_info=" + geo_info_string + "; expires="+ date.toGMTString() +"; path=/; domain="+domain;
430
431        $('.location .geo-info').html(user_state + ' ' + user_zip);
432
433        $('.geo-box .geo-alert').hide();
434        $("#primary-navigation .panel-wrapper.location").css("height", "22rem");
435
436        geo_zip_success(user_zip);
437    } else {
438        geo_lookup_error();
439    }
440}
441
442// Show and Hide Div Script
443function display(elementID) {
444    nodeItem = elementID.parentNode.nextSibling;
445
446    while (nodeItem.innerHTML == null || nodeItem.innerHTML == "") {
447        nodeItem = nodeItem.nextSibling;
448    }
449
450    $(nodeItem).slideToggle('normal');
451}
452
453// return domain for cookie setting 
454function get_cookie_domain() {
455    var page = window.location.href;
456    if (page.indexOf("geico.com") != -1) {
457        return ".geico.com";
458    } else if (page.indexOf("geico.net") != -1) {
459        return ".geico.net";
460    } else {
461        return "";
462    }
463}
464
465function checkZip(){
466    /*var zip_elements = $('#quoteForm p');
467    if ($('#quoteForm').length) {
468        if (zip_elements.css('display') == "block" && ($('#zip').val() == "" || $('#zip').val().length < 5 || !$.isNumeric($('#zip').val()))) {
469            $('.form-field--error').css('display','block');
470            $("#zip").addClass('err').focus();
471            return false;
472        }
473        else{
474            return true;
475        }
476    }*/
477    return true;
478
479}
480
481function spanishInternalModal() {
482    if (language == "es-US") {
483        var internal_forms = false;
484
485        // Get a list of all forms
486        $('#wrapper form, #homepage_manageForm, #homepage_manageForm_extra, #manageForm, [data-side-panel="account"] form').each(function() {
487            var action = $(this).attr('action');
488            var internal = [
489                "https://sales.geico.com",
490                "https://commercial.geico.com",
491                "https://propertysales.geico.com/"
492            ];
493            for (var i = 0; i < internal.length; i++) {
494                if (action != undefined && action.indexOf(internal[i]) !== -1) {
495                    internal_forms = true;
496
497                    // Make an exception for bundling (general)
498                    if (action == "https://sales.geico.com" && $(".staticBundle", this).length == 0) {
499                        internal_forms = false; 
500                    }
501
502                    // Make an exception for bundling (homepage)
503                    if (action == "https://sales.geico.com" && $('#bundle_modal input[name="lob"]').length) {
504                        if ($('#bundle_modal input[name="lob"]').attr('value').indexOf(",") == -1) {
505                            internal_forms = false;
506                        } else {
507                            internal_forms = true;
508                        }
509                    }
510
511                    if (internal_forms == true) {
512                        //if data-quote-start attribute is set, modify it with modal-spanish- prefix
513                        var data_quote_start = $('input[type="submit"], button[type="submit"]', this).attr('data-quote-start');
514                        if (typeof data_quote_start !== 'undefined' && data_quote_start !== false) {
515                            $('input[type="submit"], button[type="submit"]', this).attr('data-quote-start', 'modal-spanish-'+data_quote_start);
516                        }
517                        
518                        data_modal_view = 'spanish_internal_quote_modal';
519
520                        //set custom data_modal_view if on gfr insurance agent page (form in hero banner or sticky quote bar)
521                        if($(this).parents('#headline-wrapper.gfr-product').length || $(this).parents('#sticky-banner').siblings('#gfr_contact').length){
522                            data_modal_view = 'spanish_gfr_quote_modal';
523                        }
524                        
525                        // Set modal
526                        $('input[type="submit"], button[type="submit"]', this)
527                            .addClass('modal-trigger')
528                            .attr('data-modal-view', data_modal_view);
529                        $('#submit', this).attr('id', 'submitZip');
530
531                        $('input[type="submit"], button[type="submit"]', this).click(function(event) {
532                            var _activate_spanish_modal = true;
533
534                            // Make an exception for bundling (general)
535                            if (action == "https://sales.geico.com" && $(".staticBundle", this).length == 0) {
536                                _activate_spanish_modal = false; 
537                            }
538
539                            // Make an exception for bundling (homepage)
540                            if (action == "https://sales.geico.com" && $('#bundle_modal input[name="lob"]').length) {
541                                if ($('#bundle_modal input[name="lob"]').attr('value').indexOf(",") == -1) {
542                                    _activate_spanish_modal = false;
543                                } else {
544                                    _activate_spanish_modal = true;
545                                }
546                            }
547                            if (_activate_spanish_modal) {
548                                event.preventDefault();
549                                updateDTM('pageItem', 'Static:Spanish:QuoteModal');
550                            }
551
552                            //if data-quote-start attribute was set, move the original attribute value to the modal CTA, else remove the attribute (may have been added by previously opened instances of the modal)
553                            if (typeof data_quote_start !== 'undefined' && data_quote_start !== false) {
554                                $('#spanish_internal_quote_modal .modal--call-to-action-bar .btn--primary').attr('data-quote-start', data_quote_start);
555                            }
556                            else {
557                                $('#spanish_internal_quote_modal .modal--call-to-action-bar .btn--primary').removeAttr('data-quote-start');
558                            }
559
560                            //if the product supports Spanish, show the Spanish support text
561                            var modal_spanish_support = [
562                                'homeowners',
563                                'boat',
564                                'motorcycle',
565                                'renters'
566                            ];
567                            var modal_spanish_business = [
568                                'business'
569                            ];
570                            $('#spanish_internal_quote_modal .es_addendum').hide();
571                            if (modal_spanish_support.indexOf(data_quote_start) !== -1) {
572                                $('#spanish_internal_quote_modal .es_addendum.es_default').show();
573                            } else if (modal_spanish_business.indexOf(data_quote_start) !== -1) {
574                                $('#spanish_internal_quote_modal .es_addendum.es_business').show();
575                            }
576
577                            //if form action is ecams or contains "login" (commercial/rideshare), save the original onclick event (in case it was modified, like from the homepage) and set it back to the default "spanishModalSubmitForm(
577)"
578                            if(action.toLowerCase().indexOf('ecams') !== -1 || action.toLowerCase().indexOf('login') !== -1 ){
579                                onclick_orig = $('#spanish_internal_quote_modal .modal--call-to-action-bar .btn--primary').attr('onclick');
580
581                                $('#spanish_internal_quote_modal .modal--call-to-action-bar .btn--primary')
582                                    .attr('onclick', 'spanishModalSubmitForm()');
583
584                                //add click event to close button & clicks off of modal  to reset onclick attribute
585                                $('#spanish_internal_quote_modal, #spanish_internal_quote_modal .btn-close').click(function(){
586                                    $('#spanish_internal_quote_modal .modal--call-to-action-bar .btn--primary')
587                                    .attr('onclick', onclick_orig);
588                                });
589
590                                //stop propagation for clicks inside the modal that do not close it
591                                $('#spanish_internal_quote_modal .modal-container').click(function(event){
592                                  event.stopPropagation();
593                                });
594                            }
595
596                            // get the parent form and save it to a global variable to submit from spanishModalSubmitForm()
597                            window['spanishModalParentForm'] = $(this).parents('form');
598                        });
599                    } else {
600                        $('input[type="submit"], button[type="submit"]', this)
601                            .removeClass('modal-trigger')
602                            .removeAttr('data-modal-view');
603                    }
604                }
605            }
606        });
607
608        // Apply to Claims/B2B/Roadside links
609        var claimslinks = 'a[href*="https://claims.geico.com"], a[href*="https://geico.app.link/static"], a[href*="https://geico.app.link/Static"], a[href*="https://partners.geico.com/"], a[href*="https://propertysales.geico.com/MCRForm/Home/Index"], .bottom-content .quick-links .navigational-box-wrapper.spanish-claims-modal';
610        if ($(claimslinks).length > 0) {
611            internal_forms = true;
612            $(claimslinks).each(function() {
613                $(this).addClass('modal-trigger')
614                    .attr('data-modal-view', 'spanish_claims_modal');
615                $(this).click(function(e) {
616                    e.preventDefault();
617                    if ($(this).is('a')) {
618                        $('#spanish_claims_modal .modal-continue').attr('href', $(this).attr('href'));
619                    } else {
620                        $('#spanish_claims_modal .modal-continue').attr('href', $(this).find('a').attr('href'));
621                    }
622                });
623            });
624        }
625
626        //bind modal triggers if at least one internal form is found on Spanish page
627        if(internal_forms){
628            bind_modal_triggers();
629        }
630    }
631}
632
633function spanishModalSubmitForm() {
634    if (window['spanishModalParentForm']) {
635        window['spanishModalParentForm'].submit();
636    } else {
637        submitZip();
638    }
639}
640
641// quote submission script
642function submitZip() {
643
644    // if on default homepage, call logQuoteButton() function from homepage.js
645    if($('#primary-panel.quote').length){
646        logQuoteButton();
647    }
648    
649    //Cookie Code
650    if (document.cookie.indexOf("V5page") != -1) {
651        //unset prior cookie
652        document.cookie = 'V5page=; expires=09/09/1999 00:00:00';
653    }
654
655    if (document.cookie.indexOf("V5app") != -1) {
656        //unset prior cookie
657        document.cookie = 'V5app=; expires=09/09/1999 00:00:00';
658    }
659
660    var D = get_cookie_domain();
661
662
663    var path = escape(window.location.pathname);
664    for (var l = 0; l < path.length; l++) {
665        path = path.replace("/", "%2F");
666        path = path.replace("+", "%2B");
667    }
668
669    var d = new Date();
670    var today = new Date();
671    var type = null;
672
673    document.cookie = 'V5page=FormPage=' + path + '; expires=' + d.toGMTString(d.setTime(today.getTime() + 30000)) + '; path=/; domain=' + D;
674    if (document.getElementById('insurancetype') !== null) {
675        document.cookie = 'V5app=SelectedApp=' + document.getElementById('insurancetype').value + '; expires=' + d.toGMTString(d.setTime(today.getTime() + 30000)) + '; path=/; domain=' + D;
676        // Form submission
677        type = document.getElementById('insurancetype').value;
678    }
679
680    var isZipValid = false;
681    isZipValid = checkZip();
682    if (!IsNumeric(document.getElementById('zip').value)) {
683        document.getElementById('zip').value = '';
684    }
685
686    var send_reply = false;
687    var choiceID = null;
688    //reply() event
689    if (document.cookie.indexOf('static_site_case_id') != -1 && document.getElementById('choiceId') != null) {
690        send_reply = true;
691        choiceID = document.getElementById('choiceId').value;
692    }
693    
694    switch (type) {
695        case "auto":
696            //Auto
697            document.getElementById('zip').name = "POL_ratedZip5";
698            document.getElementById('quoteForm').method = "get";
699            document.getElementById('quoteForm').action = "https://sales.geico.com";
700            if (send_reply == true && choiceID != null) { reply(choiceID, 'Auto', 'quoteForm'); }
701            break;
702
703        case "motorcycle":
704            //Motorcycle
705            document.getElementById('zip').name = "POL_ratedZip5";
706            document.getElementById('quoteForm').method = "get";
707            document.getElementById('quoteForm').action = "https://sales.geico.com/?lob=cycle";
708            if (send_reply == true && choiceID != null) { reply(choiceID, 'Moto', 'quoteForm'); }
709            break;
710
711        case "atv":
712            //ATV
713            document.getElementById('zip').name = "POL_ratedZip5";
714            document.getElementById('quoteForm').method = "get";
715            document.getElementById('quoteForm').action = "https://sales.geico.com/?lob=cycle";
716            if (send_reply == true && choiceID != null) { reply(choiceID, 'Atv', 'quoteForm'); }
717            break;
718
719        case "home":
720            //Home
721
722            //route all traffic to SSP if flag is set
723            if ($('html').attr('data-homeowners-ssp') == '1') {
724                document.getElementById('zip').name = "POL_ratedZip5";
725                document.getElementById('quoteForm').method = "get";
726                document.getElementById('quoteForm').action = "https://sales.geico.com";
727                document.getElementById('optionHome').value = "homeowners";
728                document.getElementById('insurancetype').name = "lob";
729            }
730            else {
731                document.getElementById('quoteForm').method = "get";
732                document.getElementById('quoteForm').action = "https://propertysales.geico.com/Landing";
733                document.getElementById('zip').name = "zip";
734
735                if (document.getElementById('zip').value !== '') {
736                    if (_isContains(florida_zipcodes, document.getElementById('zip').value)) {
737                        if (typeof _gtm !== 'undefined') {
738                            _gtm.track("flZip");
739                        }
740                        var zipValue = document.getElementById('zip').value;
741                        setTimeout(() => {
742                            window.location = 'https://home.homesite.com/gco/sales/index.htm?product=home&zip=' + zipValue;
743                        }, 500);
744                        // Prevent form submission by returning early
745                        if (send_reply == true && choiceID != null) { reply(choiceID, 'HO', 'quoteForm'); }
746                        return;
747                    }
748                    else {
749                        document.getElementById('optionHome').value = "0";
750                        document.getElementById('quoteForm').action += "/StartQuote";
751                    }            
752                } else {
753                    document.getElementById('optionHome').value = "Homeowners";
754                    document.getElementById('insurancetype').name = "lob";
755                }
756            }
757            if (send_reply == true && choiceID != null) { reply(choiceID, 'HO', 'quoteForm'); }
758            break;
759
760        case "renters":
761            //Renters
762            document.getElementById('quoteForm').method = "get";
763            document.getElementById('quoteForm').action = "https://propertysales.geico.com/Landing";
764            document.getElementById('zip').name = "zip";
765
766            if(document.getElementById('zip').value !== '') {
767                document.getElementById('optionHome').value = "1";
768                document.getElementById('quoteForm').action += "/StartQuote";
769            } else {
770                document.getElementById('optionHome').value = "Renters";
771                document.getElementById('insurancetype').name = "lob";
772            }
773            if (send_reply == true && choiceID != null) { reply(choiceID, 'Rent', 'quoteForm'); }
774            break;
775
776        case "condo":
777            //Condo
778            document.getElementById('quoteForm').method = "get";
779            document.getElementById('quoteForm').action = "https://propertysales.geico.com/Landing";
780            document.getElementById('zip').name = "zip";
781
782            if(document.getElementById('zip').value !== '') {
783                document.getElementById('optionHome').value = "2";
784                document.getElementById('quoteForm').action += "/StartQuote";
785            } else {
786                document.getElementById('optionHome').value = "Condo";
787                document.getElementById('insurancetype').name = "lob";
788            }
789            if (send_reply == true && choiceID != null) { reply(choiceID, 'Condo', 'quoteForm'); }
790            break;
791
792        case "mobilehome":
793            //Mobile Home
794            document.getElementById('quoteForm').action = "/mobile-home-insurance/";
795            break;
796
797        case "boat":
798            //Boat
799            document.getElementById('zip').name = "POL_ratedZip5";
800            document.getElementById('quoteForm').method = "get";
801            document.getElementById('quoteForm').action = "https://sales.geico.com/?lob=boat";
802            if (send_reply == true && choiceID != null) { reply(choiceID, 'Boat', 'quoteForm'); }
803            break;
804
805        case "rv":
806            //RV
807            document.getElementById('quoteForm').method = "get";
808            document.getElementById('insurancetype').name = "lob";
809            document.getElementById('zip').name = "POL_ratedZip5";
810            document.getElementById('optionRV').value = "recreationalvehicle";
811            document.getElementById('quoteForm').action = "https://sales.geico.com/";
812            break;
813
814        case "life":
815            //Life
816            document.getElementById('quoteForm').method = "get";
817            document.getElementById('quoteForm').action = "https://propertysales.geico.com/Landing/?";
818            break;
819
820        case "umbrella":
821            //Umbrella
822            document.getElementById('quoteForm').action = "/umbrella-insurance/";
823            if (send_reply == true && choiceID != null) { reply(choiceID, 'Umb', 'quoteForm'); }
824            break;
825
826        case "cyberliability":
827            //Cyber Liability
828            document.getElementById('quoteForm').action = "/cyber-liability-insurance/";
829            if (send_reply == true && choiceID != null) { reply(choiceID, 'Cyber', 'quoteForm'); }
830            break;
831
832        case "idtheft":
833            //ID Theft
834            document.getElementById('quoteForm').action = "https://propertysales.geico.com/Landing?lob=IdentityTheft";
835            break;
836
837        case "landlord":
838            //Landlord
839            document.getElementById('quoteForm').action = "/landlord-insurance/";
840            break;
841
842        case "flood":
843            //Flood
844            document.getElementById('quoteForm').method = "get";
845            document.getElementById('quoteForm').action = "https://www.assurantfloodport.com/assurantagency/FloodHome.jhtml?agencyId=70277";
846            break;
847
848        case "travel":
849            //Travel
850            document.getElementById('quoteForm').action = "/travel-insurance/";
851            break;
852
853        case "overseas":
854            //Overseas
855            document.getElementById('quoteForm').action = "/overseas-insurance/";
856            if (send_reply == true && choiceID != null) { reply(choiceID, 'Sea', 'quoteForm'); }
857            break;
858
859        case "business":
860            //Business Owners
861            document.getElementById('quoteForm').method = "get";
862            document.getElementById('quoteForm').action = "https://commercial.geico.com/business-insurance/";
863            break;
864
865        case "businessowners":
866            //Business Owners
867            document.getElementById('quoteForm').method = "get";
868            document.getElementById('quoteForm').action = "https://commercial.geico.com/business-insurance/";
869            break;
870
871        case "general":
872            //General Liability
873            document.getElementById('quoteForm').method = "get";
874            document.getElementById('quoteForm').action = "https://commercial.geico.com/business-insurance/";
875            break;
876
877        case "professional":
878            //Professional Liability
879            document.getElementById('quoteForm').method = "get";
880            document.getElementById('quoteForm').action = "https://commercial.geico.com/business-insurance/";
881            break;
882
883        case "workerscompensation":
884            //Workers' Compensation
885            document.getElementById('quoteForm').method = "get";
886            document.getElementById('quoteForm').action = "https://www.biberk.com/get-a-quote/geico-workers-compensation-insurance";
887            break;
888
889        case "medicalmalpractice":
890            //Medical Malpractice
891            document.getElementById('quoteForm').method = "get";
892            document.getElementById('quoteForm').action = "https://www.berxi.com/partners/geico/";
893            break;
894
895        case "wellnessfitness":
896            //Wellness & Fitness
897            document.getElementById('quoteForm').method = "get";
898            document.getElementById('quoteForm').action = "https://www.berxi.com/partners/geicowellness/";
899            break;
900
901        case "commercial":
902            //Commercial
903            document.getElementById('quoteForm').method = "get";
904            document.getElementById('quoteForm').action = "https://commercial.geico.com/business-insurance/";
905            break;
906
907        case "collector":
908            //Collector auto
909            document.getElementById('quoteForm').action = "/collector-auto-insurance/";
910            break;
911
912        case "pet":
913            //Pet
914            document.getElementById('quoteForm').method = "get";
915            document.getElementById('quoteForm').action = "https://propertysales.geico.com/Landing/?";
916            break;
917        
918        case "mobiledevice":
919            //Mobile device
920            document.getElementById('quoteForm').action = "/mobile-device-protection/";
921            break;
922        
923        case "earthquake":
924            //Earthquake
925            document.getElementById('quoteForm').action = "https://www.bequakesafe.com/?lead=geico";
926            break;
927        
928        case "event":
929            //Event insurance
930            document.getElementById('quoteForm').action = "https://www.markelinsurance.com/event/geico";
931            break;
932        
933        case "jewelry":
934            //Jewelry
935            document.getElementById('insurancetype').name = "lob";
936            document.getElementById('optionJewelry').value = "personalarticles";
937            document.getElementById('quoteForm').action = "https://propertysales.geico.com/Landing?lob=personalarticles";
938            break;
939        
940        case "mexicoAuto":
941            //Mexico auto
942            document.getElementById('quoteForm').method = "get";
943            document.getElementById('quoteForm').action = "https://geico.app.mexicoinsuranceonline.com/en-US/quotes/new#/";
944            break;  
945
946        case "bicycle":
947            //Bicycle
948            document.getElementById('quoteForm').action = "https://www.markelinsurance.com/bicycle/geico";
949            break;
950    }
951
952    if (isZipValid == true && send_reply == false) {
953        
954        if ($(".checkbox-bundle input[type='checkbox']").is(":checked") ) {
955            $("input.staticBundle").attr('value', 'true');
956        } else {
957            false;
958        }
959
960        document.getElementById('quoteForm').submit();
961    }
962}
963
964// show/hide the zip fields and recall link for each product, format disclaimer for external products
965function format_quote_form(product, homepage) {
966    if (homepage == true) {
967        type = product;
968        var product_name = product;
969        var zip_elements = $('#quoteForm p, #quoteForm .form-field.geozip');
970        format_hp_actions();
971    } else {
972        type = product.val();
973        var product_name = $(product).find("option:selected").text().toLowerCase();
974        var zip_elements = $('label[for="zip"], input[id="zip"], #zipBox, #geolocation, #zipcode_wrapper');
975    }
976
977    var product_inputs = '';
978    var recall_link = $('#recall_link');
979    var recall_dropdown = $('#recallProduct');
980    var submit_btn = $("#quoteForm #submitButton");
981
982    var internal_type = 'internal';
983    if($('html').attr('lang') == 'es-US' && type != "auto"){
984        internal_type = 'internal_spanish';
985    }
986
987    $('.insurance-text').show();
988
989    //for external products, use format_dislcaimer(property, product_company, product_name { options })  
990    switch (type) {
991        case "auto":
992            zip_elements.show();
993            recall_link.show();
994            recall_dropdown.val(type).change();
995            format_disclaimer(internal_type);
996            break;
997
998        case "motorcycle":
999            zip_elements.show();
1000            recall_link.show();
1001            recall_dropdown.val(type).change();
1002            product_inputs += '<input type="hidden" name="lob" value="cycle">';
1003            format_disclaimer(internal_type, '', '', { extra_inputs: product_inputs });
1004            break;
1005
1006        case "atv":
1007            zip_elements.show();
1008            recall_link.show();
1009            recall_dropdown.val(type).change();
1010            product_inputs += '<input type="hidden" name="lob" value="cycle">';
1011            format_disclaimer(internal_type, '', '', { extra_inputs: product_inputs });
1012            break;
1013
1014        case "home":
1015            zip_elements.show();
1016            recall_link.show();
1017            recall_dropdown.val(type).change();
1018            format_disclaimer(internal_type);
1019            break;
1020
1021        case "renters":
1022            zip_elements.show();
1023            recall_link.show();
1024            recall_dropdown.val(type).change();
1025            format_disclaimer(internal_type);
1026            break;
1027
1028        case "condo":
1029            zip_elements.show();
1030            recall_link.show();
1031            recall_dropdown.val(type).change();
1032            format_disclaimer(internal_type);
1033            break;
1034
1035        case "mobilehome":
1036            zip_elements.hide();
1037            recall_link.hide();
1038            format_disclaimer(internal_type);
1039            format_hp_actions('none', 'none');
1040            break;
1041
1042        case "boat":
1043            zip_elements.show();
1044            recall_link.show();
1045            recall_dropdown.val(type).change();
1046            product_inputs += '<input type="hidden" name="lob" value="boat">';
1047            format_disclaimer(internal_type, '', '', { extra_inputs: product_inputs });
1048            break;
1049
1050        case "rv":
1051            zip_elements.hide();
1052            recall_link.hide();
1053            format_disclaimer(internal_type);
1054            format_hp_actions('none', 'none');
1055            break;
1056
1057        case "life":
1058            zip_elements.show();
1059            recall_link.hide();
1060            format_disclaimer('external', 'Fidelity Life Association and eFinancial, LLC and Ladder Insurance Services, LLC', product_name );
1061            format_hp_actions(false, 'none');
1062            break;
1063
1064        case "earthquake":
1065            zip_elements.hide();
1066            recall_link.hide();
1067            format_disclaimer('external', 'Be Quake Safe', product_name);
1068            format_hp_actions('none', 'none');
1069            break;
1070
1071        case "event":
1072            zip_elements.hide();
1073            recall_link.hide();
1074            format_disclaimer('external', 'Markel', product_name);
1075            format_hp_actions('none', 'none');
1076            break;
1077
1078        case "umbrella":
1079            zip_elements.hide();
1080            recall_link.hide();
1081            format_disclaimer(internal_type);
1082            format_hp_actions('none', 'none');
1083            break;
1084
1085        case "cyberliability":
1086            zip_elements.hide();
1087            recall_lin
1087k.hide();
1088            format_disclaimer(internal_type);
1089            format_hp_actions('none', 'none');
1090            break;
1091
1092        case "idtheft":
1093            zip_elements.hide();
1094            recall_link.hide();
1095            format_disclaimer(internal_type);
1096            $('.insurance-text').hide();
1097            format_hp_actions('none', 'none');
1098            break;
1099
1100        case "landlord":
1101            zip_elements.hide();
1102            recall_link.hide();
1103            format_disclaimer(internal_type);
1104            format_hp_actions('none', 'none');
1105            break;
1106
1107        case "flood":
1108            zip_elements.hide();
1109            recall_link.hide();
1110            product_inputs += '<input type="hidden" name="agencyId" value="70277">';
1111            format_disclaimer('external', 'Assurant Special Property', product_name, { extra_inputs: product_inputs });
1112            format_hp_actions('none', 'none');
1113            break;
1114
1115        case "overseas":
1116            zip_elements.hide();
1117            recall_link.hide();
1118            format_disclaimer(internal_type);
1119            format_hp_actions('none', 'none');
1120            break;
1121
1122        case "travel":
1123            zip_elements.hide();
1124            recall_link.hide();
1125            format_disclaimer(internal_type);
1126            format_hp_actions('none', 'none');
1127            break;
1128
1129        case "businessowners":
1130            zip_elements.show();
1131            recall_link.hide();
1132            product_inputs += '<input type="hidden" name="product" value="BOP">';
1133            format_disclaimer(internal_type, '', '', { extra_inputs: product_inputs, zip_name: 'zipcode' });
1134            format_hp_actions('none', 'none');
1135            break;
1136
1137        case "workerscompensation":
1138            zip_elements.hide();
1139            recall_link.hide();
1140            product_inputs += '<input type="hidden" value="geicowc" name="a">';
1141            format_disclaimer('external', 'biBERK, a Berkshire Hathaway company', 'workers\' compensation', { extra_inputs: product_inputs });
1142            format_hp_actions('none', 'none');
1143            break;
1144
1145        case "medicalmalpractice":
1146            zip_elements.hide();
1147            recall_link.hide();
1148            format_disclaimer('external', 'Berxi, a division of Berkshire Hathaway Specialty Insurance company', 'medical malpractice', { extra_inputs: product_inputs });
1149            format_hp_actions('none', 'none');
1150            break;
1151
1152        case "wellnessfitness":
1153            zip_elements.hide();
1154            recall_link.hide();
1155            format_disclaimer('external', 'Berxi, a division of Berkshire Hathaway Specialty Insurance company', 'wellness & fitness', { extra_inputs: product_inputs });
1156            format_hp_actions('none', 'none');
1157            break;
1158
1159        case "general":
1160            zip_elements.show();
1161            recall_link.hide();
1162            product_inputs += '<input type="hidden" name="product" value="GL">';
1163            format_disclaimer(internal_type, '', '', { extra_inputs: product_inputs, zip_name: 'zipcode' });
1164            format_hp_actions('none', 'none');
1165            break;
1166
1167        case "professional":
1168            zip_elements.show();
1169            recall_link.hide();
1170            product_inputs += '<input type="hidden" name="product" value="PL">';
1171            format_disclaimer(internal_type, '', '', { extra_inputs: product_inputs, zip_name: 'zipcode' });
1172            format_hp_actions('none', 'none');
1173            break;
1174
1175        case "commercial":
1176            zip_elements.show();
1177            recall_link.show();
1178            recall_dropdown.val(type).change();
1179            product_inputs += '<input type="hidden" name="product" value="CAU">';
1180            format_disclaimer(internal_type, '', '', { extra_inputs: product_inputs, zip_name: 'zipcode' });
1181            break;
1182
1183        case "business":
1184            recall_dropdown.val(type).change();
1185            break;
1186
1187        case "collector":
1188            zip_elements.hide();
1189            recall_link.hide();
1190            format_disclaimer(internal_type);
1191            format_hp_actions('none', 'none');
1192            break;
1193
1194        case "pet":
1195            zip_elements.show();
1196            recall_link.hide();
1197            format_disclaimer('external', 'Embrace', product_name );
1198            format_hp_actions(false, 'none');
1199            break;
1200
1201        case "mobiledevice":
1202            zip_elements.hide();
1203            recall_link.hide();
1204            format_disclaimer(internal_type);
1205            format_hp_actions('none', 'none');
1206            break;
1207
1208        case "jewelry":
1209            zip_elements.hide();
1210            recall_link.hide();
1211            format_disclaimer(internal_type);
1212            format_hp_actions('none', 'none');
1213            break;
1214
1215        case "mexicoAuto":
1216            zip_elements.hide();
1217            recall_link.hide();
1218            format_disclaimer('external', 'International Insurance Group, Inc.', 'Mexico auto');
1219            format_hp_actions('none', 'none');
1220            break;
1221
1222        case "cellPhone":
1223            zip_elements.hide();
1224            recall_link.hide();
1225            product_inputs += '<input type="hidden" name="utm_source" value="site">';
1226            product_inputs += '<input type="hidden" name="utm_medium" value="propcas">';
1227            product_inputs += '<input type="hidden" name="utm_campaign" value="geico_geico_static1">';
1228            format_disclaimer('external', 'Assurant', product_name, { extra_inputs: product_inputs });
1229            format_hp_actions(false, 'none');
1230            break;
1231
1232        case "bicycle":
1233            zip_elements.hide();
1234            recall_link.hide();
1235            format_disclaimer('external', 'Markel', product_name);
1236            format_hp_actions('none', 'none');
1237            break;
1238
1239        default:
1240            zip_elements.show();
1241            recall_link.show();
1242            format_disclaimer(internal_type);
1243    }
1244}
1245
1246function format_hp_actions(submit_button, agents_link) {
1247    if ($(document).width() >= 768) {
1248        $('#primary-panel .quote-form .submitButton, #primary-panel .quote-form #submitButton').css({ 'float': 'right' });
1249        $('#primary-panel #additional_links #agents_link').css({ 'float': 'right' });
1250    } else {
1251        $('#primary-panel .quote-form .submitButton, #primary-panel .quote-form #submitButton').css({ 'float': 'none' });
1252        $('#primary-panel #additional_links #agents_link').css({ 'float': 'none' });
1253    }
1254
1255    if (submit_button != false) {
1256        $('#primary-panel .quote-form .submitButton, #primary-panel .quote-form #submitButton').css({ 'float': submit_button });
1257    }
1258
1259    if (agents_link != false) {
1260        $('#primary-panel #additional_links #agents_link').css({ 'float': agents_link });
1261    }
1262}
1263
1264// Disclaimer if quote product goes to external site
1265function format_disclaimer(property, company, product_name, options) {
1266
1267    //optional arguments
1268    //zip_name used if the name of #quoteForm #zip input needs to be changed (default name = 'zip')
1269    //extra_inputs used if the product requires extra hidden parameters for tracking a sale (default value = '')
1270    var options = options || {};
1271    var zip_name = options.zip_name || 'zip';
1272    var extra_inputs = options.extra_inputs || '';
1273
1274    //variables for data-quote-start tracking
1275    var selected_product = $('#quoteForm select').find('option:selected').val();
1276
1277    //check for products that should no longer be sending in "insurancetype" param
1278    var noInsuranceType = ['atv', 'boat', 'motorcycle'];
1279    if(noInsuranceType.includes(selected_product)){
1280        $('#insurancetype').removeAttr('name');
1281    }
1282    else {
1283        $('#insurancetype').attr('name', 'insurancetype');
1284    }
1285
1286    if (property == 'external') {
1287        //rename zip input if necessary
1288        $("#quoteForm #zip").attr('name', zip_name);
1289
1290        //add any extra form inputs needed for quoting the product
1291        $("#product_inputs").html(extra_inputs);
1292
1293        //switch out geico company name based on product (if more exceptions are needed move this to format_quote_form switch cases and pass in as new variable to format_disclaimer)
1294        geico_company = 'GEICO Insurance Agency, Inc.';
1295
1296        //format disclaimer text with product and company names and set data-quote-start tracking
1297        $("#external_disclaimer_quote_modal .geico_company").text(geico_company);
1298        $("#external_disclaimer_quote_modal .external_company").text(company);
1299        $("#external_disclaimer_quote_modal .external_product").text(product_name);
1300        $("#external_disclaimer_quote_modal").attr('data-product', product_name);
1301        $("#external_disclaimer_quote_modal .btn--primary").attr('data-quote-start', 'offsite-'+selected_product);
1302
1303        //update submit button to be a modal trigger and set data-quote-start tracking
1304        $(".submitButton, #submitButton")
1305            .addClass('modal-trigger')
1306            .attr({
1307                'onclick': 'event.preventDefault();',
1308                'data-modal-view': 'external_disclaimer_quote_modal',
1309                'data-quote-start': 'modal-offsite-'+selected_product
1310            });
1311
1312        bind_modal_triggers();
1313
1314        //update #quoteForm #zip input keypress event to show modal for enter key
1315        $("#quoteForm #zip").removeAttr('onkeypress').keypress(function(event) {
1316            if (event.which == 10 || event.which == 13) {
1317                event.preventDefault();
1318                if(checkZip()) {
1319                    event.preventDefault();
1320                    external_disclaimer_quote_modal.show();
1321                }
1322                else {
1323                    $("#quoteForm #zip").addClass('err').focus();
1324                    $('.form-field--error').css('display','block');
1325                }
1326            }
1327            else{
1328                $("#quoteForm #zip").removeClass('err');
1329                $('.form-field--error').css('display','none');
1330            }
1331        });
1332    } else if (property == 'internal_spanish') {
1333        //rename zip input if necessary
1334        $("#quoteForm #zip").attr('name', zip_name);
1335
1336        //add any extra form inputs needed for quoting the product
1337        $("#product_inputs").html(extra_inputs);
1338
1339        //set data-quote-start tracking attribute in spanish modal
1340        $("#spanish_internal_quote_modal .btn--primary").attr('data-quote-start', selected_product);
1341
1342        //update submit button to be a modal trigger and set data-quote-start tracking
1343        $(".submitButton, #submitButton")
1344            .addClass('modal-trigger')
1345            .attr({
1346                'onclick': 'event.preventDefault();',
1347                'data-modal-view': 'spanish_internal_quote_modal',
1348                'data-quote-start': 'modal-spanish-'+selected_product
1349            });
1350
1351        bind_modal_triggers();
1352
1353        //update #quoteForm #zip input keypress event to show modal for enter key
1354        $("#quoteForm #zip").removeAttr('onkeypress').keypress(function(event) {
1355            if (event.which == 10 || event.which == 13) {
1356                event.preventDefault();
1357                if(checkZip()) {
1358                    event.preventDefault();
1359                    spanish_internal_quote_modal.show();
1360                }
1361                else {
1362                    $("#quoteForm #zip").addClass('err').focus();
1363                    $('.form-field--error').css('display','block');
1364                }
1365            }
1366            else{
1367                $("#quoteForm #zip").removeClass('err');
1368                $('.form-field--error').css('display','none');
1369            }
1370        });    
1371    } else {
1372        //rename zip input if necessary
1373        $("#quoteForm #zip").attr('name', zip_name);
1374
1375        //add any extra form inputs needed for quoting the product
1376        $("#product_inputs").html(extra_inputs);
1377
1378        //reset product and company names in disclaimer text, reset data=quote-start tracking attribute
1379        $("#external_disclaimer_quote_modal .geico_company").empty();
1380        $("#external_disclaimer_quote_modal .external_company").empty();
1381        $("#external_disclaimer_quote_modal .external_product").empty();
1382        $("#external_disclaimer_quote_modal .btn--primary").attr('data-quote-start', '');
1383
1384        //reset submit button to submit form, set data-quote-start tracking, unbind from modal events
1385        $(".submitButton, #submitButton")
1386            .removeClass('modal-trigger')
1387            .attr({
1388                'onclick': 'submitZip();',
1389                'data-modal-view': '',
1390                'data-quote-start': selected_product
1391            })
1392            .unbind('click');
1393
1394        //reset #quoteForm #zip input keypress event, unbind from keypress listener
1395        $("#quoteForm #zip").attr('onkeypress', 'keypressZip(event)').unbind('onkeypress');
1396    }
1397
1398}
1399
1400// Margin quote box - update button label with product name
1401function update_quote_button_text(product) {
1402    var labels = new Object;
1403    labels.auto = "Auto";
1404    labels.motorcycle = "Cycle";
1405    labels.atv = "ATV";
1406    labels.home = "Home";
1407    labels.renters = "Renters";
1408    labels.condo = "Condo";
1409    labels.boat = "Boat";
1410    labels.rv = "RV";
1411    labels.umbrella = "Umbrella";
1412    labels.landlord = "Landlord";
1413    labels.flood = "Flood";
1414    labels.travel = "Travel";
1415    labels.overseas = "Overseas";
1416    labels.pet = "Pet";
1417    labels.jewelry = "Jewelry";
1418    labels.cyberliability = "Cyberliability";
1419    labels.earthquake = "Earthquake";
1420    labels.event = "Event";
1421
1422    if (labels[product] !== undefined) {
1423        $(".submitButton, #submitButton").html("Look at " + labels[product] + " Quote &rarr;");
1424    } else {
1425        $(".submitButton, #submitButton").html("Look at Quote &rarr;");
1426    }
1427}
1428
1429
1430// Recall popup
1431function recallWindow() {
1432    var recallProduct = document.getElementById('recallProduct').value;
1433    switch (recallProduct) {
1434        case 'auto':
1435        case 'boat':
1436        case 'motorcycle':
1437        case 'atv':
1438        case 'rv':
1439            window.location = 'https://sales.geico.com/recall';
1440            break;
1441        case 'home':
1442        case 'renters':
1443        case 'condo':
1444            window.location = 'https://propertysales.geico.com/Account/';
1445            break;
1446        case 'commercial':
1447        case 'business':
1448            window.location = 'https://sales.geico.com/?quotesearch=true';
1449            break;
1450    }
1451}
1452
1453function keypressZip(e) {
1454    if (e.which == 10 || e.which == 13) {
1455        e.preventDefault();
1456        if(checkZip()) {
1457            submitZip();
1458        }
1459        else {
1460            $("#zip").addClass('err').focus();
1461            $('.form-field--error').css('display','block');
1462        }
1463    }
1464    else{
1465        $('.form-field--error').css('display','none');
1466        $("#zip").removeClass('err');
1467    }
1468}
1469
1470
1471function IsNumeric(inputString) {
1472    var validChars = "0123456789";
1473
1474    for (i = 0; i < inputString.length; i++) {
1475        if (validChars.indexOf(inputString.charAt(i)) < 0) {
1476            return false;
1477        }
1478    }
1479    return inputString.length == 0 ? false : true;
1480}
1481
1482// service disable multiple submissions (each ecams login form has its own guard; reset after bfcache back)
1483(function () {
1484    var ecamsLoginAction = 'https://ecams.geico.com/ecams/login';
1485    function bindEcamsManageFormGuards() {
1486        var forms = document.querySelectorAll('form[action="' + ecamsLoginAction + '"]');
1487        Array.prototype.forEach.call(forms, function (form) {
1488            if (form.getAttribute('data-ecams-guard-bound') === '1') {
1489                return;
1490            }
1491            form.setAttribute('data-ecams-guard-bound', '1');
1492            form.addEventListener('submit', function (e) {
1493                if (form.getAttribute('data-ecams-submitted') === '1') {
1494                    e.preventDefault();
1495                    return;
1496                }
1497                form.setAttribute('data-ecams-submitted', '1');
1498                if (document.cookie.indexOf('static_site_case_id') != -1) {
1499                    try {
1500                        reply('Service1', 'Service', 'manageForm');
1501                    } catch (eManageSubmit) {
1502                        /* allow form navigation even if reply is missing or throws */
1503                    }
1504                }
1505            });
1506        });
1507    }
1508    bindEcamsManageFormGuards();
1509    window.addEventListener('pageshow', function (ev) {
1510        if (!ev.persisted) {
1511            return;
1512        }
1513        document.querySelectorAll('form[action="' + ecamsLoginAction + '"]').forEach(function (form) {
1514            form.removeAttribute('data-ecams-submitted');
1515        });
1516    });
1517})();
1518
1519// hero layout product pages toggle
1520$('.hero-toggle-button').on('click', function() {
1521    $('.hero-wrapper').addClass('hadopened');
1522    $('.hero-wrapper').toggleClass('login');
1523});
1524
1525
1526function geo_lookup_error() {
1527    $("#primary-navigation .panel-wrapper.location").css("height", "29rem");
1528    $(".geo-box .geo-alert").show();
1529}
1530
1531$(document).ready(function() {
1532    $('.lang-toggle').click(function(e) {
1533        updateDTM('generalAction','Static:Language:ChangeTo'+ $(this).text());
1534    });
1535
1536    if($('#primary-navigation .panel-wrapper.account .location .geo-info').text() != '') {
1537        $('#primary-navigation .panel-wrapper.account #user-location').css('display','block');
1538        $('#primary-navigation .panel-wrapper.account .location form').css('display', 'none');
1539    }
1540    $('.change-location').click(function(e) {
1541        $('#geo-box').slideToggle();
1542    });
1543
1544    //override the submit button for relocation
1545    $("form.geo-box").submit(function(e) {
1546        e.preventDefault();
1547
1548        geo_box_id = this.id;
1549        
1550        zip_lookup = { zip_code: $('#' + geo_box_id + ' .user-zip').val() };
1551
1552        $.ajax({
1553            async: true,
1554            cache: false,
1555            url: "/public/php/geo_data.php",
1556            data: zip_lookup,
1557            success: function(data) {
1558                if (data['zip'] == null || data['state'] == null) {
1559                    geo_lookup_error();
1560                    $('#' + geo_box_id + ' .user-zip').focus();
1561                } else {
1562                    user_zip = data['zip'];
1563                    user_state = data['state'];
1564                    
1565                    set_geo_cookie(user_state, user_zip)
1566                }
1567            },
1568            error: function() {
1569                geo_lookup_error();
1570            },
1571            timeout: 5000,
1572        });
1573        $('#primary-navigation .panel-wrapper.account #user-location').css('display','block');
1574        $('#geo-box').slideToggle();
1575    });
1576
1577    if (navigator.geolocation) {
1578        $('#nav-geolocation').click(function(e) {
1579            e.preventDefault();
1580
1581            navigator.geolocation.getCurrentPosition(function(position) { 
1582                coords = { latitude: position.coords.latitude.toFixed(2), longitude: position.coords.longitude.toFixed(2) };
1583                
1584                $.ajax({
1585                    async: true,
1586                    cache: false,
1587                    url: "/public/php/geo_data.php",
1588                    data: coords,
1589                    success: function(data) {
1590                        if (data == '') {
1591                            show_error();
1592                        } else {
1593                            set_geo_cookie(data['state'], data['zip']);
1594                        }
1595                    },
1596                    error: function() { 
1597                        //hide geolocation loading marker
1598                        $('.geo-loading-marker').hide(); 
1599                        geo_lookup_error();
1600                    },
1601                    timeout: 5000,
1602                });
1603
1604            });
1605        });
1606    }
1607});
1608
1609//Logs Adobe Analytics Data When CAT Banner is Clicked
1610$(document).ready(function () {
1611    $('#cat_banner a').click(function(){
1612        updateDTM('generalAction', $('#cat_banner').data('dtm-string'));
1613    });
1614});
1615
1616//Modify href attriute
1617document.addEventListener("DOMContentLoaded", function () {
1618    //if mobile_app=true is one of the url parameters, hide header/footer and append mobile_app=true to all <a> elements except tel number, email address, & modal-trigger
1619    param_str = location.href.replace(location.href.split('?')[0] + '?', '');
1620    param_list = param_str.split('&');
1621    param_array = new Array;
1622
1623    if (param_list.length < 2) {
1624        if (param_str.match(/(.+?[^=])=(.*)/i)) {
1625            param_array[RegExp.$1] = RegExp.$2;
1626        }
1627    }
1628    else {
1629        for (_s = 0; _s < param_list.length; _s++) {
1630            if (param_list[_s].match(/(.+?[^=])=(.*)/i)) {
1631                param_array[RegExp.$1] = RegExp.$2;
1632            }
1633        }
1634    }
1635    
1636    isMobile = param_array['mobile_app'];
1637
1638    if (typeof isMobile !== 'undefined') {
1639        isMobile = isMobile.split("#")[0]; //in case there's also an anchor; i.e. geico.com/?mobile_app=true#anchor
1640        if (isMobile == 'true') {
1641
1642            //hide page elements from hybrid view (incl. SF Gabby popup)
1643            $('#primary-header, #breadcrumbs, #primary-footer, gds-dotcom-navigation, gds-dotcom-footer, .gabby-wrapper').hide();
1644            // gds-chat-fab uses shadow DOM; force hide so nothing overrides jQuery .hide()
1645            $('gds-chat-fab').each(function () {
1646                this.setAttribute('hidden', '');
1647                this.style.setProperty('display', 'none', 'important');
1648            });
1649
1650            //remove "Contact Us" link from contact us margin box
1651            $('#margin .box.contactus a[href="/contact-us/"]').contents().unwrap();
1652
1653            //append url parameter to links on page except tel number and email address
1654            $('a').each(function () {
1655                if (($(this).attr("href").indexOf('tel:') == -1) && ($(this).attr("href").indexOf('mailto:') == -1) && (!$(this).hasClass('modal-trigger'))) {
1656                    if ($(this).attr("href").indexOf('?') == -1)
1657                        $(this).attr("href", $(this).attr("href") + "?mobile_app=true");
1658                    else
1659                        $(this).attr("href", $(this).attr("href") + "&mobile_app=true");
1660                }
1661            });
1662
1663            if ($(window).width() < 768) {
1664                $('body').css('padding-top', '0');
1665                $('#wrapper').css('padding-bottom', '0'); //chat hidden in app webview; no FAB clearance
1666            }
1667            else {
1668                $('#wrapper').css('padding-top', '0');
1669                $('.footer-push').css('height', '0');
1670            }
1671            //remove #sticky-banner sticky bar if loaded in mobile app
1672            $(window).scroll(function () {
1673                if ($('#sticky-banner').length > 0) {
1674                    $('#sticky-banner').remove();
1675                }
1676            });
1677        }
1678    }
1679    
1680
1681//update footer urls if user is using a mobile device
1682  if (
1683    navigator.userAgent.match(/Android/i) ||
1684    navigator.userAgent.match(/webOS/i) ||
1685    navigator.userAgent.match(/iPhone/i) ||
1686    navigator.userAgent.match(/iPad/i) ||
1687    navigator.userAgent.match(/iPod/i) ||
1688    navigator.userAgent.match(/BlackBerry/i) ||
1689    navigator.userAgent.match(/Windows Phone/i)
1690  ) {
1691      $('#footer-links-social .icon-facebook').attr('href', 'https://m.facebook.com/geico');
1692      $('#footer-links-social .icon-twitter').attr('href', 'https://mobile.twitter.com/geico');
1693      $('#footer-links-social .icon-youtube').attr('href', 'https://m.youtube.com/geico');
1694  } else {
1695      return false;
1696  }
1697});
1698
1699
1700/*=======================================================================================*/
1701/*                                                                                       */
1702/*  #7707844 09-15-2023                                                                  */
1703/*  Check branch links on the page and look for specific                                 */
1704/*  https://geico.app.link/static/claims OR https://geico.app.link/static/claims/        */
1705/*  (directory level only, not any children underneath)                                  */
1706/*  If found, update url to https://claims.geico.com/ReportClaim#/ for mobile users      */
1707/*                                                                                       */
1708/*=======================================================================================*/
1709
1710$( document ).ready(function() {
1711  var report_claim_mobile_link;
1712  var branch_link_path;
1713
1714  if((location.hostname.indexOf('ut') != -1) || (location.hostname.indexOf('lt') != -1)) {
1715    report_claim_mobile_link = 'https://claimstest.geico.com/ReportClaim#/';
1716    branch_link_path = $('a[href*="geico.test-app.link/static/claims"]');
1717  }
1718  else {
1719    report_claim_mobile_link = 'https://claims.geico.com/ReportClaim#/';
1720    branch_link_path = $('a[href*="geico.app.link/static/claims"]');
1721  }
1722
1723  if(branch_link_path.length > 0){
1724    $(branch_link_path).each(function() {      
1725      var path_check = new URL(this.href).pathname.replace(/\//g,'');
1726      if(path_check == 'staticclaims' && $('html').data('ismobilephone') == '1'){
1727        $(this).attr('href', report_claim_mobile_link);
1728      }
1729    });
1730
1731  } 
1732});
1733
1734// GDS nav & footer 
1735(function () {
1736    var GDS_THEME_COOKIE = 'gdsTheme';
1737    var GDS_THEME_COOKIE_EXPIRES_DAYS = 365 * 100;
1738    var gdsThemeBodyClassApplied = null;
1739    var prefersDarkMql = window.matchMedia ? window.matchMedia('(prefers-color-scheme: dark)') : null;
1740  
1741    function mediaQueryListOnChange(mql, handler) {
1742      if (!mql || typeof handler !== 'function') {
1743        return;
1744      }
1745      if (typeof mql.addEventListener === 'function') {
1746        mql.addEventListener('change', handler);
1747      } else if (typeof mql.addListener === 'function') {
1748        mql.addListener(handler);
1749      }
1750    }
1751  
1752    /** Saved theme on <html> or cookie; when absent, UI can follow system via matchMedia. */
1753    function hasPersistedGdsTheme() {
1754      return !!(getHtmlGdsThemeAttribute() || getGdsThemeCookie());
1755    }
1756  
1757    /**
1758     * Whether the UI should represent “dark” mode.
1759     * Uses cookie/html when set; otherwise a single matchMedia read (no polling).
1760     */
1761    function themeImpliesDark(theme) {
1762      if (theme != null && String(theme).trim() !== '') {
1763        var t = String(theme).trim().toLowerCase();
1764        if (t === 'dark') {
1765          return true;
1766        }
1767        if (t === 'light') {
1768          return false;
1769        }
1770      }
1771      return prefersDarkMql ? prefersDarkMql.matches : false;
1772    }
1773  
1774    /** Match gds-dotcom-theme-toggle: data-gdsTheme wins, then data-gdstheme. */
1775    function getHtmlGdsThemeAttribute() {
1776      var htmlEl = document.documentElement;
1777      var v = htmlEl.getAttribute('data-gdsTheme');
1778      if (v == null || String(v).trim() === '') {
1779        v = htmlEl.getAttribute('data-gdstheme');
1780      }
1781      if (v == null || String(v).trim() === '') {
1782        return null;
1783      }
1784      v = String(v).trim();
1785      return v || null;
1786    }
1787  
1788    /** gds-dotcom-theme-toggle only understands dark | light for its UI state. */
1789    function normalizeThemeForGdsToggle(themeRaw) {
1790      if (themeRaw == null || String(themeRaw).trim() === '') {
1791        return null;
1792      }
1793      var t = String(themeRaw).trim().toLowerCase();
1794      if (t === 'dark') {
1795        return 'dark';
1796      }
1797      if (t === 'light') {
1798        return 'light';
1799      }
1800      return themeImpliesDark(themeRaw) ? 'dark' : 'light';
1801    }
1802  
1803    function dispatchGdsThemeChangedForToggle(themeRaw) {
1804      var toggleTheme = normalizeThemeForGdsToggle(themeRaw);
1805      if (!toggleTheme) {
1806        return;
1807      }
1808      document.dispatchEvent(new CustomEvent('gds-theme-changed', {
1809        detail: { theme: toggleTheme },
1810        bubbles: true,
1811        composed: true
1812      }));
1813    }
1814  
1815    /**
1816     * Legacy nav checkbox + gds-dotcom-theme-toggle (gds-theme-switch).
1817     * On load, prefer gdsTheme cookie so the switch matches the saved cookie.
1818     */
1819    function syncGdsDarkModeSwitch() {
1820      var theme = getGdsThemeCookie() || getHtmlGdsThemeAttribute();
1821      var cb = document.getElementById('darkModeSwitch-button-switch-checkbox');
1822      if (cb) {
1823        cb.checked = themeImpliesDark(theme);
1824      }
1825    }
1826  
1827    function onSystemColorSchemeChange() {
1828      if (hasPersistedGdsTheme()) {
1829        return;
1830      }
1831      syncGdsDarkModeSwitch();
1832    }
1833  
1834    function getGdsThemeCookie() {
1835      if (typeof $.cookie !== 'function') {
1836        return null;
1837      }
1838      var v = $.cookie(GDS_THEME_COOKIE);
1839      if (v == null || v === '') {
1840        return null;
1841      }
1842      v = String(v).trim();
1843      return v || null;
1844    }
1845  
1846    /**
1847     * On load: if gdsTheme cookie is set, mirror it onto <html> (both attributes GDS reads).
1848     */
1849    function applyGdsThemeCookieToHtml() {
1850      var theme = getGdsThemeCookie();
1851      if (!theme) {
1852        return;
1853      }
1854      var htmlEl = document.documentElement;
1855      htmlEl.setAttribute('data-gdstheme', theme);
1856      htmlEl.setAttribute('data-gdsTheme', theme);
1857    }
1858  
1859    /** Sets gdsTheme cookie; expires ~100 years from “now” (refresh on each call). */
1860    function persistGdsThemeCookie(theme) {
1861      theme = (theme || '').trim();
1862      if (!theme || typeof $.cookie !== 'function') {
1863        return;
1864      }
1865      $.cookie(GDS_THEME_COOKIE, theme, { expires: GDS_THEME_COOKIE_EXPIRES_DAYS, path: '/' });
1866    }
1867  
1868    /** When <html> theme attributes have a value, store it in the cookie (with long expiry). */
1869    function setGdsThemeCookieFromHtml() {
1870      var theme = getHtmlGdsThemeAttribute();
1871      if (theme) {
1872        persistGdsThemeCookie(theme);
1873      }
1874    }
1875  
1876    /**
1877     * After dark mode switch use: re-save cookie so expiry is again ~100 years from this interaction.
1878     * Uses data-gdstheme when present; otherwise refreshes expiry for the existing cookie value.
1879     */
1880    function refreshGdsThemeCookieAfterSwitchInteraction() {
1881      window.setTimeout(function () {
1882        var theme = getHtmlGdsThemeAttribute();
1883        if (theme) {
1884          persistGdsThemeCookie(theme);
1885          return;
1886        }
1887        var fromCookie = getGdsThemeCookie();
1888        if (fromCookie) {
1889          persistGdsThemeCookie(fromCookie);
1890        }
1891      }, 0);
1892    }
1893  
1894    function applyGdsThemeToBody() {
1895      var $body = $('body');
1896      if (!$body.length) {
1897        return;
1898      }
1899  
1900      if (gdsThemeBodyClassApplied) {
1901        $body.removeClass(gdsThemeBodyClassApplied);
1902        gdsThemeBodyClassApplied = null;
1903      }
1904  
1905      var theme = getHtmlGdsThemeAttribute();
1906      if (!theme) {
1907        theme = getGdsThemeCookie();
1908      }
1909  
1910      if (theme) {
1911        $body.addClass(theme);
1912        gdsThemeBodyClassApplied = theme;
1913      }
1914    }
1915  
1916    function onHtmlGdsThemeMutation() {
1917      applyGdsThemeToBody();
1918      setGdsThemeCookieFromHtml();
1919      syncGdsDarkModeSwitch();
1920    }
1921  
1922    $(document).ready(function () {
1923      applyGdsThemeCookieToHtml();
1924      applyGdsThemeToBody();
1925      setGdsThemeCookieFromHtml();
1926      syncGdsDarkModeSwitch();
1927  
1928      function notifyGdsThemeToggleFromCookieOrHtml() {
1929        var t = getGdsThemeCookie() || getHtmlGdsThemeAttribute();
1930        if (t) {
1931          dispatchGdsThemeChangedForToggle(t);
1932        }
1933      }
1934  
1935      notifyGdsThemeToggleFromCookieOrHtml();
1936  
1937      if (window.customElements && typeof window.customElements.whenDefined === 'function') {
1938        window.customElements.whenDefined('gds-dotcom-theme-toggle').then(notifyGdsThemeToggleFromCookieOrHtml);
1939      }
1940  
1941      $(document).on('change', '#darkModeSwitch-button-switch-checkbox', refreshGdsThemeCookieAfterSwitchInteraction);
1942  
1943      if (prefersDarkMql) {
1944        mediaQueryListOnChange(prefersDarkMql, onSystemColorSchemeChange);
1945      }
1946  
1947      if (typeof MutationObserver !== 'undefined') {
1948        new MutationObserver(onHtmlGdsThemeMutation).observe(document.documentElement, {
1949          attributes: true,
1950          attributeFilter: ['data-gdstheme', 'data-gdsTheme']
1951        });
1952      }
1953    });
1954  })();
1955
1956/**
1957 * GDS header: open #gds-side-panel-account (slide-in + backdrop) when user activates Log In
1958 * (gds-dotcom-button with href="#gds-side-panel-account").
1959 */
1960(function () {
1961  var GDS_ACCOUNT_NAV_ID = 'gds-side-panel-navigation';
1962  var GDS_ACCOUNT_PANEL_ID = 'gds-side-panel-account';
1963  var GDS_ACCOUNT_PANEL_HASH = '#gds-side-panel-account';
1964  var GDS_ACCOUNT_MOBILE_MAX_WIDTH = 999;
1965  var gdsAccountPanelOpen = false;
1966  var gdsAccountLoginDocClickBound = false;
1967
1968  function gdsAccountPanelElements() {
1969    return {
1970      nav: document.getElementById(GDS_ACCOUNT_NAV_ID),
1971      panel: document.getElementById(GDS_ACCOUNT_PANEL_ID)
1972    };
1973  }
1974
1975  function lockBodyScrollForGdsAccountPanel(lock) {
1976    if (lock && window.innerWidth <= GDS_ACCOUNT_MOBILE_MAX_WIDTH) {
1977      document.body.style.position = 'fixed';
1978      document.documentElement.style.overflow = 'hidden';
1979    } else if (!lock) {
1980      document.body.removeAttribute('style');
1981      document.documentElement.removeAttribute('style');
1982    }
1983  }
1984
1985  /**
1986   * Close GDS main nav: section dropdowns (Products, etc.), optional search panel,
1987   * and the mobile hamburger panel (#gds-nav-desktop) when open.
1988   */
1989  function closeGdsMainNavigationMenus() {
1990    var nav = document.querySelector('gds-dotcom-navigation');
1991    if (!nav) {
1992      return;
1993    }
1994    var animateMain = !nav.disableAnimations;
1995    var sr = nav.shadowRoot;
1996    var dropdowns = document.querySelectorAll('gds-dotcom-navigation-dropdown');
1997    var i;
1998    for (i = 0; i < dropdowns.length; i++) {
1999      var dd = dropdowns[i];
2000      if (typeof dd._closeDropdown === 'function') {
2001        dd._closeDropdown();
2002      }
2003    }
2004    if (sr) {
2005      var searchPanel = sr.querySelector('#main-nav-search-dropdown');
2006      if (
2007        searchPanel &&
2008        searchPanel.classList.contains('visible') &&
2009        typeof searchPanel.__dropdownCleanup === 'function'
2010      ) {
2011        searchPanel.__dropdownCleanup({ animate: animateMain });
2012      }
2013      var openId = nav._openDropdownId;
2014      if (openId) {
2015        var esc =
2016          typeof CSS !== 'undefined' && typeof CSS.escape === 'function'
2017            ? CSS.escape(openId)
2018            : openId;
2019        var mainPanel = sr.querySelector('#' + esc);
2020        if (mainPanel && typeof mainPanel.__dropdownCleanup === 'function') {
2021          mainPanel.__dropdownCleanup({ animate: animateMain });
2022        }
2023      }
2024    }
2025  }
2026
2027  function openGdsAccountSidePanel() {
2028    var els = gdsAccountPanelElements();
2029    if (!els.nav || !els.panel) {
2030      return;
2031    }
2032    closeGdsMainNavigationMenus();
2033    gdsAccountPanelOpen = true;
2034    els.nav.classList.add('open');
2035    els.nav.setAttribute('aria-hidden', 'false');
2036    els.panel.classList.remove('close');
2037    els.panel.style.display = 'block';
2038    els.panel.setAttribute('aria-hidden', 'false');
2039    lockBodyScrollForGdsAccountPanel(true);
2040    window.setTimeout(function () {
2041      els.panel.classList.add('open');
2042      var focusEl =
2043        els.panel.querySelector('.first-focusable') ||
2044        els.panel.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
2045      if (focusEl && typeof focusEl.focus === 'function') {
2046        focusEl.focus();
2047      }
2048    }, 100);
2049  }
2050
2051  function closeGdsAccountSidePanel() {
2052    var els = gdsAccountPanelElements();
2053    if (!els.nav || !els.panel) {
2054      return;
2055    }
2056    gdsAccountPanelOpen = false;
2057    els.panel.classList.remove('open');
2058    els.panel.classList.add('close');
2059    els.nav.classList.remove('open');
2060    els.nav.setAttribute('aria-hidden', 'true');
2061    els.panel.setAttribute('aria-hidden', 'true');
2062    lockBodyScrollForGdsAccountPanel(false);
2063    window.setTimeout(function () {
2064      els.panel.style.display = 'none';
2065      els.panel.classList.remove('close');
2066    }, 300);
2067  }
2068
2069  function gdsDotcomTagName(el) {
2070    return el && el.tagName ? String(el.tagName).toUpperCase() : '';
2071  }
2072
2073  function gdsDotcomButtonFromEvent(e) {
2074    var path = typeof e.composedPath === 'function' ? e.composedPath() : [];
2075    var i;
2076    for (i = 0; i < path.length; i++) {
2077      var n = path[i];
2078      if (n && n.nodeType === 1 && gdsDotcomTagName(n) === 'GDS-DOTCOM-BUTTON') {
2079        return n;
2080      }
2081    }
2082    var t = e.target;
2083    var steps = 0;
2084    while (t && steps < 64) {
2085      steps += 1;
2086      if (t.nodeType === 1 && gdsDotcomTagName(t) === 'GDS-DOTCOM-BUTTON') {
2087        return t;
2088      }
2089      if (t.parentNode) {
2090        t = t.parentNode;
2091      } else {
2092        var root = t.getRootNode && t.getRootNode();
2093        t = root && root.host ? root.host : null;
2094      }
2095    }
2096    return null;
2097  }
2098
2099  /** GDS header nav: host element id to GTM buttonId for _gtm.track (shadow-safe via composedPath). */
2100  var GDS_NAV_HOST_BUTTON_GTM = {
2101    'mobile-navigation-login': 'MobileNavigation:LogIn',
2102    'mobile-navigation-contactus': 'MobileNavigation:ContactUs',
2103    'header-login-button-desktop': 'Header:LogIn',
2104    'header-login-button-mobile': 'MobileHeader:LogIn'
2105  };
2106
2107  function gdsGtmPageNameFromMeta() {
2108    var el = document.querySelector('meta[name="data-gtm-page-name"]');
2109    return el && el.content != null ? String(el.content) : '';
2110  }
2111
2112  function trackGdsHeaderNavGtmButtonClickFromEvent(e) {
2113    var btn = gdsDotcomButtonFromEvent(e);
2114    if (!btn) {
2115      return;
2116    }
2117    if (gdsDotcomTagName(btn) !== 'GDS-DOTCOM-BUTTON') {
2118      return;
2119    }
2120    var gtm = GDS_NAV_HOST_BUTTON_GTM[btn.id];
2121    if (!gtm) {
2122      return;
2123    }
2124    if (typeof _gtm === 'undefined' || typeof _gtm.track !== 'function') {
2125      return;
2126    }
2127    var pageName = gdsGtmPageNameFromMeta();
2128    if (!pageName) {
2129      return;
2130    }
2131    _gtm.track('Click', {
2132      eventType: 'ButtonClick',
2133      pageName: pageName,
2134      buttonId: gtm
2135    });
2136  }
2137
2138  function buttonOpensGdsAccountPanel(btn) {
2139    if (!btn || gdsDotcomTagName(btn) !== 'GDS-DOTCOM-BUTTON') {
2140      return false;
2141    }
2142    if (btn.getAttribute('data-gds-account-panel') === 'true') {
2143      return true;
2144    }
2145    var hrefAttr = (btn.getAttribute('href') || '').trim();
2146    if (hrefAttr === GDS_ACCOUNT_PANEL_HASH) {
2147      return true;
2148    }
2149    try {
2150      if (btn.href) {
2151        var u = new URL(btn.href, window.location.href);
2152        if (u.hash === GDS_ACCOUNT_PANEL_HASH) {
2153          return true;
2154        }
2155      }
2156    } catch (e1) {
2157      /* ignore */
2158    }
2159    var slot = btn.getAttribute('slot') || '';
2160    if (slot !== 'cta-buttons' && slot !== 'cta-buttons-mobile' && slot !== 'mobile-cta-buttons') {
2161      return false;
2162    }
2163    var text = (btn.textContent || '').replace(/\s+/g, ' ').trim();
2164    return text.indexOf('Log In') !== -1;
2165  }
2166
2167  window.openGdsAccountSidePanel = openGdsAccountSidePanel;
2168  window.closeGdsAccountSidePanel = closeGdsAccountSidePanel;
2169
2170  $(document).ready(function () {
2171    var els = gdsAccountPanelElements();
2172    if (!els.nav || !els.panel) {
2173      return;
2174    }
2175
2176    if (els.nav.parentNode !== document.body) {
2177      document.body.appendChild(els.nav);
2178    }
2179
2180    if (!gdsAccountLoginDocClickBound) {
2181      gdsAccountLoginDocClickBound = true;
2182      document.addEventListener(
2183        'click',
2184        function (e) {
2185          var btn = gdsDotcomButtonFromEvent(e);
2186          if (!btn || !buttonOpensGdsAccountPanel(btn)) {
2187            return;
2188          }
2189          e.preventDefault();
2190          openGdsAccountSidePanel();
2191        },
2192        true
2193      );
2194      document.addEventListener(
2195        'click',
2196        function (e) {
2197          if (!gdsAccountPanelOpen) {
2198            return;
2199          }
2200          var navHost = document.querySelector('gds-dotcom-navigation');
2201          if (!navHost) {
2202            return;
2203          }
2204          var path = typeof e.composedPath === 'function' ? e.composedPath() : [];
2205          var shadowRoot = navHost.shadowRoot;
2206          var i;
2207          var n;
2208          for (i = 0; i < path.length; i++) {
2209            n = path[i];
2210            if (!n || n.nodeType !== 1 || n.tagName !== 'BUTTON' || !n.classList) {
2211              continue;
2212            }
2213            if (n.classList.contains('gds-nav-item-button') && navHost.contains(n)) {
2214              closeGdsAccountSidePanel();
2215              return;
2216            }
2217            if (
2218              n.classList.contains('gds-nav-mobile-menu-button') &&
2219              (navHost.contains(n) || (shadowRoot && shadowRoot.contains(n)))
2220            ) {
2221              closeGdsAccountSidePanel();
2222              return;
2223            }
2224          }
2225        },
2226        true
2227      );
2228    }
2229
2230    $(els.nav)
2231      .find('.nav-background')
2232      .on('click', function () {
2233        closeGdsAccountSidePanel();
2234      });
2235    $(els.panel)
2236      .find('.btn-close')
2237      .on('click', function () {
2238        closeGdsAccountSidePanel();
2239      });
2240
2241    $(document).on('keydown.gdsAccountPanel', function (e) {
2242      if (e.key !== 'Escape' || !gdsAccountPanelOpen) {
2243        return;
2244      }
2245      closeGdsAccountSidePanel();
2246    });
2247  });
2248
2249  $(document).ready(function () {
2250    document.addEventListener('click', trackGdsHeaderNavGtmButtonClickFromEvent, true);
2251  });
2252})();
2253
2254/**
2255 * `ea_bounced` is a one-shot loop-guard marker the experiment-assignment service
2256 * appends so the F5 edge can spot a client that will not persist cookies. It has
2257 * already done its job by the time the page renders, and leaving it in the address
2258 * bar means a copied or bookmarked URL pins the next visitor to the legacy pool.
2259 * Dropped with no reload, keeping every other query param and the hash intact.
2260 */
2261(function () {
2262  const EA_BOUNCED_PARAM = 'ea_bounced';
2263
2264  if (!window.history || !window.history.replaceState || typeof window.URL !== 'function') {
2265    return;
2266  }
2267
2268  const url = new URL(window.location.href);
2269  if (!url.searchParams.has(EA_BOUNCED_PARAM)) {
2270    return;
2271  }
2272
2273  url.searchParams.delete(EA_BOUNCED_PARAM);
2274  const query = url.searchParams.toString();
2275
2276  window.history.replaceState(
2277    window.history.state,
2278    '',
2279    url.pathname + (query ? '?' + query : '') + url.hash
2280  );
2281})();

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.