(function($){ 
     $.fn.extend({  
         airport: function(str, type) {
			
			var self = $(this);
			var chars = [];
	if(type == "str") {
		chars = [' ', 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
			'ą', 'ž', 'į', 'ų', 'ė', 'ū', 'č', 'š', 'ę',
			'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'Z', 
			'Q', 'W', 'Y', 'X', 'V', 'Ą', 'Ž', 'Į', 'Ė', 'Ū', 'Č', 'Š', 'Ę', '-'];
	}
	if(type == "flstr") {
		chars = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'Z', 
			'Q', 'W', 'Y', 'X', 'V', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', ' '];
	}
	if(type == "upchr") {
		chars = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'Z', 
			'Q', 'W', 'Y', 'X', 'V', 'Ą', 'Ž', 'Į', 'Ė', 'Ū', 'Č', 'Š', 'Ę'];
	}
	if(type == "time") {
		chars = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', ':'];
	}


function strlen (string) {
 
    var str = string+'';
    var i = 0, chr = '', lgth = 0;
 
    var getWholeChar = function (str, i) {
        var code = str.charCodeAt(i);
        var next = '', prev = '';
        if (0xD800 <= code && code <= 0xDBFF) { // High surrogate (could change last hex to 0xDB7F to treat high private surrogates as single characters)
            if (str.length <= (i+1))  {
                throw 'High surrogate without following low surrogate';
            }
            next = str.charCodeAt(i+1);
            if (0xDC00 > next || next > 0xDFFF) {
                throw 'High surrogate without following low surrogate';
            }
            return str.charAt(i)+str.charAt(i+1);
        } else if (0xDC00 <= code && code <= 0xDFFF) { // Low surrogate
            if (i === 0) {
                throw 'Low surrogate without preceding high surrogate';
            }
            prev = str.charCodeAt(i-1);
            if (0xD800 > prev || prev > 0xDBFF) { //(could change last hex to 0xDB7F to treat high private surrogates as single characters)
                throw 'Low surrogate without preceding high surrogate';
            }
            return false; // We can pass over low surrogates now as the second component in a pair which we have already processed
        }
        return str.charAt(i);
    };
 
    for (i=0, lgth=0; i < str.length; i++) {
        if ((chr = getWholeChar(str, i)) === false) {
            continue;
        } // Adapt this line at the top of any loop, passing in the whole string and the current iteration and returning a variable to represent the individual character; purpose is to treat the first part of a surrogate pair as the whole character and then ignore the second part
        lgth++;
    }
    return lgth;
}
				
			var longest = 0;

			function pad(a,b) { return a + new Array(b - strlen(a) + 1).join(' '); }
			
			$(this).empty();
			
			longest = strlen(str);

			str = pad(str,longest);
				
			spans = longest;
			while(spans--)
				$(this).prepend("<span class='c" + spans + "'></span>");
				
			
			function testChar(a,b,d){
					$(self).find('.c'+a).html((chars[b]==" ")?"&nbsp;":chars[b]);
					setTimeout(function() {
						if(b > strlen(chars)){
							$(self).html(str);
						}else if(chars[b] != str.substring(d,d+1))
							testChar(a,b+1,d);
						else
							testChar(a+1,0,d+1);
					}, 20);
			}
			
			testChar(0,0,0,0);
        } 
    }); 
})(jQuery);
