/*
各種ソーシャルサービスボタンを簡単設置
*/

var SNSButtonSYG = {
	
	windowOpt : "width=550, height=450,personalbar=0,toolbar=0,scrollbars=1,resizable=1",
	
	/***************************
	* Twitter
	*/
	twitter : function( url, msg, via, follow ){
		var e = encodeURIComponent;
		
		if( !url ) url = location.href;
		if( !msg ) msg= document.title;
		var openURL = 'http://twitter.com/share?url=' + e(url) + '&text=' + e(msg) + '+';
		
		if( via ) openURL += '&via=' + e(via);
		if( follow ) openURL += '&related=' + e(follow);

		window.open( openURL, 'tweetwindow', SNSButtonSYG.windowOpt );
		void(0);
		return false;
	},
	
	/***************************
	* Facebook
	*/
	facebook : function( url ){
		var e = encodeURIComponent;
		if( !url ) url = location.href;
		var openURL = 'http://www.facebook.com/share.php?u='+ e(url);

		window.open( openURL, 'facebookwindow', SNSButtonSYG.windowOpt );
		return false;
	},

	/***************************
	* mixiチェック
	*/
	mixi : function( key, url ){
		var e = encodeURIComponent;
		if( !url ) url = location.href;
		var openURL = 'http://mixi.jp/share.pl?u='+ url + '&k=' + key;

		window.open( openURL, 'share', ['width=632','height=456','location=yes','resizable=yes','toolbar=no','menubar=no','scrollbars=no','status=no'].join(',') );
		return false;
	},

	/***************************
	* はてなブックマーク
	*/
	hatebu : function( url ){
		var e = encodeURIComponent;
		if( !url ) url = location.href;
		var openURL = 'http://b.hatena.ne.jp/entry/' + e(url);

		window.open( openURL, 'hatebuwindow', SNSButtonSYG.windowOpt );
		return false;
	},

	/***************************
	* del.icio.us
	*/
	delicious : function( url, title ){
		var e = encodeURIComponent;
		if( !url ) url = location.href;
		if( !title ) title = document.title;
		var openURL = 'http://www.delicious.com/save?url=' + e(url) + '&title=' + e(title);

		window.open( openURL, 'deliciouswindow', SNSButtonSYG.windowOpt );
		return false;
	},

	/***************************
	* Yahooブックマーク
	*/
	yahoo : function( url, title ){
		var e = encodeURIComponent;
		if( !url ) url = location.href;
		if( !title ) title = document.title;
		var openURL = 'http://bookmarks.yahoo.co.jp/action/bookmark?t=' + e(title) + '&u=' + e(url);

		window.open( openURL, 'deliciouswindow', SNSButtonSYG.windowOpt );
		return false;
	},

	/***************************
	* googleブックマーク
	*/
	google : function( url, title ){
		var e = encodeURIComponent;
		if( !url ) url = location.href;
		if( !title ) title = document.title;
		var openURL = 'https://www.google.com/bookmarks/mark?op=add&bkmk=' + e(url) + '&title=' + e(title);

		window.open( openURL, 'googlewindow', SNSButtonSYG.windowOpt );
		return false;
	},

	/***************************
	* livedoorクリップ
	*/
	livedoor : function( url, title ){
		var e = encodeURIComponent;
		if( !url ) url = location.href;
		if( !title ) title = document.title;
		var openURL = 'http://clip.livedoor.com/redirect?link=' + e(url) + '&title=' + e(title) + '&ie=utf-8';
		
		window.open( openURL, 'livedoorwindow', SNSButtonSYG.windowOpt );
		return false;
	}

};
