 function tweet() {
    var login  = 'tanishin';
    var apiKey = 'R_37c721d259f4692c7026a8d7ea552939';
    bitly = 'http://api.bit.ly/shorten' 
        + '?version=2.0.1&format=json&callback=callback'
        + '&login=' + login
        + '&apiKey=' + apiKey + '&longUrl=';
    var script = document.createElement('script');

    script.type = 'text/javascript';
    script.src = bitly + encodeURIComponent(location.href) ;
    document.body.appendChild(script);

  }


function callback(bitlyResponse){
  var tw       = "http://twitter.com/home/?status=";
  var shorturl =  encodeURIComponent( bitlyResponse.results[location.href]["shortUrl"] );
  var title    =  encodeURIComponent( document.title );
  var url      = tw + title + shorturl;
  document.getElementById( "tweet" ).setAttribute( "href" , url );
}

