/***************************************
file Name: feed.js
Description: Google Feed APIを用いてフィードを取得し表示するJSです
Version: 1.0
Author: axcelwork
***************************************/
function readFeed(result) {
	//クロスブラウザ
	var cls = "class";
	if(/*@cc_on!@*/false){ cls = "className" };
	
	if (!result.error) {          
		var feedlcnt=0;
		feedloop:for (var i = 0; i < result.feed.entries.length; i++) {
			
			var entry = result.feed.entries[i];
			
			var pdate = new Date(entry.publishedDate);
			var pyear = pdate.getFullYear();
			var pmonth = pdate.getMonth() + 1;
			if (pmonth < 10) {pmonth = "0" + pmonth;}
			var pday = pdate.getDate();
			if (pday < 10) {pday = "0" + pday;}
			
			if (!entry.title.match(/PR:/i) ) {
				$('.whatsnew dl').append('<dt>' + pyear +'.' + pmonth +'.' + pday + '</dt><dd><a href="' + entry.link + '" target="_blank">' + entry.title + '</a></dd>');
				feedlcnt++;
			}else{
				feedlcnt=feedlcnt;
			}
			if(feedlcnt==4){break feedloop;}
		}
	}
	else {
		$('.whatsnew dl').append('<dt></dt><dd>取得に失敗しました</dd>');
	}
}
	
google.load("feeds", "1");
	
function initialize() {
	var rss = "http://feedblog.ameba.jp/rss/ameblo/centralaichi/rss20.xml";
	var feed = new google.feeds.Feed(rss);
	feed.setNumEntries(8);
	feed.load(readFeed);
}

google.setOnLoadCallback(initialize);
