﻿/*タイトルとURL取得*/
var title = document.title;
var Lurl = location.href;

/*twitter用タイトル（短縮）*/
title_tw = title.replace("PCパーツ・周辺機器の総合代理店　マスタードシード株式会社","マスタードシード");

/*記述内容定義（SBM）*/
/*順にアイコン（sbm_「XXXX」ここ）、URL、ALT*/

var sbmlist = [];

/*Yahoo*/
sbmlist[0] =[
			'yahoo',
			'http://bookmarks.yahoo.co.jp/action/bookmark?t='+ encodeURIComponent(title)+ '&amp;u=' + encodeURIComponent(Lurl) + '&amp;ei=UTF-8',
			'Yahoo!ブックマークに追加'
			];

/*Livedoor*/
sbmlist[1] =[
			'livedoor',
			'http://clip.livedoor.com/clip/add?link=' + encodeURIComponent(Lurl) + '&amp;title=' + encodeURIComponent(title) + '&amp;jump=ref',
			'livedoorクリップに追加'
			];

/*Hatena*/
sbmlist[2] =[
			'hatena',
			'http://b.hatena.ne.jp/entry/add/' + Lurl,
			'はてなブックマークに追加'
			];

/*Google*/
sbmlist[3] =[
			'google',
			'http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=' + encodeURIComponent(Lurl) + '&amp;title=' + encodeURIComponent(title),
			'Googleブックマークに追加'
			];

/*Buzzurl*/
sbmlist[4] =[
			'buzzurl',
			'http://buzzurl.jp/entry/' + Lurl,
			'Buzzurlにブックマーク'
			];

/*Facebook*/
	var FBurl = "http://www.facebook.com/plugins/like.php?href=" + encodeURIComponent(Lurl) + "&layout=button_count&show_faces=true&width=100&action=like&colorscheme=light";


/*記述内容定義（twitter）*/
function sbm_tweet() {
var User  = 'mustardseedweb';
var APIKey = 'R_a27c1b2e3f71c4e7240448b11148e2fc';

/*bitly = 'http://api.bit.ly/shorten?version=2.0.1&format=json&callback=callback&amp;login=' + User + '&amp;apiKey=' + Key + '&amp;longUrl=';*/

var bitly = 'http://api.bit.ly/v3/shorten?format=json&callback=Callback&login=' + User + '&apiKey=' + APIKey + '&longUrl=';

var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = bitly + encodeURIComponent(Lurl);
    document.body.appendChild(script);
};

function Callback(Res) {
var Twurl = 'http://twitter.com/home/?status=' + encodeURIComponent(title_tw + ' ' + Res.data['url']);
window.open(Twurl, '_blank');
};


/*記述生成*/
/*CSSで右寄せ、後に足すほど左に追加*/

document.write(
"<ul id=\"sbmlink\">"+
"<li><iframe src=\"" + FBurl + "\"allowtransparency=\"true\" frameborder=\"0\" scrolling=\"no\"></iframe></li>" +
"<li><a href=\"javascript:void(0)\" onClick=\"sbm_tweet(); return false;;\"><img src=\"/img/sbm_twitter.gif\" alt=\"twitterでつぶやく\" title=\"twitterでつぶやく\" /></a></li>" +
"<li><a href=\""+ sbmlist[0][1] + "\" target=\"_blank\"><img src=\"/img/sbm_" + sbmlist[0][0] + ".gif\" alt=\"" + sbmlist[0][2] + "\" title=\"" + sbmlist[0][2] + "\" /></a></li>" +
"<li><a href=\""+ sbmlist[1][1] + "\" target=\"_blank\"><img src=\"/img/sbm_" + sbmlist[1][0] + ".gif\" alt=\"" + sbmlist[1][2] + "\" title=\"" + sbmlist[1][2] + "\" /></a></li>" +
"<li><a href=\""+ sbmlist[2][1] + "\" target=\"_blank\"><img src=\"/img/sbm_" + sbmlist[2][0] + ".gif\" alt=\"" + sbmlist[2][2] + "\" title=\"" + sbmlist[2][2] + "\" /></a></li>" +
"<li><a href=\""+ sbmlist[3][1] + "\" target=\"_blank\"><img src=\"/img/sbm_" + sbmlist[3][0] + ".gif\" alt=\"" + sbmlist[3][2] + "\" title=\"" + sbmlist[3][2] + "\" /></a></li>" +
"<li><a href=\""+ sbmlist[4][1] + "\" target=\"_blank\"><img src=\"/img/sbm_" + sbmlist[4][0] + ".gif\" alt=\"" + sbmlist[4][2] + "\" title=\"" + sbmlist[4][2] + "\" /></a></li>" +
"</ul>"
);


