var url;
function setTwitLink(title,longUrl,orgUrl,summ) {
  var lv_tweet = title + ' - ' + summ;
  var tweet = lv_tweet.replace("%2c",",");
  if ($.browser.msie && $.browser.version.substr(0,1)<7) { 
    var tw_link = 'http:/'+'/twitter.com/home?status=' + encodeURIComponent( tweet + ' ' + orgUrl );
    window.open(tw_link);
  } 
  else {
    $.getJSON("http://api.bit.ly/v3/shorten?login=communicatienvbr&apiKey=R_d44ae747b75f904fd205d401ecc61ac9&longUrl=" + longUrl + "&format=json&callback=?",
      function(data) {
        url = data.data.url;
        var limit = 140 - ( url.length + 1 );
        if( tweet.length > limit ) {
            tweet = tweet.substr( 0, ( limit - 3 ) ) + '...';
        }
        var tw_link = 'http:/'+'/twitter.com/home?status=' + encodeURIComponent( tweet + ' ' + url );
  
        //document.write( '<a href="' + link + '" target="_blank">Test twitter</a>' );
        window.open(tw_link);
        return false;
    });
  }
}

