﻿var isOldBrowser = !document.createElement('canvas').getContext;


//ピックアップ
function WritePickUpWidget()
{
	document.write
	(
		'<div>' +
			'<a href="http://go.microsoft.com/?linkid=9773120" target="_blank">' +
				'<img src="http://i.msdn.microsoft.com/hh140859.180x150_claudia(ja-jp,MSDN.10).gif" width="180" height="150" alt="MSDN クラウド 技術解説コミック新登場 クラウド ガール - 窓と雲と碧い空 - " style="border-style:none" />' +
			'</a>' +
		'</div>'
	);
}

//おすすめ
function WriteWishList()
{
	var fileName = "WishList.txt";
	var wishListContainer = document.getElementById("WishListContainer");
	
	var ajaxOptions = {
		type: "GET",
		url: fileName,
		dataType: "text",
		cache: false,
		success: function(data)
		{ 
			var asimList = data.split('\n');
			var htmlText = "";
			for(var i = 0 ; i < asimList.length ; i++)
			{
				htmlText += "<div>" + GetAmazonLink(asimList[i]) + "</div>";
			}
			wishListContainer.innerHTML = htmlText ; 
		},
		error: function() { wishListContainer.innerHTML = GetAmazonVerticalList("プログラミング"); }
	};
	
	$.ajax(ajaxOptions);
	return;
}

function WriteRightSideAdvertisement()
{
	google_ad_client = "ca-pub-9470114503820768";
	/* サイドバー広告 */
	google_ad_slot = "7977438900";
	google_ad_width = 160;
	google_ad_height = 600;

	document.write(
		'<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>' 
	);
}


//Hatena
function WriteHatenaButton()
{
	document.write(
		'<a href="http://b.hatena.ne.jp/entry/' + document.URL + '" class="hatena-bookmark-button" title="このエントリーをはてなブックマークに追加">' +
		'<img src="http://b.st-hatena.com/images/entry-button/button-only.gif" alt="このエントリーをはてなブックマークに追加" width="20" height="20" style="border: none;" />' +
		'</a>' +
		'<script type="text/javascript" src="http://b.st-hatena.com/js/bookmark_button.js" charset="utf-8" async="async" ></script>'
	);
}

//Facebook Like Button
function WriteFacebookButton()
{
	if (isOldBrowser)
	{
		document.write(
			'<iframe src="http://www.facebook.com/plugins/like.php?href&amp;send=false&amp;layout=button_count&amp;width=450&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21&amp;appId=169570553120681"' +
			'style="border:none; overflow:hidden; width:100px; height:21px;" scrolling="no" frameborder="0"></iframe>'
		);
	}
	else
	{
		document.write(
			'<iframe src="http://www.facebook.com/plugins/like.php?href=' + document.URL+ '&amp;send=false&amp;layout=button_count&amp;width=450&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21&amp;appId=169570553120681"' +
			'style="border:none; overflow:hidden; width:100px; height:21px;" seamless="seamless"></iframe>'
		);
	}
}

//Facebook Like Box
function WriteFacebookLikeBox()
{
	if (isOldBrowser)
	{
		document.write('<iframe src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FWisdomSoft%2F189044671165675&amp;width=800&amp;colorscheme=light&amp;show_faces=true&amp;border_color&amp;stream=true&amp;header=true&amp;height=590" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:800px; height:590px;" allowTransparency="true"></iframe>');
	}
	else
	{
		document.write('<iframe src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FWisdomSoft%2F189044671165675&amp;width=800&amp;colorscheme=light&amp;show_faces=true&amp;border_color&amp;stream=true&amp;header=true&amp;height=590" style="border:none; overflow:hidden; width:800px; height:590px;" seamless="seamless"></iframe>');
	}	
}

//Google plus
function WriteGooglePlusButton()
{
	document.write('<g:plusone size="medium"></g:plusone>');
}
function WriteGooglePlusBadge()
{
	document.write('<div class="g-plus" data-href="https://plus.google.com/110444165422991366532" data-size="badge"></div>');
}

