<commit_before>  // v 1.14.2

// Mondido settings
(function($) {
  var do_log = function(str){
    if(window.console){
      console.log(str);
    }
  };

  if (mondidoSettings.config.development == true){
    do_log("Development mode is on");
  }

  if (typeof Mondido === "undefined") {
    console.log("Error could not load Mondido object");
    Mondido = {
      token: "<PASSWORD>",
      transaction: {
        id: "0"
      },
      merchant: {
        id: "0"
      }
    };
  }

  invoice = $.grep(mondidoSettings.supportedPaymentMethods, function(e){ return e.name == "invoice_tab"; });
  $("#accept_collector").attr("data-mulang", "invoice_accept_conditions['"+mondidoSettings.layout.name+"','"+mondidoSettings.layout.terms_and_conditions_url+"','"+invoice[0].AgreementCode+"','"+invoice[0].AgreementCode+"']");

})(jQuery);

/*
    jQuery Masked Input Plugin
    Copyright (c) 2007 - 2014 <NAME> (digitalbush.com)
    Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license)
    Version: 1.4.0
*/
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;if(0!==this.length&&!this.is(":hidden"))return"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a<g.placeholder.length?a:0)}function q(a){for(;++a<n&&!j[a];);return a}function r(a){for(;--a>=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(a.length<o.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.begin<l&&!j[b.begin];)b.begin++;B.caret(b.begin,b.begin)}else{for(A(!0);b.begin<n&&!j[b.begin];)b.begin++;B.caret(b.begin,b.begin)}h()}function v(){A(),B.val()!=E&&B.change()}function w(a){if(!B.prop("readonly")){var b,c,e,f=a.which||a.keyCode;o=B.val(),8===f||46===f||d&&127===f?(b=B.caret(),c=b.begin,e=b.end,e-c===0&&(c=46!==f?r(c):e=q(c-1),e=46===f?q(e):e),y(c,e),s(c,e-1),a.preventDefault()):13===f?v.call(this,a):27===f&&(B.val(E),B.caret(0,A()),a.preventDefault())}}function x(b){if(!B.prop("readonly")){var c,d,e,g=b.which||b.keyCode,i=B.caret();if(!(b.ctrlKey||b.altKey||b.metaKey||32>g)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++<e.length;)if(c=e.charAt(d-1),j[b].test(c)){C[b]=c,f=b;break}if(d>e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a)},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})});



