/*
 * longUrl - v0.2 - 7/8/2009
 * http://benalman.com/code/test/jquery-long-url/
 * 
 * Copyright (c) 2009 "Cowboy" Ben Alman
 * Licensed under the MIT license
 * http://benalman.com/about/license/
 */
(function($){var c={},b={},a=[],e,d={lengthen:function(f,g){f&&this.attr({title:f})},fetch:function(f,h){var i={q:f},g="http://www.longurlplease.com/api/v1.1?callback=?";$.getJSON(g,i,function(k){for(var j in k){h(k[j],j)}})},strip_www:true,max:10,delay:100};$.fn.longUrl=function(f){f=$.extend({},d,f);return this.each(function(){var i=$(this),g=i.attr("href");if(!g||!/^http:\/\//i.test(g)){return}if(f.strip_www){g=g.replace(/^http:\/\/www\./i,"http://")}if(b[g]){f.lengthen.call(i,b[g],g)}else{a.indexOf(g)===-1&&a.push(g);c[g]=c[g]?c[g].concat(this):[this]}function h(){f.fetch(a,function(j,k){b[k]=j;if(c[k]){f.lengthen.call($(c[k]),j,k);delete c[k]}});a=[]}if(a.length){e&&clearTimeout(e);if(a.length===f.max){h()}else{e=setTimeout(h,f.delay)}}})}})(jQuery);
