<!DOCTYPE html>
<html>

  <head>
    <script data-require="jquery@1.11.0" data-semver="1.11.0" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script data-require="bootstrap@3.2.0" data-semver="3.2.0" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.js"></script>
    <script type="text/javascript" src="intlTelInput.js"></script>
    
    <link data-require="bootstrap-css@3.2.0" data-semver="3.2.0" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />
    <link rel="stylesheet" href="intlTelInput.css" />
    <link rel="stylesheet" href="style.css" />
    <script src="script.js"></script>
  </head>

  <body>
    <div class="input-container">
      <div class="input-container-title">
        <code>excludeCountries: ['us', 'dz']</code> <br>
        // United States, Algeria
      </div>
      <div style="height: 500px;">
        <input type="text" id="phone" class="form-control">
      </div>
    </div>
    <div class="input-container">
      <div class="input-container-title">
        <code>excludeCountries: []</code>
      </div>
      <div style="height: 500px;">
        <input type="text" id="phone2" class="form-control">
      </div>
    </div>
  </body>

</html>
$(document).ready(function() {
  $('#phone').intlTelInput({
    container: 'body',
    excludeCountries: ['us', 'dz'],
    utilsScript: "https://rawgit.com/Bluefieldscom/intl-tel-input/master/lib/libphonenumber/build/utils.js"
  });
  $('#phone2').intlTelInput({
    container: 'body',
    utilsScript: "https://rawgit.com/Bluefieldscom/intl-tel-input/master/lib/libphonenumber/build/utils.js"
  });
});
/* Styles go here */

.ng-invalid {
  border-color: red;
}

.input-container {
  position: relative;
  padding-top: 100px; 
  padding-bottom: 15px; 
  margin-top: 20px; 
  margin-left: 300px; 
  height: 166px; 
  background: #eee; 
  overflow: scroll;
  width: 300px;
  z-index: 1050;
  float: left;
}

.input-container + .input-container {
  margin-left: 20px;
}

