
function tweet(){
 var text = document.title;
 text = text + " " + document.URL;
 text = replaceStr(text);
 text = encodeURI(text);
 window.open("http://twitter.com/home?status=" + text,"twitter");
}

function addHatebu(){
 var thisUrl = document.URL;
 thisUrl = replaceStr(thisUrl);
 var openUlr = "http://b.hatena.ne.jp/entry/add/" + thisUrl;
 window.open(openUlr,"hatebu");

}


  function tweetWithBitly() {
  	var longurl = replaceStr(document.URL);
    bitly = '/ss_link_button/bitlyproxy.php'
        + '?version=2.0.1&format=json'
        + '&callback=callback&longUrl=';
   
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = bitly + encodeURIComponent(longurl) ;
    document.body.appendChild(script);
  }

  function callback(bitlyResponse) {

    var title = document.title;
    var thisUrl = replaceStr(document.URL);
    var url = 'http://twitter.com/home/?status=' 
        + encodeURIComponent(
             title + ' ' 
               + bitlyResponse.results[thisUrl]['shortUrl']
          );
	window.open(url,"twitter");

  }
  
  
  /* 
	  jqueryを使った短縮URLによるtwitter呼び出しメソッド。
	  ポップアップウィンドウが出ない・・・ハズ。
	  要Jquery。（googleのを使うとラク）
   */
  function tweetWithBitlybyAjax() {
		var longurl = replaceStr(document.URL);
		bitly = '/ss_link_button/bitlyGetUrl.php'
        + '?version=2.0.1&format=text'
        + '&longUrl=' + encodeURIComponent(longurl);
		var text = $.ajax({
					  url: bitly,
					  async: false
					 }).responseText;
		var title = document.title;
		var url = 'http://twitter.com/home/?status=' 
		+ encodeURIComponent(
             title + ' ' 
               + text
          );
		window.open(url,"twitter");
  }
  
    
  
  function replaceStr(text){
  
   	text = text.replace(/#$/,"");
 	text = text.replace("check","www");
 	
 	return text;
  	
  }
  
	



