/**
 * bit.ly access library code.
 */
var Shortener = new JS.Singleton('Shortener', {
	shorten: function() {
	  var uri, callback;
	  
	  if (typeof arguments[0] == 'string') {
	    uri      = arguments[0];
	    callback = arguments[1];
	  } else {
	    uri      = window.location.href;
	    callback = arguments[0];
	  }
    
		var name = this._registerCallback(callback);
		
		this.CLIENT.call('shorten', {
			'longUrl': uri
		}, 'BitlyCB.' + name);
	},
	
	_dispatcher: function(callback, data) {
		var result;
		
    // Results are keyed by longUrl, so we need to grab the first one.
    for (var r in data.results) {
			result = data.results[r];
			break;
    }
		
		callback(result, data);
	},
	
	_registerCallback: function(callback) {
		var name = 'abbr' + this.callbackCount;
		this.callbackCount += 1;
		
		this.NAMESPACE[name] = function(data) {
			this._dispatcher(callback, data);
		}.bind(this);
		
		return name;
	},
	
	callbackCount: 0,
	
	CLIENT: BitlyClient,
	NAMESPACE: BitlyCB
});

@@ -80,16 +80,152 @@
 ner', %7B%0A
+  initialize: function() %7B%0A    this.extend(%7B%0A      CLIENT:    BitlyClient %7C%7C null,%0A      NAMESPACE: BitlyCB     %7C%7C null%0A    %7D);%0A  %7D,%0A  %0A
 %09shorten
@@ -503,24 +503,65 @@
 llback);%0A%09%09%0A
+%09%09if (!(name && this.CLIENT)) return;%0A%09%09%0A
 %09%09this.CLIEN
@@ -909,24 +909,66 @@
 callback) %7B%0A
+%09  if (!this.NAMESPACE) return false;%0A%09  %0A
 %09%09var name =
@@ -1146,16 +1146,16 @@
 ;%0A%09%7D,%0A%09%0A
+
 %09callbac
@@ -1167,53 +1167,8 @@
 t: 0
-,%0A%09%0A%09CLIENT: BitlyClient,%0A%09NAMESPACE: BitlyCB
 %0A%7D);

Add some error handling in case there's no connection to the bit.ly servers.