/* iframeCreate
#
#　URL、DOM挿入先ID、iframeのサイズ
#
------------------------------------- */
var iframeCreate = function(url, id, size){
	var target = document.getElementById(id);
	if(objCheck(target) == false) return false;

	var iframe = document.createElement('iframe');
	iframe.frameBorder = '0';
	iframe.allowTransparency = 'true';
	iframe.scrolling = 'no';
	iframe.style.border = 'none';
	iframe.style.width = size.width;
	iframe.style.height = size.height;
	iframe.src = url;

	target.appendChild(iframe);
};
var hatenaBookmark = function(url, title, id){
	var target = document.getElementById(id);
	if(objCheck(target) == false) return false;

	var hatena = document.createElement('a');
	var hatenaImg = new Image();
	hatena.href = 'http://b.hatena.ne.jp/entry/' + url;
	hatena.className = 'hatena-bookmark-button';
	hatena.dataHatenaBookmarkTitle = title;
	hatena.dataHatenaBookmarkLayout = 'standard';
	hatena.title = 'このエントリーをはてなブックマークに追加';
	hatenaImg.src = 'http://b.st-hatena.com/images/entry-button/button-only.gif';
	hatenaImg.alt = 'このエントリーをはてなブックマークに追加';
	hatena.appendChild(hatenaImg);

	target.appendChild(hatena);
};


function outputTools(){
	var via = 'Gomez_co_jp';
//	var url = document.location.href;
	var url = document.location.protocol + '//' + document.location.host + document.location.pathname;
	var title = document.title;

	new iframeCreate(
		'http://platform.twitter.com/widgets/tweet_button.html?url=' +  encodeURI(url) + '&via=' + via + '&text=' + encodeURIComponent(title) + '&lang=ja&count=horizontal',
		'twitter',
		{ width:'100px', height:'20px' }
	);
	new iframeCreate(
		'http://www.facebook.com/plugins/like.php?href=' +  encodeURI(url) + '&layout=button_count&show_faces=false&width=450&action=like&colorscheme=light&height=21',
		'facebook',
		{ width:'450px', height:'21px' }
	);
	new hatenaBookmark(url, title, 'hatebu');

	new iframeCreate(
		'http://platform.twitter.com/widgets/tweet_button.html?url=' +  encodeURI(url) + '&via=' + via + '&text=' + encodeURIComponent(title) + '&lang=ja&count=horizontal',
		'twitter2',
		{ width:'100px', height:'20px' }
	);
	new iframeCreate(
		'http://www.facebook.com/plugins/like.php?href=' +  encodeURI(url) + '&layout=button_count&show_faces=false&width=450&action=like&colorscheme=light&height=21',
		'facebook2',
		{ width:'450px', height:'21px' }
	);
	new hatenaBookmark(url, title, 'hatebu2');
};
addEventFunc(outputTools);

