PageSourceSearch

https://www.geico.com/_next/static/scripts/global.js

js geico.com collected 2026-10-01 08:51:54 UTC 66,959 bytes, 2,105 lines download raw bytes

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

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.