$(function(){
  $.ajax({
    url: 'blog/feed/',
    dataType: 'xml',
    success: function(data){
      $('item',data).each(function(){
        var title = $('title',this).text();
		var uploadDate =change($('pubDate',this).text());
		var url = $('link',this).text();
		var text = $('description',this).text();
		var cateValue = $('category',this).text();
		var category;
			switch(cateValue){
			case 'イラスト':
				category = '<img src="img/top/rss_illust.gif" alt="イラスト" />';
				break;
			case '写真':
				category = '<img src="img/top/rss_photo.gif" alt="写真" />';
				break;
			case 'お知らせ':
				category = '<img src="img/top/rss_news.gif" alt="おしらせ" />';
				break;
			default:
				category = '<img src="img/top/rss_other.gif" alt="そのほか" />';
			}
        $('#rss dl').append('<dt>' + category + ' <a href="' + url + '">' + title +'</a> '+ uploadDate + '</dt><dd>' + text.substring(0,12) + '…<a href="' + url + '">続きを読む</a></dd>');
      });
    }
  });
});

function change(day){
	var upDay = new Date(day);
	var year = upDay.getFullYear();
	var month = upDay.getMonth()+1;
	var date = upDay.getDate();
	day = '（'+ year + '.' + month + '.' + date +'）';
	return day;
}
