// JavaScript Document
var ie = navigator.userAgent.indexOf('MSIE') > -1 ? 1 : 0;
google.load("feeds", "1");
function initialize() {
	var fNum = 0;
	var url='';
	$(".feed").each( function() {
		url = $(this).html();
		$(this).html("");
		$(this).attr("id", 'feed'+fNum);
		fNum++;
		getRss(url, $(this).attr("id") );
	} );
}
function getRss(url, id) {
	var feed = new google.feeds.Feed(url);
	feed.setNumEntries(3);
	feed.load(function(result) {
		if (!result.error) {
			var container = document.getElementById(id);
			for (var i = 0; i < result.feed.entries.length; i++) {
				var entry = result.feed.entries[i];
				var dt = document.createElement("dt");
				if( (i+1)%2 == 0 ) dt.className = "gray";
				var dd = new Date(entry.publishedDate);
				var yearNum = dd.getYear();
				if (yearNum < 2000) yearNum += 1900;
				yearNum = yearNum+''
				var month = zeroFiller(dd.getMonth()+1);
				var day = zeroFiller(dd.getDate());
				dt.appendChild(document.createTextNode(yearNum+"."+(month)+"."+day));
				container.appendChild(dt);
				var a = document.createElement("a");
				if( container.getAttribute("rel") ) {
					a.setAttribute("href", entry.link+"&cID="+container.getAttribute("rel"));
				} else {
					a.setAttribute("href", entry.link);
				}
				a.appendChild(document.createTextNode(entry.title));
				var dd = document.createElement("dd");
				if( (i+1)%2 == 0 ) dd.className = "gray";
				dd.appendChild(a);
				container.appendChild(dd);
			}
		}
	});
}
google.setOnLoadCallback(initialize);

function zeroFiller(num) {
	num = num+'';
	return num.length < 2 ? '0'+num : num;
}
	