$(document).ready(function() {
	$.get('/blog/oyakudachi-goods/feed', function(data) {
		var item = $($(data).find('item:first'));
		if (item.length > 0) {
      var title = item.find('title:first').text();
      var link = item.find('link:first').text();
      var pub = new Date(item.find('pubDate:first').text());
      var img = item.find('image');

      var target = '.include-oyakudachi-goods';
      $(target + ' .include-pubdate').text((pub.getMonth() + 1) + '/' + pub.getDate() + 'UP!');
      $(target + ' .include-link').attr('href', link);
      $(target + ' .include-title').text('「' + title + '」');
      $(target + ' .include-img').attr('src', img.find('url').text())
        .attr('alt', img.find('title').text());
    }
	});

	$.get('/blog/fairy_noguchi/feed', function(data) {
		var item = $($(data).find('item:first'));
		if (item.length > 0) {
      var title = item.find('title:first').text();
      var link = item.find('link:first').text();
      var pub = new Date(item.find('pubDate:first').text());

      var target = '.include-fairy_noguchi';
      $(target + ' .include-pubdate').text(pub.getFullYear() + '年' + (pub.getMonth() + 1) + '月' + pub.getDate() + '日 UP!');
      $(target + ' .include-link').attr('href', link);
      $(target + ' .include-title').text('「' + title + '」');
    }
	});

	$.get('/blog/announce/feed', function(data) {
		var items = $(data).find('item');
		var target = '.include-announce';

		if (items.length > 0) {
			$(target + ' p').remove();
			var i = 0;
			items.each(function() {
				if (i > 2) return true;
				i++;
				var item = $(this);
				var title = item.find('title:first').text();
				var link = item.find('link:first').text();
				var pub = new Date(item.find('pubDate:first').text());
				$.tag('p')
					.append($.tag('a').attr('href', link).text(title))
					.append($.tag('span').text('(' + pub.getFullYear() + '/' + (pub.getMonth() + 1) + '/' + pub.getDate() + ')'))
					.appendTo($(target));
			});
		}
	});
});
