var initESW = function(gslbBaseURL) {

  buttonCityCruisesName = "City_Cruises_US_Button";
  buttonCityCruises2Name = "City_Cruises_US_Button_2";
  buttonCityExperiencesName = "City_Experiences_Chat_Button";
  buttonWalksName = "Walks_Chat_Button";
  buttonDevourName = "Devour_Chat_Button";
  deploymentWalksItalyName = 'WalksofItaly_Deployment'

  deploymentName = '';
  switch (true) {
    case window.location.href.includes("dev2.cityexperiences.com"):
      buttonName = buttonCityExperiencesName;
      displayChatButton = false;
      autoOpenPostChatSurvey = true;
      textChatWith = 'Chat with a Specialist';
      textAgentOffline = 'Agent Offline';
      destination = "";
      break;
    case
      window.location.href.includes("cityexperiences.com") &&
      (
        window.location.href.includes("/group-events")
        || window.location.href.includes("/anniversaries")
        || window.location.href.includes("/anniversary-cruises")
        || window.location.href.includes("/anniversary-party-venue")
        || window.location.href.includes("/birthday-party-venue")
        || window.location.href.includes("/birthdays-anniversaries")
        || window.location.href.includes("/birthdays")
        || window.location.href.includes("/birthday-party-cruise")
        || window.location.href.includes("/ceremonies-receptions")
        || window.location.href.includes("/client-entertainment")
        || window.location.href.includes("/client-entertaining")
        || window.location.href.includes("/corporate-events")
        || window.location.href.includes("/elementary-middle-school-events")
        || window.location.href.includes("/employee-outings")
        || window.location.href.includes("/high-school-events")
        || window.location.href.includes("/just-for-fun-venue")
        || window.location.href.includes("/meetings-events")
        || window.location.href.includes("/other-special-occasions")
        || window.location.href.includes("/private-events")
        || window.location.href.includes("/rehearsal-dinners")
        || window.location.href.includes("/schools")
        || window.location.href.includes("/social-events-birthday-party-venue")
        || window.location.href.includes("/social-events")
        || window.location.href.includes("/special-occasions")
        || window.location.href.includes("/university-events")
        || window.location.href.includes("/wedding-related-events")
        || window.location.href.includes("/weddings")
    ):
      buttonName = buttonCityExperiencesName;
      displayChatButton = false;
      autoOpenPostChatSurvey = true;
      textChatWith = 'Chat with a Specialist';
      textAgentOffline = 'Agent Offline';
      destination = "";
      break;
    case
      window.location.href.includes("cityexperiences.com") &&
      (
        window.location.href.includes("cityexperiences.com/contact-us")
        || window.location.href.includes("cityexperiences.com/account")
        || (window.location.href.toLowerCase().includes("san-francisco") && window.location.href.toLowerCase().includes("alcatraz") )
        || ( window.location.href.toLowerCase().includes("new-jersey") && window.location.href.toLowerCase().includes("statue") )
        || ( window.location.href.toLowerCase().includes("new-york") && window.location.href.toLowerCase().includes("statue") )
      ):
      buttonName = buttonCityExperiencesName;
      displayChatButton = true;
      autoOpenPostChatSurvey = true;
      textChatWith = 'Chat with a Specialist';
      textAgentOffline = 'Agent Offline';
      destination = "";
      break;
    case
      window.location.href.includes("takewalks.com")
        || window.location.href.includes("walksofitaly.com")
        || window.location.href.includes("tw-demo-env.us-east-1.elasticbeanstalk.com")
        || window.location.href.includes("walkstest") :
        buttonName = buttonWalksName;
        if(window.location.href.includes("walksofitaly.com")) {
          deploymentName = deploymentWalksItalyName
        }
        displayChatButton = true;
        autoOpenPostChatSurvey = true;
        textChatWith = 'Chat with a Specialist';
        textAgentOffline = 'Agent Offline';
        if (window.location.href.includes("tw-demo-env.us-east-1.elasticbeanstalk.com") || window.location.href.includes("walkstest") ) {
          textChatWith = 'CHAT WITH A SPECIALIST';
          textAgentOffline = 'AGENT OFFLINE';
        }
        break;
    case window.location.href.endsWith("devourtours.com/")
        || window.location.href.includes("devourtours.com/faq")
        || window.location.href.includes("devourtours.com/destinations/") :
      buttonName = buttonDevourName;
      displayChatButton = true;
      autoOpenPostChatSurvey = true;
      textChatWith = 'Chat with a Specialist';
      textAgentOffline = 'Agent Offline';
      break;
    case window.location.href.includes("devourtours.com"):
      buttonName = buttonDevourName;
      displayChatButton = false;
      break;
    default:
      //buttonName = buttonCityCruises2Name
      //destination = "New York - Statue City Cruises";
      buttonName = buttonCityExperiencesName;
      displayChatButton = true;
      autoOpenPostChatSurvey = true;
      textChatWith = 'Chat with a Specialist';
      textAgentOffline = 'Agent Offline';
      destination = "";
  }

  if ( buttonName == buttonCityCruises2Name || buttonName == buttonCityCruisesName ) {
    switch (true) {
      case window.location.href.toLowerCase().includes("san-francisco") && window.location.href.toLowerCase().includes("alcatraz"):
        destination = 'Alcatraz City Cruises';
        break;
      case window.location.href.toLowerCase().includes("san%20francisco") && window.location.href.toLowerCase().includes("alcatraz"):
        destination = 'Alcatraz City Cruises';
        break;
      case window.location.href.toLowerCase().includes("san-francisco") || window.location.href.toLowerCase().includes("san%20francisco"):
        destination = 'San Francisco';
        break;
      case window.location.href.toLowerCase().includes("new-jersey") && window.location.href.toLowerCase().includes("statue"):
        destination = 'New Jersey - Statue City Cruises';
        break;
      case window.location.href.toLowerCase().includes("new%20jersey") && window.location.href.toLowerCase().includes("statue"):
        destination = 'New Jersey - Statue City Cruises';
        break;
      case window.location.href.toLowerCase().includes("new-york") && window.location.href.toLowerCase().includes("statue"):
        destination = 'New York - Statue City Cruises';
        break;
      case window.location.href.toLowerCase().includes("new%20york") && window.location.href.toLowerCase().includes("statue"):
        destination = 'New York - Statue City Cruises';
        break;
      case window.location.href.toLowerCase().includes("statue"):
        destination = 'New York - Statue City Cruises';
        break;
      case window.location.href.toLowerCase().includes("new-york") || window.location.href.toLowerCase().includes("new%20york"):
        destination = 'New York';
        break;
      case window.location.href.toLowerCase().includes("new-jersey") || window.location.href.toLowerCase().includes("new%20jersey"):
        destination = 'New Jersey';
        break;

      case window.location.href.toLowerCase().includes("alexandria"):
        destination = 'Alexandria';
        break;
      case window.location.href.toLowerCase().includes("baltimore"):
        destination = 'Baltimore';
        break;
      case window.location.href.toLowerCase().includes("berkeley"):
        destination = 'Berkeley';
        break;
      case window.location.href.toLowerCase().includes("boston"):
        destination = 'Boston';
        break;
      case window.location.href.toLowerCase().includes("chicago"):
        destination = 'Chicago';
        break;
      case window.location.href.toLowerCase().includes("long-beach"):
        destination = 'Long Beach';
        break;
      case window.location.href.toLowerCase().includes("marina-del-rey"):
        destination = 'Marina del Rey';
        break;
      case window.location.href.toLowerCase().includes("newport-beach"):
        destination = 'Newport Beach';
        break;
      case window.location.href.toLowerCase().includes("niagara-us"):
        destination = 'Niagara Falls';
        break;
      case window.location.href.toLowerCase().includes("niagara/"):
        destination = 'Niagara Falls';
        break;
      case window.location.href.toLowerCase().includes("norfolk"):
        destination = 'Norfolk';
        break;
      case window.location.href.toLowerCase().includes("philadelphia"):
        destination = 'Philadelphia';
        break;
      case window.location.href.toLowerCase().includes("sacramento"):
        destination = 'Sacramento';
        break;
      case window.location.href.toLowerCase().includes("san-diego") || window.location.href.toLowerCase().includes("san%20diego"):
        destination = 'San Diego';
        break;
      case window.location.href.toLowerCase().includes("washington-dc") || window.location.href.toLowerCase().includes("washington%20dc"):
        destination = 'Washington DC';
        break;

      case window.location.href.toLowerCase().includes("gananoque"):
        destination = 'Gananoque';
        break;
      case window.location.href.toLowerCase().includes("toronto"):
        destination = 'Toronto';
        break;

      case window.location.href.toLowerCase().includes("london"):
        destination = 'London';
        break;
      case window.location.href.toLowerCase().includes("poole"):
        destination = 'Poole';
        break;
      case window.location.href.toLowerCase().includes("york"):
        destination = 'York';
        break;

      case window.location.href.toLowerCase().includes("paris"):
        destination = 'Other EU';
        break;
      case window.location.href.toLowerCase().includes("city=athens"):
        destination = 'Other EU';
        break;
      case window.location.href.toLowerCase().includes("city=florence"):
        destination = 'Other EU';
        break;
      case window.location.href.toLowerCase().includes("city=milan"):
        destination = 'Other EU';
        break;
      case window.location.href.toLowerCase().includes("city=pompeii"):
        destination = 'Other EU';
        break;
      case window.location.href.toLowerCase().includes("/rome/"):
        destination = 'Other EU';
        break;
      case window.location.href.toLowerCase().includes("/venice/"):
        destination = 'Other EU';
        break;
      case window.location.href.toLowerCase().includes("city=lisbon"):
        destination = 'Other EU';
        break;
      case window.location.href.toLowerCase().includes("barcelona"):
        destination = 'Other EU';
        break;
      case window.location.href.toLowerCase().includes("madrid"):
        destination = 'Other EU';
        break;
      case window.location.href.toLowerCase().includes("city=san sebastian"):
        destination = 'Other EU';
        break;
      case window.location.href.toLowerCase().includes("city=seville"):
        destination = 'Other EU';
        break;

      case window.location.href.toLowerCase().includes("weehawken"):
        destination = 'Other US';
        break;
      case window.location.href.toLowerCase().includes("city=seattle"):
        destination = 'Other US';
        break;
      case window.location.href.toLowerCase().includes("new-orleans") || window.location.href.toLowerCase().includes("new%20orleans"):
        destination = 'Other US';
        break;
      case window.location.href.toLowerCase().includes("city=charleston"):
        destination = 'Other US';
        break;
      case window.location.href.toLowerCase().includes("city=miami"):
        destination = 'Other US';
        break;

    }
  }


  if ( buttonName == buttonCityExperiencesName ) {
    switch (true) {
      case window.location.href.toLowerCase().includes("san-francisco") && window.location.href.toLowerCase().includes("alcatraz"):
        destination = 'Alcatraz City Cruises';
        break;
      case window.location.href.toLowerCase().includes("san%20francisco") && window.location.href.toLowerCase().includes("alcatraz"):
        destination = 'Alcatraz City Cruises';
        break;
      case window.location.href.toLowerCase().includes("san-francisco") || window.location.href.toLowerCase().includes("san%20francisco"):
        destination = 'San Francisco';
        break;
      case window.location.href.toLowerCase().includes("new-jersey") && window.location.href.toLowerCase().includes("statue"):
        destination = 'New Jersey - Statue City Cruises';
        break;
      case window.location.href.toLowerCase().includes("new%20jersey") && window.location.href.toLowerCase().includes("statue"):
        destination = 'New Jersey - Statue City Cruises';
        break;
      case window.location.href.toLowerCase().includes("new-york") && window.location.href.toLowerCase().includes("statue"):
        destination = 'New York - Statue City Cruises';
        break;
      case window.location.href.toLowerCase().includes("new%20york") && window.location.href.toLowerCase().includes("statue"):
        destination = 'New York - Statue City Cruises';
        break;
      case window.location.href.toLowerCase().includes("statue"):
        destination = 'New York - Statue City Cruises';
        break;
      case window.location.href.toLowerCase().includes("new-york") || window.location.href.toLowerCase().includes("new%20york"):
        destination = 'New York';
        break;
      case window.location.href.toLowerCase().includes("new-jersey") || window.location.href.toLowerCase().includes("new%20jersey"):
        destination = 'New Jersey';
        break;

      case window.location.href.toLowerCase().includes("alexandria"):
        destination = 'Alexandria';
        break;
      case window.location.href.toLowerCase().includes("baltimore"):
        destination = 'Baltimore';
        break;
      case window.location.href.toLowerCase().includes("berkeley"):
        destination = 'Berkeley';
        break;
      case window.location.href.toLowerCase().includes("boston"):
        destination = 'Boston';
        break;
      case window.location.href.toLowerCase().includes("chicago"):
        destination = 'Chicago';
        break;
      case window.location.href.toLowerCase().includes("long-beach") || window.location.href.toLowerCase().includes("long%20beach"):
        destination = 'Long Beach';
        break;
      case window.location.href.toLowerCase().includes("marina-del-rey") || window.location.href.toLowerCase().includes("marina%20del%20rey"):
        destination = 'Marina del Rey';
        break;
      case window.location.href.toLowerCase().includes("newport-beach") || window.location.href.toLowerCase().includes("newport%20beach"):
        destination = 'Newport Beach';
        break;
      case window.location.href.toLowerCase().includes("niagara-us"):
        destination = 'Niagara Falls';
        break;
      case window.location.href.toLowerCase().includes("niagara-ca"):
        destination = 'Niagara Falls (CA)';
        break;
      case window.location.href.toLowerCase().includes("niagara/"):
        destination = 'Niagara Falls';
        break;
      case window.location.href.toLowerCase().includes("norfolk"):
        destination = 'Norfolk';
        break;
      case window.location.href.toLowerCase().includes("philadelphia"):
        destination = 'Philadelphia';
        break;
      case window.location.href.toLowerCase().includes("sacramento"):
        destination = 'Sacramento';
        break;
      case window.location.href.toLowerCase().includes("san-diego") || window.location.href.toLowerCase().includes("san%20diego"):
        destination = 'San Diego';
        break;
      case window.location.href.toLowerCase().includes("washington-dc") || window.location.href.toLowerCase().includes("washington%20dc"):
        destination = 'Washington DC';
        break;

      case window.location.href.toLowerCase().includes("gananoque"):
        destination = 'Gananoque';
        break;
      case window.location.href.toLowerCase().includes("toronto"):
        destination = 'Toronto';
        break;

      case window.location.href.toLowerCase().includes("london"):
        destination = 'London (UK)';
        break;
      case window.location.href.toLowerCase().includes("poole"):
        destination = 'Poole (UK)';
        break;
      case window.location.href.toLowerCase().includes("york"):
        destination = 'York (UK)';
        break;

      case window.location.href.toLowerCase().includes("paris"):
        destination = 'Paris';
        break;
      case window.location.href.toLowerCase().includes("city=athens"):
        destination = 'Athens';
        break;
      case window.location.href.toLowerCase().includes("city=florence"):
        destination = 'Florence';
        break;
      case window.location.href.toLowerCase().includes("city=milan"):
        destination = 'Milan';
        break;
      case window.location.href.toLowerCase().includes("city=pompeii"):
        destination = 'Pompeii';
        break;
      case window.location.href.toLowerCase().includes("/rome/"):
        destination = 'Rome';
        break;
      case window.location.href.toLowerCase().includes("/venice/"):
        destination = 'Venice';
        break;
      case window.location.href.toLowerCase().includes("city=lisbon"):
        destination = 'Lisbon';
        break;
      case window.location.href.toLowerCase().includes("barcelona"):
        destination = 'Barcelona';
        break;
      case window.location.href.toLowerCase().includes("madrid"):
        destination = 'Madrid';
        break;
      case window.location.href.toLowerCase().includes("city=san sebastian"):
        destination = 'San Sebastian';
        break;
      case window.location.href.toLowerCase().includes("city=seville"):
        destination = 'Seville';
        break;

      case window.location.href.toLowerCase().includes("weehawken"):
        destination = 'Weehawken';
        break;
      case window.location.href.toLowerCase().includes("city=seattle"):
        destination = 'Seattle';
        break;
      case window.location.href.toLowerCase().includes("new-orleans"):
        destination = 'New Orleans';
        break;
      case window.location.href.toLowerCase().includes("city=charleston"):
        destination = 'Charleston';
        break;
      case window.location.href.toLowerCase().includes("city=miami"):
        destination = 'Miami';
        break;

    }
  }


  //------------------------------------------------
  embedded_svc.settings.displayHelpButton = displayChatButton; //Or false
  embedded_svc.settings.language = ''; //For example, enter 'en' or 'en-US'
  embedded_svc.settings.defaultMinimizedText = textChatWith; //(Defaults to Chat with an Expert)
  embedded_svc.settings.disabledMinimizedText = textAgentOffline; //(Defaults to Agent Offline)
  embedded_svc.settings.storageDomain = window.location.hostname.toString(); //(Sets the domain for your deployment so that visitors can navigate subdomains during a chat session)
  embedded_svc.settings.autoOpenPostChat = autoOpenPostChatSurvey; // or false
  embedded_svc.settings.enabledFeatures = ['LiveAgent'];
  embedded_svc.settings.entryFeature = 'LiveAgent';

  //------------------------------------------------
  embedded_svc.settings.extraPrechatInfo = [
    {
    "entityName": "Contact",
    "saveToTranscript": "ContactId",
    "showOnCreate": true,
    "entityFieldMaps": [{
      "doCreate": false,
      "doFind": true,
      "fieldName": "LastName",
      "isExactMatch": true,
      "label": "Last Name"
    }, {
      "doCreate": false,
      "doFind": true,
      "fieldName": "FirstName",
      "isExactMatch": true,
      "label": "First Name"
    }, {
      "doCreate": false,
      "doFind": true,
      "fieldName": "Email",
      "isExactMatch": true,
      "label": "Email"
    }, {
      "doCreate": false,
      "doFind": true,
      "fieldName": "Phone",
      "isExactMatch": true,
      "label": "Phone"
    }]
  }];
  //------------------------------------------------
  if (buttonName == buttonCityCruisesName) {
    embedded_svc.settings.prepopulatedPrechatFields = { Pre_Chat_City__c: destination } // (field name is on the contact object)
    embedded_svc.settings.extraPrechatFormDetails = [
      {
        "label": "Last Name",
        "transcriptFields": ["PreChat_Last_Name__c"],
        "displayToAgent": true
      },
      {
        "label": "First Name",
        "transcriptFields": ["PreChat_First_Name__c"],
        "displayToAgent": true
      },
      {
        "label": "Email",
        "transcriptFields": ["PreChat_Email__c"],
        "displayToAgent": true
      },
      {
        "label": "Phone",
        "transcriptFields": ["PreChat_Phone__c"],
        "displayToAgent": true
      },
      {
        "label": "Confirmation Number",
        "transcriptFields": ["PreChat_Confirmation_Number__c"],
        "displayToAgent": true
      },
      {
        "label": "Destination City",
        "transcriptFields": ["PreChat_Port__c"],
        "displayToAgent": true
      },
      {
        "label": "SourceURL",
        "value": window.location.href,
        "transcriptFields": ["PreChat_URL__c"],
        "displayToAgent": true
      },
      {
        "label": "SourceURLPath",
        "value": window.origin + window.location.pathname,
        "transcriptFields": ["PreChat_URL_Path__c"],
        "displayToAgent": true
      },
      {
        "label": "ChatButton",
        "value": buttonName,
        "transcriptFields": ["PreChat_Chat_Button__c"],
        "displayToAgent": true
      }
    ];

    embedded_svc.init(
      'https://hornblowergroup.my.salesforce.com',
      'https://hornblower.secure.force.com/survey',
      gslbBaseURL,
      '00Di0000000eM4Z',
      'City_Cruises_US_Button', {
        baseLiveAgentContentURL: 'https://c.la1-c2-ia4.salesforceliveagent.com/content',
        deploymentId: '5723r000000JPv6',
        buttonId: '5733r000000JSmR',
        baseLiveAgentURL: 'https://d.la1-c2-ia4.salesforceliveagent.com/chat',
        eswLiveAgentDevName: 'City_Cruises_US_Button',
        isOfflineSupportEnabled: false
      }
    );

  }
  //------------------------------------------------
  if (buttonName == buttonCityCruises2Name) {
    //------------------------------------------------
    embedded_svc.settings.prepopulatedPrechatFields = { Pre_Chat_City__c: destination } // (field name is on the contact object)
    embedded_svc.settings.extraPrechatFormDetails = [
      {
        "label": "Last Name",
        "transcriptFields": ["PreChat_Last_Name__c"],
        "displayToAgent": true
      },
      {
        "label": "First Name",
        "transcriptFields": ["PreChat_First_Name__c"],
        "displayToAgent": true
      },
      {
        "label": "Email",
        "transcriptFields": ["PreChat_Email__c"],
        "displayToAgent": true
      },
      {
        "label": "Phone",
        "transcriptFields": ["PreChat_Phone__c"],
        "displayToAgent": true
      },
      {
        "label": "Confirmation Number",
        "transcriptFields": ["PreChat_Confirmation_Number__c"],
        "displayToAgent": true
      },
      {
        "label": "Destination City",
        "transcriptFields": ["PreChat_Port__c"],
        "displayToAgent": true
      },
      {
        "label": "SourceURL",
        "value": window.location.href,
        "transcriptFields": ["PreChat_URL__c"],
        "displayToAgent": true
      },
      {
        "label": "SourceURLPath",
        "value": window.origin + window.location.pathname,
        "transcriptFields": ["PreChat_URL_Path__c"],
        "displayToAgent": true
      },
      {
        "label": "ChatButton",
        "value": buttonName,
        "transcriptFields": ["PreChat_Chat_Button__c"],
        "displayToAgent": true
      }
    ];

    embedded_svc.init('https://hornblowergroup.my.salesforce.com', 'https://hornblower.secure.force.com/redirect', gslbBaseURL, '00Di0000000eM4Z',
      'City_Cruises_US_2_Chat_Embedded_Service', {
        baseLiveAgentContentURL: 'https://c.la1-c2-ia4.salesforceliveagent.com/content',
        deploymentId: '5723r000000JPw4',
        buttonId: '5733r000000JSnA',
        baseLiveAgentURL: 'https://d.la1-c2-ia4.salesforceliveagent.com/chat',
        eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04I3r000000fxTTEAY_18024523c47',
        isOfflineSupportEnabled: false
      }
    );
  }
  //------------------------------------------------
  if (buttonName == buttonCityExperiencesName) {
    embedded_svc.settings.chatbotAvatarImgURL = 'https://hornblowergroup.lightning.force.com/resource/1651731587000/ce_chatbotAvatarImg';
    embedded_svc.settings.prepopulatedPrechatFields = { } // (field name is on the contact object)
    embedded_svc.settings.extraPrechatFormDetails = [
      {
        "label": "Last Name",
        "transcriptFields": ["PreChat_Last_Name__c"],
        "displayToAgent": true
      },
      {
        "label": "First Name",
        "transcriptFields": ["PreChat_First_Name__c"],
        "displayToAgent": true
      },
      {
        "label": "Email",
        "transcriptFields": ["PreChat_Email__c"],
        "displayToAgent": true
      },
      {
        "label": "Phone",
        "transcriptFields": ["PreChat_Phone__c"],
        "displayToAgent": true
      },
      {
        "label": "Destination",
        "value": destination,
        "transcriptFields": ["PreChat_Port__c"],
        "displayToAgent": true
      },
      {
        "label": "SourceURL",
        "value": window.location.href,
        "transcriptFields": ["PreChat_URL__c"],
        "displayToAgent": true
      },
      {
        "label": "SourceURLPath",
        "value": window.origin + window.location.pathname,
        "transcriptFields": ["PreChat_URL_Path__c"],
        "displayToAgent": true
      },
      {
        "label": "ChatButton",
        "value": buttonName,
        "transcriptFields": ["PreChat_Chat_Button__c"],
        "displayToAgent": true
      }
    ];

    embedded_svc.init('https://hornblowergroup.my.salesforce.com', 'https://hornblower.secure.force.com/redirect', gslbBaseURL, '00Di0000000eM4Z',
      'City_Experiences_Chat_Embedded_Service_Deployment', {
        baseLiveAgentContentURL: 'https://c.la1-c2-ia4.salesforceliveagent.com/content',
        deploymentId: '5723r000000JPvz',
        buttonId: '5733r000000JSn5',
        baseLiveAgentURL: 'https://d.la1-c2-ia4.salesforceliveagent.com/chat',
        eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04I3r000000fxTJEAY_17f9e91a832',
        isOfflineSupportEnabled: false
      }
    );
  }
  //------------------------------------------------
  if (buttonName == buttonWalksName || buttonName == buttonDevourName) {
    destination = buttonName == buttonWalksName ? 'Italy' : 'Spain';
    switch (true) {
      case window.location.href.toLowerCase().includes("/spain/"): destination = 'Spain'; break;
      case window.location.href.toLowerCase().includes("/france/"): destination = 'France'; break;
      case window.location.href.toLowerCase().includes("/uk/"): destination = 'UK'; break;
      case window.location.href.toLowerCase().includes("/united-states/"): destination = 'US'; break;
      case window.location.href.toLowerCase().includes("/italy/"): destination = 'Italy'; break;
      case window.location.href.toLowerCase().includes("/portugal/"): destination = 'Portugal'; break;
      case window.location.href.toLowerCase().includes("walksofitaly"): destination = 'Italy'; break;

      case window.location.href.toLowerCase().includes("london-tours"): destination = 'UK'; break;
      case window.location.href.toLowerCase().includes("paris-tours"): destination = 'France'; break;
      case window.location.href.toLowerCase().includes("athens-tours"): destination = 'Greece'; break;
      case window.location.href.toLowerCase().includes("florence-tours"): destination = 'Italy'; break;
      case window.location.href.toLowerCase().includes("milan-tours"): destination = 'Italy'; break;
      case window.location.href.toLowerCase().includes("pompeii-tours"): destination = 'Italy'; break;
      case window.location.href.toLowerCase().includes("rome-tours"): destination = 'Italy'; break;
      case window.location.href.toLowerCase().includes("venice-tours"): destination = 'Italy'; break;
      case window.location.href.toLowerCase().includes("barcelona-tours"): destination = 'Spain'; break;
      case window.location.href.toLowerCase().includes("madrid-tours"): destination = 'Spain'; break;

      case window.location.href.toLowerCase().includes("new-york-tours"): destination = 'US'; break;
      case window.location.href.toLowerCase().includes("niagara-falls-tours"): destination = 'US'; break;
      case window.location.href.toLowerCase().includes("boston-tours"): destination = 'US'; break;
      case window.location.href.toLowerCase().includes("san-francisco-tours"): destination = 'US'; break;
      case window.location.href.toLowerCase().includes("chicago-tours"): destination = 'US'; break;
      case window.location.href.toLowerCase().includes("new-orleans-tours"): destination = 'US'; break;
      case window.location.href.toLowerCase().includes("statue-of-liberty-tour-ellis-island-tour"): destination = 'US'; break;
    }
    if(buttonName == buttonWalksName) {
      embedded_svc.settings.prepopulatedPrechatFields = {PreChat_Destination_Walks__c: destination}; // (field name is on the contact object)
      embedded_svc.settings.extraPrechatFormDetails = [
        {
          "label": "Last Name",
          "transcriptFields": ["PreChat_Last_Name__c"],
          "displayToAgent": true
        },
        {
          "label": "First Name",
          "transcriptFields": ["PreChat_First_Name__c"],
          "displayToAgent": true
        },
        {
          "label": "Email",
          "transcriptFields": ["PreChat_Email__c"],
          "displayToAgent": true
        },
        {
          "label": "Phone",
          "transcriptFields": ["PreChat_Phone__c"],
          "displayToAgent": true
        },
        {
          "label": "Confirmation Number",
          "transcriptFields": ["PreChat_Confirmation_Number__c"],
          "displayToAgent": true
        },
        {
          "label": "Destination",
          "transcriptFields": ["PreChat_Port__c"],
          "displayToAgent": true
        },
        {
          "label": "SourceURL",
          "value": window.location.href,
          "transcriptFields": ["PreChat_URL__c"],
          "displayToAgent": true
        },
        {
          "label": "SourceURLPath",
          "value": window.origin + window.location.pathname,
          "transcriptFields": ["PreChat_URL_Path__c"],
          "displayToAgent": true
        },
        {
          "label": "ChatButton",
          "value": buttonName,
          "transcriptFields": ["PreChat_Chat_Button__c"],
          "displayToAgent": true
        }
      ];
    }
    if(buttonName == buttonDevourName) {
      embedded_svc.settings.prepopulatedPrechatFields = {PreChat_Destination_Devour__c: destination}; // (field name is on the contact object)
      embedded_svc.settings.extraPrechatFormDetails = [
        {
          "label": "Last Name",
          "transcriptFields": ["PreChat_Last_Name__c"],
          "displayToAgent": true
        },
        {
          "label": "First Name",
          "transcriptFields": ["PreChat_First_Name__c"],
          "displayToAgent": true
        },
        {
          "label": "Email",
          "transcriptFields": ["PreChat_Email__c"],
          "displayToAgent": true
        },
        {
          "label": "Phone",
          "transcriptFields": ["PreChat_Phone__c"],
          "displayToAgent": true
        },
        {
          "label": "Confirmation Number",
          "transcriptFields": ["PreChat_Confirmation_Number__c"],
          "displayToAgent": true
        },
        {
          "label": "Destination",
          "transcriptFields": ["PreChat_Port__c"],
          "displayToAgent": true
        },
        {
          "label": "SourceURL",
          "value": window.location.href,
          "transcriptFields": ["PreChat_URL__c"],
          "displayToAgent": true
        },
        {
          "label": "SourceURLPath",
          "value": window.origin + window.location.pathname,
          "transcriptFields": ["PreChat_URL_Path__c"],
          "displayToAgent": true
        },
        {
          "label": "ChatButton",
          "value": buttonName,
          "transcriptFields": ["PreChat_Chat_Button__c"],
          "displayToAgent": true
        }
      ];
    }


    if (deploymentName == deploymentWalksItalyName ) {

      embedded_svc.init(
        'https://hornblowergroup.my.salesforce.com',
        'https://hornblower.secure.force.com/redirect',
        gslbBaseURL,
        '00Di0000000eM4Z',
        'WalksofItaly_Deployment',
        {
          baseLiveAgentContentURL: 'https://c.la1-c2-ia4.salesforceliveagent.com/content',
          deploymentId: '5723r000000JPvl',
          buttonId: '5733r000000JSml',
          baseLiveAgentURL: 'https://d.la1-c2-ia4.salesforceliveagent.com/chat',
          eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04I3r000000fxTYEAY_180b7c94f7f',
          isOfflineSupportEnabled: false
        }
      );

    } else if ( buttonName == buttonDevourName ) {

      embedded_svc.init(
        'https://hornblowergroup.my.salesforce.com',
        'https://hornblower.secure.force.com/redirect',
        gslbBaseURL,
        '00Di0000000eM4Z',
        'Devour_Chat_Button_Deployment',
        {
            baseLiveAgentContentURL: 'https://c.la1-c2-ia4.salesforceliveagent.com/content',
            deploymentId: '5723r000000JPvl',
            buttonId: '5733r000000JSnK',
            baseLiveAgentURL: 'https://d.la1-c2-ia4.salesforceliveagent.com/chat',
            eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04I3r000000fxTdEAI_181430f993c',
            isOfflineSupportEnabled: false
        }
      );

    } else {

      embedded_svc.init(
          'https://hornblowergroup.my.salesforce.com',
          'https://hornblower.secure.force.com/redirect',
          gslbBaseURL,
          '00Di0000000eM4Z',
          'Walks_Chat_Embedded_Service_Deployment',
          {
            baseLiveAgentContentURL: 'https://c.la1-c2-ia4.salesforceliveagent.com/content',
            deploymentId: '5723r000000JPvl',
            buttonId: '5733r000000JSml',
            baseLiveAgentURL: 'https://d.la1-c2-ia4.salesforceliveagent.com/chat',
            eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04I3r000000fxT5EAI_17f4fa8f00d',
            isOfflineSupportEnabled: false
          }
      );

    }

  }
  //------------------------------------------------
};

//------------------------------------------------
if (!window.embedded_svc) {
  var s = document.createElement('script');
  s.setAttribute('src', 'https://hornblowergroup.my.salesforce.com/embeddedservice/5.0/esw.min.js');
  s.onload = function() {
    initESW(null);
  };
  document.body.appendChild(s);
} else {
  initESW('https://service.force.com');
}
//------------------------------------------------