/*! iFrame Resizer (iframeSizer.min.js ) - v3.5.14 - 2017-09-25
 *  Desc: Force cross domain iframes to size to content.
 *  Requires: iframeResizer.contentWindow.min.js to be loaded into the target frame.
 *  Copyright: (c) 2017 David J. Bradshaw - dave@bradshaw.net
 *  License: MIT
 */

!function(a){"use strict";function b(a,b,c){"addEventListener"in window?a.addEventListener(b,c,!1):"attachEvent"in window&&a.attachEvent("on"+b,c)}function c(a,b,c){"removeEventListener"in window?a.removeEventListener(b,c,!1):"detachEvent"in window&&a.detachEvent("on"+b,c)}function d(){var a,b=["moz","webkit","o","ms"];for(a=0;a<b.length&&!N;a+=1)N=window[b[a]+"RequestAnimationFrame"];N||h("setup","RequestAnimationFrame not supported")}function e(a){var b="Host page: "+a;return window.top!==window.self&&(b=window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+a:"Nested host page: "+a),b}function f(a){return K+"["+e(a)+"]"}function g(a){return P[a]?P[a].log:G}function h(a,b){k("log",a,b,g(a))}function i(a,b){k("info",a,b,g(a))}function j(a,b){k("warn",a,b,!0)}function k(a,b,c,d){!0===d&&"object"==typeof window.console&&console[a](f(b),c)}function l(a){function d(){function a(){s(U),p(V),I("resizedCallback",U)}f("Height"),f("Width"),t(a,U,"init")}function e(){var a=T.substr(L).split(":");return{iframe:P[a[0]].iframe,id:a[0],height:a[1],width:a[2],type:a[3]}}function f(a){var b=Number(P[V]["max"+a]),c=Number(P[V]["min"+a]),d=a.toLowerCase(),e=Number(U[d]);h(V,"Checking "+d+" is in range "+c+"-"+b),e<c&&(e=c,h(V,"Set "+d+" to min value")),e>b&&(e=b,h(V,"Set "+d+" to max value")),U[d]=""+e}function g(){function b(){function a(){var a=0,b=!1;for(h(V,"Checking connection is from allowed list of origins: "+d);a<d.length;a++)if(d[a]===c){b=!0;break}return b}function b(){var a=P[V].remoteHost;return h(V,"Checking connection is from: "+a),c===a}return d.constructor===Array?a():b()}var c=a.origin,d=P[V].checkOrigin;if(d&&""+c!="null"&&!b())throw new Error("Unexpected message received from: "+c+" for "+U.iframe.id+". Message was: "+a.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}function k(){return K===(""+T).substr(0,L)&&T.substr(L).split(":")[0]in P}function l(){var a=U.type in{true:1,false:1,undefined:1};return a&&h(V,"Ignoring init message from meta parent page"),a}function w(a){return T.substr(T.indexOf(":")+J+a)}function y(a){h(V,"MessageCallback passed: {iframe: "+U.iframe.id+", message: "+a+"}"),I("messageCallback",{iframe:U.iframe,message:JSON.parse(a)}),h(V,"--")}function z(){var a=document.body.getBoundingClientRect(),b=U.iframe.getBoundingClientRect();return JSON.stringify({iframeHeight:b.height,iframeWidth:b.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(b.top-a.top,10),offsetLeft:parseInt(b.left-a.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset})}function A(a,b){function c(){u("Send Page Info","pageInfo:"+z(),a,b)}x(c,32)}function B(){function a(a,b){function c(){P[f]?A(P[f].iframe,f):d()}["scroll","resize"].forEach(function(d){h(f,a+d+" listener for sendPageInfo"),b(window,d,c)})}function d(){a("Remove ",c)}function e(){a("Add ",b)}var f=V;e(),P[f].stopPageInfo=d}function C(){P[V]&&P[V].stopPageInfo&&(P[V].stopPageInfo(),delete P[V].stopPageInfo)}function D(){var a=!0;return null===U.iframe&&(j(V,"IFrame ("+U.id+") not found"),a=!1),a}function E(a){var b=a.getBoundingClientRect();return o(V),{x:Math.floor(Number(b.left)+Number(M.x)),y:Math.floor(Number(b.top)+Number(M.y))}}function F(a){function b(){M=f,G(),h(V,"--")}function c(){return{x:Number(U.width)+e.x,y:Number(U.height)+e.y}}function d(){window.parentIFrame?window.parentIFrame["scrollTo"+(a?"Offset":"")](f.x,f.y):j(V,"Unable to scroll to requested position, window.parentIFrame not found")}var e=a?E(U.iframe):{x:0,y:0},f=c();h(V,"Reposition requested from iFrame (offset x:"+e.x+" y:"+e.y+")"),window.top!==window.self?d():b()}function G(){!1!==I("scrollCallback",M)?p(V):q()}function H(a){function b(){var a=E(f);h(V,"Moving to in page link (#"+d+") at x: "+a.x+" y: "+a.y),M={x:a.x,y:a.y},G(),h(V,"--")}function c(){window.parentIFrame?window.parentIFrame.moveToAnchor(d):h(V,"In page link #"+d+" not found and window.parentIFrame not found")}var d=a.split("#")[1]||"",e=decodeURIComponent(d),f=document.getElementById(e)||document.getElementsByName(e)[0];f?b():window.top!==window.self?c():h(V,"In page link #"+d+" not found")}function I(a,b){return m(V,a,b)}function N(){switch(P[V].firstRun&&S(),U.type){case"close":n(U.iframe);break;case"message":y(w(6));break;case"scrollTo":F(!1);break;case"scrollToOffset":F(!0);break;case"pageInfo":A(P[V].iframe,V),B();break;case"pageInfoStop":C();break;case"inPageLink":H(w(9));break;case"reset":r(U);break;case"init":d(),I("initCallback",U.iframe);break;default:d()}}function O(a){var b=!0;return P[a]||(b=!1,j(U.type+" No settings for "+a+". Message was: "+T)),b}function Q(){for(var a in P)u("iFrame requested init",v(a),document.getElementById(a),a)}function S(){P[V].firstRun=!1}var T=a.data,U={},V=null;"[iFrameResizerChild]Ready"===T?Q():k()?(U=e(),V=R=U.id,P[V].loaded=!0,!l()&&O(V)&&(h(V,"Received: "+T),D()&&g()&&N())):i(V,"Ignored: "+T)}function m(a,b,c){var d=null,e=null;if(P[a]){if("function"!=typeof(d=P[a][b]))throw new TypeError(b+" on iFrame["+a+"] is not a function");e=d(c)}return e}function n(a){var b=a.id;h(b,"Removing iFrame: "+b),a.parentNode&&a.parentNode.removeChild(a),m(b,"closedCallback",b),h(b,"--"),delete P[b]}function o(b){null===M&&(M={x:window.pageXOffset!==a?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==a?window.pageYOffset:document.documentElement.scrollTop},h(b,"Get page position: "+M.x+","+M.y))}function p(a){null!==M&&(window.scrollTo(M.x,M.y),h(a,"Set page position: "+M.x+","+M.y),q())}function q(){M=null}function r(a){function b(){s(a),u("reset","reset",a.iframe,a.id)}h(a.id,"Size reset requested by "+("init"===a.type?"host page":"iFrame")),o(a.id),t(b,a,"reset")}function s(a){function b(b){a.iframe.style[b]=a[b]+"px",h(a.id,"IFrame ("+e+") "+b+" set to "+a[b]+"px")}function c(b){H||"0"!==a[b]||(H=!0,h(e,"Hidden iFrame detected, creating visibility listener"),y())}function d(a){b(a),c(a)}var e=a.iframe.id;P[e]&&(P[e].sizeHeight&&d("height"),P[e].sizeWidth&&d("width"))}function t(a,b,c){c!==b.type&&N?(h(b.id,"Requesting animation frame"),N(a)):a()}function u(a,b,c,d,e){function f(){var e=P[d].targetOrigin;h(d,"["+a+"] Sending msg to iframe["+d+"] ("+b+") targetOrigin: "+e),c.contentWindow.postMessage(K+b,e)}function g(){j(d,"["+a+"] IFrame("+d+") not found")}function i(){c&&"contentWindow"in c&&null!==c.contentWindow?f():g()}function k(){function a(){!P[d]||P[d].loaded||l||(l=!0,j(d,"IFrame has not responded within "+P[d].warningTimeout/1e3+" seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ingored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning."))}e&&P[d].warningTimeout&&(P[d].msgTimeout=setTimeout(a,P[d].warningTimeout))}var l=!1;d=d||c.id,P[d]&&(i(),k())}function v(a){return a+":"+P[a].bodyMarginV1+":"+P[a].sizeWidth+":"+P[a].log+":"+P[a].interval+":"+P[a].enablePublicMethods+":"+P[a].autoResize+":"+P[a].bodyMargin+":"+P[a].heightCalculationMethod+":"+P[a].bodyBackground+":"+P[a].bodyPadding+":"+P[a].tolerance+":"+P[a].inPageLinks+":"+P[a].resizeFrom+":"+P[a].widthCalculationMethod}function w(c,d){function e(){function a(a){1/0!==P[x][a]&&0!==P[x][a]&&(c.style[a]=P[x][a]+"px",h(x,"Set "+a+" = "+P[x][a]+"px"))}function b(a){if(P[x]["min"+a]>P[x]["max"+a])throw new Error("Value for min"+a+" can not be greater than max"+a)}b("Height"),b("Width"),a("maxHeight"),a("minHeight"),a("maxWidth"),a("minWidth")}function f(){var a=d&&d.id||S.id+F++;return null!==document.getElementById(a)&&(a+=F++),a}function g(a){return R=a,""===a&&(c.id=a=f(),G=(d||{}).log,R=a,h(a,"Added missing iframe ID: "+a+" ("+c.src+")")),a}function i(){switch(h(x,"IFrame scrolling "+(P[x].scrolling?"enabled":"disabled")+" for "+x),c.style.overflow=!1===P[x].scrolling?"hidden":"auto",P[x].scrolling){case!0:c.scrolling="yes";break;case!1:c.scrolling="no";break;default:c.scrolling=P[x].scrolling}}function k(){"number"!=typeof P[x].bodyMargin&&"0"!==P[x].bodyMargin||(P[x].bodyMarginV1=P[x].bodyMargin,P[x].bodyMargin=P[x].bodyMargin+"px")}function l(){var a=P[x].firstRun,b=P[x].heightCalculationMethod in O;!a&&b&&r({iframe:c,height:0,width:0,type:"init"})}function m(){Function.prototype.bind&&(P[x].iframe.iFrameResizer={close:n.bind(null,P[x].iframe),resize:u.bind(null,"Window resize","resize",P[x].iframe),moveToAnchor:function(a){u("Move to anchor","moveToAnchor:"+a,P[x].iframe,x)},sendMessage:function(a){a=JSON.stringify(a),u("Send Message","message:"+a,P[x].iframe,x)}})}function o(d){function e(){u("iFrame.onload",d,c,a,!0),l()}b(c,"load",e),u("init",d,c,a,!0)}function p(a){if("object"!=typeof a)throw new TypeError("Options is not an object")}function q(a){for(var b in S)S.hasOwnProperty(b)&&(P[x][b]=a.hasOwnProperty(b)?a[b]:S[b])}function s(a){return""===a||"file://"===a?"*":a}function t(a){a=a||{},P[x]={firstRun:!0,iframe:c,remoteHost:c.src.split("/").slice(0,3).join("/")},p(a),q(a),P[x].targetOrigin=!0===P[x].checkOrigin?s(P[x].remoteHost):"*"}function w(){return x in P&&"iFrameResizer"in c}var x=g(c.id);w()?j(x,"Ignored iFrame, already setup."):(t(d),i(),e(),k(),o(v(x)),m())}function x(a,b){null===Q&&(Q=setTimeout(function(){Q=null,a()},b))}function y(){function a(){function a(a){function b(b){return"0px"===P[a].iframe.style[b]}function c(a){return null!==a.offsetParent}c(P[a].iframe)&&(b("height")||b("width"))&&u("Visibility change","resize",P[a].iframe,a)}for(var b in P)a(b)}function b(b){h("window","Mutation observed: "+b[0].target+" "+b[0].type),x(a,16)}function c(){var a=document.querySelector("body"),c={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};new d(b).observe(a,c)}var d=window.MutationObserver||window.WebKitMutationObserver;d&&c()}function z(a){function b(){B("Window "+a,"resize")}h("window","Trigger event: "+a),x(b,16)}function A(){function a(){B("Tab Visable","resize")}"hidden"!==document.visibilityState&&(h("document","Trigger event: Visiblity change"),x(a,16))}function B(a,b){function c(a){return"parent"===P[a].resizeFrom&&P[a].autoResize&&!P[a].firstRun}for(var d in P)c(d)&&u(a,b,document.getElementById(d),d)}function C(){b(window,"message",l),b(window,"resize",function(){z("resize")}),b(document,"visibilitychange",A),b(document,"-webkit-visibilitychange",A),b(window,"focusin",function(){z("focus")}),b(window,"focus",function(){z("focus")})}function D(){function b(a,b){function c(){if(!b.tagName)throw new TypeError("Object is not a valid DOM element");if("IFRAME"!==b.tagName.toUpperCase())throw new TypeError("Expected <IFRAME> tag, found <"+b.tagName+">")}b&&(c(),w(b,a),e.push(b))}function c(a){a&&a.enablePublicMethods&&j("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}var e;return d(),C(),function(d,f){switch(e=[],c(d),typeof f){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(f||"iframe"),b.bind(a,d));break;case"object":b(d,f);break;default:throw new TypeError("Unexpected data type ("+typeof f+")")}return e}}function E(a){a.fn?a.fn.iFrameResize||(a.fn.iFrameResize=function(a){function b(b,c){w(c,a)}return this.filter("iframe").each(b).end()}):i("","Unable to bind to jQuery, it is not fully loaded.")}if("undefined"!=typeof window){var F=0,G=!1,H=!1,I="message",J=I.length,K="[iFrameSizer]",L=K.length,M=null,N=window.requestAnimationFrame,O={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},P={},Q=null,R="Host Page",S={autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",closedCallback:function(){},initCallback:function(){},messageCallback:function(){j("MessageCallback function not defined")},resizedCallback:function(){},scrollCallback:function(){return!0}};window.jQuery&&E(window.jQuery),window.workbuster=window.workbuster||{},window.workbuster.iFrameResize=window.workbuster.iFrameResize||D()}}();
//# sourceMappingURL=iframeResizer.map

(function() {
  "use strict";

  /*
   * Workbuster installation
   * ---------------------------------------------------------------------------
   */
  var workbuster = {
    /**
     * The Workbuster installation script tag.
     *
     * @var {Object}
     */
    script: null,

    /**
     * The ID of target container, default: "workbuster_container".
     *
     * @var {String}
     */
    containerId: "workbuster_container",

    /**
     * The actual workbuster container, e.g. div#workbuster_container.
     *
     * @var {Object}
     */
    container: null,

    /**
     * The customer channel name.
     *
     * @var {String}
     */
    channel: "",

    /**
     * The customers career page URL.
     *
     * @var {String}
     */
    baseUrl: "//frontadvokater.workbuster.com",

    /**
     * Decides what page to be visible. Default is NULL and will
     * show landing page.
     *
     * @var {String} Can be NULL, 'open-application'
     */
    page: "",

    /**
     * The iFrame object
     *
     * @var {Object}
     */
    iFrame: null,

    /**
     * The job ID
     *
     * @var {Integer}
     */
    jobId: "",

    /**
     * The AGUID
     *
     * @var {String}
     */
    aguid: "",

    /**
     * The UUID
     *
     * @var {String}
     */
    uuid: "",

    /**
     * Hard coded referrer as parameter
     *
     * @var {String}
     */
    ref: "",

    /**
     * The Google Analytics variable
     *
     * @var {String}
     */
    _ga: "",

    /**
     * If set to true, this will result in the window scrolling to the top of the
     * iframe when the iframes onload callback is triggered.
     *
     * @var {String}
     */
    scrollOnLoad: false,

    /**
     * Trigger scroll to iframe if url has ref
     *
     * @var {String}
     */
    scrollOnRef: false,

    /**
     * The department category ID
     *
     * @var {Integer}
     */
    departmentId: "",

    /**
     * The story ID
     *
     * @var {Integer}
     */
    storyId: "",

    /**
     * The location category ID
     *
     * @var {Integer}
     */
    locationId: "",

    /**
     * The company category ID
     *
     * @var {Integer}
     */
    companyId: "",

    /**
     * Iframe careerpage language
     *
     * @var {String}
     */
    language: "",

    /**
     * Which cookie categories are consented to
     *
     * @var {Object}
     */
    cookieConsent: {"all":true},

    /**
     * The iFrame attributes
     *
     * @var {Object}
     */
    iFrameAttributes: {
      frameborder: 0,
      id: "workbuster_iframe",
      allowtransparency: "true",
      name: "workbuster_iframe",
      src: "",
      class: "optanon-category-c0001 optanon-category-c0003 optanon-category-c0002 optanon-category-c0004",
      style: "min-width:100%; width: 100%; overflow-y: hidden;",
      allow: "camera; microphone;",
      title: "Job application"
    },

    /**
     * Create the iFrame.
     *
     * @return {Object} The iFrame element.
     */
    createIframe: function() {
      var iFrame = window.document.createElement("iframe");
      var _this = this

      // Set predefined iFrame attributes
      for (var key in this.iFrameAttributes) {

        // Set the SRC
        if (key === 'src') {

          // Job ID
          if (!this.jobId) {
            this.jobId = this.getQuery('jobid');
          }

          // AGUID
          if (!this.aguid) {
            this.aguid = this.getQuery('aguid');
          }

          // UUID
          if (!this.uuid) {
            this.uuid = this.getQuery('uuid');
          }

          // Page
          if (this.getQuery('page')) {
            this.page = this.getQuery('page');
          }

          // Department
          if (this.getQuery('departmentid')) {
            this.departmentId = this.getQuery('departmentid')
          }

          // Story
          if (this.getQuery('storyid')) {
            this.storyId = this.getQuery('storyid')
          }

          // Location
          if (this.getQuery('locationid')) {
            this.locationId = this.getQuery('locationid')
          }

          // Company
          if (this.getQuery('companyid')) {
            this.companyId = this.getQuery('companyid')
          }

          // Dont run analytics if browser is in China
          var isChina = new Date().getTimezoneOffset() / 60 === -8

          if (!isChina && (this.cookieConsent.statistics || this.cookieConsent.all)) {
            // Initiate google analytics and pass clientId to iframe
            if(!window.ga){
              (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
              (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
              m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
              })(window,document,'script','https://www.google-analytics.com/analytics.js','ga')
            }

            ga('create', {
              trackingId: "UA-1346306-5",
              cookieDomain: 'auto',
              name: 'workbusterIframeTracker',
              cookieFlags: "secure;samesite=none",
              storage: 'none'
            })

            ga(function() {
              var tracker = ga.getByName('workbusterIframeTracker')
              var referrer = _this.getQuery('ref') || tracker.get('referrer')

              _this.setIframeSrc(referrer, key)

              _this.iFrame = iFrame
              _this.iFrame.setAttribute('src', _this.iFrameAttributes[key])
              // data-src is required by Onetrust consent manager
              _this.iFrame.setAttribute('data-src', _this.iFrameAttributes[key])
              _this.install(true)
              _this.iFrame.setAttribute('height', 1000)
            })
          } else {
            _this.setIframeSrc((_this.getQuery('ref') || _this.getQuery('ga_referrer') || document.referrer), key)
            _this.iFrame = iFrame
            _this.iFrame.setAttribute('src', _this.iFrameAttributes[key])
            // data-src is required by Onetrust consent manager
            _this.iFrame.setAttribute('data-src', _this.iFrameAttributes[key])
            _this.install(true)
            _this.iFrame.setAttribute('height', 1000)
          }

          setTimeout(function() {
            if (!_this.iFrame.src) {
              _this.setIframeSrc((_this.getQuery('ref') || _this.getQuery('ga_referrer') || document.referrer), key)
              _this.iFrame = iFrame
              _this.iFrame.setAttribute('src', _this.iFrameAttributes[key])
              // data-src is required by Onetrust consent manager
              _this.iFrame.setAttribute('data-src', _this.iFrameAttributes[key])
              _this.install(true)
              _this.iFrame.setAttribute('height', 1000)
            }
          }, 1000)
        } else {
          iFrame.setAttribute(key, this.iFrameAttributes[key]);
        }
      }

      return this.iFrame = iFrame;
    },

    /**
     * Create cookie-consent parameter from
     * cookie-consent object
     * @returns {string}
     */
    getCookieConsentParam: function () {
      var categories = Object.keys(this.cookieConsent);
      var categoriesLength = categories.length;
      var paramString = '&cookie-consent=';

      if (this.cookieConsent.all) {
        return '';
      }

      for (var i = 0; i < categoriesLength; i++) {
        if (!this.cookieConsent[categories[i]]) {
          continue;
        }
        // Minus 2 since 'all' is unused here
        var delimiter = i !== categoriesLength - 2
          ? ','
          : '';

          paramString += categories[i] + delimiter;
      }
      return paramString;
    },

    setIframeSrc: function(referrer, key) {
      var typePath = this.getQuery('type') === 'story' ? 'stories' : 'jobs';
      var cookieConsentValues = this.getCookieConsentParam();
      var ref = this.getQuery('ref') && this.ref.length === 0
        ? decodeURIComponent(this.getQuery('ref'))
        : this.ref;

      this.iFrameAttributes[key] = this.baseUrl
        + (this.page ? '/' + this.page : '')
        + (this.jobId ? '/jobs/' + this.jobId : '')
        + (this.aguid && !this.jobId ? '/jobs/?aguid=' + this.aguid : '')
        + (this.uuid && !this.aguid && !this.jobId ? '/' + typePath + '/?uuid=' + this.uuid : '')
        + (this.departmentId ? '/departments/' + this.departmentId : '')
        + (this.storyId ? '/stories/' + this.storyId : '')
        + (this.locationId ? '/locations/' + this.locationId : '')
        + (this.companyId ? '/companies/' + this.companyId : '')
        + (!this.aguid && !this.uuid ? '?_=' + Math.random() : '')
        + ('&ref=' + encodeURIComponent(ref))
        + (this.getQuery('channel') ? '&channel=' + this.getQuery('channel') : '')
        + (this.getQuery('language') && !this.language ? '&language=' + this.getQuery('language') : '&language=' + this.language)
        + (referrer ? '&ga_referrer=' + referrer : '')
        + (cookieConsentValues);
    },

    /**
     * Get value from QueryString.
     *
     * @var {String} name
     * @return {String}
     */
    getQuery: function(name) {
      var match = window.location.search.substring(1).match(new RegExp(name + '=([^&]*)'))
      if (match) {
        return match[1].replace(/\//, '')
      }

      if (name === 'jobid') {
        match = window.location.href.split(/\/jobs\//);

        if (match.length > 1) {
          return match[1];
        }
      } else if (name === 'departmentid') {
        match = window.location.href.split(/\/departments\//);

        if (match.length > 1) {
          return match[1];
        }
      } else if (name === 'locationid') {
        match = window.location.href.split(/\/locations\//);

        if (match.length > 1) {
          return match[1];
        }
      } else if (name === 'companyid') {
        match = window.location.href.split(/\/companies\//);

        if (match.length > 1) {
          return match[1];
        }
      }

      return null;
    },

    /**
     * Get installation script
     *
     * return {Object}
     */
    getScript: function() {
      var scripts = window.document.getElementsByTagName("script");
      return this.script = scripts[scripts.length - 1];
    },

    /**
     * Different polyfills for general use.
     */
    polyfills: function() {
      // Console error
      var console = window.console || {error: function() {} };
    },

    scrollToTop: function() {
      var bounds = document.getElementById('workbuster_iframe').getBoundingClientRect()
      var scrollTarget = bounds.top + window.pageYOffset - 50
      window.scrollTo(0, scrollTarget)
    },

    /**
     * Install workbuster.
     *
     * @return {Void}
     */
    install: function(skipInit) {

      var _this = this

      if(!skipInit){
        this.polyfills();
        this.createIframe();
      }

      // We need an ID for the workbuster container
      if (!this.containerId) {
        return console.error("Workbuster: We need an element ID to use as a container for the iFrame. Pass it as a string without a hash.");
      }

      // Get the container element
      this.container = window.document.getElementById(this.containerId);

      // We need a container to append the iFrame to.
      if (typeof this.container === 'undefined' || !this.container) {
        return console.error("Workbuster: We could not target the workbuster container with the ID: "  + this.containerId);
      }

      var scrollOnRef = this.scrollOnRef && this.getQuery('ref');
      var jobId = this.getQuery('jobid');

      if (this.scrollOnLoad || scrollOnRef) {
        var firstLoad = true
        this.iFrame.onload = function() {
          if (!firstLoad || scrollOnRef || jobId) {
            _this.scrollToTop()
          }
          firstLoad = false
        }
      }

      this.container.appendChild(this.iFrame);
      var isOldIE = (navigator.userAgent.indexOf("MSIE") !== -1);
      window.workbuster.iFrameResize({
        heightCalculationMethod: isOldIE ? 'max' : 'lowestElement',
        checkOrigin: false
      }, '#workbuster_iframe');
    }
  };

  workbuster.install();
})(window);
