function getParameterByName(e){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var t="[\\?&]"+e+"=([^&#]*)";var n=new RegExp(t);var r=n.exec(window.location.search);if(r==null)return"";else return decodeURIComponent(r[1].replace(/\+/g," "))}function parseURL(e){var t=document.createElement("a");t.href=e;var n="";return t.hostname.includes("www.")?(n=t.hostname.split("www."),n[1]):t.hostname}function getDomain(e){var t=e.split(".");"www"===t[0]&&"com"!==t[1]&&t.shift();for(var n,a=t.length,r=a,m=t[t.length-1].length;n=t[--r];)if(0===r||a-2>r||n.length<m||TLDs.indexOf(n)<0){for(var i="."+n;a-1>r;)r++,i=i+"."+t[r];return i}}function crumbleCookie(e){for(var t=document.cookie.split(";"),n={},a=0;a<t.length;a++){var r=t[a].substring(0,t[a].indexOf("=")).trim(),m=t[a].substring(t[a].indexOf("=")+1,t[a].length).trim();n[r]=m}return e?n[e]?n[e]:null:n}function get_cookie(e){var t=e+"=",n="";return document.cookie.length>0&&(offset=document.cookie.indexOf(t),-1!=offset&&(offset+=t.length,end=document.cookie.indexOf(";",offset),-1==end&&(end=document.cookie.length),n=unescape(document.cookie.substring(offset,end)))),n}function bomCookies(){var e=function(){var e,t,n,a,r,m,i,c;if(!crumbleCookie("__bomz"))return null;e=crumbleCookie("__bomz");for(var u=e.split("|"),o=0;o<u.length;o++){var g=u[o].substring(0,u[o].indexOf("=")),s=decodeURIComponent(u[o].substring(u[o].indexOf("=")+1,u[o].length));switch(s=s.replace(/^\(|\)$/g,""),g){case"utmcsr":t=s;break;case"utmcmd":n=s;break;case"utmccn":a=s;break;case"utmctr":r=s;break;case"utmcct":m=s;break;case"utmgclid":i=s;break;case"utmrefer":c=s}}return{cookie:e,source:t,medium:n,name:a,term:r,content:m,gclid:i,refer:c}};this.getCampaignSource=function(){return e()&&e().source?e().source:null},this.getCampaignMedium=function(){return e()&&e().medium?e().medium:null},this.getCampaignName=function(){return e()&&e().name?e().name:null},this.getCampaignTerm=function(){return e()&&e().term?e().term:null},this.getCampaignContent=function(){return e()&&e().content?e().content:null},this.getCampaignReferUrl=function(){return e()&&e().refer?e().refer:null}}function getHiddenFields(e,t,n){var a=new bomCookies,r=!1,m="",i="",c="",u="",o="";if(a.getCampaignReferUrl())var m=a.getCampaignReferUrl();else if(getParameterByName("utm_ref"))var m=getParameterByName("utm_ref");else var m=document.referrer;if(a.getCampaignSource()){var g=a.getCampaignSource(),s=g;a.getCampaignName()&&(i=a.getCampaignName(),g=g+"-"+i),a.getCampaignContent()&&(c=a.getCampaignContent(),g=g+"-"+c),a.getCampaignMedium()&&(u=a.getCampaignMedium()),a.getCampaignTerm()&&(o=a.getCampaignTerm())}else if(getParameterByName("utm_source")){var g=getParameterByName("utm_source"),s=g;getParameterByName("utm_campaign")&&(i=getParameterByName("utm_campaign"),g=g+"-"+i),getParameterByName("utm_content")&&(c=getParameterByName("utm_content"),g=g+"-"+c),getParameterByName("utm_medium")&&(u=getParameterByName("utm_medium")),getParameterByName("utm_term")&&(o=getParameterByName("utm_term")),r=!0}else if(n)var g=n,u=n;else{var g=parseURL(document.referrer),s=g;r=!0}if(r){var d=new Date;d.setTime(d.setMonth(d.getMonth()+6));var l="expires="+d.toGMTString(),f=getDomain(location.host);f?document.cookie="__bomz=utmcsr="+s+"|utmccn="+i+"|utmcct="+c+"|utmcmd="+u+"|utmctr="+o+"|utmrefer="+m+";"+l+";domain="+f+";path=/":document.cookie="__bomz=utmcsr="+s+"|utmccn="+i+"|utmcct="+c+"|utmcmd="+u+"|utmctr="+o+"|utmrefer="+m+";"+l}"Affiliate"==g&&(g=g+" - "+get_cookie("ifaffiliatecode"));for(var b=document.getElementsByTagName("form"),p=0;p<b.length;p++)if(b[p].inf_form_xid||b[p].__bomz_lt){if(g){var h=document.createElement("input");h.setAttribute("type","hidden"),h.setAttribute("name","inf_field_LeadSourceName"),h.setAttribute("value",g),b[p].appendChild(h)}if(u){var h=document.createElement("input");h.setAttribute("type","hidden"),h.setAttribute("name","inf_field_LeadSourceCategoryName"),h.setAttribute("value",u),b[p].appendChild(h)}if(e&&o){var h=document.createElement("input");h.setAttribute("type","hidden"),h.setAttribute("name","inf_custom_"+e),h.setAttribute("value",o),b[p].appendChild(h)}if(t&&m){var h=document.createElement("input");h.setAttribute("type","hidden"),h.setAttribute("name","inf_custom_"+t),h.setAttribute("value",m),b[p].appendChild(h)}}else if(b[p].infusion_xid){if(g){var h=document.createElement("input");h.setAttribute("type","hidden"),h.setAttribute("name","Contact0Leadsource"),h.setAttribute("value",g),b[p].appendChild(h)}if(e&&o){var h=document.createElement("input");h.setAttribute("type","hidden"),h.setAttribute("name","Contact0_"+e),h.setAttribute("value",o),b[p].appendChild(h)}if(t&&m){var h=document.createElement("input");h.setAttribute("type","hidden"),h.setAttribute("name","Contact0_"+t),h.setAttribute("value",m),b[p].appendChild(h)}}}var TLDs=["ac","ad","ae","aero","af","ag","ai","al","am","an","ao","aq","ar","arpa","as","asia","at","au","aw","ax","az","ba","bb","bd","be","bf","bg","bh","bi","biz","bj","bm","bn","bo","br","bs","bt","bv","bw","by","bz","ca","cat","cc","cd","cf","cg","ch","ci","ck","cl","cm","cn","co","com","coop","cr","cu","cv","cx","cy","cz","de","dj","dk","dm","do","dz","ec","edu","ee","eg","er","es","et","eu","fi","fj","fk","fm","fo","fr","ga","gb","gd","ge","gf","gg","gh","gi","gl","gm","gn","gov","gp","gq","gr","gs","gt","gu","gw","gy","hk","hm","hn","hr","ht","hu","id","ie","il","im","in","info","int","io","iq","ir","is","it","je","jm","jo","jobs","jp","ke","kg","kh","ki","km","kn","kp","kr","kw","ky","kz","la","lb","lc","li","lk","lr","ls","lt","lu","lv","ly","ma","mc","md","me","mg","mh","mil","mk","ml","mm","mn","mo","mobi","mp","mq","mr","ms","mt","mu","museum","mv","mw","mx","my","mz","na","name","nc","ne","net","nf","ng","ni","nl","no","np","nr","nu","nz","om","org","pa","pe","pf","pg","ph","pk","pl","pm","pn","pr","pro","ps","pt","pw","py","qa","re","ro","rs","ru","rw","sa","sb","sc","sd","se","sg","sh","si","sj","sk","sl","sm","sn","so","sr","st","su","sv","sy","sz","tc","td","tel","tf","tg","th","tj","tk","tl","tm","tn","to","tp","tr","travel","tt","tv","tw","tz","ua","ug","uk","us","uy","uz","va","vc","ve","vg","vi","vn","vu","wf","ws","xn--0zwm56d","xn--11b5bs3a9aj6g","xn--3e0b707e","xn--45brj9c","xn--80akhbyknj4f","xn--90a3ac","xn--9t4b11yi5a","xn--clchc0ea0b2g2a9gcd","xn--deba0ad","xn--fiqs8s","xn--fiqz9s","xn--fpcrj9c3d","xn--fzc2c9e2c","xn--g6w251d","xn--gecrj9c","xn--h2brj9c","xn--hgbk6aj7f53bba","xn--hlcj6aya9esc7a","xn--j6w193g","xn--jxalpdlp","xn--kgbechtv","xn--kprw13d","xn--kpry57d","xn--lgbbat1ad8j","xn--mgbaam7a8h","xn--mgbayh7gpa","xn--mgbbh1a71e","xn--mgbc0a9azcg","xn--mgberp4a5d4ar","xn--o3cw4h","xn--ogbpf8fl","xn--p1ai","xn--pgbs0dh","xn--s9brj9c","xn--wgbh1c","xn--wgbl6a","xn--xkc2al3hye2a","xn--xkc2dl3a5ee0h","xn--yfro4i67o","xn--ygbi2ammx","xn--zckzah","xxx","ye","yt","za","zm","zw"].join();
var stateCodes = [];
stateCodes['Alabama'] = 'AL';
stateCodes['Alaska'] = 'AK';
stateCodes['Arizona'] = 'AZ';
stateCodes['Arkansas'] = 'AR';
stateCodes['California'] = 'CA';
stateCodes['Colorado'] = 'CO';
stateCodes['Connecticut'] = 'CT';
stateCodes['Delaware'] = 'DE';
stateCodes['Florida'] = 'FL';
stateCodes['Georgia'] = 'GA';
stateCodes['Hawaii'] = 'HI';
stateCodes['Idaho'] = 'ID';
stateCodes['Illinois'] = 'IL';
stateCodes['Indiana'] = 'IN';
stateCodes['Iowa'] = 'IA';
stateCodes['Kansas'] = 'KS';
stateCodes['Kentucky'] = 'KY';
stateCodes['Louisiana'] = 'LA';
stateCodes['Maine'] = 'ME';
stateCodes['Maryland'] = 'MD';
stateCodes['Massachusetts'] = 'MA';
stateCodes['Michigan'] = 'MI';
stateCodes['Minnesota'] = 'MN';
stateCodes['Mississippi'] = 'MS';
stateCodes['Missouri'] = 'MO';
stateCodes['Montana'] = 'MT';
stateCodes['Nebraska'] = 'NE';
stateCodes['Nevada'] = 'NV';
stateCodes['New Hampshire'] = 'NH';
stateCodes['New Jersey'] = 'NJ';
stateCodes['New Mexico'] = 'NM';
stateCodes['New York'] = 'NY';
stateCodes['North Carolina'] = 'NC';
stateCodes['North Dakota'] = 'ND';
stateCodes['Ohio'] = 'OH';
stateCodes['Oklahoma'] = 'OK';
stateCodes['Oregon'] = 'OR';
stateCodes['Pennsylvania'] = 'PA';
stateCodes['Rhode Island'] = 'RI';
stateCodes['South Carolina'] = 'SC';
stateCodes['South Dakota'] = 'SD';
stateCodes['Tennessee'] = 'TN';
stateCodes['Texas'] = 'TX';
stateCodes['Utah'] = 'UT';
stateCodes['Vermont'] = 'VT';
stateCodes['Virginia'] = 'VA';
stateCodes['Washington'] = 'WA';
stateCodes['West Virginia'] = 'WV';
stateCodes['Wisconsin'] = 'WI';
stateCodes['Wyoming'] = 'WY';
stateCodes['American Samoa'] = 'AS';
stateCodes['District of Columbia'] = 'DC';
stateCodes['Federated States of Micronesia'] = 'FM';
stateCodes['Guam'] = 'GU';
stateCodes['Marshall Islands'] = 'MH';
stateCodes['Northern Mariana Islands'] = 'MP';
stateCodes['Palau'] = 'PW';
stateCodes['Puerto Rico'] = 'PR';
stateCodes['Virgin Islands'] = 'VI';


