$(window).load(function() {
	// 連携キット、local時はexit
	if ($.LiVE.bdkit && location.protocol=="file:") return;
	
	var $like = $.LiVE.Elements.WIDGETS.like.find(".default");
	$like.each(function() {
		var $this = $(this),
			$thanks = $this.find(".thanks"),
			$btn = $this.find('.button'),
			likeUrl = $btn.attr('data-url'),
			_width = 88,
			_height = 30;
		
		$like.height('100%');
		
		if ( likeUrl == "#" ) {
			likeUrl = encodeURI( location.href );
			$btn.html('<fb:like href="'+ likeUrl +'" layout="button_count" send="false" width="200" show_faces="false"></fb:like>');
		}
		
		function thanks() {
			var _easing = "easeOutBack",
				_center = $this.width()/2;
			
			$thanks.css({
				display: "block",
				width: 0,
				height: 0,
				left: _center,
				top: 0
			}).animate({
				width: _width,
				height: _height,
				left: _center - _width/2,
				top: _height * -1
			}, 200, _easing);
			
			$thanks.delay(3000).animate({
				width: 0,
				height: 0,
				left: _center,
				top: 0
			}, 200, _easing);
		}
		
		if (typeof(FB)!='undefined') {
			FB.Event.subscribe('edge.create', function(response) {
				thanks();
			});
		}
	});
	
	// load API
	(function(d, s, id) {
	var js, fjs = d.getElementsByTagName(s)[0];
	if (d.getElementById(id)) return;
	js = d.createElement(s); js.id = id;
	js.src = $.LiVE.util.getEmbedProtocol()+"//connect.facebook.net/ja_JP/all.js#xfbml=1";
	fjs.parentNode.insertBefore(js, fjs);
	}(document, 'script', 'facebook-jssdk'));
});