//nikki Feed
function convertDateString(dateString){
	var date = new Date(dateString);
	return date.getFullYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日";
}

function showNikki(){
	var feed = new google.feeds.Feed('http://nikki.awayuki.net/feed');
	feed.load(function(result) {
		var items = result.feed.entries;
		if(items.length<1) {
			$("#nikkiFeed").append("<p>記事がありません</p>");
			return false;
		}
		$(result.feed.entries).each(function(i){
			var thumb = $("img:first",this.content).attr("width","120").removeAttr("height");
			$("#nikkiFeed").append(
				$('<div class="item" />').append(
					$('<a />',{
						href: this.link
					}).append(thumb[0])
				).append(
					$('<span />',{
						text: convertDateString(this.publishedDate)
					}).addClass("date")
				).append(
					$('<a />',{
						href: this.link,
						text: this.title
					}).addClass("title")
				)
			);
		});
		$("#nikkiFeed .item").hide();
		$("#nikkiFeed .item").slideDown("slow");
	});
}

//Juitter Setting
function showTw() {
	$.Juitter.start({
		searchType:"fromUser",
		searchObject:"awayuki",
		lang:"all",
		live:"live-30",
		placeHolder:"twTimeLine",
		loadMSG: "Loading tweets...", 
		imgName: "loader.gif",
		total: 5,
		readMore: "[more]",
		nameUser:"text",
		openExternalLinks:"sameWindow"
	});
}

//twitpic

//function showTwPic() {
//	$.getScript(
//		'http://api.twitpic.com/2/users/show.jsonp?username=awayuki'
//	);
//}
//		function TwitpicLoad(data) {
//			var picID = data.images[0].short_id
//			var picUrl = "http://twitpic.com/"+picID;
//			var picSrc = "http://twitpic.com/show/thumb/"+picID;
//			var picAlt = data.images[0].message;
//			$("#twPic").append("<a><img /></a>");
//			$("#twPic a").attr("href",picUrl);
//			$("#twPic img").attr("src",picSrc).attr("title",picAlt);
//		}

//Initialize
function initialize() {
	showNikki();
	showTw();
}
$(initialize);

