(function($){
  $.fn.extend({
    airportwriter:function(options) {
      var defaults = {
        speed:100, 
        complete: null,
        chars : 'QWERTZUIOPASDFGHJKLYXCVBNM0123456789',
        num : 0
      }
      var options =  $.extend(defaults, options);
      return this.each(function() {
        var item = $(this);
        var text = item.html().match(/(\<\/?[^>]*\>)|(&\w*;)|(.)/g).reverse();
        var characters = options.chars.split('');
        var c = 0, i = 0;
        var interval = parseInt(options.speed/jQuery.fx.interval);
        var steps = text.length;
        var e = new jQuery.fx(this, {});
        e.step = function(gotoEnd) {
          if(++c == interval || gotoEnd){
            this.update();
            c = 0;
            i= text.length;
            steps = (gotoEnd)? 0 : steps;
            var tmp = '';
            while(--i>=((options.num == 0)? 0 : ((steps-options.num >= 0)? steps-options.num : 0))){
              if(i>=steps){
                tmp += text[i];
              }else{
                if(text[i].match(/\W/g)){
                  tmp += text[i]
                }else{
                   tmp += characters[parseInt(Math.random()*characters.length)];
                }
              }
            }          
            item.html(tmp);
            if(--steps<0){
              if(options.complete){
                 options.complete.call(item);
              }
              return false;
            }
          }
          this.update();
          return true;
        }
        e.custom( steps, 0, '');
      });
    }
  });
})(jQuery);
