$(document).ready(function(){
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=$.LiVE.util.getEmbedProtocol()+"//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
});

$(function() {
	// 連携キット、local時はexit
	if ($.LiVE.bdkit && location.protocol=="file:") return;
	
	var $follow = $.LiVE.Elements.WIDGETS.follow.find(".extended");
	
	$follow.each(function() {
		var $this = $(this).parent(),
			$number = $this.find(".number"),
			account = $number.attr("data-account"),
			id = $this.attr("id"),
			val = $.LiVE.widget[id];
		
		$follow.height('100%');
		
		//カウント強制非表示
		$this.find(".twitter-follow-button").attr("data-show-count", false);
		
		function formatNumber(src) {
			var numStr = new String(src);
			while(numStr != (numStr = numStr.replace(/^(-?\d+)(\d{3})/,"$1,$2")));
			return numStr;
		}
		function dispAccount(json) {
			$number.find("b").text(formatNumber(json.followers_count));
		}
		
		// get account data.
		if (account) {
			$.getJSON("http://twitter.com/status/user_timeline/" + account + ".json?count=1&callback=?", function(json){
				dispAccount(json[0].user);
			});
		}
	});
	
});