var HubSpotFormChainer=function(a,b,c){function d(a){var b=c.cookie.match("(^|;) ?"+a+"=([^;]*)(;|$)");return b?b[2]:null}function e(a,b,d){var e=new Date;e.setTime(e.getTime()+864e5*d),c.cookie=a+"="+b+";path=/;."+F.cookieDomain+";expires="+e.toGMTString()}function f(a){return a=d(a),null!=a&&""!=a}function g(a){return encodeURIComponent(JSON.stringify(a))}function h(a){return JSON.parse(decodeURIComponent(a))}function i(b,c){var i=f(F.cookieName)?h(d(F.cookieName)):{};if(a.extend(i,b),a.extend(I,c),delete i.hs_context,delete i.username,delete i.password,F.cookieIgnoreFields)for(var j=0;j<F.cookieIgnoreFields.length;j++)i[F.cookieIgnoreFields[j]]&&(I[F.cookieIgnoreFields[j]]=i[F.cookieIgnoreFields[j]],delete i[F.cookieIgnoreFields[j]]);e(F.cookieName,g(i),F.cookieExpiresDays)}function j(){e(F.cookieName,"",-1)}function k(a,c){c||(c=b.location.href),a=a.replace(/[\[\]]/g,"\\$&");var d=new RegExp("[?&]"+a+"(=([^&#]*)|&|#|$)"),e=d.exec(c);return e?e[2]?decodeURIComponent(e[2].replace(/\+/g," ")):"":null}function l(){var b=k("hsFormGuid"),c=k("step"),d=0,e=m(F.forms,"id",b);return a.isNumeric(c)?d=c-1:"complete"==c?d=e:b&&(d=e+1),d}function m(a,b,c){for(var d=0;d<a.length;d+=1)if(a[d][b]===c)return d;return-1}function n(b){var c={};return a.each(b,function(){"undefined"!=typeof c[this.name]?(c[this.name].push||(c[this.name]=[c[this.name]]),c[this.name].push(this.value||"")):c[this.name]=this.value||""}),c}function o(a){return a.toString().toLowerCase().trim().replace(/\s+/g,"-").replace(/&/g,"-and-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-")}function p(c,d,e){if(c){var f=F.gaType?F.gaType:"gtm",g="Conversions",h=F.appName+" - Submitted Step "+(e+1),i=d.id,j=F.pageviewBase?F.pageviewBase:o(F.appName),k=a.isNumeric(e)?"step-"+e:"complete",l="/virtual/"+j+"/"+k;if("classic"==f)try{"event"==c&&d&&_gaq.push(["_trackEvent",g,h,i,null,!0]),"pageview"==c&&_gaq.push(["_trackPageview",l])}catch(m){}else if("universal"==f)try{"event"==c&&d&&ga("send","event",g,h,i,null,{nonInteraction:1}),"pageview"==c&&ga("send","pageview",l)}catch(m){}else if("gtm"==f)try{"event"==c&&d&&b[F.gtmDataLayerName].push({event:"Send Event",event_category:g,event_action:h,event_label:i}),"pageview"==c&&b[F.gtmDataLayerName].push({event:"Virtual Pageview",pageview_title:F.appName,pageview_path:l})}catch(m){}}}function q(b){b="undefined"==typeof b?"json":"hubspot";var c=f(F.cookieName)?h(d(F.cookieName)):{},e={};a.extend(e,c,I);for(key in e)e.hasOwnProperty(key)&&F.cookieIgnoreFields.indexOf(key)===-1&&"hubspot"==b&&e[key].constructor===Array&&(e[key]=e[key].join(";"));return e}function r(b,c){var d=b.find('input[type="hidden"]');d.each(function(b){var d=a(this),e=d.attr("name");""==d.val()&&"undefined"!=typeof c[e]&&d.val(c[e]).change()})}function s(b,c){a.each(c,function(d){var e=!1,f=b.find('*[name="'+c[d]+'"]');f.each(function(b){var c=a(this);c.is('input[type="radio"], input[type="checkbox"]')&&"checked"==c.attr("checked")&&c.change()}),f.is("select")&&f.find("option:selected")&&f.change(),e=!!f.val()||!f.attr("required"),e&&f.parents(".hs-form-field").hide()})}function t(b){return"function"!=typeof b?void console.log("Invalid callback - terminating script"):void("undefined"==typeof hbspt||"undefined"==typeof hbspt.forms?a.getScript("//js.hsforms.net/forms/v2.js",function(a,c,d){b()}):b())}function u(b){if(F.progress){switch(F.progressType){case"bar":H=a('<div class="hsfc__progress hsfc__progress--'+F.progressType+'"></div>'),H.append('<div class="hsfc__bar"><div class="hsfc__bar-fill" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"><span class="hsfc__bar-label hsfcPercentComplete"></span></div></div><div class="hsfc__bar-text">Step <span class="hsfcCurrentStep"></span> of '+D+"</div>");break;case"steps":default:H=a('<div class="hsfc__progress hsfc__progress--'+F.progressType+'" data-hsfc-step-count="'+F.forms.length+'"></div>'),a.each(F.forms,function(a){var b="hsfc__step hsfc__step--"+(a+1),c=this.stepName;this.translations&&this.translations[F.locale]&&this.translations[F.locale].hsfc&&(c=this.translations[F.locale].hsfc.stepName),H.append('<div class="'+b+'"><button aria-controls="#hsfcTarget--'+this.id+'" data-hsfc-step="'+a+'" data-hsfc-form-id="'+this.id+'"><span class="hsfc__step-number"><span>'+(a+1)+"</span></span>"+(c?' <span class="hsfc__step-label">'+c+"</span>":"")+"</button></div>")}),F.backButtons&&a(c).on("click",".hsfc__step--complete button",function(){var b=a(this).data("hsfc-step");C(b,null,!0)})}a(F.initialTarget).prepend(H)}}function v(b){if(F.progress)switch(F.progressType){case"bar":var c=0;b>=D?(c=100,H.find(".hsfc__bar-text").text("Complete!")):(c=b/D*100,H.find(".hsfcCurrentStep").text(b+1)),H.find(".hsfcPercentComplete").text(Math.round(c)+"%"),H.find(".hsfc__bar-fill").attr("aria-valuenow",c).css("width",c+"%");break;case"steps":default:a.each(H.find(".hsfc__step"),function(c){var d=a(this),e=d.find("button"),f="hsfc__step--current",g="hsfc__step--complete";e.prop("disabled",!0),b===c?d.removeClass(g).addClass(f):(c<b&&(d.removeClass(f).addClass(g),e.prop("disabled",!1)),c>b&&d.removeClass(f+" "+g))})}}function w(b,c){if(F.backButtons&&0!==c){var d=b.find(".actions"),e=F.backButtonText;F.translations[F.locale]&&F.translations[F.locale].hsfc&&(e=F.translations[F.locale].hsfc.backButtonText),d.prepend('<button class="hs-button hsfc__btn hsfc__btn--back" type="button" data-hsfc-step="'+(c-1)+'">'+e+"</button>"),a(".actions").on("click","button.hsfc__btn--back",function(a){a.preventDefault(),C(c-1,null,!0)})}}function x(a){if(a+=1,b.history&&b.history.pushState){var d=location.pathname,e=location.search.replace("&amp;","&");if(a<=D&&a>1)d+=e?e.indexOf("step=")!==-1?e.replace(/step=[0-9]+/,"step="+a):e+"&step="+a:"?step="+a;else{var f=e.split("&").length;if(1===f)d+=e.replace(/\?step=[0-9]+/,"");else{var g=1===e.indexOf("step=")?/step=[0-9]+&/:/&step=[0-9]+/;d+=e.replace(g,"")}}d!==location.pathname+location.search&&history.pushState({},c.title,d)}}function y(){G=a(F.initialTarget);var c="";G.empty(),b.navigator.cookieEnabled?a.each(F.forms,function(a){var b="hsfc__target",d=b,e=a+1;d+=" "+b+"--"+e,d+=e===F.forms.length?" "+b+"--last":"",c+='<section id="hsfcTarget--'+this.id+'" class="'+d+'" data-hsfc-form-id="'+this.id+'"></section>\n'}):c+='<div class="alert alert-warning hsfc__alert hsfc__alert--warning"><strong>Please Enable Cookies</strong><br>This application requires cookies to be enabled in your browser to function properly.</div>',G.attr("role","region").addClass("hsfc").prepend(c)}function z(b){var c=a(b?b:".hsfc__target");c.removeClass("hsfc__target--current hsfc__target--complete"),F.transition?setTimeout(function(){c.empty()},200):c.empty()}function A(){var b=a(".hsfc__msg");b.slice(-1,1).remove()}function B(a,b){if("object"!=typeof F.forms[a].requiredData)return a;var c=[a];for(var d in F.forms[a].requiredData)if(F.forms[a].requiredData.hasOwnProperty(d)){var e=F.forms[a].requiredData[d].match(/[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}/)?"id":"stepName";b[d]||c.push(m(F.forms,e,F.forms[a].requiredData[d]))}return Math.min.apply(null,c)}function C(b,c,d){var e={json:q(),hubspot:q("hubspot")};b=B(b,e.json),v(b),x(b);var f=F.forms[b],g=m(F.forms,"id",f.id);f.stepIndex=b+1;var h=JSON.parse(JSON.stringify(f)),k="#hsfcTarget--"+f.id,l=a(k);if(!0===d)for(var o=0;o<D;o++)f.id!==F.forms[o].id&&z("#hsfcTarget--"+F.forms[o].id);else z(k);var t=F.forms[b+1],u=g+1,y=b-1>-1&&F.forms[b-1].id,E=!!y&&a("#hsfcTarget--"+y),I={portalId:F.portalId,formId:f.id,formInstanceId:Math.floor(26*Math.random())+Date.now(),target:k,locale:F.locale,translations:{},blockedDomains:F.blockedDomains.constructor===Array?F.blockedDomains:[],css:F.css,cssClass:"hs-form hsfc__form "+(F.formClasses?" "+F.formClasses:""),submitButtonClass:"hsfc__btn hsfc__btn--submit "+(f.submitButtonClass||"hs-button hs-submit"),onBeforeFormInit:function(a){var b=f.stepIndex-1;E&&E.attr("class","hsfc__target hsfc__target--"+b+" hsfc__target--complete"),l.attr("class","hsfc__target hsfc__target--"+f.stepIndex),"function"==typeof f.onBeforeFormInit&&f.onBeforeFormInit(a),"function"==typeof F.onBeforeFormInit&&F.onBeforeFormInit(a)},onFormReady:function(a){E&&E.empty(),G.removeClass("hsfc--complete"),l.removeClass("submitted-message"),l.addClass("hsfc__target--current"),F.transition&&l.fadeIn(200),a.addClass("hsfc__form--ready"),p("pageview",f,g+1),r(a,e.hubspot),f.hiddenLogicFields&&s(a,f.hiddenLogicFields),w(a,b),"function"==typeof f.onFormReady&&f.onFormReady(a,e.json,h),"function"==typeof F.onFormReady&&F.onFormReady(a,e.json,h)},onFormSubmit:function(a){var b=n(a.find('input[type="number"], input[type="checkbox"], input[type="radio"], select').serializeArray()),d=n(a.find('input[type="text"], input[type="email"], input[type="tel"]').serializeArray());i(b,d),p("event",f,g+1),"function"==typeof f.onFormSubmit&&f.onFormSubmit(a,q()),"function"==typeof F.onFormSubmit&&F.onFormSubmit(a,q(),h),A(),l.addClass("hsfc__target--complete"),l.removeClass("submitted-message"),t?(F.transition&&l.fadeOut(200),C(u,c)):(G.addClass("hsfc--complete"),H.remove(),p("pageview",f,"complete"),j())}};if(a.extend(!0,I.translations,F.translations,f.translations),I.properties=e.hubspot,f.hasOwnProperty("msg")){var J=f.msg;f.translations&&f.translations[F.locale]&&f.translations[F.locale].hsfc&&(J=f.translations[F.locale].hsfc.msg),I.inlineMessage='<div class="hsfc__msg">'+J+"</div>"}else I.inlineMessage='<div style="display: none;" class="hsfc__msg">&nbsp;</div>';setTimeout(function(){hbspt.forms.create(I)},200)}var D,E={appName:"HubSpot Form Chainer",portalId:!1,initialTarget:!1,formClasses:"",locale:"en",translations:{},blockedDomains:[],transition:!1,cookieName:"hsFormChainer",cookieDomain:location.hostname,cookieExpiresDays:30,cookieIgnoreFields:[],css:"",forms:null,gaType:!1,gtmDataLayerName:"dataLayer",progress:!0,progressType:"steps",backButtons:!0,backButtonText:"&lsaquo; Go Back",onBeforeFormInit:null,onFormReady:null,onFormSubmit:null,scrollToFormTop:!0,debug:!1},F={},G=!1,H=!1,I={};return{create:function(c){if(c){a.extend(!0,F,E,c),D=F.forms.length;var d=l();F.forms[d];F.initialTarget&&t(function(){y(),F.progress&&u(d),C(d,null)}),b.history&&b.history.pushState&&b.addEventListener("popstate",function(a){z(),C(l(),null)})}},destroy:function(){G&&G.remove(),H&&H.remove(),D=0,F={}}}}(jQuery,window,document);