var countryCodes = [];
countryCodes["Afghanistan"] = "Afghanistan";
countryCodes["Aland Islands"] = "Åland Islands";
countryCodes["Albania"] = "Albania";
countryCodes["Algeria"] = "Algeria";
countryCodes["American Samoa"] = "American Samoa";
countryCodes["Andorra"] = "Andorra";
countryCodes["Angola"] = "Angola";
countryCodes["Anguilla"] = "Anguilla";
countryCodes["Antarctica"] = "Antarctica";
countryCodes["Antigua and Barbuda"] = "Antigua and Barbuda";
countryCodes["Argentina"] = "Argentina";
countryCodes["Armenia"] = "Armenia";
countryCodes["Aruba"] = "Aruba";
countryCodes["Australia"] = "Australia";
countryCodes["Austria"] = "Austria";
countryCodes["Azerbaijan"] = "Azerbaijan";
countryCodes["Bahamas"] = "Bahamas (the)";
countryCodes["Bahrain"] = "Bahrain";
countryCodes["Bangladesh"] = "Bangladesh";
countryCodes["Barbados"] = "Barbados";
countryCodes["Belarus"] = "Belarus";
countryCodes["Belgium"] = "Belgium";
countryCodes["Belize"] = "Belize";
countryCodes["Benin"] = "Benin";
countryCodes["Bermuda"] = "Bermuda";
countryCodes["Bhutan"] = "Bhutan";
countryCodes["Bolivia, Plurinational State of"] = "Bolivia (Plurinational State of)";
countryCodes["Bonaire, Sint Eustatius and Saba"] = "Bonaire, Sint Eustatius and Saba";
countryCodes["Bosnia and Herzegovina"] = "Bosnia and Herzegovina";
countryCodes["Botswana"] = "Botswana";
countryCodes["Bouvet Island"] = "Bouvet Island";
countryCodes["Brazil"] = "Brazil";
countryCodes["British Indian Ocean Territory"] = "British Indian Ocean Territory (the)";
countryCodes["Brunei Darussalam"] = "Brunei Darussalam";
countryCodes["Bulgaria"] = "Bulgaria";
countryCodes["Burkina Faso"] = "Burkina Faso";
countryCodes["Burundi"] = "Burundi";
countryCodes["Cabo Verde"] = "Cabo Verde";
countryCodes["Cambodia"] = "Cambodia";
countryCodes["Cameroon"] = "Cameroon";
countryCodes["Canada"] = "Canada";
countryCodes["Cayman Islands"] = "Cayman Islands (the)";
countryCodes["Central African Republic"] = "Central African Republic (the)";
countryCodes["Chad"] = "Chad";
countryCodes["Chile"] = "Chile";
countryCodes["China"] = "China";
countryCodes["Christmas Island"] = "Christmas Island";
countryCodes["Cocos (Keeling) Islands (the)"] = "Cocos (Keeling) Islands (the)";
countryCodes["Colombia"] = "Colombia";
countryCodes["Comoros"] = "Comoros (the)";
countryCodes["Congo"] = "Congo (the)";
countryCodes["Congo, The Democratic Republic of The"] = "Congo (the Democratic Republic of the)";
countryCodes["Cook Islands"] = "Cook Islands (the)";
countryCodes["Costa Rica"] = "Costa Rica";
countryCodes["Cote D'ivoire"] = "Côte d'Ivoire";
countryCodes["Croatia"] = "Croatia";
countryCodes["Cuba"] = "Cuba";
countryCodes["Curacao"] = "Curaçao";
countryCodes["Cyprus"] = "Cyprus";
countryCodes["Czech Republic"] = "Czech Republic (the)";
countryCodes["Denmark"] = "Denmark";
countryCodes["Djibouti"] = "Djibouti";
countryCodes["Dominica"] = "Dominica";
countryCodes["Dominican Republic"] = "Dominican Republic (the)";
countryCodes["Ecuador"] = "Ecuador";
countryCodes["Egypt"] = "Egypt";
countryCodes["El Salvador"] = "El Salvador";
countryCodes["Equatorial Guinea"] = "Equatorial Guinea";
countryCodes["Eritrea"] = "Eritrea";
countryCodes["Estonia"] = "Estonia";
countryCodes["Ethiopia"] = "Ethiopia";
countryCodes["Falkland Islands (Malvinas)"] = "Falkland Islands (the) [Malvinas]";
countryCodes["Faroe Islands"] = "Faroe Islands (the)";
countryCodes["Fiji"] = "Fiji";
countryCodes["Finland"] = "Finland";
countryCodes["France"] = "France";
countryCodes["French Guiana"] = "French Guiana";
countryCodes["French Polynesia"] = "French Polynesia";
countryCodes["French Southern Territories (the)"] = "French Southern Territories (the)";
countryCodes["Gabon"] = "Gabon";
countryCodes["Gambia"] = "Gambia (the)";
countryCodes["Georgia"] = "Georgia";
countryCodes["Germany"] = "Germany";
countryCodes["Ghana"] = "Ghana";
countryCodes["Gibraltar"] = "Gibraltar";
countryCodes["Greece"] = "Greece";
countryCodes["Greenland"] = "Greenland";
countryCodes["Grenada"] = "Grenada";
countryCodes["Guadeloupe"] = "Guadeloupe";
countryCodes["Guam"] = "Guam";
countryCodes["Guatemala"] = "Guatemala";
countryCodes["Guernsey"] = "Guernsey";
countryCodes["Guinea"] = "Guinea";
countryCodes["Guinea-Bissau"] = "Guinea-Bissau";
countryCodes["Guyana"] = "Guyana";
countryCodes["Haiti"] = "Haiti";
countryCodes["Heard Island and McDonald Islands"] = "Heard Island and McDonald Islands";
countryCodes["Holy See"] = "Holy See (the)";
countryCodes["Honduras"] = "Honduras";
countryCodes["Hong Kong"] = "Hong Kong";
countryCodes["Hungary"] = "Hungary";
countryCodes["Iceland"] = "Iceland";
countryCodes["India"] = "India";
countryCodes["Indonesia"] = "Indonesia";
countryCodes["Iran, Islamic Republic of"] = "Iran (Islamic Republic of)";
countryCodes["Iraq"] = "Iraq";
countryCodes["Ireland"] = "Ireland";
countryCodes["Isle of Man"] = "Isle of Man";
countryCodes["Israel"] = "Israel";
countryCodes["Italy"] = "Italy";
countryCodes["Jamaica"] = "Jamaica";
countryCodes["Japan"] = "Japan";
countryCodes["Jersey"] = "Jersey";
countryCodes["Johnston Island"] = "Johnston Island";
countryCodes["Jordan"] = "Jordan";
countryCodes["Kazakhstan"] = "Kazakhstan";
countryCodes["Kenya"] = "Kenya";
countryCodes["Kiribati"] = "Kiribati";
countryCodes["Korea, Democratic People's Republic of"] = "Korea (the Democratic People's Republic of)";
countryCodes["Korea, Republic of"] = "Korea (the Republic of)";
countryCodes["Kuwait"] = "Kuwait";
countryCodes["Kyrgyzstan"] = "Kyrgyzstan";
countryCodes["Lao People's Democratic Republic"] = "Lao People's Democratic Republic (the)";
countryCodes["Latvia"] = "Latvia";
countryCodes["Lebanon"] = "Lebanon";
countryCodes["Lesotho"] = "Lesotho";
countryCodes["Liberia"] = "Liberia";
countryCodes["Libya"] = "Libya";
countryCodes["Liechtenstein"] = "Liechtenstein";
countryCodes["Lithuania"] = "Lithuania";
countryCodes["Luxembourg"] = "Luxembourg";
countryCodes["Macao"] = "Macao";
countryCodes["Macedonia, The Former Yugoslav Republic of"] = "Macedonia (the former Yugoslav Republic of)";
countryCodes["Madagascar"] = "Madagascar";
countryCodes["Malawi"] = "Malawi";
countryCodes["Malaysia"] = "Malaysia";
countryCodes["Maldives"] = "Maldives";
countryCodes["Mali"] = "Mali";
countryCodes["Malta"] = "Malta";
countryCodes["Marshall Islands"] = "Marshall Islands (the)";
countryCodes["Martinique"] = "Martinique";
countryCodes["Mauritania"] = "Mauritania";
countryCodes["Mauritius"] = "Mauritius";
countryCodes["Mayotte"] = "Mayotte";
countryCodes["Mexico"] = "Mexico";
countryCodes["Micronesia, Federated States of"] = "Micronesia (Federated States of)";
countryCodes["Midway Islands"] = "Midway Islands";
countryCodes["Moldova, Republic of"] = "Moldova (the Republic of)";
countryCodes["Monaco"] = "Monaco";
countryCodes["Mongolia"] = "Mongolia";
countryCodes["Montenegro"] = "Montenegro";
countryCodes["Montserrat"] = "Montserrat";
countryCodes["Morocco"] = "Morocco";
countryCodes["Mozambique"] = "Mozambique";
countryCodes["Myanmar"] = "Myanmar";
countryCodes["Namibia"] = "Namibia";
countryCodes["Nauru"] = "Nauru";
countryCodes["Nepal"] = "Nepal";
countryCodes["Netherlands"] = "Netherlands (the)";
countryCodes["New Caledonia"] = "New Caledonia";
countryCodes["New Zealand"] = "New Zealand";
countryCodes["Nicaragua"] = "Nicaragua";
countryCodes["Niger"] = "Niger (the)";
countryCodes["Nigeria"] = "Nigeria";
countryCodes["Niue"] = "Niue";
countryCodes["Norfolk Island"] = "Norfolk Island";
countryCodes["Northern Mariana Islands"] = "Northern Mariana Islands (the)";
countryCodes["Norway"] = "Norway";
countryCodes["Oman"] = "Oman";
countryCodes["Pakistan"] = "Pakistan";
countryCodes["Palau"] = "Palau";
countryCodes["Palestine, State of"] = "Palestine, State of";
countryCodes["Panama"] = "Panama";
countryCodes["Papua New Guinea"] = "Papua New Guinea";
countryCodes["Paraguay"] = "Paraguay";
countryCodes["Peru"] = "Peru";
countryCodes["Philippines"] = "Philippines (the)";
countryCodes["Pitcairn"] = "Pitcairn";
countryCodes["Poland"] = "Poland";
countryCodes["Portugal"] = "Portugal";
countryCodes["Puerto Rico"] = "Puerto Rico";
countryCodes["Qatar"] = "Qatar";
countryCodes["Reunion"] = "Réunion";
countryCodes["Romania"] = "Romania";
countryCodes["Russian Federation"] = "Russian Federation (the)";
countryCodes["Rwanda"] = "Rwanda";
countryCodes["Saint Barthelemy"] = "Saint Barthélemy";
countryCodes["Saint Helena, Ascension and Tristan da Cunha"] = "Saint Helena, Ascension and Tristan da Cunha";
countryCodes["Saint Kitts and Nevis"] = "Saint Kitts and Nevis";
countryCodes["Saint Lucia"] = "Saint Lucia";
countryCodes["Saint Martin (French Part)"] = "Saint Martin (French part)";
countryCodes["Saint Pierre and Miquelon"] = "Saint Pierre and Miquelon";
countryCodes["Saint Vincent and The Grenadines"] = "Saint Vincent and the Grenadines";
countryCodes["Samoa"] = "Samoa";
countryCodes["San Marino"] = "San Marino";
countryCodes["Sao Tome and Principe"] = "Sao Tome and Principe";
countryCodes["Saudi Arabia"] = "Saudi Arabia";
countryCodes["Senegal"] = "Senegal";
countryCodes["Serbia"] = "Serbia";
countryCodes["Seychelles"] = "Seychelles";
countryCodes["Sierra Leone"] = "Sierra Leone";
countryCodes["Singapore"] = "Singapore";
countryCodes["Sint Maarten (Dutch Part)"] = "Sint Maarten (Dutch part)";
countryCodes["Slovakia"] = "Slovakia";
countryCodes["Slovenia"] = "Slovenia";
countryCodes["Solomon Islands"] = "Solomon Islands";
countryCodes["Somalia"] = "Somalia";
countryCodes["South Africa"] = "South Africa";
countryCodes["South Georgia and The South Sandwich Islands"] = "South Georgia and the South Sandwich Islands";
countryCodes["South Sudan"] = "South Sudan";
countryCodes["Southern Rhodesia"] = "Southern Rhodesia";
countryCodes["Spain"] = "Spain";
countryCodes["Sri Lanka"] = "Sri Lanka";
countryCodes["Sudan"] = "Sudan (the)";
countryCodes["Suriname"] = "Suriname";
countryCodes["Svalbard and Jan Mayen"] = "Svalbard and Jan Mayen";
countryCodes["Swaziland"] = "Swaziland";
countryCodes["Sweden"] = "Sweden";
countryCodes["Switzerland"] = "Switzerland";
countryCodes["Syrian Arab Republic"] = "Syrian Arab Republic";
countryCodes["Taiwan, Province of China"] = "Taiwan (Province of China)";
countryCodes["Tajikistan"] = "Tajikistan";
countryCodes["Tanzania, United Republic of"] = "Tanzania, United Republic of";
countryCodes["Thailand"] = "Thailand";
countryCodes["Timor-Leste"] = "Timor-Leste";
countryCodes["Togo"] = "Togo";
countryCodes["Tokelau"] = "Tokelau";
countryCodes["Tonga"] = "Tonga";
countryCodes["Trinidad and Tobago"] = "Trinidad and Tobago";
countryCodes["Tunisia"] = "Tunisia";
countryCodes["Turkey"] = "Turkey";
countryCodes["Turkmenistan"] = "Turkmenistan";
countryCodes["Turks and Caicos Islands"] = "Turks and Caicos Islands (the)";
countryCodes["Tuvalu"] = "Tuvalu";
countryCodes["Uganda"] = "Uganda";
countryCodes["Ukraine"] = "Ukraine";
countryCodes["United Arab Emirates"] = "United Arab Emirates (the)";
countryCodes["United Kingdom"] = "United Kingdom";
countryCodes["United States"] = "United States";
countryCodes["United States of America"] = "United States";
countryCodes["United States Minor Outlying Islands"] = "United States Minor Outlying Islands (the)";
countryCodes["Upper Volta"] = "Upper Volta";
countryCodes["Uruguay"] = "Uruguay";
countryCodes["Uzbekistan"] = "Uzbekistan";
countryCodes["Vanuatu"] = "Vanuatu";
countryCodes["Venezuela, Bolivarian Republic of"] = "Venezuela (Bolivarian Republic of)";
countryCodes["Viet Nam"] = "Viet Nam";
countryCodes["Virgin Islands, British"] = "Virgin Islands (British)";
countryCodes["Virgin Islands, U.S"] = "Virgin Islands (U.S.)";
countryCodes["Wallis and Futuna"] = "Wallis and Futuna";
countryCodes["Western Sahara"] = "Western Sahara";
countryCodes["Yemen"] = "Yemen";
countryCodes["Zambia"] = "Zambia";
countryCodes["Zimbabwe"] = "Zimbabwe";