//Amazon Item Link
function GetAmazonLink(asim)
{
	var result = '';
	var imageOnly = true;
	
	if (imageOnly)
	{
		result = '<a href="http://www.amazon.co.jp/gp/product/' + asim + '/ref=as_li_ss_il?ie=UTF8&tag=wisdo-22&linkCode=as2&camp=247&creative=7399&creativeASIN=' + asim +
			'"><img src="http://ws.assoc-amazon.jp/widgets/q?_encoding=UTF8&Format=_SL160_&ASIN=' + asim +
			'&MarketPlace=JP&ID=AsinImage&WS=1&tag=wisdo-22&ServiceVersion=20070822" alt="" style="border:none" /></a><img src="http://www.assoc-amazon.jp/e/ir?t=wisdo-22&l=as2&o=9&a=' + asim +
			'" width="1" height="1" alt="" style="border:none !important; margin:0px !important;" />'
	}
	else
	{	
		if (isOldBrowser)
			result = '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?lt1=_blank&bc1=FFFFFF&IS2=1&nou=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=wisdo-22&o=9&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=' + asim +
				'" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>';
		else
			result = '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?lt1=_blank&bc1=FFFFFF&IS2=1&nou=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=wisdo-22&o=9&p=8&l=as4&m=amazon&f=ifr&ref=ss_til&asins=' + asim +
				'" style="border:none; overflow:hidden; width:120px; height:240px;" seamless="seamless"></iframe>';
	}

	return result;
}
function WriteAmazonLink(asim)
{
	var htmlText = GetAmazonLink(asim);
	document.write(htmlText);
}
function WriteAmazonLinkList(asimList, itemBegin, itemEnd)
{
	for(var i = 0 ; i < asimList.length ; i++)
	{
		if (itemBegin) document.write(itemBegin);
		WriteAmazonLink(asimList[i]);
		if (itemEnd) document.write(itemEnd);
	}
}

//Amazon Search List(Live Link) - Vertical
function GetAmazonVerticalList(search)
{
	if(isOldBrowser)
	{
		return '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=wisdo-22&amp;o=9&amp;p=14&amp;l=st1&amp;mode=books-jp&amp;search=' + search + '&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" width="160" height="600" style="border:none; overflow: hidden;" scrolling="no" frameborder="0"></iframe>';
	}
	else
	{
		return '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=wisdo-22&amp;o=9&amp;p=14&amp;l=st1&amp;mode=books-jp&amp;search=' + search + '&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" width="160" height="600" style="border:none; overflow: hidden;" seamless="seamless"></iframe>';
	}

}
function WriteAmazonVerticalList(search)
{
	var htmlText = GetAmazonVerticalList(search);
	document.write(htmlText);
}

//Amazon Search List(Live Link) - Horizontal
function GetAmazonHorizontalList(search)
{
	if(isOldBrowser)
	{
		return '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=wisdo-22&amp;o=9&amp;p=48&amp;l=st1&amp;mode=books-jp&amp;search=' + search + '&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" width="728" height="90" style="border:none; overflow: hidden;" scrolling="no" frameborder="0"></iframe>';
	}
	else
	{
		return '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=wisdo-22&amp;o=9&amp;p=48&amp;l=st1&amp;mode=books-jp&amp;search=' + search + '&amp;fc1=000000&amp;lt1=_blank&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" width="728" height="90" style="border:none; overflow: hidden;" seamless="seamless"></iframe>';
	}

}
function WriteAmazonHorizontalList(search)
{
	var htmlText = GetAmazonHorizontalList(search);
	document.write(htmlText);
}

//LinkedIn
function WriteLinkedInProfileBar(profileURL)
{
	document.write('<' + 'script src="http://platform.linkedin.com/in.js" type="text/javascript"></script>');
	document.write('<' + 'script type="IN/MemberProfile" data-id="' + profileURL + '" data-format="inline" data-related="false">');
	document.write('<' + '/script>');
}

//Blogger
function WriteBlogger()
{
	if (isOldBrowser)
	{
		document.write('<iframe src="http://wisdomsoft-blog.blogspot.com/" style="width:800px; height:1600px; border-style:none; overflow:hidden; " scrolling="no" frameborder="0"></iframe>');
	}
	else
	{
		document.write('<iframe src="http://wisdomsoft-blog.blogspot.com/" style="width:100%; height:1600px; border-style:none; overflow:hidden; " seamless="seamless"></iframe>');
	}
}
