/*
*   Bit.Ly shorten URL service.
*/
var twext_glob = "";

BitlyCB.shortenResponse = function(data) 
{                
	var s = '';
	var first_result;
   
	// Results are keyed by longUrl, so we need to grab the first one.
	for (var r in data.results) {
		first_result = data.results[r];
		break;
	}


	sUrl = first_result['shortUrl'];
   
	var twext = twext_glob;
	if (twext != '') {
		var twext = twext_glob;
		tweet_a = $('#tweetthis');
		tweet_a.attr('href', 'http://twitter.com/home?status='+sUrl+' '+twext);
	}
}

/********************************************************************************************/
function make_twlink(twext){
	
	window.onload = function() 
	{
		twext_glob = twext;
		if (twext.length > 105) {
			twext = twext.substr(0, (105))+'...';
		}
	
		BitlyClient.shorten(document.location, 'BitlyCB.shortenResponse');
	}
	
}





