/**
 * rssheadline.js
 * 
 * 2008/08/20 Tomoaki Shibata
 */

if( typeof syun == 'undefined' ) {
    syun = {};
}

syun.RSSHeadline = function () {
    return {
	show : function(id, url, max) {
	    if(typeof max == 'undefined') { max = -1; }
	    $.getJSON('http://pipes.yahoo.com/saiten/feez2json?_render=json&_callback=?&url=' + url, null, function(xml) {         
		var cnt = 0;
		$.each(xml['value']['items'], function(k, v) { 
		    if(max < 0 || cnt < max) {
			var d = new Date(v.pubDate);
			var str_date = d.getFullYear() + "/" + (d.getMonth()+1) + "/" + d.getDate();
			$('<dt></dt>').html(str_date).appendTo(id);
			$('<dd></dd>').html('<a href="' + v.link + '">' + v.title +'</a>').appendTo(id);
			cnt++;
		    }
		});
	    });
	}
    };
}();