.input-container-title {
  position: absolute;
  top: 0;
}
/*
International Telephone Input v6.0.2
https://github.com/Bluefieldscom/intl-tel-input.git
*/
// wrap in UMD - see https://github.com/umdjs/umd/blob/master/jqueryPlugin.js
(function(factory) {
    if (typeof define === "function" && define.amd) {
        define([ "jquery" ], function($) {
            factory($, window, document);
        });
    } else {
        factory(jQuery, window, document);
    }
})(function($, window, document, undefined) {
    "use strict";
    // these vars persist through all instances of the plugin
    var pluginName = "intlTelInput", id = 1, // give each instance it's own id for namespaced event handling
    defaults = {
        // typing digits after a valid number will be added to the extension part of the number
        allowExtensions: false,
        // automatically format the number according to the selected country
        autoFormat: true,
        // if there is just a dial code in the input: remove it on blur, and re-add it on focus
        autoHideDialCode: true,
        // add or remove input placeholder with an example number for the selected country
        autoPlaceholder: true,
        // append menu to a specific element
        container: false,
        // default country
        defaultCountry: "",
        // geoIp lookup function
        geoIpLookup: null,
        // don't insert international dial codes
        nationalMode: true,
        // number type to use for placeholders
        numberType: "MOBILE",
        // display only these countries
        onlyCountries: [],
        // display all countries except these
        excludeCountries: [],
        // the countries at the top of the list. defaults to united states and united kingdom
        preferredCountries: [ "us", "gb" ],
        // specify the path to the libphonenumber script to enable validation/formatting
        utilsScript: ""
    }, keys = {
        UP: 38,
        DOWN: 40,
        ENTER: 13,
        ESC: 27,
        PLUS: 43,
        A: 65,
        Z: 90,
        ZERO: 48,
        NINE: 57,
        SPACE: 32,
        BSPACE: 8,
        TAB: 9,
        DEL: 46,
        CTRL: 17,
        CMD1: 91,
        // Chrome
        CMD2: 224
    }, windowLoaded = false;
    // keep track of if the window.load event has fired as impossible to check after the fact
    $(window).load(function() {
        windowLoaded = true;
    });
    function Plugin(element, options) {
        this.element = element;
        this.options = $.extend({}, defaults, options);
        this._defaults = defaults;
        // event namespace
        this.ns = "." + pluginName + id++;
        // Chrome, FF, Safari, IE9+
        this.isGoodBrowser = Boolean(element.setSelectionRange);
        this.hadInitialPlaceholder = Boolean($(element).attr("placeholder"));
        this._name = pluginName;
    }
    Plugin.prototype = {
        _init: function() {
            // if in nationalMode, disable options relating to dial codes
            if (this.options.nationalMode) {
                this.options.autoHideDialCode = false;
            }
            // IE Mobile doesn't support the keypress event (see issue 68) which makes autoFormat impossible
            if (navigator.userAgent.match(/IEMobile/i)) {
                this.options.autoFormat = false;
            }
            // we cannot just test screen size as some smartphones/website meta tags will report desktop resolutions
            // Note: for some reason jasmine fucks up if you put this in the main Plugin function with the rest of these declarations
            // Note: to target Android Mobiles (and not Tablets), we must find "Android" and "Mobile"
            this.isMobile = /Android.+Mobile|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
            // we return these deferred objects from the _init() call so they can be watched, and then we resolve them when each specific request returns
            // Note: again, jasmine had a spazz when I put these in the Plugin function
            this.autoCountryDeferred = new $.Deferred();
            this.utilsScriptDeferred = new $.Deferred();
            // process all the data: onlyCountries, preferredCountries etc
            this._processCountryData();
            // generate the markup
            this._generateMarkup();
            // set the initial state of the input value and the selected flag
            this._setInitialState();
            // start all of the event listeners: autoHideDialCode, input keydown, selectedFlag click
            this._initListeners();
            // utils script, and auto country
            this._initRequests();
            this.$drop = null;
            // return the deferreds
            return [ this.autoCountryDeferred, this.utilsScriptDeferred ];
        },
        /********************
   *  PRIVATE METHODS
   ********************/
        // prepare all of the country data, including onlyCountries and preferredCountries options
        _processCountryData: function() {
            // set the instances country data objects
            this._setInstanceCountryData();
            // set the preferredCountries property
            this._setPreferredCountries();
        },
        // add a country code to this.countryCodes
        _addCountryCode: function(iso2, dialCode, priority) {
            if (!(dialCode in this.countryCodes)) {
                this.countryCodes[dialCode] = [];
            }
            var index = priority || 0;
            this.countryCodes[dialCode][index] = iso2;
        },
        // process onlyCountries array if present, and generate the countryCodes map
        _setInstanceCountryData: function() {
            var i;
            // process onlyCountries option
            if (this.options.onlyCountries.length) {
                // standardise case
                for (i = 0; i < this.options.onlyCountries.length; i++) {
                    this.options.onlyCountries[i] = this.options.onlyCountries[i].toLowerCase();
                }
                // build instance country array
                this.countries = [];
                for (i = 0; i < allCountries.length; i++) {
                    if ($.inArray(allCountries[i].iso2, this.options.onlyCountries) != -1) {
                        this.countries.push(allCountries[i]);
                    }
                }
            } else if (this.options.excludeCountries.length) {
                // standardise case
                for (i = 0; i < this.options.excludeCountries.length; i++) {
                    this.options.excludeCountries[i] = this.options.excludeCountries[i].toLowerCase();
                }
                // build instance country array
                this.countries = [];
                for (i = 0; i < allCountries.length; i++) {
                    if ($.inArray(allCountries[i].iso2, this.options.excludeCountries) == -1) {
                        this.countries.push(allCountries[i]);
                    }
                }
            } else {
                this.countries = allCountries;
            }
            // generate countryCodes map
            this.countryCodes = {};
            for (i = 0; i < this.countries.length; i++) {
                var c = this.countries[i];
                this._addCountryCode(c.iso2, c.dialCode, c.priority);
                // area codes
                if (c.areaCodes) {
                    for (var j = 0; j < c.areaCodes.length; j++) {
                        // full dial code is country code + dial code
                        this._addCountryCode(c.iso2, c.dialCode + c.areaCodes[j]);
                    }
                }
            }
        },
        // process preferred countries - iterate through the preferences,
        // fetching the country data for each one
        _setPreferredCountries: function() {
            this.preferredCountries = [];
            for (var i = 0; i < this.options.preferredCountries.length; i++) {
                var countryCode = this.options.preferredCountries[i].toLowerCase(), countryData = this._getCountryData(countryCode, false, true);
                if (countryData) {
                    this.preferredCountries.push(countryData);
                }
            }
        },
        // generate all of the markup for the plugin: the selected flag overlay, and the dropdown
        _generateMarkup: function() {
            // telephone input
            this.telInput = $(this.element);
            // prevent autocomplete as there's no safe, cross-browser event we can react to, so it can easily put the plugin in an inconsistent state e.g. the wrong flag selected for the autocompleted number, which on submit could mean the wrong number is saved (esp in nationalMode)
            this.telInput.attr("autocomplete", "off");
            // containers (mostly for positioning)
            this.telInput.wrap($("<div>", {
                "class": "intl-tel-input"
            }));
            this.flagsContainer = $("<div>", {
                "class": "flag-dropdown"
            }).insertBefore(this.telInput);
            // currently selected flag (displayed to left of input)
            var selectedFlag = $("<div>", {
                // make element focusable and tab naviagable
                tabindex: "0",
                "class": "selected-flag"
            }).appendTo(this.flagsContainer);
            this.selectedFlagInner = $("<div>", {
                "class": "iti-flag"
            }).appendTo(selectedFlag);
            // CSS triangle
            $("<div>", {
                "class": "arrow"
            }).appendTo(selectedFlag);
            // country list
            // mobile is just a native select element
            // desktop is a proper list containing: preferred countries, then divider, then all countries
            if (this.isMobile) {
                this.countryList = $("<select>", {
                    "class": "iti-mobile-select"
                }).appendTo(this.flagsContainer);
            } else {
                this.countryList = $("<ul>", {
                    "class": "country-list v-hide"
                }).appendTo(this.flagsContainer);
                if (this.preferredCountries.length && !this.isMobile) {
                    this._appendListItems(this.preferredCountries, "preferred");
                    $("<li>", {
                        "class": "divider"
                    }).appendTo(this.countryList);
                }
            }
            this._appendListItems(this.countries, "");
            if (!this.isMobile) {
                // now we can grab the dropdown height, and hide it properly
                this.dropdownHeight = this.countryList.outerHeight();
                this.countryList.removeClass("v-hide").addClass("hide");
                // this is useful in lots of places
                this.countryListItems = this.countryList.children(".country");
            }
        },
        // add a country <li> to the countryList <ul> container
        // UPDATE: if isMobile, add an <option> to the countryList <select> container
        _appendListItems: function(countries, className) {
            // we create so many DOM elements, it is faster to build a temp string
            // and then add everything to the DOM in one go at the end
            var tmp = "";
            // for each country
            for (var i = 0; i < countries.length; i++) {
                var c = countries[i];
                if (this.isMobile) {
                    tmp += "<option data-dial-code='" + c.dialCode + "' value='" + c.iso2 + "'>";
                    tmp += c.name + " +" + c.dialCode;
                    tmp += "</option>";
                } else {
                    // open the list item
                    tmp += "<li class='country " + className + "' data-dial-code='" + c.dialCode + "' data-country-code='" + c.iso2 + "'>";
                    // add the flag
                    tmp += "<div class='flag'><div class='iti-flag " + c.iso2 + "'></div></div>";
                    // and the country name and dial code
                    tmp += "<span class='country-name'>" + c.name + "</span>";
                    tmp += "<span class='dial-code'>+" + c.dialCode + "</span>";
                    // close the list item
                    tmp += "</li>";
                }
            }
            this.countryList.append(tmp);
        },
        // set the initial state of the input value and the selected flag
        _setInitialState: function() {
            var val = this.telInput.val();
            // if there is a number, and it's valid, we can go ahead and set the flag, else fall back to default
            if (this._getDialCode(val)) {
                this._updateFlagFromNumber(val, true);
            } else if (this.options.defaultCountry != "auto") {
                // check the defaultCountry option, else fall back to the first in the list
                if (this.options.defaultCountry) {
                    this.options.defaultCountry = this._getCountryData(this.options.defaultCountry.toLowerCase(), false, false);
                } else {
                    this.options.defaultCountry = this.preferredCountries.length ? this.preferredCountries[0] : this.countries[0];
                }
                this._selectFlag(this.options.defaultCountry.iso2);
                // if empty, insert the default dial code (this function will check !nationalMode and !autoHideDialCode)
                if (!val) {
                    this._updateDialCode(this.options.defaultCountry.dialCode, false);
                }
            }
            // format
            if (val) {
                // this wont be run after _updateDialCode as that's only called if no val
                this._updateVal(val);
            }
        },
        // initialise the main event listeners: input keyup, and click selected flag
        _initListeners: function() {
            var that = this;
            this._initKeyListeners();
            // autoFormat prevents the change event from firing, so we need to check for changes between focus and blur in order to manually trigger it
            if (this.options.autoHideDialCode || this.options.autoFormat) {
                this._initFocusListeners();
            }
            if (this.isMobile) {
                this.countryList.on("change" + this.ns, function(e) {
                    that._selectListItem($(this).find("option:selected"));
                });
            } else {
                // hack for input nested inside label: clicking the selected-flag to open the dropdown would then automatically trigger a 2nd click on the input which would close it again
                var label = this.telInput.closest("label");
                if (label.length) {
                    label.on("click" + this.ns, function(e) {
                        // if the dropdown is closed, then focus the input, else ignore the click
                        if (that.countryList.hasClass("hide")) {
                            that.telInput.focus();
                        } else {
                            e.preventDefault();
                        }
                    });
                }
                // toggle country dropdown on click
                var selectedFlag = this.selectedFlagInner.parent();
                selectedFlag.on("click" + this.ns, function(e) {
                    // only intercept this event if we're opening the dropdown
                    // else let it bubble up to the top ("click-off-to-close" listener)
                    // we cannot just stopPropagation as it may be needed to close another instance
                    if (that.countryList.hasClass("hide") && !that.telInput.prop("disabled") && !that.telInput.prop("readonly")) {
                        that._showDropdown();
                    }
                });
            }
            // open dropdown list if currently focused
            this.flagsContainer.on("keydown" + that.ns, function(e) {
                var isDropdownHidden = that.countryList.hasClass("hide");
                if (isDropdownHidden && (e.which == keys.UP || e.which == keys.DOWN || e.which == keys.SPACE || e.which == keys.ENTER)) {
                    // prevent form from being submitted if "ENTER" was pressed
                    e.preventDefault();
                    // prevent event from being handled again by document
                    e.stopPropagation();
                    that._showDropdown();
                }
                // allow navigation from dropdown to input on TAB
                if (e.which == keys.TAB) {
                    that._closeDropdown();
                }
            });
        },
        _initRequests: function() {
            var that = this;
            // if the user has specified the path to the utils script, fetch it on window.load
            if (this.options.utilsScript) {
                // if the plugin is being initialised after the window.load event has already been fired
                if (windowLoaded) {
                    this.loadUtils();
                } else {
                    // wait until the load event so we don't block any other requests e.g. the flags image
                    $(window).load(function() {
                        that.loadUtils();
                    });
                }
            } else {
                this.utilsScriptDeferred.resolve();
            }
            if (this.options.defaultCountry == "auto") {
                this._loadAutoCountry();
            } else {
                this.autoCountryDeferred.resolve();
            }
        },
        _loadAutoCountry: function() {
            var that = this;
            // check for cookie
            var cookieAutoCountry = $.cookie ? $.cookie("itiAutoCountry") : "";
            if (cookieAutoCountry) {
                $.fn[pluginName].autoCountry = cookieAutoCountry;
            }
            // 3 options:
            // 1) already loaded (we're done)
            // 2) not already started loading (start)
            // 3) already started loading (do nothing - just wait for loading callback to fire)
            if ($.fn[pluginName].autoCountry) {
                this.autoCountryLoaded();
            } else if (!$.fn[pluginName].startedLoadingAutoCountry) {
                // don't do this twice!
                $.fn[pluginName].startedLoadingAutoCountry = true;
                if (typeof this.options.geoIpLookup === "function") {
                    this.options.geoIpLookup(function(countryCode) {
                        $.fn[pluginName].autoCountry = countryCode.toLowerCase();
                        if ($.cookie) {
                            $.cookie("itiAutoCountry", $.fn[pluginName].autoCountry, {
                                path: "/"
                            });
                        }
                        // tell all instances the auto country is ready
                        // TODO: this should just be the current instances
                        $(".intl-tel-input input").intlTelInput("autoCountryLoaded");
                    });
                }
            }
        },
        _initKeyListeners: function() {
            var that = this;
            if (this.options.autoFormat) {
                // format number and update flag on keypress
                // use keypress event as we want to ignore all input except for a select few keys,
                // but we dont want to ignore the navigation keys like the arrows etc.
                // NOTE: no point in refactoring this to only bind these listeners on focus/blur because then you would need to have those 2 listeners running the whole time anyway...
                this.telInput.on("keypress" + this.ns, function(e) {
                    // 32 is space, and after that it's all chars (not meta/nav keys)
                    // this fix is needed for Firefox, which triggers keypress event for some meta/nav keys
                    // Update: also ignore if this is a metaKey e.g. FF and Safari trigger keypress on the v of Ctrl+v
                    // Update: also ignore if ctrlKey (FF on Windows/Ubuntu)
                    // Update: also check that we have utils before we do any autoFormat stuff
                    if (e.which >= keys.SPACE && !e.ctrlKey && !e.metaKey && window.intlTelInputUtils && !that.telInput.prop("readonly")) {
                        e.preventDefault();
                        // allowed keys are just numeric keys and plus
                        // we must allow plus for the case where the user does select-all and then hits plus to start typing a new number. we could refine this logic to first check that the selection contains a plus, but that wont work in old browsers, and I think it's overkill anyway
                        var isAllowedKey = e.which >= keys.ZERO && e.which <= keys.NINE || e.which == keys.PLUS, input = that.telInput[0], noSelection = that.isGoodBrowser && input.selectionStart == input.selectionEnd, max = that.telInput.attr("maxlength"), val = that.telInput.val(), // assumes that if max exists, it is >0
                        isBelowMax = max ? val.length < max : true;
                        // first: ensure we dont go over maxlength. we must do this here to prevent adding digits in the middle of the number
                        // still reformat even if not an allowed key as they could by typing a formatting char, but ignore if there's a selection as doesn't make sense to replace selection with illegal char and then immediately remove it
                        if (isBelowMax && (isAllowedKey || noSelection)) {
                            var newChar = isAllowedKey ? String.fromCharCode(e.which) : null;
                            that._handleInputKey(newChar, true, isAllowedKey);
                            // if something has changed, trigger the input event (which was otherwised squashed by the preventDefault)
                            if (val != that.telInput.val()) {
                                that.telInput.trigger("input");
                            }
                        }
                        if (!isAllowedKey) {
                            that._handleInvalidKey();
                        }
                    }
                });
            }
            // handle cut/paste event (now supported in all major browsers)
            this.telInput.on("cut" + this.ns + " paste" + this.ns, function() {
                // hack because "paste" event is fired before input is updated
                setTimeout(function() {
                    if (that.options.autoFormat && window.intlTelInputUtils) {
                        var cursorAtEnd = that.isGoodBrowser && that.telInput[0].selectionStart == that.telInput.val().length;
                        that._handleInputKey(null, cursorAtEnd);
                        that._ensurePlus();
                    } else {
                        // if no autoFormat, just update flag
                        that._updateFlagFromNumber(that.telInput.val());
                    }
                });
            });
            // handle keyup event
            // if autoFormat enabled: we use keyup to catch delete events (after the fact)
            // if no autoFormat, this is used to update the flag
            this.telInput.on("keyup" + this.ns, function(e) {
                // the "enter" key event from selecting a dropdown item is triggered here on the input, because the document.keydown handler that initially handles that event triggers a focus on the input, and so the keyup for that same key event gets triggered here. weird, but just make sure we dont bother doing any re-formatting in this case (we've already done preventDefault in the keydown handler, so it wont actually submit the form or anything).
                // ALSO: ignore keyup if readonly
                if (e.which == keys.ENTER || that.telInput.prop("readonly")) {} else if (that.options.autoFormat && window.intlTelInputUtils) {
                    // cursorAtEnd defaults to false for bad browsers else they would never get a reformat on delete
                    var cursorAtEnd = that.isGoodBrowser && that.telInput[0].selectionStart == that.telInput.val().length;
                    if (!that.telInput.val()) {
                        // if they just cleared the input, update the flag to the default
                        that._updateFlagFromNumber("");
                    } else if (e.which == keys.DEL && !cursorAtEnd || e.which == keys.BSPACE) {
                        // if delete in the middle: reformat with no suffix (no need to reformat if delete at end)
                        // if backspace: reformat with no suffix (need to reformat if at end to remove any lingering suffix - this is a feature)
                        // important to remember never to add suffix on any delete key as can fuck up in ie8 so you can never delete a formatting char at the end
                        that._handleInputKey();
                    }
                    that._ensurePlus();
                } else {
                    // if no autoFormat, just update flag
                    that._updateFlagFromNumber(that.telInput.val());
                }
            });
        },
        // prevent deleting the plus (if not in nationalMode)
        _ensurePlus: function() {
            if (!this.options.nationalMode) {
                var val = this.telInput.val(), input = this.telInput[0];
                if (val.charAt(0) != "+") {
                    // newCursorPos is current pos + 1 to account for the plus we are about to add
                    var newCursorPos = this.isGoodBrowser ? input.selectionStart + 1 : 0;
                    this.telInput.val("+" + val);
                    if (this.isGoodBrowser) {
                        input.setSelectionRange(newCursorPos, newCursorPos);
                    }
                }
            }
        },
        // alert the user to an invalid key event
        _handleInvalidKey: function() {
            var that = this;
            this.telInput.trigger("invalidkey").addClass("iti-invalid-key");
            setTimeout(function() {
                that.telInput.removeClass("iti-invalid-key");
            }, 100);
        },
        // when autoFormat is enabled: handle various key events on the input:
        // 1) adding a new number character, which will replace any selection, reformat, and preserve the cursor position
        // 2) reformatting on backspace/delete
        // 3) cut/paste event
        _handleInputKey: function(newNumericChar, addSuffix, isAllowedKey) {
            var val = this.telInput.val(), cleanBefore = this._getClean(val), originalLeftChars, // raw DOM element
            input = this.telInput[0], digitsOnRight = 0;
            if (this.isGoodBrowser) {
                // cursor strategy: maintain the number of digits on the right. we use the right instead of the left so that A) we dont have to account for the new digit (or multiple digits if paste event), and B) we're always on the right side of formatting suffixes
                digitsOnRight = this._getDigitsOnRight(val, input.selectionEnd);
                // if handling a new number character: insert it in the right place
                if (newNumericChar) {
                    // replace any selection they may have made with the new char
                    val = val.substr(0, input.selectionStart) + newNumericChar + val.substring(input.selectionEnd, val.length);
                } else {
                    // here we're not handling a new char, we're just doing a re-format (e.g. on delete/backspace/paste, after the fact), but we still need to maintain the cursor position. so make note of the char on the left, and then after the re-format, we'll count in the same number of digits from the right, and then keep going through any formatting chars until we hit the same left char that we had before.
                    // UPDATE: now have to store 2 chars as extensions formatting contains 2 spaces so you need to be able to distinguish
                    originalLeftChars = val.substr(input.selectionStart - 2, 2);
                }
            } else if (newNumericChar) {
                val += newNumericChar;
            }
            // update the number and flag
            this.setNumber(val, null, addSuffix, true, isAllowedKey);
            // update the cursor position
            if (this.isGoodBrowser) {
                var newCursor;
                val = this.telInput.val();
                // if it was at the end, keep it there
                if (!digitsOnRight) {
                    newCursor = val.length;
                } else {
                    // else count in the same number of digits from the right
                    newCursor = this._getCursorFromDigitsOnRight(val, digitsOnRight);
                    // but if delete/paste etc, keep going left until hit the same left char as before
                    if (!newNumericChar) {
                        newCursor = this._getCursorFromLeftChar(val, newCursor, originalLeftChars);
                    }
                }
                // set the new cursor
                input.setSelectionRange(newCursor, newCursor);
            }
        },
        // we start from the position in guessCursor, and work our way left until we hit the originalLeftChars or a number to make sure that after reformatting the cursor has the same char on the left in the case of a delete etc
        _getCursorFromLeftChar: function(val, guessCursor, originalLeftChars) {
            for (var i = guessCursor; i > 0; i--) {
                var leftChar = val.charAt(i - 1);
                if ($.isNumeric(leftChar) || val.substr(i - 2, 2) == originalLeftChars) {
                    return i;
                }
            }
            return 0;
        },
        // after a reformat we need to make sure there are still the same number of digits to the right of the cursor
        _getCursorFromDigitsOnRight: function(val, digitsOnRight) {
            for (var i = val.length - 1; i >= 0; i--) {
                if ($.isNumeric(val.charAt(i))) {
                    if (--digitsOnRight === 0) {
                        return i;
                    }
                }
            }
            return 0;
        },
        // get the number of numeric digits to the right of the cursor so we can reposition the cursor correctly after the reformat has happened
        _getDigitsOnRight: function(val, selectionEnd) {
            var digitsOnRight = 0;
            for (var i = selectionEnd; i < val.length; i++) {
                if ($.isNumeric(val.charAt(i))) {
                    digitsOnRight++;
                }
            }
            return digitsOnRight;
        },
        // listen for focus and blur
        _initFocusListeners: function() {
            var that = this;
            if (this.options.autoHideDialCode) {
                // mousedown decides where the cursor goes, so if we're focusing we must preventDefault as we'll be inserting the dial code, and we want the cursor to be at the end no matter where they click
                this.telInput.on("mousedown" + this.ns, function(e) {
                    if (!that.telInput.is(":focus") && !that.telInput.val()) {
                        e.preventDefault();
                        // but this also cancels the focus, so we must trigger that manually
                        that.telInput.focus();
                    }
                });
            }
            this.telInput.on("focus" + this.ns, function(e) {
                var value = that.telInput.val();
                // save this to compare on blur
                that.telInput.data("focusVal", value);
                // on focus: if empty, insert the dial code for the currently selected flag
                if (that.options.autoHideDialCode && !value && !that.telInput.prop("readonly") && that.selectedCountryData.dialCode) {
                    that._updateVal("+" + that.selectedCountryData.dialCode, null, true);
                    // after auto-inserting a dial code, if the first key they hit is '+' then assume they are entering a new number, so remove the dial code. use keypress instead of keydown because keydown gets triggered for the shift key (required to hit the + key), and instead of keyup because that shows the new '+' before removing the old one
                    that.telInput.one("keypress.plus" + that.ns, function(e) {
                        if (e.which == keys.PLUS) {
                            // if autoFormat is enabled, this key event will have already have been handled by another keypress listener (hence we need to add the "+"). if disabled, it will be handled after this by a keyup listener (hence no need to add the "+").
                            var newVal = that.options.autoFormat && window.intlTelInputUtils ? "+" : "";
                            that.telInput.val(newVal);
                        }
                    });
                    // after tabbing in, make sure the cursor is at the end we must use setTimeout to get outside of the focus handler as it seems the selection happens after that
                    setTimeout(function() {
                        var input = that.telInput[0];
                        if (that.isGoodBrowser) {
                            var len = that.telInput.val().length;
                            input.setSelectionRange(len, len);
                        }
                    });
                }
            });
            this.telInput.on("blur" + this.ns, function() {
                if (that.options.autoHideDialCode) {
                    // on blur: if just a dial code then remove it
                    var value = that.telInput.val(), startsPlus = value.charAt(0) == "+";
                    if (startsPlus) {
                        var numeric = that._getNumeric(value);
                        // if just a plus, or if just a dial code
                        if (!numeric || that.selectedCountryData.dialCode == numeric) {
                            that.telInput.val("");
                        }
                    }
                    // remove the keypress listener we added on focus
                    that.telInput.off("keypress.plus" + that.ns);
                }
                // if autoFormat, we must manually trigger change event if value has changed
                if (that.options.autoFormat && window.intlTelInputUtils && that.telInput.val() != that.telInput.data("focusVal")) {
                    that.telInput.trigger("change");
                }
            });
        },
        // extract the numeric digits from the given string
        _getNumeric: function(s) {
            return s.replace(/\D/g, "");
        },
        _getClean: function(s) {
            var prefix = s.charAt(0) == "+" ? "+" : "";
            return prefix + this._getNumeric(s);
        },
        // show the dropdown
        _showDropdown: function() {
            this._setDropdownPosition();
            // update highlighting and scroll to active list item
            var activeListItem = this.countryList.children(".active");
            if (activeListItem.length) {
                this._highlightListItem(activeListItem);
            }
            // show it
            this.countryList.removeClass("hide");
            if (activeListItem.length) {
                this._scrollTo(activeListItem);
            }
            // bind all the dropdown-related listeners: mouseover, click, click-off, keydown
            this._bindDropdownListeners();
            // update the arrow
            this.selectedFlagInner.children(".arrow").addClass("up");
        },
        // decide where to position dropdown (depends on position within viewport, and scroll)
        _setDropdownPosition: function() {
            var that = this,
                pos = this.telInput.offset(),
                inputTop = pos.top, windowTop = $(window).scrollTop(), // dropdownFitsBelow = (dropdownBottom < windowBottom)
            dropdownFitsBelow = inputTop + this.telInput.outerHeight() + this.dropdownHeight < windowTop + $(window).height(), dropdownFitsAbove = inputTop - this.dropdownHeight > windowTop;
            // dropdownHeight - 1 for border
            var cssTop = !dropdownFitsBelow && dropdownFitsAbove ? "-" + (this.dropdownHeight - 1) + "px" : "";
            this.countryList.css("top", cssTop);
            
            // if container, append countryList to this.$drop and this.$drop to container
            if (this.options.container) {
              //this.$drop = $("<div class='intl-tel-input iti-container'><div class='flag-dropdown'></div></div>");
              //this.$drop = $("<div class='intl-tel-input iti-container'><div class='flag-dropdown'></div></div>");
              
              this.$drop = $("<div>", {
                "class": "intl-tel-input iti-container"
              });
              
              var $dropInner = $("<div>", {
                "class": "flag-dropdown"
              }).appendTo(this.$drop),
                  inputHeight = !dropdownFitsBelow && dropdownFitsAbove ? 0 : that.telInput.outerHeight();
              
              // calculate placement
              that.$drop.css({
                "top": pos.top + inputHeight - parseInt(this.telInput.css('borderTopWidth'), 10) - parseInt(this.telInput.css('borderBottomWidth'), 10),
                "left": pos.left,
                "position": "absolute"
              });
              
              // close menu on resize/scroll
              this.telInput.parents().off("resize" + this.ns + " scroll" + this.ns).on("resize" + this.ns + " scroll" + this.ns, function () {
                if (!that.countryList.hasClass("hide")) that._closeDropdown();
              });
              
              this.$drop.appendTo(this.options.container);
              $dropInner.append(this.countryList);
            }
        },
        // we only bind dropdown listeners when the dropdown is open
        _bindDropdownListeners: function() {
            var that = this;
            // when mouse over a list item, just highlight that one
            // we add the class "highlight", so if they hit "enter" we know which one to select
            this.countryList.on("mouseover" + this.ns, ".country", function(e) {
                that._highlightListItem($(this));
            });
            // listen for country selection
            this.countryList.on("click" + this.ns, ".country", function(e) {
                that._selectListItem($(this));
            });
            // click off to close
            // (except when this initial opening click is bubbling up)
            // we cannot just stopPropagation as it may be needed to close another instance
            var isOpening = true;
            $("html").on("click" + this.ns, function(e) {
                if (!isOpening) {
                    that._closeDropdown();
                }
                isOpening = false;
            });
            // listen for up/down scrolling, enter to select, or letters to jump to country name.
            // use keydown as keypress doesn't fire for non-char keys and we want to catch if they
            // just hit down and hold it to scroll down (no keyup event).
            // listen on the document because that's where key events are triggered if no input has focus
            var query = "", queryTimer = null;
            $(document).on("keydown" + this.ns, function(e) {
                // prevent down key from scrolling the whole page,
                // and enter key from submitting a form etc
                e.preventDefault();
                if (e.which == keys.UP || e.which == keys.DOWN) {
                    // up and down to navigate
                    that._handleUpDownKey(e.which);
                } else if (e.which == keys.ENTER) {
                    // enter to select
                    that._handleEnterKey();
                } else if (e.which == keys.ESC) {
                    // esc to close
                    that._closeDropdown();
                } else if (e.which >= keys.A && e.which <= keys.Z || e.which == keys.SPACE) {
                    // upper case letters (note: keyup/keydown only return upper case letters)
                    // jump to countries that start with the query string
                    if (queryTimer) {
                        clearTimeout(queryTimer);
                    }
                    query += String.fromCharCode(e.which);
                    that._searchForCountry(query);
                    // if the timer hits 1 second, reset the query
                    queryTimer = setTimeout(function() {
                        query = "";
                    }, 1e3);
                }
            });
        },
        // highlight the next/prev item in the list (and ensure it is visible)
        _handleUpDownKey: function(key) {
            var current = this.countryList.children(".highlight").first();
            var next = key == keys.UP ? current.prev() : current.next();
            if (next.length) {
                // skip the divider
                if (next.hasClass("divider")) {
                    next = key == keys.UP ? next.prev() : next.next();
                }
                this._highlightListItem(next);
                this._scrollTo(next);
            }
        },
        // select the currently highlighted item
        _handleEnterKey: function() {
            var currentCountry = this.countryList.children(".highlight").first();
            if (currentCountry.length) {
                this._selectListItem(currentCountry);
            }
        },
        // find the first list item whose name starts with the query string
        _searchForCountry: function(query) {
            for (var i = 0; i < this.countries.length; i++) {
                if (this._startsWith(this.countries[i].name, query)) {
                    var listItem = this.countryList.children("[data-country-code=" + this.countries[i].iso2 + "]").not(".preferred");
                    // update highlighting and scroll
                    this._highlightListItem(listItem);
                    this._scrollTo(listItem, true);
                    break;
                }
            }
        },
        // check if (uppercase) string a starts with string b
        _startsWith: function(a, b) {
            return a.substr(0, b.length).toUpperCase() == b;
        },
        // update the input's value to the given val
        // if autoFormat=true, format it first according to the country-specific formatting rules
        // Note: preventConversion will be false (i.e. we allow conversion) on init and when dev calls public method setNumber
        _updateVal: function(val, format, addSuffix, preventConversion, isAllowedKey) {
            var formatted;
            if (this.options.autoFormat && window.intlTelInputUtils && this.selectedCountryData) {
                if (typeof format == "number" && intlTelInputUtils.isValidNumber(val, this.selectedCountryData.iso2)) {
                    // if user specified a format, and it's a valid number, then format it accordingly
                    formatted = intlTelInputUtils.formatNumberByType(val, this.selectedCountryData.iso2, format);
                } else if (!preventConversion && this.options.nationalMode && val.charAt(0) == "+" && intlTelInputUtils.isValidNumber(val, this.selectedCountryData.iso2)) {
                    // if nationalMode and we have a valid intl number, convert it to ntl
                    formatted = intlTelInputUtils.formatNumberByType(val, this.selectedCountryData.iso2, intlTelInputUtils.numberFormat.NATIONAL);
                } else {
                    // else do the regular AsYouType formatting
                    formatted = intlTelInputUtils.formatNumber(val, this.selectedCountryData.iso2, addSuffix, this.options.allowExtensions, isAllowedKey);
                }
                // ensure we dont go over maxlength. we must do this here to truncate any formatting suffix, and also handle paste events
                var max = this.telInput.attr("maxlength");
                if (max && formatted.length > max) {
                    formatted = formatted.substr(0, max);
                }
            } else {
                // no autoFormat, so just insert the original value
                formatted = val;
            }
            this.telInput.val(formatted);
        },
        // check if need to select a new flag based on the given number
        _updateFlagFromNumber: function(number, updateDefault) {
            // if we're in nationalMode and we're on US/Canada, make sure the number starts with a +1 so _getDialCode will be able to extract the area code
            // update: if we dont yet have selectedCountryData, but we're here (trying to update the flag from the number), that means we're initialising the plugin with a number that already has a dial code, so fine to ignore this bit
            if (number && this.options.nationalMode && this.selectedCountryData && this.selectedCountryData.dialCode == "1" && number.charAt(0) != "+") {
                if (number.charAt(0) != "1") {
                    number = "1" + number;
                }
                number = "+" + number;
            }
            // try and extract valid dial code from input
            var dialCode = this._getDialCode(number), countryCode = null;
            if (dialCode) {
                // check if one of the matching countries is already selected
                var countryCodes = this.countryCodes[this._getNumeric(dialCode)], alreadySelected = this.selectedCountryData && $.inArray(this.selectedCountryData.iso2, countryCodes) != -1;
                // if a matching country is not already selected (or this is an unknown NANP area code): choose the first in the list
                if (!alreadySelected || this._isUnknownNanp(number, dialCode)) {
                    // if using onlyCountries option, countryCodes[0] may be empty, so we must find the first non-empty index
                    for (var j = 0; j < countryCodes.length; j++) {
                        if (countryCodes[j]) {
                            countryCode = countryCodes[j];
                            break;
                        }
                    }
                }
            } else if (number.charAt(0) == "+" && this._getNumeric(number).length) {
                // invalid dial code, so empty
                // Note: use getNumeric here because the number has not been formatted yet, so could contain bad shit
                countryCode = "";
            } else if (!number || number == "+") {
                // empty, or just a plus, so default
                countryCode = this.options.defaultCountry.iso2;
            }
            if (countryCode !== null) {
                this._selectFlag(countryCode, updateDefault);
            }
        },
        // check if the given number contains an unknown area code from the North American Numbering Plan i.e. the only dialCode that could be extracted was +1 but the actual number's length is >=4
        _isUnknownNanp: function(number, dialCode) {
            return dialCode == "+1" && this._getNumeric(number).length >= 4;
        },
        // remove highlighting from other list items and highlight the given item
        _highlightListItem: function(listItem) {
            this.countryListItems.removeClass("highlight");
            listItem.addClass("highlight");
        },
        // find the country data for the given country code
        // the ignoreOnlyCountriesOption is only used during init() while parsing the onlyCountries array
        _getCountryData: function(countryCode, ignoreOnlyCountriesOption, allowFail) {
            var countryList = ignoreOnlyCountriesOption ? allCountries : this.countries;
            for (var i = 0; i < countryList.length; i++) {
                if (countryList[i].iso2 == countryCode) {
                    return countryList[i];
                }
            }
            if (allowFail) {
                return null;
            } else {
                throw new Error("No country data for '" + countryCode + "'");
            }
        },
        // select the given flag, update the placeholder and the active list item
        _selectFlag: function(countryCode, updateDefault) {
            // do this first as it will throw an error and stop if countryCode is invalid
            this.selectedCountryData = countryCode ? this._getCountryData(countryCode, false, false) : {};
            // update the "defaultCountry" - we only need the iso2 from now on, so just store that
            if (updateDefault && this.selectedCountryData.iso2) {
                // can't just make this equal to selectedCountryData as would be a ref to that object
                this.options.defaultCountry = {
                    iso2: this.selectedCountryData.iso2
                };
            }
            this.selectedFlagInner.attr("class", "iti-flag " + countryCode);
            // update the selected country's title attribute
            var title = countryCode ? this.selectedCountryData.name + ": +" + this.selectedCountryData.dialCode : "Unknown";
            this.selectedFlagInner.parent().attr("title", title);
            // and the input's placeholder
            this._updatePlaceholder();
            if (this.isMobile) {
                this.countryList.val(countryCode);
            } else {
                // update the active list item
                this.countryListItems.removeClass("active");
                if (countryCode) {
                    this.countryListItems.find(".iti-flag." + countryCode).first().closest(".country").addClass("active");
                }
            }
        },
        // update the input placeholder to an example number from the currently selected country
        _updatePlaceholder: function() {
            if (window.intlTelInputUtils && !this.hadInitialPlaceholder && this.options.autoPlaceholder && this.selectedCountryData) {
                var iso2 = this.selectedCountryData.iso2, numberType = intlTelInputUtils.numberType[this.options.numberType || "FIXED_LINE"], placeholder = iso2 ? intlTelInputUtils.getExampleNumber(iso2, this.options.nationalMode, numberType) : "";
                this.telInput.attr("placeholder", placeholder);
            }
        },
        // called when the user selects a list item from the dropdown
        _selectListItem: function(listItem) {
            var countryCodeAttr = this.isMobile ? "value" : "data-country-code";
            // update selected flag and active list item
            this._selectFlag(listItem.attr(countryCodeAttr), true);
            if (!this.isMobile) {
                this._closeDropdown();
            }
            this._updateDialCode(listItem.attr("data-dial-code"), true);
            // always fire the change event as even if nationalMode=true (and we haven't updated the input val), the system as a whole has still changed - see country-sync example. think of it as making a selection from a select element.
            this.telInput.trigger("change");
            // focus the input
            this.telInput.focus();
            // fix for FF and IE11 (with nationalMode=false i.e. auto inserting dial code), who try to put the cursor at the beginning the first time
            if (this.isGoodBrowser) {
                var len = this.telInput.val().length;
                this.telInput[0].setSelectionRange(len, len);
            }
        },
        // close the dropdown and unbind any listeners
        _closeDropdown: function() {
            this.countryList.addClass("hide");
            // update the arrow
            this.selectedFlagInner.children(".arrow").removeClass("up");
            // unbind key events
            $(document).off(this.ns);
            // unbind click-off-to-close
            $("html").off(this.ns);
            // unbind hover and click listeners
            this.countryList.off(this.ns);
            // remove menu from container
            if (this.options.container) this.$drop.detach();
        },
        // check if an element is visible within it's container, else scroll until it is
        _scrollTo: function(element, middle) {
            var container = this.countryList, containerHeight = container.height(), containerTop = container.offset().top, containerBottom = containerTop + containerHeight, elementHeight = element.outerHeight(), elementTop = element.offset().top, elementBottom = elementTop + elementHeight, newScrollTop = elementTop - containerTop + container.scrollTop(), middleOffset = containerHeight / 2 - elementHeight / 2;
            if (elementTop < containerTop) {
                // scroll up
                if (middle) {
                    newScrollTop -= middleOffset;
                }
                container.scrollTop(newScrollTop);
            } else if (elementBottom > containerBottom) {
                // scroll down
                if (middle) {
                    newScrollTop += middleOffset;
                }
                var heightDifference = containerHeight - elementHeight;
                container.scrollTop(newScrollTop - heightDifference);
            }
        },
        // replace any existing dial code with the new one (if not in nationalMode)
        // also we need to know if we're focusing for a couple of reasons e.g. if so, we want to add any formatting suffix, also if the input is empty and we're not in nationalMode, then we want to insert the dial code
        _updateDialCode: function(newDialCode, focusing) {
            var inputVal = this.telInput.val(), newNumber;
            // save having to pass this every time
            newDialCode = "+" + newDialCode;
            if (this.options.nationalMode && inputVal.charAt(0) != "+") {
                // if nationalMode, we just want to re-format
                newNumber = inputVal;
            } else if (inputVal) {
                // if the previous number contained a valid dial code, replace it
                // (if more than just a plus character)
                var prevDialCode = this._getDialCode(inputVal);
                if (prevDialCode.length > 1) {
                    newNumber = inputVal.replace(prevDialCode, newDialCode);
                } else {
                    // if the previous number didn't contain a dial code, we should persist it
                    var existingNumber = inputVal.charAt(0) != "+" ? $.trim(inputVal) : "";
                    newNumber = newDialCode + existingNumber;
                }
            } else {
                newNumber = !this.options.autoHideDialCode || focusing ? newDialCode : "";
            }
            this._updateVal(newNumber, null, focusing);
        },
        // try and extract a valid international dial code from a full telephone number
        // Note: returns the raw string inc plus character and any whitespace/dots etc
        _getDialCode: function(number) {
            var dialCode = "";
            // only interested in international numbers (starting with a plus)
            if (number.charAt(0) == "+") {
                var numericChars = "";
                // iterate over chars
                for (var i = 0; i < number.length; i++) {
                    var c = number.charAt(i);
                    // if char is number
                    if ($.isNumeric(c)) {
                        numericChars += c;
                        // if current numericChars make a valid dial code
                        if (this.countryCodes[numericChars]) {
                            // store the actual raw string (useful for matching later)
                            dialCode = number.substr(0, i + 1);
                        }
                        // longest dial code is 4 chars
                        if (numericChars.length == 4) {
                            break;
                        }
                    }
                }
            }
            return dialCode;
        },
        /********************
   *  PUBLIC METHODS
   ********************/
        // this is called when the geoip call returns
        autoCountryLoaded: function() {
            if (this.options.defaultCountry == "auto") {
                this.options.defaultCountry = $.fn[pluginName].autoCountry;
                this._setInitialState();
                this.autoCountryDeferred.resolve();
            }
        },
        // remove plugin
        destroy: function() {
            if (!this.isMobile) {
                // make sure the dropdown is closed (and unbind listeners)
                this._closeDropdown();
            }
            // key events, and focus/blur events if autoHideDialCode=true
            this.telInput.off(this.ns);
            if (this.isMobile) {
                // change event on select country
                this.countryList.off(this.ns);
            } else {
                // click event to open dropdown
                this.selectedFlagInner.parent().off(this.ns);
                // label click hack
                this.telInput.closest("label").off(this.ns);
            }
            // remove markup
            var container = this.telInput.parent();
            container.before(this.telInput).remove();
        },
        // extract the phone number extension if present
        getExtension: function() {
            return this.telInput.val().split(" ext. ")[1] || "";
        },
        // format the number to the given type
        getNumber: function(type) {
            if (window.intlTelInputUtils) {
                return intlTelInputUtils.formatNumberByType(this.telInput.val(), this.selectedCountryData.iso2, type);
            }
            return "";
        },
        // get the type of the entered number e.g. landline/mobile
        getNumberType: function() {
            if (window.intlTelInputUtils) {
                return intlTelInputUtils.getNumberType(this.telInput.val(), this.selectedCountryData.iso2);
            }
            return -99;
        },
        // get the country data for the currently selected flag
        getSelectedCountryData: function() {
            // if this is undefined, the plugin will return it's instance instead, so in that case an empty object makes more sense
            return this.selectedCountryData || {};
        },
        // get the validation error
        getValidationError: function() {
            if (window.intlTelInputUtils) {
                return intlTelInputUtils.getValidationError(this.telInput.val(), this.selectedCountryData.iso2);
            }
            return -99;
        },
        // validate the input val - assumes the global function isValidNumber (from utilsScript)
        isValidNumber: function() {
            var val = $.trim(this.telInput.val()), countryCode = this.options.nationalMode ? this.selectedCountryData.iso2 : "";
            if (window.intlTelInputUtils) {
                return intlTelInputUtils.isValidNumber(val, countryCode);
            }
            return false;
        },
        // load the utils script
        loadUtils: function(path) {
            var that = this;
            var utilsScript = path || this.options.utilsScript;
            if (!$.fn[pluginName].loadedUtilsScript && utilsScript) {
                // don't do this twice! (dont just check if the global intlTelInputUtils exists as if init plugin multiple times in quick succession, it may not have finished loading yet)
                $.fn[pluginName].loadedUtilsScript = true;
                // dont use $.getScript as it prevents caching
                $.ajax({
                    url: utilsScript,
                    success: function() {
                        // tell all instances the utils are ready
                        $(".intl-tel-input input").intlTelInput("utilsLoaded");
                    },
                    complete: function() {
                        that.utilsScriptDeferred.resolve();
                    },
                    dataType: "script",
                    cache: true
                });
            } else {
                this.utilsScriptDeferred.resolve();
            }
        },
        // update the selected flag, and update the input val accordingly
        selectCountry: function(countryCode) {
            countryCode = countryCode.toLowerCase();
            // check if already selected
            if (!this.selectedFlagInner.hasClass(countryCode)) {
                this._selectFlag(countryCode, true);
                this._updateDialCode(this.selectedCountryData.dialCode, false);
            }
        },
        // set the input value and update the flag
        setNumber: function(number, format, addSuffix, preventConversion, isAllowedKey) {
            // ensure starts with plus
            if (!this.options.nationalMode && number.charAt(0) != "+") {
                number = "+" + number;
            }
            // we must update the flag first, which updates this.selectedCountryData, which is used later for formatting the number before displaying it
            this._updateFlagFromNumber(number);
            this._updateVal(number, format, addSuffix, preventConversion, isAllowedKey);
        },
        // this is called when the utils are ready
        utilsLoaded: function() {
            // if autoFormat is enabled and there's an initial value in the input, then format it
            if (this.options.autoFormat && this.telInput.val()) {
                this._updateVal(this.telInput.val());
            }
            this._updatePlaceholder();
        }
    };
    // adapted to allow public functions
    // using https://github.com/jquery-boilerplate/jquery-boilerplate/wiki/Extending-jQuery-Boilerplate
    $.fn[pluginName] = function(options) {
        var args = arguments;
        // Is the first parameter an object (options), or was omitted,
        // instantiate a new instance of the plugin.
        if (options === undefined || typeof options === "object") {
            var deferreds = [];
            this.each(function() {
                if (!$.data(this, "plugin_" + pluginName)) {
                    var instance = new Plugin(this, options);
                    var instanceDeferreds = instance._init();
                    // we now have 2 deffereds: 1 for auto country, 1 for utils script
                    deferreds.push(instanceDeferreds[0]);
                    deferreds.push(instanceDeferreds[1]);
                    $.data(this, "plugin_" + pluginName, instance);
                }
            });
            // return the promise from the "master" deferred object that tracks all the others
            return $.when.apply(null, deferreds);
        } else if (typeof options === "string" && options[0] !== "_") {
            // If the first parameter is a string and it doesn't start
            // with an underscore or "contains" the `init`-function,
            // treat this as a call to a public method.
            // Cache the method call to make it possible to return a value
            var returns;
            this.each(function() {
                var instance = $.data(this, "plugin_" + pluginName);
                // Tests that there's already a plugin-instance
                // and checks that the requested public method exists
                if (instance instanceof Plugin && typeof instance[options] === "function") {
                    // Call the method of our plugin instance,
                    // and pass it the supplied arguments.
                    returns = instance[options].apply(instance, Array.prototype.slice.call(args, 1));
                }
                // Allow instances to be destroyed via the 'destroy' method
                if (options === "destroy") {
                    $.data(this, "plugin_" + pluginName, null);
                }
            });
            // If the earlier cached method gives a value back return the value,
            // otherwise return this to preserve chainability.
            return returns !== undefined ? returns : this;
        }
    };
    /********************
 *  STATIC METHODS
 ********************/
    // get the country data object
    $.fn[pluginName].getCountryData = function() {
        return allCountries;
    };
    // Tell JSHint to ignore this warning: "character may get silently deleted by one or more browsers"
    // jshint -W100
    // Array of country objects for the flag dropdown.
    // Each contains a name, country code (ISO 3166-1 alpha-2) and dial code.
    // Originally from https://github.com/mledoze/countries
    // then modified using the following JavaScript (NOW OUT OF DATE):
    /*
var result = [];
_.each(countries, function(c) {
  // ignore countries without a dial code
  if (c.callingCode[0].length) {
    result.push({
      // var locals contains country names with localised versions in brackets
      n: _.findWhere(locals, {
        countryCode: c.cca2
      }).name,
      i: c.cca2.toLowerCase(),
      d: c.callingCode[0]
    });
  }
});
JSON.stringify(result);
*/
    // then with a couple of manual re-arrangements to be alphabetical
    // then changed Kazakhstan from +76 to +7
    // and Vatican City from +379 to +39 (see issue 50)
    // and Caribean Netherlands from +5997 to +599
    // and Curacao from +5999 to +599
    // Removed: Åland Islands, Christmas Island, Cocos Islands, Guernsey, Isle of Man, Jersey, Kosovo, Mayotte, Pitcairn Islands, South Georgia, Svalbard, Western Sahara
    // Update: converted objects to arrays to save bytes!
    // Update: added "priority" for countries with the same dialCode as others
    // Update: added array of area codes for countries with the same dialCode as others
    // So each country array has the following information:
    // [
    //    Country name,
    //    iso2 code,
    //    International dial code,
    //    Order (if >1 country with same dial code),
    //    Area codes (if >1 country with same dial code)
    // ]
    var allCountries = [ [ "Afghanistan (‫افغانستان‬‎)", "af", "93" ], [ "Albania (Shqipëri)", "al", "355" ], [ "Algeria (‫الجزائر‬‎)", "dz", "213" ], [ "American Samoa", "as", "1684" ], [ "Andorra", "ad", "376" ], [ "Angola", "ao", "244" ], [ "Anguilla", "ai", "1264" ], [ "Antigua and Barbuda", "ag", "1268" ], [ "Argentina", "ar", "54" ], [ "Armenia (Հայաստան)", "am", "374" ], [ "Aruba", "aw", "297" ], [ "Australia", "au", "61" ], [ "Austria (Österreich)", "at", "43" ], [ "Azerbaijan (Azərbaycan)", "az", "994" ], [ "Bahamas", "bs", "1242" ], [ "Bahrain (‫البحرين‬‎)", "bh", "973" ], [ "Bangladesh (বাংলাদেশ)", "bd", "880" ], [ "Barbados", "bb", "1246" ], [ "Belarus (Беларусь)", "by", "375" ], [ "Belgium (België)", "be", "32" ], [ "Belize", "bz", "501" ], [ "Benin (Bénin)", "bj", "229" ], [ "Bermuda", "bm", "1441" ], [ "Bhutan (འབྲུག)", "bt", "975" ], [ "Bolivia", "bo", "591" ], [ "Bosnia and Herzegovina (Босна и Херцеговина)", "ba", "387" ], [ "Botswana", "bw", "267" ], [ "Brazil (Brasil)", "br", "55" ], [ "British Indian Ocean Territory", "io", "246" ], [ "British Virgin Islands", "vg", "1284" ], [ "Brunei", "bn", "673" ], [ "Bulgaria (България)", "bg", "359" ], [ "Burkina Faso", "bf", "226" ], [ "Burundi (Uburundi)", "bi", "257" ], [ "Cambodia (កម្ពុជា)", "kh", "855" ], [ "Cameroon (Cameroun)", "cm", "237" ], [ "Canada", "ca", "1", 1, [ "204", "226", "236", "249", "250", "289", "306", "343", "365", "387", "403", "416", "418", "431", "437", "438", "450", "506", "514", "519", "548", "579", "581", "587", "604", "613", "639", "647", "672", "705", "709", "742", "778", "780", "782", "807", "819", "825", "867", "873", "902", "905" ] ], [ "Cape Verde (Kabu Verdi)", "cv", "238" ], [ "Caribbean Netherlands", "bq", "599", 1 ], [ "Cayman Islands", "ky", "1345" ], [ "Central African Republic (République centrafricaine)", "cf", "236" ], [ "Chad (Tchad)", "td", "235" ], [ "Chile", "cl", "56" ], [ "China (中国)", "cn", "86" ], [ "Colombia", "co", "57" ], [ "Comoros (‫جزر القمر‬‎)", "km", "269" ], [ "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)", "cd", "243" ], [ "Congo (Republic) (Congo-Brazzaville)", "cg", "242" ], [ "Cook Islands", "ck", "682" ], [ "Costa Rica", "cr", "506" ], [ "Côte d’Ivoire", "ci", "225" ], [ "Croatia (Hrvatska)", "hr", "385" ], [ "Cuba", "cu", "53" ], [ "Curaçao", "cw", "599", 0 ], [ "Cyprus (Κύπρος)", "cy", "357" ], [ "Czech Republic (Česká republika)", "cz", "420" ], [ "Denmark (Danmark)", "dk", "45" ], [ "Djibouti", "dj", "253" ], [ "Dominica", "dm", "1767" ], [ "Dominican Republic (República Dominicana)", "do", "1", 2, [ "809", "829", "849" ] ], [ "Ecuador", "ec", "593" ], [ "Egypt (‫مصر‬‎)", "eg", "20" ], [ "El Salvador", "sv", "503" ], [ "Equatorial Guinea (Guinea Ecuatorial)", "gq", "240" ], [ "Eritrea", "er", "291" ], [ "Estonia (Eesti)", "ee", "372" ], [ "Ethiopia", "et", "251" ], [ "Falkland Islands (Islas Malvinas)", "fk", "500" ], [ "Faroe Islands (Føroyar)", "fo", "298" ], [ "Fiji", "fj", "679" ], [ "Finland (Suomi)", "fi", "358" ], [ "France", "fr", "33" ], [ "French Guiana (Guyane française)", "gf", "594" ], [ "French Polynesia (Polynésie française)", "pf", "689" ], [ "Gabon", "ga", "241" ], [ "Gambia", "gm", "220" ], [ "Georgia (საქართველო)", "ge", "995" ], [ "Germany (Deutschland)", "de", "49" ], [ "Ghana (Gaana)", "gh", "233" ], [ "Gibraltar", "gi", "350" ], [ "Greece (Ελλάδα)", "gr", "30" ], [ "Greenland (Kalaallit Nunaat)", "gl", "299" ], [ "Grenada", "gd", "1473" ], [ "Guadeloupe", "gp", "590", 0 ], [ "Guam", "gu", "1671" ], [ "Guatemala", "gt", "502" ], [ "Guinea (Guinée)", "gn", "224" ], [ "Guinea-Bissau (Guiné Bissau)", "gw", "245" ], [ "Guyana", "gy", "592" ], [ "Haiti", "ht", "509" ], [ "Honduras", "hn", "504" ], [ "Hong Kong (香港)", "hk", "852" ], [ "Hungary (Magyarország)", "hu", "36" ], [ "Iceland (Ísland)", "is", "354" ], [ "India (भारत)", "in", "91" ], [ "Indonesia", "id", "62" ], [ "Iran (‫ایران‬‎)", "ir", "98" ], [ "Iraq (‫العراق‬‎)", "iq", "964" ], [ "Ireland", "ie", "353" ], [ "Israel (‫ישראל‬‎)", "il", "972" ], [ "Italy (Italia)", "it", "39", 0 ], [ "Jamaica", "jm", "1876" ], [ "Japan (日本)", "jp", "81" ], [ "Jordan (‫الأردن‬‎)", "jo", "962" ], [ "Kazakhstan (Казахстан)", "kz", "7", 1 ], [ "Kenya", "ke", "254" ], [ "Kiribati", "ki", "686" ], [ "Kuwait (‫الكويت‬‎)", "kw", "965" ], [ "Kyrgyzstan (Кыргызстан)", "kg", "996" ], [ "Laos (ລາວ)", "la", "856" ], [ "Latvia (Latvija)", "lv", "371" ], [ "Lebanon (‫لبنان‬‎)", "lb", "961" ], [ "Lesotho", "ls", "266" ], [ "Liberia", "lr", "231" ], [ "Libya (‫ليبيا‬‎)", "ly", "218" ], [ "Liechtenstein", "li", "423" ], [ "Lithuania (Lietuva)", "lt", "370" ], [ "Luxembourg", "lu", "352" ], [ "Macau (澳門)", "mo", "853" ], [ "Macedonia (FYROM) (Македонија)", "mk", "389" ], [ "Madagascar (Madagasikara)", "mg", "261" ], [ "Malawi", "mw", "265" ], [ "Malaysia", "my", "60" ], [ "Maldives", "mv", "960" ], [ "Mali", "ml", "223" ], [ "Malta", "mt", "356" ], [ "Marshall Islands", "mh", "692" ], [ "Martinique", "mq", "596" ], [ "Mauritania (‫موريتانيا‬‎)", "mr", "222" ], [ "Mauritius (Moris)", "mu", "230" ], [ "Mexico (México)", "mx", "52" ], [ "Micronesia", "fm", "691" ], [ "Moldova (Republica Moldova)", "md", "373" ], [ "Monaco", "mc", "377" ], [ "Mongolia (Монгол)", "mn", "976" ], [ "Montenegro (Crna Gora)", "me", "382" ], [ "Montserrat", "ms", "1664" ], [ "Morocco (‫المغرب‬‎)", "ma", "212" ], [ "Mozambique (Moçambique)", "mz", "258" ], [ "Myanmar (Burma) (မြန်မာ)", "mm", "95" ], [ "Namibia (Namibië)", "na", "264" ], [ "Nauru", "nr", "674" ], [ "Nepal (नेपाल)", "np", "977" ], [ "Netherlands (Nederland)", "nl", "31" ], [ "New Caledonia (Nouvelle-Calédonie)", "nc", "687" ], [ "New Zealand", "nz", "64" ], [ "Nicaragua", "ni", "505" ], [ "Niger (Nijar)", "ne", "227" ], [ "Nigeria", "ng", "234" ], [ "Niue", "nu", "683" ], [ "Norfolk Island", "nf", "672" ], [ "North Korea (조선 민주주의 인민 공화국)", "kp", "850" ], [ "Northern Mariana Islands", "mp", "1670" ], [ "Norway (Norge)", "no", "47" ], [ "Oman (‫عُمان‬‎)", "om", "968" ], [ "Pakistan (‫پاکستان‬‎)", "pk", "92" ], [ "Palau", "pw", "680" ], [ "Palestine (‫فلسطين‬‎)", "ps", "970" ], [ "Panama (Panamá)", "pa", "507" ], [ "Papua New Guinea", "pg", "675" ], [ "Paraguay", "py", "595" ], [ "Peru (Perú)", "pe", "51" ], [ "Philippines", "ph", "63" ], [ "Poland (Polska)", "pl", "48" ], [ "Portugal", "pt", "351" ], [ "Puerto Rico", "pr", "1", 3, [ "787", "939" ] ], [ "Qatar (‫قطر‬‎)", "qa", "974" ], [ "Réunion (La Réunion)", "re", "262" ], [ "Romania (România)", "ro", "40" ], [ "Russia (Россия)", "ru", "7", 0 ], [ "Rwanda", "rw", "250" ], [ "Saint Barthélemy (Saint-Barthélemy)", "bl", "590", 1 ], [ "Saint Helena", "sh", "290" ], [ "Saint Kitts and Nevis", "kn", "1869" ], [ "Saint Lucia", "lc", "1758" ], [ "Saint Martin (Saint-Martin (partie française))", "mf", "590", 2 ], [ "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)", "pm", "508" ], [ "Saint Vincent and the Grenadines", "vc", "1784" ], [ "Samoa", "ws", "685" ], [ "San Marino", "sm", "378" ], [ "São Tomé and Príncipe (São Tomé e Príncipe)", "st", "239" ], [ "Saudi Arabia (‫المملكة العربية السعودية‬‎)", "sa", "966" ], [ "Senegal (Sénégal)", "sn", "221" ], [ "Serbia (Србија)", "rs", "381" ], [ "Seychelles", "sc", "248" ], [ "Sierra Leone", "sl", "232" ], [ "Singapore", "sg", "65" ], [ "Sint Maarten", "sx", "1721" ], [ "Slovakia (Slovensko)", "sk", "421" ], [ "Slovenia (Slovenija)", "si", "386" ], [ "Solomon Islands", "sb", "677" ], [ "Somalia (Soomaaliya)", "so", "252" ], [ "South Africa", "za", "27" ], [ "South Korea (대한민국)", "kr", "82" ], [ "South Sudan (‫جنوب السودان‬‎)", "ss", "211" ], [ "Spain (España)", "es", "34" ], [ "Sri Lanka (ශ්‍රී ලංකාව)", "lk", "94" ], [ "Sudan (‫السودان‬‎)", "sd", "249" ], [ "Suriname", "sr", "597" ], [ "Swaziland", "sz", "268" ], [ "Sweden (Sverige)", "se", "46" ], [ "Switzerland (Schweiz)", "ch", "41" ], [ "Syria (‫سوريا‬‎)", "sy", "963" ], [ "Taiwan (台灣)", "tw", "886" ], [ "Tajikistan", "tj", "992" ], [ "Tanzania", "tz", "255" ], [ "Thailand (ไทย)", "th", "66" ], [ "Timor-Leste", "tl", "670" ], [ "Togo", "tg", "228" ], [ "Tokelau", "tk", "690" ], [ "Tonga", "to", "676" ], [ "Trinidad and Tobago", "tt", "1868" ], [ "Tunisia (‫تونس‬‎)", "tn", "216" ], [ "Turkey (Türkiye)", "tr", "90" ], [ "Turkmenistan", "tm", "993" ], [ "Turks and Caicos Islands", "tc", "1649" ], [ "Tuvalu", "tv", "688" ], [ "U.S. Virgin Islands", "vi", "1340" ], [ "Uganda", "ug", "256" ], [ "Ukraine (Україна)", "ua", "380" ], [ "United Arab Emirates (‫الإمارات العربية المتحدة‬‎)", "ae", "971" ], [ "United Kingdom", "gb", "44" ], [ "United States", "us", "1", 0 ], [ "Uruguay", "uy", "598" ], [ "Uzbekistan (Oʻzbekiston)", "uz", "998" ], [ "Vanuatu", "vu", "678" ], [ "Vatican City (Città del Vaticano)", "va", "39", 1 ], [ "Venezuela", "ve", "58" ], [ "Vietnam (Việt Nam)", "vn", "84" ], [ "Wallis and Futuna", "wf", "681" ], [ "Yemen (‫اليمن‬‎)", "ye", "967" ], [ "Zambia", "zm", "260" ], [ "Zimbabwe", "zw", "263" ] ];
    // loop over all of the countries above
    for (var i = 0; i < allCountries.length; i++) {
        var c = allCountries[i];
        allCountries[i] = {
            name: c[0],
            iso2: c[1],
            dialCode: c[2],
            priority: c[3] || 0,
            areaCodes: c[4] || null
        };
    }
});
.intl-tel-input {
    position: relative;
    display: inline-block
}
.intl-tel-input * {
    box-sizing: border-box;
    -moz-box-sizing: border-box
}
.intl-tel-input .hide {
    display: none
}
.intl-tel-input .v-hide {
    visibility: hidden
}
.intl-tel-input input,
.intl-tel-input input[type=text],
.intl-tel-input input[type=tel] {
    position: relative;
    z-index: 0;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-left: 48px;
    margin-left: 0;
    transition: background-color 100ms ease-out
}
.intl-tel-input input.iti-invalid-key {
    transition: background-color 0;
    background-color: #FFC7C7
}
.intl-tel-input .flag-dropdown {
    position: absolute;
    top: 0;
    bottom: 0;
    padding: 1px
}
.intl-tel-input.iti-container {
    z-index: 1060;
}
.intl-tel-input .flag-dropdown:hover {
    cursor: pointer
}
.intl-tel-input .flag-dropdown:hover .selected-flag {
    background-color: rgba(0, 0, 0, 0.05)
}
.intl-tel-input input[disabled]+.flag-dropdown:hover,
.intl-tel-input input[readonly]+.flag-dropdown:hover {
    cursor: default
}
.intl-tel-input input[disabled]+.flag-dropdown:hover .selected-flag,
.intl-tel-input input[readonly]+.flag-dropdown:hover .selected-flag {
    background-color: transparent
}
.intl-tel-input .selected-flag {
    z-index: 1;
    position: relative;
    width: 42px;
    height: 100%;
    padding: 0 0 0 8px
}
.intl-tel-input .selected-flag .iti-flag {
    position: absolute;
    top: 0;
    bottom: 0;
    margin: auto
}
.intl-tel-input .selected-flag .arrow {
    position: absolute;
    top: 50%;
    margin-top: -2px;
    right: 4px;
    width: 0;
    height: 0;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-top: 4px solid #555
}
.intl-tel-input .selected-flag .arrow.up {
    border-top: none;
    border-bottom: 4px solid #555
}
.intl-tel-input .country-list {
    list-style: none;
    position: absolute;
    z-index: 2;
    padding: 0;
    margin: 0 0 0 -1px;
    box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2);
    background-color: white;
    border: 1px solid #CCC;
    white-space: nowrap;
    max-height: 200px;
    overflow-y: scroll
}
.intl-tel-input .country-list .flag {
    display: inline-block;
    width: 20px
}
@media (max-width: 500px) {
    .intl-tel-input .country-list {
        white-space: normal
    }
}
.intl-tel-input .country-list .divider {
    padding-bottom: 5px;
    margin-bottom: 5px;
    border-bottom: 1px solid #CCC
}
.intl-tel-input .country-list .country {
    padding: 5px 10px
}
.intl-tel-input .country-list .country .dial-code {
    color: #999
}
.intl-tel-input .country-list .country.highlight {
    background-color: rgba(0, 0, 0, 0.05)
}
.intl-tel-input .country-list .flag,
.intl-tel-input .country-list .country-name,
.intl-tel-input .country-list .dial-code {
    vertical-align: middle
}
.intl-tel-input .country-list .flag,
.intl-tel-input .country-list .country-name {
    margin-right: 6px
}
.intl-tel-input select {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    width: 42px;
    height: 100%;
    opacity: 0
}
.iti-flag {
    width: 20px
}
.iti-flag.be {
    width: 18px
}
.iti-flag.ch {
    width: 15px
}
.iti-flag.mc {
    width: 19px
}
.iti-flag.ne {
    width: 18px
}
.iti-flag.np {
    width: 13px
}
.iti-flag.va {
    width: 15px
}
@media only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (min--moz-device-pixel-ratio: 2),
only screen and (-o-min-device-pixel-ratio: 2 / 1),
only screen and (min-device-pixel-ratio: 2),
only screen and (min-resolution: 192dpi),
only screen and (min-resolution: 2dppx) {
    .iti-flag {
        background-size: 5630px 15px
    }
}
.iti-flag.ac {
    height: 10px;
    background-position: 0px 0px
}
.iti-flag.ad {
    height: 14px;
    background-position: -22px 0px
}
.iti-flag.ae {
    height: 10px;
    background-position: -44px 0px
}
.iti-flag.af {
    height: 14px;
    background-position: -66px 0px
}
.iti-flag.ag {
    height: 14px;
    background-position: -88px 0px
}
.iti-flag.ai {
    height: 10px;
    background-position: -110px 0px
}
.iti-flag.al {
    height: 15px;
    background-position: -132px 0px
}
.iti-flag.am {
    height: 10px;
    background-position: -154px 0px
}
.iti-flag.ao {
    height: 14px;
    background-position: -176px 0px
}
.iti-flag.aq {
    height: 14px;
    background-position: -198px 0px
}
.iti-flag.ar {
    height: 13px;
    background-position: -220px 0px
}
.iti-flag.as {
    height: 10px;
    background-position: -242px 0px
}
.iti-flag.at {
    height: 14px;
    background-position: -264px 0px
}
.iti-flag.au {
    height: 10px;
    background-position: -286px 0px
}
.iti-flag.aw {
    height: 14px;
    background-position: -308px 0px
}
.iti-flag.ax {
    height: 13px;
    background-position: -330px 0px
}
.iti-flag.az {
    height: 10px;
    background-position: -352px 0px
}
.iti-flag.ba {
    height: 10px;
    background-position: -374px 0px
}
.iti-flag.bb {
    height: 14px;
    background-position: -396px 0px
}
.iti-flag.bd {
    height: 12px;
    background-position: -418px 0px
}
.iti-flag.be {
    height: 15px;
    background-position: -440px 0px
}
.iti-flag.bf {
    height: 14px;
    background-position: -460px 0px
}
.iti-flag.bg {
    height: 12px;
    background-position: -482px 0px
}
.iti-flag.bh {
    height: 12px;
    background-position: -504px 0px
}
.iti-flag.bi {
    height: 12px;
    background-position: -526px 0px
}
.iti-flag.bj {
    height: 14px;
    background-position: -548px 0px
}
.iti-flag.bl {
    height: 14px;
    background-position: -570px 0px
}
.iti-flag.bm {
    height: 10px;
    background-position: -592px 0px
}
.iti-flag.bn {
    height: 10px;
    background-position: -614px 0px
}
.iti-flag.bo {
    height: 14px;
    background-position: -636px 0px
}
.iti-flag.bq {
    height: 14px;
    background-position: -658px 0px
}
.iti-flag.br {
    height: 14px;
    background-position: -680px 0px
}
.iti-flag.bs {
    height: 10px;
    background-position: -702px 0px
}
.iti-flag.bt {
    height: 14px;
    background-position: -724px 0px
}
.iti-flag.bv {
    height: 15px;
    background-position: -746px 0px
}
.iti-flag.bw {
    height: 14px;
    background-position: -768px 0px
}
.iti-flag.by {
    height: 10px;
    background-position: -790px 0px
}
.iti-flag.bz {
    height: 14px;
    background-position: -812px 0px
}
.iti-flag.ca {
    height: 10px;
    background-position: -834px 0px
}
.iti-flag.cc {
    height: 10px;
    background-position: -856px 0px
}
.iti-flag.cd {
    height: 15px;
    background-position: -878px 0px
}
.iti-flag.cf {
    height: 14px;
    background-position: -900px 0px
}
.iti-flag.cg {
    height: 14px;
    background-position: -922px 0px
}
.iti-flag.ch {
    height: 15px;
    background-position: -944px 0px
}
.iti-flag.ci {
    height: 14px;
    background-position: -961px 0px
}
.iti-flag.ck {
    height: 10px;
    background-position: -983px 0px
}
.iti-flag.cl {
    height: 14px;
    background-position: -1005px 0px
}
.iti-flag.cm {
    height: 14px;
    background-position: -1027px 0px
}
.iti-flag.cn {
    height: 14px;
    background-position: -1049px 0px
}
.iti-flag.co {
    height: 14px;
    background-position: -1071px 0px
}
.iti-flag.cp {
    height: 14px;
    background-position: -1093px 0px
}
.iti-flag.cr {
    height: 12px;
    background-position: -1115px 0px
}
.iti-flag.cu {
    height: 10px;
    background-position: -1137px 0px
}
.iti-flag.cv {
    height: 12px;
    background-position: -1159px 0px
}
.iti-flag.cw {
    height: 14px;
    background-position: -1181px 0px
}
.iti-flag.cx {
    height: 10px;
    background-position: -1203px 0px
}
.iti-flag.cy {
    height: 14px;
    background-position: -1225px 0px
}
.iti-flag.cz {
    height: 14px;
    background-position: -1247px 0px
}
.iti-flag.de {
    height: 12px;
    background-position: -1269px 0px
}
.iti-flag.dg {
    height: 10px;
    background-position: -1291px 0px
}
.iti-flag.dj {
    height: 14px;
    background-position: -1313px 0px
}
.iti-flag.dk {
    height: 15px;
    background-position: -1335px 0px
}
.iti-flag.dm {
    height: 10px;
    background-position: -1357px 0px
}
.iti-flag.do {
    height: 13px;
    background-position: -1379px 0px
}
.iti-flag.dz {
    height: 14px;
    background-position: -1401px 0px
}
.iti-flag.ea {
    height: 14px;
    background-position: -1423px 0px
}
.iti-flag.ec {
    height: 14px;
    background-position: -1445px 0px
}
.iti-flag.ee {
    height: 13px;
    background-position: -1467px 0px
}
.iti-flag.eg {
    height: 14px;
    background-position: -1489px 0px
}
.iti-flag.eh {
    height: 10px;
    background-position: -1511px 0px
}
.iti-flag.er {
    height: 10px;
    background-position: -1533px 0px
}
.iti-flag.es {
    height: 14px;
    background-position: -1555px 0px
}
.iti-flag.et {
    height: 10px;
    background-position: -1577px 0px
}
.iti-flag.eu {
    height: 14px;
    background-position: -1599px 0px
}
.iti-flag.fi {
    height: 12px;
    background-position: -1621px 0px
}
.iti-flag.fj {
    height: 10px;
    background-position: -1643px 0px
}
.iti-flag.fk {
    height: 10px;
    background-position: -1665px 0px
}
.iti-flag.fm {
    height: 11px;
    background-position: -1687px 0px
}
.iti-flag.fo {
    height: 15px;
    background-position: -1709px 0px
}
.iti-flag.fr {
    height: 14px;
    background-position: -1731px 0px
}
.iti-flag.ga {
    height: 15px;
    background-position: -1753px 0px
}
.iti-flag.gb {
    height: 10px;
    background-position: -1775px 0px
}
.iti-flag.gd {
    height: 12px;
    background-position: -1797px 0px
}
.iti-flag.ge {
    height: 14px;
    background-position: -1819px 0px
}
.iti-flag.gf {
    height: 14px;
    background-position: -1841px 0px
}
.iti-flag.gg {
    height: 14px;
    background-position: -1863px 0px
}
.iti-flag.gh {
    height: 14px;
    background-position: -1885px 0px
}
.iti-flag.gi {
    height: 10px;
    background-position: -1907px 0px
}
.iti-flag.gl {
    height: 14px;
    background-position: -1929px 0px
}
.iti-flag.gm {
    height: 14px;
    background-position: -1951px 0px
}
.iti-flag.gn {
    height: 14px;
    background-position: -1973px 0px
}
.iti-flag.gp {
    height: 14px;
    background-position: -1995px 0px
}
.iti-flag.gq {
    height: 14px;
    background-position: -2017px 0px
}
.iti-flag.gr {
    height: 14px;
    background-position: -2039px 0px
}
.iti-flag.gs {
    height: 10px;
    background-position: -2061px 0px
}
.iti-flag.gt {
    height: 13px;
    background-position: -2083px 0px
}
.iti-flag.gu {
    height: 11px;
    background-position: -2105px 0px
}
.iti-flag.gw {
    height: 10px;
    background-position: -2127px 0px
}
.iti-flag.gy {
    height: 12px;
    background-position: -2149px 0px
}
.iti-flag.hk {
    height: 14px;
    background-position: -2171px 0px
}
.iti-flag.hm {
    height: 10px;
    background-position: -2193px 0px
}
.iti-flag.hn {
    height: 10px;
    background-position: -2215px 0px
}
.iti-flag.hr {
    height: 10px;
    background-position: -2237px 0px
}
.iti-flag.ht {
    height: 12px;
    background-position: -2259px 0px
}
.iti-flag.hu {
    height: 10px;
    background-position: -2281px 0px
}
.iti-flag.ic {
    height: 14px;
    background-position: -2303px 0px
}
.iti-flag.id {
    height: 14px;
    background-position: -2325px 0px
}
.iti-flag.ie {
    height: 10px;
    background-position: -2347px 0px
}
.iti-flag.il {
    height: 15px;
    background-position: -2369px 0px
}
.iti-flag.im {
    height: 10px;
    background-position: -2391px 0px
}
.iti-flag.in {
    height: 14px;
    background-position: -2413px 0px
}
.iti-flag.io {
    height: 10px;
    background-position: -2435px 0px
}
.iti-flag.iq {
    height: 14px;
    background-position: -2457px 0px
}
.iti-flag.ir {
    height: 12px;
    background-position: -2479px 0px
}
.iti-flag.is {
    height: 15px;
    background-position: -2501px 0px
}
.iti-flag.it {
    height: 14px;
    background-position: -2523px 0px
}
.iti-flag.je {
    height: 12px;
    background-position: -2545px 0px
}
.iti-flag.jm {
    height: 10px;
    background-position: -2567px 0px
}
.iti-flag.jo {
    height: 10px;
    background-position: -2589px 0px
}
.iti-flag.jp {
    height: 14px;
    background-position: -2611px 0px
}
.iti-flag.ke {
    height: 14px;
    background-position: -2633px 0px
}
.iti-flag.kg {
    height: 12px;
    background-position: -2655px 0px
}
.iti-flag.kh {
    height: 13px;
    background-position: -2677px 0px
}
.iti-flag.ki {
    height: 10px;
    background-position: -2699px 0px
}
.iti-flag.km {
    height: 12px;
    background-position: -2721px 0px
}
.iti-flag.kn {
    height: 14px;
    background-position: -2743px 0px
}
.iti-flag.kp {
    height: 10px;
    background-position: -2765px 0px
}
.iti-flag.kr {
    height: 14px;
    background-position: -2787px 0px
}
.iti-flag.kw {
    height: 10px;
    background-position: -2809px 0px
}
.iti-flag.ky {
    height: 10px;
    background-position: -2831px 0px
}
.iti-flag.kz {
    height: 10px;
    background-position: -2853px 0px
}
.iti-flag.la {
    height: 14px;
    background-position: -2875px 0px
}
.iti-flag.lb {
    height: 14px;
    background-position: -2897px 0px
}
.iti-flag.lc {
    height: 10px;
    background-position: -2919px 0px
}
.iti-flag.li {
    height: 12px;
    background-position: -2941px 0px
}
.iti-flag.lk {
    height: 10px;
    background-position: -2963px 0px
}
.iti-flag.lr {
    height: 11px;
    background-position: -2985px 0px
}
.iti-flag.ls {
    height: 14px;
    background-position: -3007px 0px
}
.iti-flag.lt {
    height: 12px;
    background-position: -3029px 0px
}
.iti-flag.lu {
    height: 12px;
    background-position: -3051px 0px
}
.iti-flag.lv {
    height: 10px;
    background-position: -3073px 0px
}
.iti-flag.ly {
    height: 10px;
    background-position: -3095px 0px
}
.iti-flag.ma {
    height: 14px;
    background-position: -3117px 0px
}
.iti-flag.mc {
    height: 15px;
    background-position: -3139px 0px
}
.iti-flag.md {
    height: 10px;
    background-position: -3160px 0px
}
.iti-flag.me {
    height: 10px;
    background-position: -3182px 0px
}
.iti-flag.mf {
    height: 14px;
    background-position: -3204px 0px
}
.iti-flag.mg {
    height: 14px;
    background-position: -3226px 0px
}
.iti-flag.mh {
    height: 11px;
    background-position: -3248px 0px
}
.iti-flag.mk {
    height: 10px;
    background-position: -3270px 0px
}
.iti-flag.ml {
    height: 14px;
    background-position: -3292px 0px
}
.iti-flag.mm {
    height: 14px;
    background-position: -3314px 0px
}
.iti-flag.mn {
    height: 10px;
    background-position: -3336px 0px
}
.iti-flag.mo {
    height: 14px;
    background-position: -3358px 0px
}
.iti-flag.mp {
    height: 10px;
    background-position: -3380px 0px
}
.iti-flag.mq {
    height: 14px;
    background-position: -3402px 0px
}
.iti-flag.mr {
    height: 14px;
    background-position: -3424px 0px
}
.iti-flag.ms {
    height: 10px;
    background-position: -3446px 0px
}
.iti-flag.mt {
    height: 14px;
    background-position: -3468px 0px
}
.iti-flag.mu {
    height: 14px;
    background-position: -3490px 0px
}
.iti-flag.mv {
    height: 14px;
    background-position: -3512px 0px
}
.iti-flag.mw {
    height: 14px;
    background-position: -3534px 0px
}
.iti-flag.mx {
    height: 12px;
    background-position: -3556px 0px
}
.iti-flag.my {
    height: 10px;
    background-position: -3578px 0px
}
.iti-flag.mz {
    height: 14px;
    background-position: -3600px 0px
}
.iti-flag.na {
    height: 14px;
    background-position: -3622px 0px
}
.iti-flag.nc {
    height: 10px;
    background-position: -3644px 0px
}
.iti-flag.ne {
    height: 15px;
    background-position: -3666px 0px
}
.iti-flag.nf {
    height: 10px;
    background-position: -3686px 0px
}
.iti-flag.ng {
    height: 10px;
    background-position: -3708px 0px
}
.iti-flag.ni {
    height: 12px;
    background-position: -3730px 0px
}
.iti-flag.nl {
    height: 14px;
    background-position: -3752px 0px
}
.iti-flag.no {
    height: 15px;
    background-position: -3774px 0px
}
.iti-flag.np {
    height: 15px;
    background-position: -3796px 0px
}
.iti-flag.nr {
    height: 10px;
    background-position: -3811px 0px
}
.iti-flag.nu {
    height: 10px;
    background-position: -3833px 0px
}
.iti-flag.nz {
    height: 10px;
    background-position: -3855px 0px
}
.iti-flag.om {
    height: 10px;
    background-position: -3877px 0px
}
.iti-flag.pa {
    height: 14px;
    background-position: -3899px 0px
}
.iti-flag.pe {
    height: 14px;
    background-position: -3921px 0px
}
.iti-flag.pf {
    height: 14px;
    background-position: -3943px 0px
}
.iti-flag.pg {
    height: 15px;
    background-position: -3965px 0px
}
.iti-flag.ph {
    height: 10px;
    background-position: -3987px 0px
}
.iti-flag.pk {
    height: 14px;
    background-position: -4009px 0px
}
.iti-flag.pl {
    height: 13px;
    background-position: -4031px 0px
}
.iti-flag.pm {
    height: 14px;
    background-position: -4053px 0px
}
.iti-flag.pn {
    height: 10px;
    background-position: -4075px 0px
}
.iti-flag.pr {
    height: 14px;
    background-position: -4097px 0px
}
.iti-flag.ps {
    height: 10px;
    background-position: -4119px 0px
}
.iti-flag.pt {
    height: 14px;
    background-position: -4141px 0px
}
.iti-flag.pw {
    height: 13px;
    background-position: -4163px 0px
}
.iti-flag.py {
    height: 11px;
    background-position: -4185px 0px
}
.iti-flag.qa {
    height: 8px;
    background-position: -4207px 0px
}
.iti-flag.re {
    height: 14px;
    background-position: -4229px 0px
}
.iti-flag.ro {
    height: 14px;
    background-position: -4251px 0px
}
.iti-flag.rs {
    height: 14px;
    background-position: -4273px 0px
}
.iti-flag.ru {
    height: 14px;
    background-position: -4295px 0px
}
.iti-flag.rw {
    height: 14px;
    background-position: -4317px 0px
}
.iti-flag.sa {
    height: 14px;
    background-position: -4339px 0px
}
.iti-flag.sb {
    height: 10px;
    background-position: -4361px 0px
}
.iti-flag.sc {
    height: 10px;
    background-position: -4383px 0px
}
.iti-flag.sd {
    height: 10px;
    background-position: -4405px 0px
}
.iti-flag.se {
    height: 13px;
    background-position: -4427px 0px
}
.iti-flag.sg {
    height: 14px;
    background-position: -4449px 0px
}
.iti-flag.sh {
    height: 10px;
    background-position: -4471px 0px
}
.iti-flag.si {
    height: 10px;
    background-position: -4493px 0px
}
.iti-flag.sj {
    height: 15px;
    background-position: -4515px 0px
}
.iti-flag.sk {
    height: 14px;
    background-position: -4537px 0px
}
.iti-flag.sl {
    height: 14px;
    background-position: -4559px 0px
}
.iti-flag.sm {
    height: 15px;
    background-position: -4581px 0px
}
.iti-flag.sn {
    height: 14px;
    background-position: -4603px 0px
}
.iti-flag.so {
    height: 14px;
    background-position: -4625px 0px
}
.iti-flag.sr {
    height: 14px;
    background-position: -4647px 0px
}
.iti-flag.ss {
    height: 10px;
    background-position: -4669px 0px
}
.iti-flag.st {
    height: 10px;
    background-position: -4691px 0px
}
.iti-flag.sv {
    height: 12px;
    background-position: -4713px 0px
}
.iti-flag.sx {
    height: 14px;
    background-position: -4735px 0px
}
.iti-flag.sy {
    height: 14px;
    background-position: -4757px 0px
}
.iti-flag.sz {
    height: 14px;
    background-position: -4779px 0px
}
.iti-flag.ta {
    height: 10px;
    background-position: -4801px 0px
}
.iti-flag.tc {
    height: 10px;
    background-position: -4823px 0px
}
.iti-flag.td {
    height: 14px;
    background-position: -4845px 0px
}
.iti-flag.tf {
    height: 14px;
    background-position: -4867px 0px
}
.iti-flag.tg {
    height: 13px;
    background-position: -4889px 0px
}
.iti-flag.th {
    height: 14px;
    background-position: -4911px 0px
}
.iti-flag.tj {
    height: 10px;
    background-position: -4933px 0px
}
.iti-flag.tk {
    height: 10px;
    background-position: -4955px 0px
}
.iti-flag.tl {
    height: 10px;
    background-position: -4977px 0px
}
.iti-flag.tm {
    height: 14px;
    background-position: -4999px 0px
}
.iti-flag.tn {
    height: 14px;
    background-position: -5021px 0px
}
.iti-flag.to {
    height: 10px;
    background-position: -5043px 0px
}
.iti-flag.tr {
    height: 14px;
    background-position: -5065px 0px
}
.iti-flag.tt {
    height: 12px;
    background-position: -5087px 0px
}
.iti-flag.tv {
    height: 10px;
    background-position: -5109px 0px
}
.iti-flag.tw {
    height: 14px;
    background-position: -5131px 0px
}
.iti-flag.tz {
    height: 14px;
    background-position: -5153px 0px
}
.iti-flag.ua {
    height: 14px;
    background-position: -5175px 0px
}
.iti-flag.ug {
    height: 14px;
    background-position: -5197px 0px
}
.iti-flag.um {
    height: 11px;
    background-position: -5219px 0px
}
.iti-flag.us {
    height: 11px;
    background-position: -5241px 0px
}
.iti-flag.uy {
    height: 14px;
    background-position: -5263px 0px
}
.iti-flag.uz {
    height: 10px;
    background-position: -5285px 0px
}
.iti-flag.va {
    height: 15px;
    background-position: -5307px 0px
}
.iti-flag.vc {
    height: 14px;
    background-position: -5324px 0px
}
.iti-flag.ve {
    height: 14px;
    background-position: -5346px 0px
}
.iti-flag.vg {
    height: 10px;
    background-position: -5368px 0px
}
.iti-flag.vi {
    height: 14px;
    background-position: -5390px 0px
}
.iti-flag.vn {
    height: 14px;
    background-position: -5412px 0px
}
.iti-flag.vu {
    height: 12px;
    background-position: -5434px 0px
}
.iti-flag.wf {
    height: 14px;
    background-position: -5456px 0px
}
.iti-flag.ws {
    height: 10px;
    background-position: -5478px 0px
}
.iti-flag.xk {
    height: 15px;
    background-position: -5500px 0px
}
.iti-flag.ye {
    height: 14px;
    background-position: -5522px 0px
}
.iti-flag.yt {
    height: 14px;
    background-position: -5544px 0px
}
.iti-flag.za {
    height: 14px;
    background-position: -5566px 0px
}
.iti-flag.zm {
    height: 14px;
    background-position: -5588px 0px
}
.iti-flag.zw {
    height: 10px;
    background-position: -5610px 0px
}
.iti-flag {
    width: 20px;
    height: 15px;
    box-shadow: 0px 0px 1px 0px #888;
    background-image: url("https://rawgit.com/Bluefieldscom/intl-tel-input/master/build/img/flags.png");
    background-repeat: no-repeat;
    background-color: #DBDBDB;
    background-position: 20px 0
}
@media only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (min--moz-device-pixel-ratio: 2),
only screen and (-o-min-device-pixel-ratio: 2 / 1),
only screen and (min-device-pixel-ratio: 2),
only screen and (min-resolution: 192dpi),
only screen and (min-resolution: 2dppx) {
    .iti-flag {
        background-image: url("https://rawgit.com/Bluefieldscom/intl-tel-input/master/build/img/flags.png@2x.png")
    }
}
.iti-flag.np {
    background-color: transparent
}