/*
 * jQuery longUrl - v1.0 - 1/23/2010
 * http://benalman.com/projects/jquery-longurl-plugin/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function($,e){var a={},c,b,d={fetch:function(f,g){$.ajax({dataType:"jsonp",traditional:1,url:"http://www.longurlplease.com/api/v1.1",data:{q:f},success:g})},batch:10};$.longUrl=c=function(j,k){var f={},g=0;if(Object.prototype.toString.call(j)==="[object Object]"){b=$.extend({},d,j);return}j=typeof j==="string"?[j]:j;(function h(){var i=[],l;while(g<j.length&&i.length<b.batch){l=j[g++];if(!l||!/^https?:\/\//i.test(l)){continue}if(a[l]!==e){f[l]=a[l]}else{if($.inArray(l,i)===-1){i.push(l)}}}if(i.length){b.fetch(i,function(m){$.each(m,function(n,o){f[n]=a[n]=o});h()})}else{k(f)}})()};c({});$.fn.longUrl=function(g){var h=this,f={},j=[],i={callback:function(k,l){if(l){this.each(function(){var n=$(this),m=n.html();n.attr({title:l,href:l});if(n.html()!==m){n.html(m)}})}}};g=$.extend(i,g);this.each(function(){var l=$(this),k=l.attr("href");if(k){f[k]=f[k]?f[k].add(this):l;j.push(k)}});c(j,function(k){g.callback&&$.each(k,function(l,m){if(f[l]){g.callback.call(f[l],l,m);delete f[l]}});f=null;g.complete&&g.complete.call(h,k)});return this}})(jQuery);
