$(function() {
	//IE対策
	function replaceTwTimeStr(time){
		var tArray = time.split(" ");
		var timeStr = tArray[0] + " " + tArray[1] + " " + tArray[2] + " " + tArray[5] + " " + tArray[3] + " " + tArray[4];
		return timeStr;
	}
	var dateObj = new Date;
	$.getJSON('http://twitter.com/statuses/user_timeline/KantoDai1_PR.json?callback=?', function (json) {
		for(var i in json){
			var text = json[i].text;
			//URLにリンクを付ける
			text = text.replace(/(s?https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:@&=+$,%#]+)/gi,'<a href="$1">$1</a>');
			//ハッシュタグにリンク
			text = text.replace(/#(\w+)/gi,'<a href="http://twitter.com/search?q=%23$1">#$1</a>');
			//リプライにリンク
			text = text.replace(/@(\w+)/gi,'<a href="http://twitter.com/$1">@$1</a>');
			//つぶやきを表示
			$("#twitter div").append("<dl><dt>" + 
				dateObj.format('Y-m-d H:i:s', replaceTwTimeStr(json[i].created_at)) + 
				"</dt><dd>" + text + "</dd></dl>");
		}
	});
	/*
	//Youtube(クラブ)取得
	$.getJSON('http://gdata.youtube.com/feeds/api/users/kanichiclub/uploads?alt=json&max-results=1&callback=?', function (json) {
		var items = json.feed.entry;
		$.each(items,function(i){
			$('#youtube .club-channel div').append('<a href="'+ items[i].link[0].href +'" target="_blank"><img src="'+items[i].media$group.media$thumbnail[0].url+'" width="180" height="135" /></a>');
		});
	});
	
	//Youtube(イベント)取得
	$.getJSON('http://gdata.youtube.com/feeds/api/users/kanichievent/uploads?alt=json&max-results=1&callback=?', function (json) {
		var items = json.feed.entry;
		$.each(items,function(i){
			$('#youtube .event-channel div').append('<a href="'+ items[i].link[0].href +'" target="_blank"><img src="'+items[i].media$group.media$thumbnail[0].url+'" width="180" height="135" /></a>');
		});
	});
	*/
});
