function bitlyDataHandler(){}bitlyDataHandler.prototype.proccess=function(a){if(a.statusCode=="OK"){this.onSuccess(a.results)}else{this.onError(a.errorCode,a.errorMessage)}return true};bitlyDataHandler.prototype.onSuccess=function(a){try{console.info(a)}catch(b){}};bitlyDataHandler.prototype.onError=function(b,a){try{console.error("Bitly error: "+b+"\n"+a)}catch(c){}};jQuery.fn.bitly=function(e,c,a){var b=jQuery.extend({},jQuery.fn.bitly.defaults,a);var d=new bitlyDataHandler();if(typeof(c)=="function"){d.onSuccess=c}var f=new Array();this.each(function(){var i=jQuery(this);var h=i.val();if(!h){h=i.attr("href")}f.push(h)});var g=jQuery.post(b.url,{action:e,url:f.join(",")},function(h){return d.proccess(h)},"json");return g};jQuery.fn.bitly.defaults={url:"/bitly/bitly.php"};jQuery.fn.shortenUrl=function(a){return this.each(function(){var b=jQuery(this);b.bitly("shorten",function(g){var f=new RegExp('http://[^( |$|\\]|")]+',"g");var h=b.val().match(f);if(h){for(var e=0;e<h.length;e++){var d=h[e];if(typeof(g[d])!="undefined"){var c=g[d].shortUrl;b.val(b.val().replace(d,c))}}}if(typeof(a)=="function"){a(g)}})})};jQuery.fn.addPreview=function(d,a){var c=jQuery.extend({},jQuery.fn.addPreview.defaults,a);var b=c.xOffset;var f=c.yOffset;var e;jQuery(this).hover(function(){var g=$(this).attr("href");if(!g){return false}jQuery("body").append('<div id="preview"/>');var h=jQuery("#preview").css("position","absolute").append("<em>"+c.message+"</em>").fadeIn();e=jQuery(this).bitly("info",function(i){h.children().remove();d(i)})},function(){e.abort();jQuery("#preview").fadeOut().remove()}).mousemove(function(i){var h=i.pageX+b;var g=i.pageY+f;jQuery("#preview").css("top",g+"px").css("left",h+"px")})};jQuery.fn.addPreview.defaults={xOffset:10,yOffset:10,message:"Loading..."};