function getLocFields(field){
	if(field > 0) {
		if(field == 1) {
			field = '';
		}
        }
function checkCookie() {
  geolocationCookie = getCookie('geolocation');
  console.log(geolocationCookie);
  if (geolocationCookie) {
    return true;
  }
  else {
    return false;
  }
}

function getCookie(c_name) {
  if (document.cookie.length > 0 ) {
    c_start=document.cookie.indexOf(c_name + "=");
    if (c_start != -1){
      c_start=c_start + c_name.length+1;
      c_end=document.cookie.indexOf(";",c_start);
      if (c_end == -1) {c_end=document.cookie.length;}
      return unescape(document.cookie.substring(c_start,c_end));
    }
  }
  return '';
}

function setCookie(c_name, value, expire) {
  var exdate=new Date();
  exdate.setDate(exdate.getDate()+expire);
  document.cookie = c_name+ "=" +escape(value) + ((expire==null) ? "" : ";expires="+exdate.toGMTString());
}

function setFormFields(locationData){
  var field = 3;
  var jsonLocationData = JSON.parse(locationData);
  var fieldValue = setFormFieldsArray(jsonLocationData);
  var forms = document.getElementsByClassName("infusion-form");
  var ipInfo = ['cityName','regionName','countryName','zipCode'];
  var fields = ['City'+field,'State'+field,'Country'+field,'PostalCode'+field];

  for(var i = 0; i < forms.length; i++) {
    for (var j = 0; j < 4; j++) {
      value = fieldValue[j];
      if(ipInfo[j] == 'regionName' && stateCodes[value]) {value = stateCodes[value];}
      if(ipInfo[j] == 'countryName' && countryCodes[value]) {value = countryCodes[value];} 
      if(forms[i].inf_form_xid || forms[i].__bomz_gl){
        var el = document.getElementById("inf_field_"+fields[j]);
        if ((el == null) && (value != "-")) {
          var input = document.createElement("input");
          input.setAttribute("type", "hidden");
          input.setAttribute("name", "inf_field_"+fields[j]);
          input.setAttribute("value", value);
          forms[i].appendChild(input);
        }
        else{el.value = value;}
      }
      else if(forms[i].infusion_xid){
        var el = document.getElementById("Contact0"+fields[j]);
        if ((el == null) && (value != "-")) {
          var input = document.createElement("input");
          input.setAttribute("type", "hidden");
          input.setAttribute("name", "Contact0"+fields[j]);
          input.setAttribute("value", value);
          forms[i].appendChild(input);
        }
        else{el.value = value;}
      }
    }
  }
}


function setFormFieldsArray(jsonData){
  fieldData = [jsonData.cityName,jsonData.regionName,jsonData.countryName,jsonData.zipCode];
  return fieldData;
}

var cookieExists = checkCookie();

if(!cookieExists){
  function createCORSRequest(method, url){
    var xhr = new XMLHttpRequest();
    if("withCredentials" in xhr){
      xhr.open(method, url, true);
    }
    else if (typeof XDomainRequest != "undefined"){
      xhr = new XDomainRequest();
      xhr.open(method, url);
    }
    else{
      xhr = null;
    }
    return xhr;
  }

  var xhr = createCORSRequest('POST', 'https://bom.bz/scripts/cors/postCatchGeoLocation.php');
  if (!xhr){throw new Error('CORS not supported');}

  xhr.onload = function() {
    var responseText = xhr.responseText;
    setFormFields(responseText);
    setCookie('geolocation', responseText, 365);
  };

  xhr.onerror = function() {
    console.log('There was an error!');
  };

  xhr.send();
}
else setFormFields(getCookie('geolocation'));
}
var ready=function(){function i(){if(r.isReady){return}try{document.documentElement.doScroll("left")}catch(e){setTimeout(i,1);return}r.ready()}function s(t){r.bindReady();var n=r.type(t);e.done(t)}var e,t,n={};n["[object Boolean]"]="boolean";n["[object Number]"]="number";n["[object String]"]="string";n["[object Function]"]="function";n["[object Array]"]="array";n["[object Date]"]="date";n["[object RegExp]"]="regexp";n["[object Object]"]="object";var r={isReady:false,readyWait:1,holdReady:function(e){if(e){r.readyWait++}else{r.ready(true)}},ready:function(t){if(t===true&&!--r.readyWait||t!==true&&!r.isReady){if(!document.body){return setTimeout(r.ready,1)}r.isReady=true;if(t!==true&&--r.readyWait>0){return}e.resolveWith(document,[r])}},bindReady:function(){if(e){return}e=r._Deferred();if(document.readyState==="complete"){return setTimeout(r.ready,1)}if(document.addEventListener){document.addEventListener("DOMContentLoaded",t,false);window.addEventListener("load",r.ready,false)}else if(document.attachEvent){document.attachEvent("onreadystatechange",t);window.attachEvent("onload",r.ready);var n=false;try{n=window.frameElement==null}catch(s){}if(document.documentElement.doScroll&&n){i()}}},_Deferred:function(){var e=[],t,n,i,s={done:function(){if(!i){var n=arguments,o,u,a,f,l;if(t){l=t;t=0}for(o=0,u=n.length;o<u;o++){a=n[o];f=r.type(a);if(f==="array"){s.done.apply(s,a)}else if(f==="function"){e.push(a)}}if(l){s.resolveWith(l[0],l[1])}}return this},resolveWith:function(r,s){if(!i&&!t&&!n){s=s||[];n=1;try{while(e[0]){e.shift().apply(r,s)}}finally{t=[r,s];n=0}}return this},resolve:function(){s.resolveWith(this,arguments);return this},isResolved:function(){return!!(n||t)},cancel:function(){i=1;e=[];return this}};return s},type:function(e){return e==null?String(e):n[Object.prototype.toString.call(e)]||"object"}};if(document.addEventListener){t=function(){document.removeEventListener("DOMContentLoaded",t,false);r.ready()}}else if(document.attachEvent){t=function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",t);r.ready()}}}return s}();
ready(function(){var te = "Term"; var ur = "ReferringURL"; var de = "";  getHiddenFields(te, ur, de);var field = 3; getLocFields(field);});