//https://github.com/stripe/jquery.payment - 2.0.0
// Generated by CoffeeScript 1.7.1
(function() {
  var $, cardFromNumber, cardFromType, cards, defaultFormat, formatBackCardNumber, formatBackExpiry, formatCardNumber, formatExpiry, formatForwardExpiry, formatForwardSlashAndSpace, hasTextSelected, luhnCheck, reFormatCVC, reFormatCardNumber, reFormatExpiry, reFormatNumeric, replaceFullWidthChars, restrictCVC, restrictCardNumber, restrictExpiry, restrictNumeric, safeVal, setCardType,
    __slice = [].slice,
    __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

  $ = window.jQuery || window.Zepto || window.$;

  $.payment = {};

  $.payment.fn = {};

  $.fn.payment = function() {
    var args, method;
    method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
    return $.payment.fn[method].apply(this, args);
  };

  defaultFormat = /(\d{1,4})/g;

  $.payment.cards = cards = [
    {
      type: 'elo',
      patterns: [4011, 4312, 4389, 4514, 4573, 4576, 5041, 5066, 5067, 509, 6277, 6362, 6363, 650, 6516, 6550],
      format: defaultFormat,
      length: [16],
      cvcLength: [3],
      luhn: true
    }, {
      type: 'visaelectron',
      patterns: [4026, 417500, 4405, 4508, 4844, 4913, 4917],
      format: defaultFormat,
      length: [16],
      cvcLength: [3],
      luhn: true
    }, {
      type: 'maestro',
      patterns: [5018, 502, 503, 506, 56, 58, 639, 6220, 67],
      format: defaultFormat,
      length: [12, 13, 14, 15, 16, 17, 18, 19],
      cvcLength: [3],
      luhn: true
    }, {
      type: 'forbrugsforeningen',
      patterns: [600],
      format: defaultFormat,
      length: [16],
      cvcLength: [3],
      luhn: true
    }, {
      type: 'dankort',
      patterns: [5019],
      format: defaultFormat,
      length: [16],
      cvcLength: [3],
      luhn: true
    }, {
      type: 'visa',
      patterns: [4],
      format: defaultFormat,
      length: [13, 16],
      cvcLength: [3],
      luhn: true
    }, {
      type: 'mastercard',
      patterns: [51, 52, 53, 54, 55, 22, 23, 24, 25, 26, 27],
      format: defaultFormat,
      length: [16],
      cvcLength: [3],
      luhn: true
    }, {
      type: 'amex',
      patterns: [34, 37],
      format: /(\d{1,4})(\d{1,6})?(\d{1,5})?/,
      length: [15],
      cvcLength: [3, 4],
      luhn: true
    }, {
      type: 'dinersclub',
      patterns: [30, 36, 38, 39],
      format: /(\d{1,4})(\d{1,6})?(\d{1,4})?/,
      length: [14],
      cvcLength: [3],
      luhn: true
    }, {
      type: 'discover',
      patterns: [60, 64, 65, 622],
      format: defaultFormat,
      length: [16],
      cvcLength: [3],
      luhn: true
    }, {
      type: 'unionpay',
      patterns: [62, 88],
      format: defaultFormat,
      length: [16, 17, 18, 19],
      cvcLength: [3],
      luhn: false
    }, {
      type: 'jcb',
      patterns: [35],
      format: defaultFormat,
      length: [16],
      cvcLength: [3],
      luhn: true
    }
  ];

  cardFromNumber = function(num) {
    var card, p, pattern, _i, _j, _len, _len1, _ref;
    num = (num + '').replace(/\D/g, '');
    for (_i = 0, _len = cards.length; _i < _len; _i++) {
      card = cards[_i];
      _ref = card.patterns;
      for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
        pattern = _ref[_j];
        p = pattern + '';
        if (num.substr(0, p.length) === p) {
          return card;
        }
      }
    }
  };

  cardFromType = function(type) {
    var card, _i, _len;
    for (_i = 0, _len = cards.length; _i < _len; _i++) {
      card = cards[_i];
      if (card.type === type) {
        return card;
      }
    }
  };

  luhnCheck = function(num) {
    var digit, digits, odd, sum, _i, _len;
    odd = true;
    sum = 0;
    digits = (num + '').split('').reverse();
    for (_i = 0, _len = digits.length; _i < _len; _i++) {
      digit = digits[_i];
      digit = parseInt(digit, 10);
      if ((odd = !odd)) {
        digit *= 2;
      }
      if (digit > 9) {
        digit -= 9;
      }
      sum += digit;
    }
    return sum % 10 === 0;
  };

  hasTextSelected = function($target) {
    var _ref;
    if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== $target.prop('selectionEnd')) {
      return true;
    }
    if ((typeof document !== "undefined" && document !== null ? (_ref = document.selection) != null ? _ref.createRange : void 0 : void 0) != null) {
      if (document.selection.createRange().text) {
        return true;
      }
    }
    return false;
  };

  safeVal = function(value, $target) {
    var currPair, cursor, digit, error, last, prevPair;
    try {
      cursor = $target.prop('selectionStart');
    } catch (_error) {
      error = _error;
      cursor = null;
    }
    last = $target.val();
    $target.val(value);
    if (cursor !== null && $target.is(":focus")) {
      if (cursor === last.length) {
        cursor = value.length;
      }
      if (last !== value) {
        prevPair = last.slice(cursor - 1, +cursor + 1 || 9e9);
        currPair = value.slice(cursor - 1, +cursor + 1 || 9e9);
        digit = value[cursor];
        if (/\d/.test(digit) && prevPair === ("" + digit + " ") && currPair === (" " + digit)) {
          cursor = cursor + 1;
        }
      }
      $target.prop('selectionStart', cursor);
      return $target.prop('selectionEnd', cursor);
    }
  };

  replaceFullWidthChars = function(str) {
    var chars, chr, fullWidth, halfWidth, idx, value, _i, _len;
    if (str == null) {
      str = '';
    }
    fullWidth = '\uff10\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19';
    halfWidth = '0123456789';
    value = '';
    chars = str.split('');
    for (_i = 0, _len = chars.length; _i < _len; _i++) {
      chr = chars[_i];
      idx = fullWidth.indexOf(chr);
      if (idx > -1) {
        chr = halfWidth[idx];
      }
      value += chr;
    }
    return value;
  };

  reFormatNumeric = function(e) {
    var $target;
    $target = $(e.currentTarget);
    return setTimeout(function() {
      var value;
      value = $target.val();
      value = replaceFullWidthChars(value);
      value = value.replace(/\D/g, '');
      return safeVal(value, $target);
    });
  };

  reFormatCardNumber = function(e) {
    var $target;
    $target = $(e.currentTarget);
    return setTimeout(function() {
      var value;
      value = $target.val();
      value = replaceFullWidthChars(value);
      value = $.payment.formatCardNumber(value);
      return safeVal(value, $target);
    });
  };

  formatCardNumber = function(e) {
    var $target, card, digit, length, re, upperLength, value;
    digit = String.fromCharCode(e.which);
    if (!/^\d+$/.test(digit)) {
      return;
    }
    $target = $(e.currentTarget);
    value = $target.val();
    card = cardFromNumber(value + digit);
    length = (value.replace(/\D/g, '') + digit).length;
    upperLength = 16;
    if (card) {
      upperLength = card.length[card.length.length - 1];
    }
    if (length >= upperLength) {
      return;
    }
    if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
      return;
    }
    if (card && card.type === 'amex') {
      re = /^(\d{4}|\d{4}\s\d{6})$/;
    } else {
      re = /(?:^|\s)(\d{4})$/;
    }
    if (re.test(value)) {
      e.preventDefault();
      return setTimeout(function() {
        return $target.val(value + ' ' + digit);
      });
    } else if (re.test(value + digit)) {
      e.preventDefault();
      return setTimeout(function() {
        return $target.val(value + digit + ' ');
      });
    }
  };

  formatBackCardNumber = function(e) {
    var $target, value;
    $target = $(e.currentTarget);
    value = $target.val();
    if (e.which !== 8) {
      return;
    }
    if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
      return;
    }
    if (/\d\s$/.test(value)) {
      e.preventDefault();
      return setTimeout(function() {
        return $target.val(value.replace(/\d\s$/, ''));
      });
    } else if (/\s\d?$/.test(value)) {
      e.preventDefault();
      return setTimeout(function() {
        return $target.val(value.replace(/\d$/, ''));
      });
    }
  };

  reFormatExpiry = function(e) {
    var $target;
    $target = $(e.currentTarget);
    return setTimeout(function() {
      var value;
      value = $target.val();
      value = replaceFullWidthChars(value);
      value = $.payment.formatExpiry(value);
      return safeVal(value, $target);
    });
  };

  formatExpiry = function(e) {
    var $target, digit, val;
    digit = String.fromCharCode(e.which);
    if (!/^\d+$/.test(digit)) {
      return;
    }
    $target = $(e.currentTarget);
    val = $target.val() + digit;
    if (/^\d$/.test(val) && (val !== '0' && val !== '1')) {
      e.preventDefault();
      return setTimeout(function() {
        return $target.val("0" + val + " / ");
      });
    } else if (/^\d\d$/.test(val)) {
      e.preventDefault();
      return setTimeout(function() {
        var m1, m2;
        m1 = parseInt(val[0], 10);
        m2 = parseInt(val[1], 10);
        if (m2 > 2 && m1 !== 0) {
          return $target.val("0" + m1 + " / " + m2);
        } else {
          return $target.val("" + val + " / ");
        }
      });
    }
  };

  formatForwardExpiry = function(e) {
    var $target, digit, val;
    digit = String.fromCharCode(e.which);
    if (!/^\d+$/.test(digit)) {
      return;
    }
    $target = $(e.currentTarget);
    val = $target.val();
    if (/^\d\d$/.test(val)) {
      return $target.val("" + val + " / ");
    }
  };

  formatForwardSlashAndSpace = function(e) {
    var $target, val, which;
    which = String.fromCharCode(e.which);
    if (!(which === '/' || which === ' ')) {
      return;
    }
    $target = $(e.currentTarget);
    val = $target.val();
    if (/^\d$/.test(val) && val !== '0') {
      return $target.val("0" + val + " / ");
    }
  };

  formatBackExpiry = function(e) {
    var $target, value;
    $target = $(e.currentTarget);
    value = $target.val();
    if (e.which !== 8) {
      return;
    }
    if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
      return;
    }
    if (/\d\s\/\s$/.test(value)) {
      e.preventDefault();
      return setTimeout(function() {
        return $target.val(value.replace(/\d\s\/\s$/, ''));
      });
    }
  };

  reFormatCVC = function(e) {
    var $target;
    $target = $(e.currentTarget);
    return setTimeout(function() {
      var value;
      value = $target.val();
      value = replaceFullWidthChars(value);
      value = value.replace(/\D/g, '').slice(0, 4);
      return safeVal(value, $target);
    });
  };

  restrictNumeric = function(e) {
    var input;
    if (e.metaKey || e.ctrlKey) {
      return true;
    }
    if (e.which === 32) {
      return false;
    }
    if (e.which === 0) {
      return true;
    }
    if (e.which < 33) {
      return true;
    }
    input = String.fromCharCode(e.which);
    return !!/[\d\s]/.test(input);
  };

  restrictCardNumber = function(e) {
    var $target, card, digit, value;
    $target = $(e.currentTarget);
    digit = String.fromCharCode(e.which);
    if (!/^\d+$/.test(digit)) {
      return;
    }
    if (hasTextSelected($target)) {
      return;
    }
    value = ($target.val() + digit).replace(/\D/g, '');
    card = cardFromNumber(value);
    if (card) {
      return value.length <= card.length[card.length.length - 1];
    } else {
      return value.length <= 16;
    }
  };

  restrictExpiry = function(e) {
    var $target, digit, value;
    $target = $(e.currentTarget);
    digit = String.fromCharCode(e.which);
    if (!/^\d+$/.test(digit)) {
      return;
    }
    if (hasTextSelected($target)) {
      return;
    }
    value = $target.val() + digit;
    value = value.replace(/\D/g, '');
    if (value.length > 6) {
      return false;
    }
  };

  restrictCVC = function(e) {
    var $target, digit, val;
    $target = $(e.currentTarget);
    digit = String.fromCharCode(e.which);
    if (!/^\d+$/.test(digit)) {
      return;
    }
    if (hasTextSelected($target)) {
      return;
    }
    val = $target.val() + digit;
    return val.length <= 4;
  };

  setCardType = function(e) {
    var $target, allTypes, card, cardType, val;
    $target = $(e.currentTarget);
    val = $target.val();
    cardType = $.payment.cardType(val) || 'unknown';
    if (!$target.hasClass(cardType)) {
      allTypes = (function() {
        var _i, _len, _results;
        _results = [];
        for (_i = 0, _len = cards.length; _i < _len; _i++) {
          card = cards[_i];
          _results.push(card.type);
        }
        return _results;
      })();
      $target.removeClass('unknown');
      $target.removeClass(allTypes.join(' '));
      $target.addClass(cardType);
      $target.toggleClass('identified', cardType !== 'unknown');
      return $target.trigger('payment.cardType', cardType);
    }
  };

  $.payment.fn.formatCardCVC = function() {
    this.on('keypress', restrictNumeric);
    this.on('keypress', restrictCVC);
    this.on('paste', reFormatCVC);
    this.on('change', reFormatCVC);
    this.on('input', reFormatCVC);
    return this;
  };

  $.payment.fn.formatCardExpiry = function() {
    this.on('keypress', restrictNumeric);
    this.on('keypress', restrictExpiry);
    this.on('keypress', formatExpiry);
    this.on('keypress', formatForwardSlashAndSpace);
    this.on('keypress', formatForwardExpiry);
    this.on('keydown', formatBackExpiry);
    this.on('change', reFormatExpiry);
    this.on('input', reFormatExpiry);
    return this;
  };

  $.payment.fn.formatCardNumber = function() {
    this.on('keypress', restrictNumeric);
    this.on('keypress', restrictCardNumber);
    this.on('keypress', formatCardNumber);
    this.on('keydown', formatBackCardNumber);
    this.on('keyup', setCardType);
    this.on('paste', reFormatCardNumber);
    this.on('change', reFormatCardNumber);
    this.on('input', reFormatCardNumber);
    this.on('input', setCardType);
    return this;
  };

  $.payment.fn.restrictNumeric = function() {
    this.on('keypress', restrictNumeric);
    this.on('paste', reFormatNumeric);
    this.on('change', reFormatNumeric);
    this.on('input', reFormatNumeric);
    return this;
  };

  $.payment.fn.cardExpiryVal = function() {
    return $.payment.cardExpiryVal($(this).val());
  };

  $.payment.cardExpiryVal = function(value) {
    var month, prefix, year, _ref;
    _ref = value.split(/[\s\/]+/, 2), month = _ref[0], year = _ref[1];
    if ((year != null ? year.length : void 0) === 2 && /^\d+$/.test(year)) {
      prefix = (new Date).getFullYear();
      prefix = prefix.toString().slice(0, 2);
      year = prefix + year;
    }
    month = parseInt(month, 10);
    year = parseInt(year, 10);
    return {
      month: month,
      year: year
    };
  };

  $.payment.validateCardNumber = function(num) {
    var card, _ref;
    num = (num + '').replace(/\s+|-/g, '');
    if (!/^\d+$/.test(num)) {
      return false;
    }
    card = cardFromNumber(num);
    if (!card) {
      return false;
    }
    return (_ref = num.length, __indexOf.call(card.length, _ref) >= 0) && (card.luhn === false || luhnCheck(num));
  };

  $.payment.validateCardExpiry = function(month, year) {
    var currentTime, expiry, _ref;
    if (typeof month === 'object' && 'month' in month) {
      _ref = month, month = _ref.month, year = _ref.year;
    }
    if (!(month && year)) {
      return false;
    }
    month = $.trim(month);
    year = $.trim(year);
    if (!/^\d+$/.test(month)) {
      return false;
    }
    if (!/^\d+$/.test(year)) {
      return false;
    }
    if (!((1 <= month && month <= 12))) {
      return false;
    }
    if (year.length === 2) {
      if (year < 70) {
        year = "20" + year;
      } else {
        year = "19" + year;
      }
    }
    if (year.length !== 4) {
      return false;
    }
    expiry = new Date(year, month);
    currentTime = new Date;
    expiry.setMonth(expiry.getMonth() - 1);
    expiry.setMonth(expiry.getMonth() + 1, 1);
    return expiry > currentTime;
  };

  $.payment.validateCardCVC = function(cvc, type) {
    var card, _ref;
    cvc = $.trim(cvc);
    if (!/^\d+$/.test(cvc)) {
      return false;
    }
    card = cardFromType(type);
    if (card != null) {
      return _ref = cvc.length, __indexOf.call(card.cvcLength, _ref) >= 0;
    } else {
      return cvc.length >= 3 && cvc.length <= 4;
    }
  };

  $.payment.cardType = function(num) {
    var _ref;
    if (!num) {
      return null;
    }
    return ((_ref = cardFromNumber(num)) != null ? _ref.type : void 0) || null;
  };

  $.payment.formatCardNumber = function(num) {
    var card, groups, upperLength, _ref;
    num = num.replace(/\D/g, '');
    card = cardFromNumber(num);
    if (!card) {
      return num;
    }
    upperLength = card.length[card.length.length - 1];
    num = num.slice(0, upperLength);
    if (card.format.global) {
      return (_ref = num.match(card.format)) != null ? _ref.join(' ') : void 0;
    } else {
      groups = card.format.exec(num);
      if (groups == null) {
        return;
      }
      groups.shift();
      groups = $.grep(groups, function(n) {
        return n;
      });
      return groups.join(' ');
    }
  };

  $.payment.formatExpiry = function(expiry) {
    var mon, parts, sep, year;
    parts = expiry.match(/^\D*(\d{1,2})(\D+)?(\d{1,4})?/);
    if (!parts) {
      return '';
    }
    mon = parts[1] || '';
    sep = parts[2] || '';
    year = parts[3] || '';
    if (year.length > 0) {
      sep = ' / ';
    } else if (sep === ' /') {
      mon = mon.substring(0, 1);
      sep = '';
    } else if (mon.length === 2 || sep.length > 0) {
      sep = ' / ';
    } else if (mon.length === 1 && (mon !== '0' && mon !== '1')) {
      mon = "0" + mon;
      sep = ' / ';
    }
    return mon + sep + year;
  };

}).call(this);

  /*
    Mulang 1.2
    Multi Language Template Plugin
    By <EMAIL>

    Requires JQuery to work.
   */
  (function ( $ ) {

      var methods = {
          init : function(options) {

          },
          getCountry : function(data) {
          /*
          Get estimated country from metadata and/or locale string
          returns for example: se,us,unknown
          */
              var filter = [
              {r: '(usa|united states|en_US)',c: 'us', l: 'en'},
              {r: '(austria|Ã¶sterreich|de_AT)',c: 'at', l: 'de'},
              {r: '(belgium|belgiÃ«|nl_BE)',c: 'be', l: 'nl'},
              {r: '(belgium|belgique|fr_BE)',c: 'be', l: 'fr'},
              {r: '(bulgaria|Ð‘ÑŠÐ»Ð³Ð°Ñ€Ð¸Ñ|bg_BG)',c: 'bg', l: 'en'},
              {r: '(croatia|hrvatska|hr_HR)',c: 'hr', l: 'en'},
              {r: '(czech republic|ÄeskÃ¡ republika|cs_CZ)',c: 'cz', l: 'en'},
              {r: '(cyprus|kÏÏ€ÏÎ¿Ï‚|el_CY)',c: 'cy', l: 'en'},
              {r: '(denmark|danmark|da_DK)',c: 'dk', l: 'da'},
              {r: '(estonia|eesti|et_EE)',c: 'ee', l: 'en'},
              {r: '(finland|suomi|fi_FI)',c: 'fi', l: 'fi'},
              {r: '(finland|finland|sv_FI)',c: 'fi', l: 'sv'},
              {r: '(france|france|fr_FR)',c: 'fr', l: 'fr'},
              {r: '(germany|deutschland|de_DE)',c: 'de', l: 'de'},
              {r: '(greece|eÎ»Î»Î¬Î´Î±|el_GR)',c: 'gr', l: 'en'},
              {r: '(hungary|magyarorszÃ¡g|hu_HU)',c: 'hu', l: 'en'},
              {r: '(ireland|ireland|en_IE)',c: 'ie', l: 'en'},
              {r: '(italy|italia|it_IT)',c: 'it', l: 'en'},
              {r: '(latvia|latvija|lv_LV)',c: 'lv', l: 'en'},
              {r: '(lithuania|lietuva|lt_LT)',c: 'lt', l: 'en'},
              {r: '(luxembourg|luxembourg|fr_LU)',c: 'lu', l: 'fr'},
              {r: '(luxembourg|luxemburg|de_LU)',c: 'lu', l: 'de'},
              {r: '(malta|malta|mt_MT)',c: 'mt', l: 'en'},
              {r: '(netherlands|nederland|nl_NL)',c: 'nl', l: 'nl'},
              {r: '(norway|norge|no_NO)',c: 'no', l: 'en'},
              {r: '(poland|polska|pl_PL)',c: 'pl', l: 'en'},
              {r: '(portugal|portugal|pt_PT)',c: 'pt', l: 'en'},
              {r: '(romania|romÃ¢nia|ro_RO)',c: 'ro', l: 'en'},
              {r: '(slovakia|slovensko|sk_SK)',c: 'sk', l: 'en'},
              {r: '(slovenia|slovenija|sl_SI)',c: 'si', l: 'en'},
              {r: '(spain|espaÃ±a|es_ES)',c: 'es', l: 'es'},
              {r: '(united kingdom|uk|en_GB)',c: 'gb', l: 'en'},
              {r: '(sweden|sverige|se_SE)',c: 'se', l: 'sv'}
              ];
              var score = [];
              $(filter).each(function(){
                  var regex = new RegExp(this.r,'gi');
                  var res = data.match(regex);
                  if(res){
                      score.splice(res.length, 0, this);
                  }
              });
              if(score.length > 0){
                  return score[score.length-1];
              }else{
                  return null;
              }
          }
      };


    $.fn.mulang = function( options ) {

      if ( methods[options] ) {
          return methods[ options ].apply( this, Array.prototype.slice.call( arguments, 1 ));
      }

      if(!options){
        options = {};
      }
      if(!options.fallback){
        options.fallback = 'en';
      }
      var do_log = function(str){
        if(window.console){
          console.log(str);
        }
      };

      if(!options.lang){ //if there is no lang in options, grab from the browser
        options.lang = window.navigator.userLanguage || window.navigator.language;
        langFromData = $.fn.mulang('getCountry',options.data +' '+options.lang.replace('-','_'));
        if(langFromData){
            options.lang = langFromData.l;
        }
        do_log('mulang is grabbing '+options.lang+' from browser and metadata');
        if(options.ignore_locale){ //should we ignore locale and use ex. en for en-US
          options.lang = options.lang.substr(0,options.lang.indexOf('-'));
          do_log('mulang is ignoring locale and using '+options.lang);
        }
      }else{
        do_log('mulang is grabbing '+options.lang+' from options');
      }
      //do we have text data?
      if(window.__mulang === undefined){
        do_log('mulang languages file not loaded');
        return false;
      }
      if(!__mulang[options.lang]){
        do_log(options.lang+' is not found in mulang language file');
        if(options.fallback){
          do_log('mulang is trying fallback language '+options.fallback);
          options.lang = options.fallback;
          if(!__mulang[options.lang]){
            do_log(options.lang+' is not found in mulang language file');
            return false;
          }
        }
      }

      window.__mulang.current = options.lang;

      //find placeholder array
      var find_ph = function(str){
        var re = /.*(\[.*]).*/;
        var m;
        if ((m = re.exec(str)) !== null) {
          if (m.index === re.lastIndex) {
            re.lastIndex++;
          }
          return m[1];
        }
        return null;
      };

      //check if string contains html
      var contains_html = function(str){
        var re = /.*<.*>.*/;
        var m;
        if ((m = re.exec(str)) !== null) {
          return true;
        }
        return false;
      };

      //replace placeholders for array values
      var parse_ph = function(str,arr_str){
        var arr = eval(arr_str);
        if( Object.prototype.toString.call(arr) != '[object Array]' ) {
          do_log('placeholder parameters for is not an Array ('+arr_str+')');
        }
        for(var i = 0;i< arr.length;i++){
          str = str.replace('{'+i+'}', arr[i]);
        }
        return str;
      };

      //loop all elements
      this.each(function(){
        var found_attr = false;
        var attr_name = 'mulang'; //old name

        if($(this).attr(attr_name) !== undefined){
          found_attr = true;
        }

        if(!found_attr){
          attr_name = 'data-mulang';
          if($(this).attr(attr_name) === undefined){
            return true; //no language settings
          }
        }

        var lang_key = $(this).attr(attr_name);
        var attr = 'text';
        //find array
        var param_arr = null;
        if(lang_key.indexOf('[') > -1){
          param_arr = find_ph(lang_key);
          lang_key = lang_key.substr(0,lang_key.indexOf('['));
        }

        //find attr value
        if(lang_key.indexOf(':') > -1){
          attr = lang_key.substr(lang_key.indexOf(':')+1);
          lang_key = lang_key.substr(0,lang_key.indexOf(':'));
        }
        var txt = __mulang[options.lang][lang_key];
        if(txt === undefined){
          txt = $(this).attr(attr_name);
        }
        if(param_arr !== null){
          txt = parse_ph(txt,param_arr);
        }
        if(attr=='text'){
          if(contains_html(txt)){
            $(this).html(txt);
          }else{
            $(this).text(txt);
          }
        }else{
          $(this).attr(attr,txt);

        }
      });
    };

  }( jQuery ));


  function initMulang(lang){
      var options = {ignore_locale:true};
      if(lang){
          options.lang = lang
      }
      $('.mulang').mulang(options);
  }

  function createLangSwitch(obj){
      var ul = $('<ul class="langswitch"></ul>');
      var cssAttr = '';
      $(window.__mulang.languages).each(function(){
          if(window.__mulang.current === this.code ){
              cssAttr = 'active';
          }else{
              cssAttr = '';
          }
          var a = $('<a href="#" data-langcode="'+this.code+'">'+this.name+'</a>');
          a.addClass(cssAttr);
          var li = $('<li></li>');
          li.append(a);
          $(ul).append(li);
      });
      $(obj).append(ul);
      $(obj).find('a').on('click',function(e){
          e.preventDefault;
          $('.langswitch .active').removeClass('active');
          $('.mulang').mulang({lang: $(this).attr('data-langcode')});
          $(this).addClass('active');
      });
  }

  $('.mulang').mulang({data: mondidoSettings.metadata});
  createLangSwitch($('#languages'));

  if(document.location.href.indexOf('declined') > -1 || document.location.href.indexOf('fail') > -1) {
      alert($('#try-again').text().replace(/\s+/, ""));
  }

  /* mondido lib 1.1*/

  jQuery(function($) {
      $('#myTab li').hide();
      var tarr = [];
      var lang = window.navigator.userLanguage || window.navigator.language;
      if(window.navigator.languages){
          lang += ' '+window.navigator.languages.toString();
      }
      var country = $.fn.mulang('getCountry',mondidoSettings.metadata +' '+ lang.replace('-','_'));
      $(mondidoSettings.supportedPaymentMethods).each(function(){
          var name = this.name;
          var keep = false;

          if(this.active){
              if($.inArray('all', this.currencies) > -1 || $.inArray(mondidoSettings.currency, this.currencies) > -1){ // allowed currency
                  if($.inArray('all', this.countries) > -1 || $.inArray(country.c, this.countries) > -1){ // allowed country
                      $('.'+name).show();
                      keep = true;
                  }
              }
          }

          if(keep){
              tarr.push($($('.'+name)[0]).detach());
          }else{
              $($('.'+name)[0]).detach();
          }
      });

      $(tarr).each(function(){
          $('#myTab').append(this);
          this.show();
      });

      if(document.location.href.indexOf('payment.selected') > -1) {
          var tabName = getParameterByName('payment.selected')+"_tab";
          if($('.'+tabName+' a').length > 0){
              mondidoSettings.activePaymentMethod = tabName;
          }
      }
      $('.'+mondidoSettings.activePaymentMethod+' a').trigger('click');
      $('[data-numeric]').payment('restrictNumeric');
      $('.cc-number').payment('formatCardNumber');
      $('.cc-cvc').payment('formatCardCVC');

      $.fn.toggleInputError = function(erred) {
          this.parent('.form-group').toggleClass('has-error', erred);
          return this;
      };
  });

  $(document).ready(function(){

      invoice = $.grep(mondidoSettings.supportedPaymentMethods, function(e){ return e.name == "invoice_tab"; });
      segmentation = invoice[0].segmentation;

      if (invoice[0].segmentation.b2b == true && invoice[0].segmentation.b2c == true){
        $('#segmentation_toggle').removeClass('hidden');

        $( ".segmentation_select" ).click(function() {
          var str = "";
         // alert($(this).attr('data-value'));
          set_segmentation($(this).attr('data-value'));

        });


        if (isBlank($('#segmentation').val())){
          $('#segmentation').val(segmentation.defualt);
        }

      } else {

        if (invoice[0].segmentation.b2c == true){
          $('#row-ssn-details').removeClass('hidden');

          $('#first_name').attr('disabled', 'disabled');
          $('#last_name').attr('disabled', 'disabled');
          $('#zip').attr('disabled', 'disabled');
          $('#city').attr('disabled', 'disabled');
          $('#address_1').attr('disabled', 'disabled');
          $('#address_2').attr('disabled', 'disabled');

          $('#segmentation').val("b2c");
          $('#segmentation').addClass('hidden');
        } else {
          $('#segmentation').val("b2b");
          $('#segmentation').addClass('hidden');
        }
      }

      function set_segmentation(segmentation){

        if (segmentation == "b2c"){
          $('#b2c').addClass('btn-primary');
          $('#b2c').removeClass('btn-secondary');

          $('#b2b').removeClass('btn-primary');
          $('#b2b').addClass('btn-secondary');

        } else {
          $('#b2b').addClass('btn-primary');
          $('#b2b').removeClass('btn-secondary');

          $('#b2c').removeClass('btn-primary');
          $('#b2c').addClass('btn-secondary');
        }




        $('#ssn').val("");
        $('#row-customer-details').addClass('hidden');
        $('#first_name').val("");
        $('#last_name').val("");
        $('#zip').val("");
        $('#city').val("");
        $('#address_1').val("");
        $('#address_2').val("");
      }

      var ssn_on_load = $('#ssn').val();

      var lastKey = null;
      var loading_ssn = $("#row-ssn-details-loading");
      var last_ssn = $('#ssn').val();

      if (isBlank($('#country_code').val())){
          $('#country_code').val("swe");
      }

      function ssn_lookup(ssn_value){
        var api_url = mondidoSettings.config.system.endpoint;

        var ssn = ssn_value;
        var is_test = 'true';
        var country_code = mondidoSettings.country_code;

        if(country_code == "SWE" && ssn.length === 12){
          ssn = ssn.slice(2);
        }

        if ( country_code != "SWE"){
            $('#row-ssn-details').removeClass('hidden');
            $('#row-customer-details').removeClass('hidden');
            $('#ssn').addClass('valid');
            $('#ow-ssn-details-loading').addClass('hidden');
            ssn_on_load = 0;

        } else if (isSwedishSocialSecurityNumber(ssn_on_load)){
          var first_name =  $('#first_name').val();
          var last_name = $('#last_name').val();
          var zip = $('#zip').val();
          var city = $('#city').val();
          var address_1 = $('#address_1').val();

          if (!isBlank(first_name) && !isBlank(last_name) && !isBlank(zip) && !isBlank(city) && !isBlank(address_1)) {
            $('#row-ssn-details').removeClass('hidden');
            $('#row-customer-details').removeClass('hidden');
            $('#ssn').addClass('valid');
            $('#ow-ssn-details-loading').addClass('hidden');
            ssn_on_load = 0;
            return true;
          }
        }

      var ssn_url = api_url+"ssn?token="+Mondido.token+"&transaction_id="+Mondido.transaction.id+"&merchant_id="+Mondido.merchant.id+"&test="+is_test+"&ssn="+ssn+"&country="+country_code;

      if (mondidoSettings.config.development == true || $('#segmentation').val() == "b2b"  || country_code != "SWE"){
        $('#row-ssn-details').removeClass('hidden');

        if ($('#segmentation').val() == "b2b"  || country_code != "SWE"){
          $('#row-ssn-details').removeClass('hidden');

          $('#first_name').removeAttr("disabled");
          $('#last_name').removeAttr("disabled");
          $('#zip').removeAttr("disabled");
          $('#city').removeAttr("disabled");
          $('#address_1').removeAttr("disabled");
          $('#address_2').removeAttr("disabled");

           $('#ssn').removeClass('invalid');
           $('#ssn').addClass('valid');
        } else {

          $('#first_name').val("first_name - Development").addClass('valid');
          $('#last_name').val("last_name - Development").addClass('valid');
          $('#zip').val("zip - Development").addClass('valid');
          $('#country_code').val("SWE").addClass('valid');
          $('#city').val("city - Development").addClass('valid');
          $('#address_1').val("address_1 - Development").addClass('valid');
          $('#address_2').val("address_2 - Development").addClass('valid');
          $('#pending_payment_customer').val("");

          $('#first_name').attr('disabled', 'disabled');
          $('#last_name').attr('disabled', 'disabled');
          $('#zip').attr('disabled', 'disabled');
          $('#city').attr('disabled', 'disabled');
          $('#address_1').attr('disabled', 'disabled');
          $('#address_2').attr('disabled', 'disabled');

        }

          $('#row-customer-details').removeClass('hidden');
          $('#row-ssn-details-error').addClass('hidden');
  
      } else {
    
        var jqxhr = $.get( ssn_url, function() {
            }).done(function(address) {

              $('#row-ssn-details').removeClass('hidden');
              $('#first_name').val(address.first_name).addClass('valid');
              $('#last_name').val(address.last_name).addClass('valid');
              $('#zip').val(address.zip).addClass('valid');
              $('#country_code').val(address.country).addClass('valid');
              $('#city').val(address.city).addClass('valid');
              $('#address_1').val(address.address_1).addClass('valid');
              $('#address_2').val(address.address_2).addClass('valid');
              $('#pending_payment_customer').val(address.id);

              if (address.address_2 === undefined || address.address_2 === null || isBlank(address.address_2)) {
                $('#address_2').addClass('hidden');
              }

              $('#row-customer-details').removeClass('hidden');
              $('#row-ssn-details-error').addClass('hidden');

               $('#ssn').removeClass('invalid');
               $('#ssn').addClass('valid');
            })
            .fail(function(data) {
              loading_ssn.addClass('hidden');
              $('#row-ssn-details-error').removeClass('hidden');
              $('#ow-ssn-details-loading').addClass('hidden');
              $('#ssn').addClass('invalid');
            })
            .always(function() {
              if ($('#segmentation').val() == "b2c"){
                $('#first_name').attr('disabled', 'disabled');
                $('#last_name').attr('disabled', 'disabled');
                $('#zip').attr('disabled', 'disabled');
                $('#city').attr('disabled', 'disabled');
                $('#address_1').attr('disabled', 'disabled');
                $('#address_2').attr('disabled', 'disabled');
              }
            });
        }
      }

      $('#btn-get-address').on('click',function(e){
        var ssn=$('#ssn').val();
        ssn_lookup(ssn);
      });

      $("#trustlyform").attr("action", $("#mondidopayform").attr("action"));
      $("#swishform").attr("action", $("#mondidopayform").attr("action"));
      $("#paypalform").attr("action", $("#mondidopayform").attr("action"));

      $('#myTab a').click(function (e) {
          e.preventDefault();
          var set_payment_method = function(m){
              $('#payment_method').val(m);
          };
          set_payment_method('credit_card_'); //default

          if($(this).attr("href")=="#trustly_tab"){
              set_payment_method('bank');
              $('#trustlyform').submit();

          }else if($(this).attr('href') == '#invoice_tab'){
              set_payment_method('invoice');
          }else if($(this).attr('href') == '#swish_tab'){
              set_payment_method('swish');
          }
          $(this).tab('show');
      });

      $('#myTab li[class="active"] a').trigger('click');

      $.changeFocus = function(object){
          // Enable Pay Button
          if(object.attr("id")=="card_cvv"){
              $("#paybtn-cc").prop("disabled", false);
          }
      };

      // Mobile Modifications
      if( (/iPhone|iPod|iPad|Android|BlackBerry/).test(navigator.userAgent)){
          $("#card_number").attr("pattern","\\d*");
      }

      var current_y = parseInt((new Date()).getFullYear().toString().substr(2,2));
      $("#card_number").keydown(function(e){
          $("#card_number").validateCreditCard(function(result){
              if (result.card_type) {
                  $(".cards").removeClass("visa");
                  $(".cards").removeClass("visa_electron");
                  $(".cards").removeClass("electron");
                  $(".cards").removeClass("maestro");
                  $(".cards").removeClass("mastercard");
                  $(".cards").removeClass("discover");
                  $(".cards").removeClass("amex");
<commit_msg>Fix input focus<commit_after>  // v 1.14.2

// Mondido settings
(function($) {
  var do_log = function(str){
    if(window.console){
      console.log(str);
    }
  };

  if (mondidoSettings.config.development == true){
    do_log("Development mode is on");
  }

  if (typeof Mondido === "undefined") {
    console.log("Error could not load Mondido object");
    Mondido = {
      token: "<PASSWORD>",
      transaction: {
        id: "0"
      },
      merchant: {
        id: "0"
      }
    };
  }

  invoice = $.grep(mondidoSettings.supportedPaymentMethods, function(e){ return e.name == "invoice_tab"; });
  $("#accept_collector").attr("data-mulang", "invoice_accept_conditions['"+mondidoSettings.layout.name+"','"+mondidoSettings.layout.terms_and_conditions_url+"','"+invoice[0].AgreementCode+"','"+invoice[0].AgreementCode+"']");

})(jQuery);

/*
    jQuery Masked Input Plugin
    Copyright (c) 2007 - 2014 <NAME> (digitalbush.com)
    Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license)
    Version: 1.4.0
*/
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b,c=navigator.userAgent,d=/iphone/i.test(c),e=/chrome/i.test(c),f=/android/i.test(c);a.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},autoclear:!0,dataName:"rawMaskFn",placeholder:"_"},a.fn.extend({caret:function(a,b){var c;if(0!==this.length&&!this.is(":hidden"))return"number"==typeof a?(b="number"==typeof b?b:a,this.each(function(){this.setSelectionRange?this.setSelectionRange(a,b):this.createTextRange&&(c=this.createTextRange(),c.collapse(!0),c.moveEnd("character",b),c.moveStart("character",a),c.select())})):(this[0].setSelectionRange?(a=this[0].selectionStart,b=this[0].selectionEnd):document.selection&&document.selection.createRange&&(c=document.selection.createRange(),a=0-c.duplicate().moveStart("character",-1e5),b=a+c.text.length),{begin:a,end:b})},unmask:function(){return this.trigger("unmask")},mask:function(c,g){var h,i,j,k,l,m,n,o;if(!c&&this.length>0){h=a(this[0]);var p=h.data(a.mask.dataName);return p?p():void 0}return g=a.extend({autoclear:a.mask.autoclear,placeholder:a.mask.placeholder,completed:null},g),i=a.mask.definitions,j=[],k=n=c.length,l=null,a.each(c.split(""),function(a,b){"?"==b?(n--,k=a):i[b]?(j.push(new RegExp(i[b])),null===l&&(l=j.length-1),k>a&&(m=j.length-1)):j.push(null)}),this.trigger("unmask").each(function(){function h(){if(g.completed){for(var a=l;m>=a;a++)if(j[a]&&C[a]===p(a))return;g.completed.call(B)}}function p(a){return g.placeholder.charAt(a<g.placeholder.length?a:0)}function q(a){for(;++a<n&&!j[a];);return a}function r(a){for(;--a>=0&&!j[a];);return a}function s(a,b){var c,d;if(!(0>a)){for(c=a,d=q(b);n>c;c++)if(j[c]){if(!(n>d&&j[c].test(C[d])))break;C[c]=C[d],C[d]=p(d),d=q(d)}z(),B.caret(Math.max(l,a))}}function t(a){var b,c,d,e;for(b=a,c=p(a);n>b;b++)if(j[b]){if(d=q(b),e=C[b],C[b]=c,!(n>d&&j[d].test(e)))break;c=e}}function u(){var a=B.val(),b=B.caret();if(a.length<o.length){for(A(!0);b.begin>0&&!j[b.begin-1];)b.begin--;if(0===b.begin)for(;b.begin<l&&!j[b.begin];)b.begin++;B.caret(b.begin,b.begin)}else{for(A(!0);b.begin<n&&!j[b.begin];)b.begin++;B.caret(b.begin,b.begin)}h()}function v(){A(),B.val()!=E&&B.change()}function w(a){if(!B.prop("readonly")){var b,c,e,f=a.which||a.keyCode;o=B.val(),8===f||46===f||d&&127===f?(b=B.caret(),c=b.begin,e=b.end,e-c===0&&(c=46!==f?r(c):e=q(c-1),e=46===f?q(e):e),y(c,e),s(c,e-1),a.preventDefault()):13===f?v.call(this,a):27===f&&(B.val(E),B.caret(0,A()),a.preventDefault())}}function x(b){if(!B.prop("readonly")){var c,d,e,g=b.which||b.keyCode,i=B.caret();if(!(b.ctrlKey||b.altKey||b.metaKey||32>g)&&g&&13!==g){if(i.end-i.begin!==0&&(y(i.begin,i.end),s(i.begin,i.end-1)),c=q(i.begin-1),n>c&&(d=String.fromCharCode(g),j[c].test(d))){if(t(c),C[c]=d,z(),e=q(c),f){var k=function(){a.proxy(a.fn.caret,B,e)()};setTimeout(k,0)}else B.caret(e);i.begin<=m&&h()}b.preventDefault()}}}function y(a,b){var c;for(c=a;b>c&&n>c;c++)j[c]&&(C[c]=p(c))}function z(){B.val(C.join(""))}function A(a){var b,c,d,e=B.val(),f=-1;for(b=0,d=0;n>b;b++)if(j[b]){for(C[b]=p(b);d++<e.length;)if(c=e.charAt(d-1),j[b].test(c)){C[b]=c,f=b;break}if(d>e.length){y(b+1,n);break}}else C[b]===e.charAt(d)&&d++,k>b&&(f=b);return a?z():k>f+1?g.autoclear||C.join("")===D?(B.val()&&B.val(""),y(0,n)):z():(z(),B.val(B.val().substring(0,f+1))),k?b:l}var B=a(this),C=a.map(c.split(""),function(a,b){return"?"!=a?i[a]?p(b):a:void 0}),D=C.join(""),E=B.val();B.data(a.mask.dataName,function(){return a.map(C,function(a,b){return j[b]&&a!=p(b)?a:null}).join("")}),B.one("unmask",function(){B.off(".mask").removeData(a.mask.dataName)}).on("focus.mask",function(){if(!B.prop("readonly")){clearTimeout(b);var a;E=B.val(),a=A(),b=setTimeout(function(){z(),a==c.replace("?","").length?B.caret(0,a):B.caret(a)},10)}}).on("blur.mask",v).on("keydown.mask",w).on("keypress.mask",x).on("input.mask paste.mask",function(){B.prop("readonly")||setTimeout(function(){var a=A(!0);B.caret(a),h()},0)}),e&&f&&B.off("input.mask").on("input.mask",u),A()})}})});



//https://github.com/stripe/jquery.payment - 2.0.0
// Generated by CoffeeScript 1.7.1
(function() {
  var $, cardFromNumber, cardFromType, cards, defaultFormat, formatBackCardNumber, formatBackExpiry, formatCardNumber, formatExpiry, formatForwardExpiry, formatForwardSlashAndSpace, hasTextSelected, luhnCheck, reFormatCVC, reFormatCardNumber, reFormatExpiry, reFormatNumeric, replaceFullWidthChars, restrictCVC, restrictCardNumber, restrictExpiry, restrictNumeric, safeVal, setCardType,
    __slice = [].slice,
    __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

  $ = window.jQuery || window.Zepto || window.$;

  $.payment = {};

  $.payment.fn = {};

  $.fn.payment = function() {
    var args, method;
    method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
    return $.payment.fn[method].apply(this, args);
  };

  defaultFormat = /(\d{1,4})/g;

  $.payment.cards = cards = [
    {
      type: 'elo',
      patterns: [4011, 4312, 4389, 4514, 4573, 4576, 5041, 5066, 5067, 509, 6277, 6362, 6363, 650, 6516, 6550],
      format: defaultFormat,
      length: [16],
      cvcLength: [3],
      luhn: true
    }, {
      type: 'visaelectron',
      patterns: [4026, 417500, 4405, 4508, 4844, 4913, 4917],
      format: defaultFormat,
      length: [16],
      cvcLength: [3],
      luhn: true
    }, {
      type: 'maestro',
      patterns: [5018, 502, 503, 506, 56, 58, 639, 6220, 67],
      format: defaultFormat,
      length: [12, 13, 14, 15, 16, 17, 18, 19],
      cvcLength: [3],
      luhn: true
    }, {
      type: 'forbrugsforeningen',
      patterns: [600],
      format: defaultFormat,
      length: [16],
      cvcLength: [3],
      luhn: true
    }, {
      type: 'dankort',
      patterns: [5019],
      format: defaultFormat,
      length: [16],
      cvcLength: [3],
      luhn: true
    }, {
      type: 'visa',
      patterns: [4],
      format: defaultFormat,
      length: [13, 16],
      cvcLength: [3],
      luhn: true
    }, {
      type: 'mastercard',
      patterns: [51, 52, 53, 54, 55, 22, 23, 24, 25, 26, 27],
      format: defaultFormat,
      length: [16],
      cvcLength: [3],
      luhn: true
    }, {
      type: 'amex',
      patterns: [34, 37],
      format: /(\d{1,4})(\d{1,6})?(\d{1,5})?/,
      length: [15],
      cvcLength: [3, 4],
      luhn: true
    }, {
      type: 'dinersclub',
      patterns: [30, 36, 38, 39],
      format: /(\d{1,4})(\d{1,6})?(\d{1,4})?/,
      length: [14],
      cvcLength: [3],
      luhn: true
    }, {
      type: 'discover',
      patterns: [60, 64, 65, 622],
      format: defaultFormat,
      length: [16],
      cvcLength: [3],
      luhn: true
    }, {
      type: 'unionpay',
      patterns: [62, 88],
      format: defaultFormat,
      length: [16, 17, 18, 19],
      cvcLength: [3],
      luhn: false
    }, {
      type: 'jcb',
      patterns: [35],
      format: defaultFormat,
      length: [16],
      cvcLength: [3],
      luhn: true
    }
  ];

  cardFromNumber = function(num) {
    var card, p, pattern, _i, _j, _len, _len1, _ref;
    num = (num + '').replace(/\D/g, '');
    for (_i = 0, _len = cards.length; _i < _len; _i++) {
      card = cards[_i];
      _ref = card.patterns;
      for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
        pattern = _ref[_j];
        p = pattern + '';
        if (num.substr(0, p.length) === p) {
          return card;
        }
      }
    }
  };

  cardFromType = function(type) {
    var card, _i, _len;
    for (_i = 0, _len = cards.length; _i < _len; _i++) {
      card = cards[_i];
      if (card.type === type) {
        return card;
      }
    }
  };

  luhnCheck = function(num) {
    var digit, digits, odd, sum, _i, _len;
    odd = true;
    sum = 0;
    digits = (num + '').split('').reverse();
    for (_i = 0, _len = digits.length; _i < _len; _i++) {
      digit = digits[_i];
      digit = parseInt(digit, 10);
      if ((odd = !odd)) {
        digit *= 2;
      }
      if (digit > 9) {
        digit -= 9;
      }
      sum += digit;
    }
    return sum % 10 === 0;
  };

  hasTextSelected = function($target) {
    var _ref;
    if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== $target.prop('selectionEnd')) {
      return true;
    }
    if ((typeof document !== "undefined" && document !== null ? (_ref = document.selection) != null ? _ref.createRange : void 0 : void 0) != null) {
      if (document.selection.createRange().text) {
        return true;
      }
    }
    return false;
  };

  safeVal = function(value, $target) {
    var currPair, cursor, digit, error, last, prevPair;
    try {
      cursor = $target.prop('selectionStart');
    } catch (_error) {
      error = _error;
      cursor = null;
    }
    last = $target.val();
    $target.val(value);
    if (cursor !== null && $target.is(":focus")) {
      if (cursor === last.length) {
        cursor = value.length;
      }
      if (last !== value) {
        prevPair = last.slice(cursor - 1, +cursor + 1 || 9e9);
        currPair = value.slice(cursor - 1, +cursor + 1 || 9e9);
        digit = value[cursor];
        if (/\d/.test(digit) && prevPair === ("" + digit + " ") && currPair === (" " + digit)) {
          cursor = cursor + 1;
        }
      }
      $target.prop('selectionStart', cursor);
      return $target.prop('selectionEnd', cursor);
    }
  };

  replaceFullWidthChars = function(str) {
    var chars, chr, fullWidth, halfWidth, idx, value, _i, _len;
    if (str == null) {
      str = '';
    }
    fullWidth = '\uff10\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19';
    halfWidth = '0123456789';
    value = '';
    chars = str.split('');
    for (_i = 0, _len = chars.length; _i < _len; _i++) {
      chr = chars[_i];
      idx = fullWidth.indexOf(chr);
      if (idx > -1) {
        chr = halfWidth[idx];
      }
      value += chr;
    }
    return value;
  };

  reFormatNumeric = function(e) {
    var $target;
    $target = $(e.currentTarget);
    return setTimeout(function() {
      var value;
      value = $target.val();
      value = replaceFullWidthChars(value);
      value = value.replace(/\D/g, '');
      return safeVal(value, $target);
    });
  };

  reFormatCardNumber = function(e) {
    var $target;
    $target = $(e.currentTarget);
    return setTimeout(function() {
      var value;
      value = $target.val();
      value = replaceFullWidthChars(value);
      value = $.payment.formatCardNumber(value);
      return safeVal(value, $target);
    });
  };

  formatCardNumber = function(e) {
    var $target, card, digit, length, re, upperLength, value;
    digit = String.fromCharCode(e.which);
    if (!/^\d+$/.test(digit)) {
      return;
    }
    $target = $(e.currentTarget);
    value = $target.val();
    card = cardFromNumber(value + digit);
    length = (value.replace(/\D/g, '') + digit).length;
    upperLength = 16;
    if (card) {
      upperLength = card.length[card.length.length - 1];
    }
    if (length >= upperLength) {
      return;
    }
    if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
      return;
    }
    if (card && card.type === 'amex') {
      re = /^(\d{4}|\d{4}\s\d{6})$/;
    } else {
      re = /(?:^|\s)(\d{4})$/;
    }
    if (re.test(value)) {
      e.preventDefault();
      return setTimeout(function() {
        return $target.val(value + ' ' + digit);
      });
    } else if (re.test(value + digit)) {
      e.preventDefault();
      return setTimeout(function() {
        return $target.val(value + digit + ' ');
      });
    }
  };

  formatBackCardNumber = function(e) {
    var $target, value;
    $target = $(e.currentTarget);
    value = $target.val();
    if (e.which !== 8) {
      return;
    }
    if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
      return;
    }
    if (/\d\s$/.test(value)) {
      e.preventDefault();
      return setTimeout(function() {
        return $target.val(value.replace(/\d\s$/, ''));
      });
    } else if (/\s\d?$/.test(value)) {
      e.preventDefault();
      return setTimeout(function() {
        return $target.val(value.replace(/\d$/, ''));
      });
    }
  };

  reFormatExpiry = function(e) {
    var $target;
    $target = $(e.currentTarget);
    return setTimeout(function() {
      var value;
      value = $target.val();
      value = replaceFullWidthChars(value);
      value = $.payment.formatExpiry(value);
      return safeVal(value, $target);
    });
  };

  formatExpiry = function(e) {
    var $target, digit, val;
    digit = String.fromCharCode(e.which);
    if (!/^\d+$/.test(digit)) {
      return;
    }
    $target = $(e.currentTarget);
    val = $target.val() + digit;
    if (/^\d$/.test(val) && (val !== '0' && val !== '1')) {
      e.preventDefault();
      return setTimeout(function() {
        return $target.val("0" + val + " / ");
      });
    } else if (/^\d\d$/.test(val)) {
      e.preventDefault();
      return setTimeout(function() {
        var m1, m2;
        m1 = parseInt(val[0], 10);
        m2 = parseInt(val[1], 10);
        if (m2 > 2 && m1 !== 0) {
          return $target.val("0" + m1 + " / " + m2);
        } else {
          return $target.val("" + val + " / ");
        }
      });
    }
  };

  formatForwardExpiry = function(e) {
    var $target, digit, val;
    digit = String.fromCharCode(e.which);
    if (!/^\d+$/.test(digit)) {
      return;
    }
    $target = $(e.currentTarget);
    val = $target.val();
    if (/^\d\d$/.test(val)) {
      return $target.val("" + val + " / ");
    }
  };

  formatForwardSlashAndSpace = function(e) {
    var $target, val, which;
    which = String.fromCharCode(e.which);
    if (!(which === '/' || which === ' ')) {
      return;
    }
    $target = $(e.currentTarget);
    val = $target.val();
    if (/^\d$/.test(val) && val !== '0') {
      return $target.val("0" + val + " / ");
    }
  };

  formatBackExpiry = function(e) {
    var $target, value;
    $target = $(e.currentTarget);
    value = $target.val();
    if (e.which !== 8) {
      return;
    }
    if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
      return;
    }
    if (/\d\s\/\s$/.test(value)) {
      e.preventDefault();
      return setTimeout(function() {
        return $target.val(value.replace(/\d\s\/\s$/, ''));
      });
    }
  };

  reFormatCVC = function(e) {
    var $target;
    $target = $(e.currentTarget);
    return setTimeout(function() {
      var value;
      value = $target.val();
      value = replaceFullWidthChars(value);
      value = value.replace(/\D/g, '').slice(0, 4);
      return safeVal(value, $target);
    });
  };

  restrictNumeric = function(e) {
    var input;
    if (e.metaKey || e.ctrlKey) {
      return true;
    }
    if (e.which === 32) {
      return false;
    }
    if (e.which === 0) {
      return true;
    }
    if (e.which < 33) {
      return true;
    }
    input = String.fromCharCode(e.which);
    return !!/[\d\s]/.test(input);
  };

  restrictCardNumber = function(e) {
    var $target, card, digit, value;
    $target = $(e.currentTarget);
    digit = String.fromCharCode(e.which);
    if (!/^\d+$/.test(digit)) {
      return;
    }
    if (hasTextSelected($target)) {
      return;
    }
    value = ($target.val() + digit).replace(/\D/g, '');
    card = cardFromNumber(value);
    if (card) {
      return value.length <= card.length[card.length.length - 1];
    } else {
      return value.length <= 16;
    }
  };

  restrictExpiry = function(e) {
    var $target, digit, value;
    $target = $(e.currentTarget);
    digit = String.fromCharCode(e.which);
    if (!/^\d+$/.test(digit)) {
      return;
    }
    if (hasTextSelected($target)) {
      return;
    }
    value = $target.val() + digit;
    value = value.replace(/\D/g, '');
    if (value.length > 6) {
      return false;
    }
  };

  restrictCVC = function(e) {
    var $target, digit, val;
    $target = $(e.currentTarget);
    digit = String.fromCharCode(e.which);
    if (!/^\d+$/.test(digit)) {
      return;
    }
    if (hasTextSelected($target)) {
      return;
    }
    val = $target.val() + digit;
    return val.length <= 4;
  };

  setCardType = function(e) {
    var $target, allTypes, card, cardType, val;
    $target = $(e.currentTarget);
    val = $target.val();
    cardType = $.payment.cardType(val) || 'unknown';
    if (!$target.hasClass(cardType)) {
      allTypes = (function() {
        var _i, _len, _results;
        _results = [];
        for (_i = 0, _len = cards.length; _i < _len; _i++) {
          card = cards[_i];
          _results.push(card.type);
        }
        return _results;
      })();
      $target.removeClass('unknown');
      $target.removeClass(allTypes.join(' '));
      $target.addClass(cardType);
      $target.toggleClass('identified', cardType !== 'unknown');
      return $target.trigger('payment.cardType', cardType);
    }
  };

  $.payment.fn.formatCardCVC = function() {
    this.on('keypress', restrictNumeric);
    this.on('keypress', restrictCVC);
    this.on('paste', reFormatCVC);
    this.on('change', reFormatCVC);
    this.on('input', reFormatCVC);
    return this;
  };

  $.payment.fn.formatCardExpiry = function() {
    this.on('keypress', restrictNumeric);
    this.on('keypress', restrictExpiry);
    this.on('keypress', formatExpiry);
    this.on('keypress', formatForwardSlashAndSpace);
    this.on('keypress', formatForwardExpiry);
    this.on('keydown', formatBackExpiry);
    this.on('change', reFormatExpiry);
    this.on('input', reFormatExpiry);
    return this;
  };

  $.payment.fn.formatCardNumber = function() {
    this.on('keypress', restrictNumeric);
    this.on('keypress', restrictCardNumber);
    this.on('keypress', formatCardNumber);
    this.on('keydown', formatBackCardNumber);
    this.on('keyup', setCardType);
    this.on('paste', reFormatCardNumber);
    this.on('change', reFormatCardNumber);
    this.on('input', reFormatCardNumber);
    this.on('input', setCardType);
    return this;
  };

  $.payment.fn.restrictNumeric = function() {
    this.on('keypress', restrictNumeric);
    this.on('paste', reFormatNumeric);
    this.on('change', reFormatNumeric);
    this.on('input', reFormatNumeric);
    return this;
  };

  $.payment.fn.cardExpiryVal = function() {
    return $.payment.cardExpiryVal($(this).val());
  };

  $.payment.cardExpiryVal = function(value) {
    var month, prefix, year, _ref;
    _ref = value.split(/[\s\/]+/, 2), month = _ref[0], year = _ref[1];
    if ((year != null ? year.length : void 0) === 2 && /^\d+$/.test(year)) {
      prefix = (new Date).getFullYear();
      prefix = prefix.toString().slice(0, 2);
      year = prefix + year;
    }
    month = parseInt(month, 10);
    year = parseInt(year, 10);
    return {
      month: month,
      year: year
    };
  };

  $.payment.validateCardNumber = function(num) {
    var card, _ref;
    num = (num + '').replace(/\s+|-/g, '');
    if (!/^\d+$/.test(num)) {
      return false;
    }
    card = cardFromNumber(num);
    if (!card) {
      return false;
    }
    return (_ref = num.length, __indexOf.call(card.length, _ref) >= 0) && (card.luhn === false || luhnCheck(num));
  };

  $.payment.validateCardExpiry = function(month, year) {
    var currentTime, expiry, _ref;
    if (typeof month === 'object' && 'month' in month) {
      _ref = month, month = _ref.month, year = _ref.year;
    }
    if (!(month && year)) {
      return false;
    }
    month = $.trim(month);
    year = $.trim(year);
    if (!/^\d+$/.test(month)) {
      return false;
    }
    if (!/^\d+$/.test(year)) {
      return false;
    }
    if (!((1 <= month && month <= 12))) {
      return false;
    }
    if (year.length === 2) {
      if (year < 70) {
        year = "20" + year;
      } else {
        year = "19" + year;
      }
    }
    if (year.length !== 4) {
      return false;
    }
    expiry = new Date(year, month);
    currentTime = new Date;
    expiry.setMonth(expiry.getMonth() - 1);
    expiry.setMonth(expiry.getMonth() + 1, 1);
    return expiry > currentTime;
  };

  $.payment.validateCardCVC = function(cvc, type) {
    var card, _ref;
    cvc = $.trim(cvc);
    if (!/^\d+$/.test(cvc)) {
      return false;
    }
    card = cardFromType(type);
    if (card != null) {
      return _ref = cvc.length, __indexOf.call(card.cvcLength, _ref) >= 0;
    } else {
      return cvc.length >= 3 && cvc.length <= 4;
    }
  };

  $.payment.cardType = function(num) {
    var _ref;
    if (!num) {
      return null;
    }
    return ((_ref = cardFromNumber(num)) != null ? _ref.type : void 0) || null;
  };

  $.payment.formatCardNumber = function(num) {
    var card, groups, upperLength, _ref;
    num = num.replace(/\D/g, '');
    card = cardFromNumber(num);
    if (!card) {
      return num;
    }
    upperLength = card.length[card.length.length - 1];
    num = num.slice(0, upperLength);
    if (card.format.global) {
      return (_ref = num.match(card.format)) != null ? _ref.join(' ') : void 0;
    } else {
      groups = card.format.exec(num);
      if (groups == null) {
        return;
      }
      groups.shift();
      groups = $.grep(groups, function(n) {
        return n;
      });
      return groups.join(' ');
    }
  };

  $.payment.formatExpiry = function(expiry) {
    var mon, parts, sep, year;
    parts = expiry.match(/^\D*(\d{1,2})(\D+)?(\d{1,4})?/);
    if (!parts) {
      return '';
    }
    mon = parts[1] || '';
    sep = parts[2] || '';
    year = parts[3] || '';
    if (year.length > 0) {
      sep = ' / ';
    } else if (sep === ' /') {
      mon = mon.substring(0, 1);
      sep = '';
    } else if (mon.length === 2 || sep.length > 0) {
      sep = ' / ';
    } else if (mon.length === 1 && (mon !== '0' && mon !== '1')) {
      mon = "0" + mon;
      sep = ' / ';
    }
    return mon + sep + year;
  };

}).call(this);

  /*
    Mulang 1.2
    Multi Language Template Plugin
    By <EMAIL>

    Requires JQuery to work.
   */
  (function ( $ ) {

      var methods = {
          init : function(options) {

          },
          getCountry : function(data) {
          /*
          Get estimated country from metadata and/or locale string
          returns for example: se,us,unknown
          */
              var filter = [
              {r: '(usa|united states|en_US)',c: 'us', l: 'en'},
              {r: '(austria|Ã¶sterreich|de_AT)',c: 'at', l: 'de'},
              {r: '(belgium|belgiÃ«|nl_BE)',c: 'be', l: 'nl'},
              {r: '(belgium|belgique|fr_BE)',c: 'be', l: 'fr'},
              {r: '(bulgaria|Ð‘ÑŠÐ»Ð³Ð°Ñ€Ð¸Ñ|bg_BG)',c: 'bg', l: 'en'},
              {r: '(croatia|hrvatska|hr_HR)',c: 'hr', l: 'en'},
              {r: '(czech republic|ÄeskÃ¡ republika|cs_CZ)',c: 'cz', l: 'en'},
              {r: '(cyprus|kÏÏ€ÏÎ¿Ï‚|el_CY)',c: 'cy', l: 'en'},
              {r: '(denmark|danmark|da_DK)',c: 'dk', l: 'da'},
              {r: '(estonia|eesti|et_EE)',c: 'ee', l: 'en'},
              {r: '(finland|suomi|fi_FI)',c: 'fi', l: 'fi'},
              {r: '(finland|finland|sv_FI)',c: 'fi', l: 'sv'},
              {r: '(france|france|fr_FR)',c: 'fr', l: 'fr'},
              {r: '(germany|deutschland|de_DE)',c: 'de', l: 'de'},
              {r: '(greece|eÎ»Î»Î¬Î´Î±|el_GR)',c: 'gr', l: 'en'},
              {r: '(hungary|magyarorszÃ¡g|hu_HU)',c: 'hu', l: 'en'},
              {r: '(ireland|ireland|en_IE)',c: 'ie', l: 'en'},
              {r: '(italy|italia|it_IT)',c: 'it', l: 'en'},
              {r: '(latvia|latvija|lv_LV)',c: 'lv', l: 'en'},
              {r: '(lithuania|lietuva|lt_LT)',c: 'lt', l: 'en'},
              {r: '(luxembourg|luxembourg|fr_LU)',c: 'lu', l: 'fr'},
              {r: '(luxembourg|luxemburg|de_LU)',c: 'lu', l: 'de'},
              {r: '(malta|malta|mt_MT)',c: 'mt', l: 'en'},
              {r: '(netherlands|nederland|nl_NL)',c: 'nl', l: 'nl'},
              {r: '(norway|norge|no_NO)',c: 'no', l: 'en'},
              {r: '(poland|polska|pl_PL)',c: 'pl', l: 'en'},
              {r: '(portugal|portugal|pt_PT)',c: 'pt', l: 'en'},
              {r: '(romania|romÃ¢nia|ro_RO)',c: 'ro', l: 'en'},
              {r: '(slovakia|slovensko|sk_SK)',c: 'sk', l: 'en'},
              {r: '(slovenia|slovenija|sl_SI)',c: 'si', l: 'en'},
              {r: '(spain|espaÃ±a|es_ES)',c: 'es', l: 'es'},
              {r: '(united kingdom|uk|en_GB)',c: 'gb', l: 'en'},
              {r: '(sweden|sverige|se_SE)',c: 'se', l: 'sv'}
              ];
              var score = [];
              $(filter).each(function(){
                  var regex = new RegExp(this.r,'gi');
                  var res = data.match(regex);
                  if(res){
                      score.splice(res.length, 0, this);
                  }
              });
              if(score.length > 0){
                  return score[score.length-1];
              }else{
                  return null;
              }
          }
      };


    $.fn.mulang = function( options ) {

      if ( methods[options] ) {
          return methods[ options ].apply( this, Array.prototype.slice.call( arguments, 1 ));
      }

      if(!options){
        options = {};
      }
      if(!options.fallback){
        options.fallback = 'en';
      }
      var do_log = function(str){
        if(window.console){
          console.log(str);
        }
      };

      if(!options.lang){ //if there is no lang in options, grab from the browser
        options.lang = window.navigator.userLanguage || window.navigator.language;
        langFromData = $.fn.mulang('getCountry',options.data +' '+options.lang.replace('-','_'));
        if(langFromData){
            options.lang = langFromData.l;
        }
        do_log('mulang is grabbing '+options.lang+' from browser and metadata');
        if(options.ignore_locale){ //should we ignore locale and use ex. en for en-US
          options.lang = options.lang.substr(0,options.lang.indexOf('-'));
          do_log('mulang is ignoring locale and using '+options.lang);
        }
      }else{
        do_log('mulang is grabbing '+options.lang+' from options');
      }
      //do we have text data?
      if(window.__mulang === undefined){
        do_log('mulang languages file not loaded');
        return false;
      }
      if(!__mulang[options.lang]){
        do_log(options.lang+' is not found in mulang language file');
        if(options.fallback){
          do_log('mulang is trying fallback language '+options.fallback);
          options.lang = options.fallback;
          if(!__mulang[options.lang]){
            do_log(options.lang+' is not found in mulang language file');
            return false;
          }
        }
      }

      window.__mulang.current = options.lang;

      //find placeholder array
      var find_ph = function(str){
        var re = /.*(\[.*]).*/;
        var m;
        if ((m = re.exec(str)) !== null) {
          if (m.index === re.lastIndex) {
            re.lastIndex++;
          }
          return m[1];
        }
        return null;
      };

      //check if string contains html
      var contains_html = function(str){
        var re = /.*<.*>.*/;
        var m;
        if ((m = re.exec(str)) !== null) {
          return true;
        }
        return false;
      };

      //replace placeholders for array values
      var parse_ph = function(str,arr_str){
        var arr = eval(arr_str);
        if( Object.prototype.toString.call(arr) != '[object Array]' ) {
          do_log('placeholder parameters for is not an Array ('+arr_str+')');
        }
        for(var i = 0;i< arr.length;i++){
          str = str.replace('{'+i+'}', arr[i]);
        }
        return str;
      };

      //loop all elements
      this.each(function(){
        var found_attr = false;
        var attr_name = 'mulang'; //old name

        if($(this).attr(attr_name) !== undefined){
          found_attr = true;
        }

        if(!found_attr){
          attr_name = 'data-mulang';
          if($(this).attr(attr_name) === undefined){
            return true; //no language settings
          }
        }

        var lang_key = $(this).attr(attr_name);
        var attr = 'text';
        //find array
        var param_arr = null;
        if(lang_key.indexOf('[') > -1){
          param_arr = find_ph(lang_key);
          lang_key = lang_key.substr(0,lang_key.indexOf('['));
        }

        //find attr value
        if(lang_key.indexOf(':') > -1){
          attr = lang_key.substr(lang_key.indexOf(':')+1);
          lang_key = lang_key.substr(0,lang_key.indexOf(':'));
        }
        var txt = __mulang[options.lang][lang_key];
        if(txt === undefined){
          txt = $(this).attr(attr_name);
        }
        if(param_arr !== null){
          txt = parse_ph(txt,param_arr);
        }
        if(attr=='text'){
          if(contains_html(txt)){
            $(this).html(txt);
          }else{
            $(this).text(txt);
          }
        }else{
          $(this).attr(attr,txt);

        }
      });
    };

  }( jQuery ));


  function initMulang(lang){
      var options = {ignore_locale:true};
      if(lang){
          options.lang = lang
      }
      $('.mulang').mulang(options);
  }

  function createLangSwitch(obj){
      var ul = $('<ul class="langswitch"></ul>');
      var cssAttr = '';
      $(window.__mulang.languages).each(function(){
          if(window.__mulang.current === this.code ){
              cssAttr = 'active';
          }else{
              cssAttr = '';
          }
          var a = $('<a href="#" data-langcode="'+this.code+'">'+this.name+'</a>');
          a.addClass(cssAttr);
          var li = $('<li></li>');
          li.append(a);
          $(ul).append(li);
      });
      $(obj).append(ul);
      $(obj).find('a').on('click',function(e){
          e.preventDefault;
          $('.langswitch .active').removeClass('active');
          $('.mulang').mulang({lang: $(this).attr('data-langcode')});
          $(this).addClass('active');
      });
  }

  $('.mulang').mulang({data: mondidoSettings.metadata});
  createLangSwitch($('#languages'));

  if(document.location.href.indexOf('declined') > -1 || document.location.href.indexOf('fail') > -1) {
      alert($('#try-again').text().replace(/\s+/, ""));
  }

  /* mondido lib 1.1*/

  jQuery(function($) {
      $('#myTab li').hide();
      var tarr = [];
      var lang = window.navigator.userLanguage || window.navigator.language;
      if(window.navigator.languages){
          lang += ' '+window.navigator.languages.toString();
      }
      var country = $.fn.mulang('getCountry',mondidoSettings.metadata +' '+ lang.replace('-','_'));
      $(mondidoSettings.supportedPaymentMethods).each(function(){
          var name = this.name;
          var keep = false;

          if(this.active){
              if($.inArray('all', this.currencies) > -1 || $.inArray(mondidoSettings.currency, this.currencies) > -1){ // allowed currency
                  if($.inArray('all', this.countries) > -1 || $.inArray(country.c, this.countries) > -1){ // allowed country
                      $('.'+name).show();
                      keep = true;
                  }
              }
          }

          if(keep){
              tarr.push($($('.'+name)[0]).detach());
          }else{
              $($('.'+name)[0]).detach();
          }
      });

      $(tarr).each(function(){
          $('#myTab').append(this);
          this.show();
      });

      if(document.location.href.indexOf('payment.selected') > -1) {
          var tabName = getParameterByName('payment.selected')+"_tab";
          if($('.'+tabName+' a').length > 0){
              mondidoSettings.activePaymentMethod = tabName;
          }
      }
      $('.'+mondidoSettings.activePaymentMethod+' a').trigger('click');
      $('[data-numeric]').payment('restrictNumeric');
      $('.cc-number').payment('formatCardNumber');
      $('.cc-cvc').payment('formatCardCVC');

      $.fn.toggleInputError = function(erred) {
          this.parent('.form-group').toggleClass('has-error', erred);
          return this;
      };
  });

  $(document).ready(function(){

      invoice = $.grep(mondidoSettings.supportedPaymentMethods, function(e){ return e.name == "invoice_tab"; });
      segmentation = invoice[0].segmentation;

      if (invoice[0].segmentation.b2b == true && invoice[0].segmentation.b2c == true){
        $('#segmentation_toggle').removeClass('hidden');

        $( ".segmentation_select" ).click(function() {
          var str = "";
         // alert($(this).attr('data-value'));
          set_segmentation($(this).attr('data-value'));

        });


        if (isBlank($('#segmentation').val())){
          $('#segmentation').val(segmentation.defualt);
        }

      } else {

        if (invoice[0].segmentation.b2c == true){
          $('#row-ssn-details').removeClass('hidden');

          $('#first_name').attr('disabled', 'disabled');
          $('#last_name').attr('disabled', 'disabled');
          $('#zip').attr('disabled', 'disabled');
          $('#city').attr('disabled', 'disabled');
          $('#address_1').attr('disabled', 'disabled');
          $('#address_2').attr('disabled', 'disabled');

          $('#segmentation').val("b2c");
          $('#segmentation').addClass('hidden');
        } else {
          $('#segmentation').val("b2b");
          $('#segmentation').addClass('hidden');
        }
      }

      function set_segmentation(segmentation){

        if (segmentation == "b2c"){
          $('#b2c').addClass('btn-primary');
          $('#b2c').removeClass('btn-secondary');

          $('#b2b').removeClass('btn-primary');
          $('#b2b').addClass('btn-secondary');

        } else {
          $('#b2b').addClass('btn-primary');
          $('#b2b').removeClass('btn-secondary');

          $('#b2c').removeClass('btn-primary');
          $('#b2c').addClass('btn-secondary');
        }




        $('#ssn').val("");
        $('#row-customer-details').addClass('hidden');
        $('#first_name').val("");
        $('#last_name').val("");
        $('#zip').val("");
        $('#city').val("");
        $('#address_1').val("");
        $('#address_2').val("");
      }

      var ssn_on_load = $('#ssn').val();

      var lastKey = null;
      var loading_ssn = $("#row-ssn-details-loading");
      var last_ssn = $('#ssn').val();

      if (isBlank($('#country_code').val())){
          $('#country_code').val("swe");
      }

      function ssn_lookup(ssn_value){
        var api_url = mondidoSettings.config.system.endpoint;

        var ssn = ssn_value;
        var is_test = 'true';
        var country_code = mondidoSettings.country_code;

        if(country_code == "SWE" && ssn.length === 12){
          ssn = ssn.slice(2);
        }

        if ( country_code != "SWE"){
            $('#row-ssn-details').removeClass('hidden');
            $('#row-customer-details').removeClass('hidden');
            $('#ssn').addClass('valid');
            $('#ow-ssn-details-loading').addClass('hidden');
            ssn_on_load = 0;

        } else if (isSwedishSocialSecurityNumber(ssn_on_load)){
          var first_name =  $('#first_name').val();
          var last_name = $('#last_name').val();
          var zip = $('#zip').val();
          var city = $('#city').val();
          var address_1 = $('#address_1').val();

          if (!isBlank(first_name) && !isBlank(last_name) && !isBlank(zip) && !isBlank(city) && !isBlank(address_1)) {
            $('#row-ssn-details').removeClass('hidden');
            $('#row-customer-details').removeClass('hidden');
            $('#ssn').addClass('valid');
            $('#ow-ssn-details-loading').addClass('hidden');
            ssn_on_load = 0;
            return true;
          }
        }

      var ssn_url = api_url+"ssn?token="+Mondido.token+"&transaction_id="+Mondido.transaction.id+"&merchant_id="+Mondido.merchant.id+"&test="+is_test+"&ssn="+ssn+"&country="+country_code;

      if (mondidoSettings.config.development == true || $('#segmentation').val() == "b2b"  || country_code != "SWE"){
        $('#row-ssn-details').removeClass('hidden');

        if ($('#segmentation').val() == "b2b"  || country_code != "SWE"){
          $('#row-ssn-details').removeClass('hidden');

          $('#first_name').removeAttr("disabled");
          $('#last_name').removeAttr("disabled");
          $('#zip').removeAttr("disabled");
          $('#city').removeAttr("disabled");
          $('#address_1').removeAttr("disabled");
          $('#address_2').removeAttr("disabled");

           $('#ssn').removeClass('invalid');
           $('#ssn').addClass('valid');
        } else {

          $('#first_name').val("first_name - Development").addClass('valid');
          $('#last_name').val("last_name - Development").addClass('valid');
          $('#zip').val("zip - Development").addClass('valid');
          $('#country_code').val("SWE").addClass('valid');
          $('#city').val("city - Development").addClass('valid');
          $('#address_1').val("address_1 - Development").addClass('valid');
          $('#address_2').val("address_2 - Development").addClass('valid');
          $('#pending_payment_customer').val("");

          $('#first_name').attr('disabled', 'disabled');
          $('#last_name').attr('disabled', 'disabled');
          $('#zip').attr('disabled', 'disabled');
          $('#city').attr('disabled', 'disabled');
          $('#address_1').attr('disabled', 'disabled');
          $('#address_2').attr('disabled', 'disabled');

        }

          $('#row-customer-details').removeClass('hidden');
          $('#row-ssn-details-error').addClass('hidden');
  
      } else {
    
        var jqxhr = $.get( ssn_url, function() {
            }).done(function(address) {

              $('#row-ssn-details').removeClass('hidden');
              $('#first_name').val(address.first_name).addClass('valid');
              $('#last_name').val(address.last_name).addClass('valid');
              $('#zip').val(address.zip).addClass('valid');
              $('#country_code').val(address.country).addClass('valid');
              $('#city').val(address.city).addClass('valid');
              $('#address_1').val(address.address_1).addClass('valid');
              $('#address_2').val(address.address_2).addClass('valid');
              $('#pending_payment_customer').val(address.id);

              if (address.address_2 === undefined || address.address_2 === null || isBlank(address.address_2)) {
                $('#address_2').addClass('hidden');
              }

              $('#row-customer-details').removeClass('hidden');
              $('#row-ssn-details-error').addClass('hidden');

               $('#ssn').removeClass('invalid');
               $('#ssn').addClass('valid');
            })
            .fail(function(data) {
              loading_ssn.addClass('hidden');
              $('#row-ssn-details-error').removeClass('hidden');
              $('#ow-ssn-details-loading').addClass('hidden');
              $('#ssn').addClass('invalid');
            })
            .always(function() {
              if ($('#segmentation').val() == "b2c"){
                $('#first_name').attr('disabled', 'disabled');
                $('#last_name').attr('disabled', 'disabled');
                $('#zip').attr('disabled', 'disabled');
                $('#city').attr('disabled', 'disabled');
                $('#address_1').attr('disabled', 'disabled');
                $('#address_2').attr('disabled', 'disabled');
              }
            });
        }
      }

      $('#btn-get-address').on('click',function(e){
        var ssn=$('#ssn').val();
        ssn_lookup(ssn);
      });

      $("#trustlyform").attr("action", $("#mondidopayform").attr("action"));
      $("#swishform").attr("action", $("#mondidopayform").attr("action"));
      $("#paypalform").attr("action", $("#mondidopayform").attr("action"));

      $('#myTab a').click(function (e) {
          e.preventDefault();
          var set_payment_method = function(m){
              $('#payment_method').val(m);
          };
          set_payment_method('credit_card_'); //default

          if($(this).attr("href")=="#trustly_tab"){
              set_payment_method('bank');
              $('#trustlyform').submit();

          }else if($(this).attr('href') == '#invoice_tab'){
              set_payment_method('invoice');
          }else if($(this).attr('href') == '#swish_tab'){
              set_payment_method('swish');
          }
          $('input:enabled').blur();

          $(this).tab('show');

           var is_focus = false;
           $('input:visible:enabled').each(function( i ) {
              if (isBlank($(this).val()) && is_focus == false ) {
                $(this).focus();
                is_focus = true
              }
            });
           if (is_focus == false){
              $('input:visible:enabled:last').focus();
           }

      });

      $('#myTab li[class="active"] a').trigger('click');

      $.changeFocus = function(object){
          // Enable Pay Button
          if(object.attr("id")=="card_cvv"){
              $("#paybtn-cc").prop("disabled", false);
          }
      };

      // Mobile Modifications
      if( (/iPhone|iPod|iPad|Android|BlackBerry/).test(navigator.userAgent)){
          $("#card_number").attr("pattern","\\d*");
      }

      var current_y = parseInt((new Date()).getFullYear().toString().substr(2,2));
      $("#card_number").keydown(function(e){
          $("#card_number").validateCreditCard(function(result){
              if (result.card_type) {
                  $(".cards").removeClass("visa");
                  $(".cards").removeClass("visa_electron");
                  $(".cards").removeClass("electron");
                  $(".cards").removeClass("maestro");
                  $(".cards").removeClass("mastercard");
                  $(".cards").removeClass("discover");
                  $(".cards").removeClass("amex");

{'fraction_non_alphanumeric': 0.2136693492115179, 'fraction_numerical': 0.013443736335302601, 'mean_word_length': 2.4442441720740207, 'pattern_counts': {'":': 6, '<': 71, '<?xml version=': 0, '>': 103, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3277683', 'n_tokens_mistral': 30093, 'n_tokens_neox': 29364, 'n_words': 4797}