var _cv_phoneinput = true;

function initializePhoneInput() {
	jQuery(".phone-container").each(function() {
		var phoneInput=jQuery(this);
		var setup=phoneInput.data('specific');
		phoneInput.intlTelInput({ 
			initialCountry: "auto",
			dropdownContainer: 'body',
			autoPlaceholder: 'aggressive',
			preferredCountries: ['ro'],
			geoIpLookup: function(callback) {
				$.get('https://ipinfo.io', function() {}, "jsonp").always(function(resp) {
				  var countryCode = (resp && resp.country) ? resp.country : "";
				  callback(countryCode);
				});
			},
			utilsScript: siteUrl+"js/intlTelInput-utils/utils.js" // just for formatting/placeholders etc
		});

		phoneInput.on('change', function(event) {
			var internationalNumber = phoneInput.intlTelInput("getNumber");
			jQuery("#"+setup['linked-to']).val(internationalNumber);
		});
		
		if (jQuery(this).data('smooth'))
		{
			jQuery(this).parent().addClass('smooth-container smooth-elem');
			if (jQuery(this).data('smooth') !== true) jQuery(this).parent().addClass(jQuery(this).data('smooth'));
			var Placeholder=jQuery("<div></div>");
			Placeholder.addClass('placeholder');
			Placeholder.html(jQuery(this).attr('placeholder'));
			jQuery(this).attr('placeholder', '');
			jQuery(this).parent().append(Placeholder);
			initializeSmoothInputs();
		}
		
	});
}