(function () {
  "use strict";
    
  function receiveMessage(event) {
    if (event.data.url) {
      setTimeout(function(){ document.location = event.data.url; }, 500);
    };
    return false;
  }

  window.addEventListener("message", receiveMessage, false);
  
  var BeGateway = function (options) {
    if (!options.url) {
      return false;
    };
    
    this.url = options.url;
    this.styles = options.style;
    this.type = options.type;
    this.anchor = options.id;
    this.iframeDivId = 'beGatewayForm';

    if (options.size) {
      this.size = options.size;
    } else {
      this.size = { height: 480, width: 320 };  
    };
  };

  BeGateway.prototype.isMobile = function () {
    if ( navigator.userAgent.match(/Android/i) ||
      navigator.userAgent.match(/iPhone/i) ||
      navigator.userAgent.match(/Windows Phone/i) ) {
      return true;
    } else {
      return false;
    }
  }

  BeGateway.prototype.prepareIframe = function (url) {
    var iframeDiv = document.createElement("div");
    iframeDiv.setAttribute("id", this.iframeDivId);
    iframeDiv.style.display = "none";

    var iframe = document.createElement("IFRAME");
    iframe.setAttribute("src", url);
    iframe.setAttribute("frameborder", "0");
    iframe.style.display = "block";
    iframe.style.margin = "auto";

    if (this.size) {
      iframe.style.width = this.size.width + "px";
      iframe.style.height = this.size.height + "px";
    };

    iframeDiv.appendChild(iframe);

    if (this.anchor && document.getElementById(this.anchor)) {
      document.getElementById(this.anchor).appendChild(iframeDiv);
    } else {
      document.body.appendChild(iframeDiv);
    };

    var styles = this.styles;
    var size = this.size;

    iframe.onload = function() {
      iframe.contentWindow.postMessage({ css: styles }, "*");
      if ($('#closeWindow').size() == 0) {
        $('.ui-dialog').prepend("<a href='#' id='closeWindow'></div>");
        $("a#closeWindow").css("left", size.width);

        $('a#closeWindow').click(function() {
          $('#dialogWindow').dialog('close');
        });

      };
    };
    return iframe;
  }

  BeGateway.prototype.buildOverlayForm = function (url) {
    var linkId = '#' + this.anchor;
    var size = this.size;
    var that = this;
    var dialogId = "dialogWindow";

    var emptyDiv = document.createElement('div');
    emptyDiv.setAttribute("id", dialogId);
    document.body.appendChild(emptyDiv);
    
    var reg = new RegExp('([http|https].+\/)checkout')
    var path =  reg.exec(this.url)[1];
    var cssPath = path + 'stylesheets/jquery-ui.min.css'
    $('body').append('<link rel="stylesheet" href="' + cssPath + '">');

    $(linkId).click(function(event) {
      event.preventDefault();

      if (that.isMobile()) {
        window.open(that.url);
        return false;
      }

      $('#' + dialogId).dialog({
        modal: true,
        width: size.width + 10,
        height: size.height + 30,
        show: {
          effect: "fadeIn"
        },
        hide: {
          effect: "fadeOut"
        },
        open: function () {
          if ($('#' + dialogId).children('iframe').size() == 0) {
            document.getElementById(dialogId).appendChild(that.prepareIframe(url + "&iframe=overlay"));
          };
        }
      });
    });
  };

  BeGateway.prototype.buildInlineForm = function(url) {
    url = url + "&iframe=inline";

    this.prepareIframe(url);
    $('#' + this.iframeDivId).show();
  }

  BeGateway.prototype.buildForm = function () {
    if (options.style) {
      this.styles = options.style;
    };

    if (this.type == 'overlay') {
      this.buildOverlayForm(this.url);
      return false;
    };

    if (this.type == 'inline') {
      this.buildInlineForm(this.url);
      return false;
    };
  };

  window.BeGateway = BeGateway;
}());

@@ -2063,16 +2063,25 @@
 ogWindow
+BeGateway
 ').dialo
@@ -2318,16 +2318,25 @@
 ogWindow
+BeGateway
 %22;%0A%0A    
@@ -2465,20 +2465,16 @@
 tyDiv);%0A
-    
 %0A    var
@@ -2850,16 +2850,97 @@
      %7D%0A%0A
+      var new_width = size.width + 10;%0A      var new_height = size.height + 10;%0A%0A
       $(
@@ -2964,16 +2964,47 @@
 ialog(%7B%0A
+        dialogClass: dialogId,%0A
         
@@ -3031,31 +3031,25 @@
  width: 
-size.width + 10
+new_width
 ,%0A      
@@ -3062,24 +3062,18 @@
 ht: 
-size.
+new_
 height
- + 30
 ,%0A  
@@ -3386,24 +3386,242 @@
          %7D;%0A
+          $('#' + dialogId).css(%22cssText%22,%0A            %22width: %22 + new_width + %22px !important;;%22 + %0A            %22max-height:%22 + new_height + %22px !important;%22 +%0A            %22height: %22 + new_height + %22px !important;%22 );%0A
         %7D%0A  

Add hot fix for cases when user made custom style for bootstrap css